[Bio] / Sprout / ERDBObject.pm Repository:
ViewVC logotype

Diff of /Sprout/ERDBObject.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Tue Apr 10 05:54:58 2007 UTC revision 1.3, Mon Jul 16 20:04:51 2007 UTC
# Line 31  Line 31 
31  associated with a database. The parameter list should be an entity name followed by  associated with a database. The parameter list should be an entity name followed by
32  a set of key-value pairs. Each key should be in the standard I<objectName>C<(>I<attributeName>C<)>  a set of key-value pairs. Each key should be in the standard I<objectName>C<(>I<attributeName>C<)>
33  format used by all of the ERDB methods. All values must be list references. For example,  format used by all of the ERDB methods. All values must be list references. For example,
34  the following code fragment creates an pseudo-Feature named C<peg.1> with two aliases.  the following code fragment creates an pseudo-Feature named C<peg.1> with two hyperlinks.
35    
36  C<< my $feature = ERDBObject::new('Feature(id)' => ['peg.1'], >>      my $feature = ERDBObject::new('Feature(id)' => ['peg.1'],
37  C<<                             'Feature(alias)' => ['NC1004', 'PC1006']); >>                                    'Feature(link)' => ['http://www.undhoople.edu/NC1004.html',
38                                                          'http://www.miskatonic.edu/PC1006.html']);
39    
40  =cut  =cut
41    
# Line 176  Line 177 
177      Tracer::AddToListMap($fields, $name, @values);      Tracer::AddToListMap($fields, $name, @values);
178  }  }
179    
180    =head3 PrimaryValue
181    
182    C<< my $value = $dbObject->PrimaryValue($name); >>
183    
184    Return the primary value of a field. This will be its first value in a standard value list.
185    
186    This method is a more convenient version of L</Value>. Basically, the call
187    
188        my ($value) = $dbObject->Value($name);
189    
190    is equivalent to
191    
192        my $value = $dbObject->PrimaryValue($name);
193    
194    but the latter is syntactically more convenient.
195    
196    =over 4
197    
198    =item name
199    
200    Name of the field whose value is desired, in the standard form.
201    
202    =item RETURN
203    
204    Returns the value of the specified field, or C<undef> if the field has no value.
205    
206    =back
207    
208    =cut
209    
210    sub PrimaryValue {
211        # Get the parameters.
212        my ($self, $name) = @_;
213        # Get the value.
214        my ($retVal) = $self->Value($name);
215        # Return it.
216        return $retVal;
217    }
218    
219  =head3 Value  =head3 Value
220    
221  C<< my @values = $dbObject->Value($attributeName); >>  C<< my @values = $dbObject->Value($attributeName); >>
# Line 254  Line 294 
294  the L</Value> method for each element in the parameter list and returns a flattened list of all  the L</Value> method for each element in the parameter list and returns a flattened list of all
295  the results.  the results.
296    
297  For example, let us say that C<$feature> contains a feature with two aliases and a translation.  For example, let us say that C<$feature> contains a feature with two links and a translation.
298  The following call will put the aliases in C<$alias1> and C<$alias2> and the translation in  The following call will put the feature links in C<$link1> and C<$link2> and the translation in
299  C<$translation>.  C<$translation>.
300    
301  C<< my ($alias1, $alias2, $translation) = $feature->Values(['Feature(alias)', 'Feature(translation)']); >>  C<< my ($link1, $link2, $translation) = $feature->Values(['Feature(link)', 'Feature(translation)']); >>
302    
303  =over 4  =over 4
304    
# Line 340  Line 380 
380          $targetEntity = $relationship->{from};          $targetEntity = $relationship->{from};
381      }      }
382      # Get the ID of the starting instance.      # Get the ID of the starting instance.
383      my ($id) = $self->Value("$startingEntity(id)");      my $id = $self->PrimaryValue("$startingEntity(id)");
384      # Create the WHERE clause.      # Create the WHERE clause.
385      my $superFilter = "$startLinkName = ?";      my $superFilter = "$startLinkName = ?";
386      # Analyze the filter clause. We need to pull out any strings and put them in parameters.      # Analyze the filter clause. We need to pull out any strings and put them in parameters.

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3