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

Diff of /Sprout/CustomAttributes.pm

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

revision 1.1, Fri Nov 3 00:32:05 2006 UTC revision 1.2, Fri Nov 3 16:50:04 2006 UTC
# Line 26  Line 26 
26    
27      my @values = $attrDB->GetAttributes($fid, Feature => 'essential');      my @values = $attrDB->GetAttributes($fid, Feature => 'essential');
28    
29  where I<$fid> contains the ID of the desired feature.  where I<$fid> contains the ID of the desired feature. Each attribute has
30    an alternate index to allow searching for attributes by value.
31    
32  New attributes are introduced by updating the database definition at  New attributes are introduced by updating the database definition at
33  run-time. Attribute values are stored by uploading data from files.  run-time. Attribute values are stored by uploading data from files.
# Line 217  Line 218 
218      if (! exists $entityHash->{$entityName}) {      if (! exists $entityHash->{$entityName}) {
219          Confess("Entity $entityName not found.");          Confess("Entity $entityName not found.");
220      } else {      } else {
221          # Okay, we're ready to begin. Get the field hash.          # Okay, we're ready to begin. Get the entity hash and the field hash.
222            my $entityData = $entityHash->{$entityName};
223          my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName);          my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName);
224          # Compute the attribute's relation name.          # Compute the attribute's relation name.
225          my $relName = join("", $entityName, map { ucfirst $_ } split(/-/, $attributeName));          my $relName = join("", $entityName, map { ucfirst $_ } split(/-/, $attributeName));
# Line 226  Line 228 
228          # an attribute.          # an attribute.
229          $fieldHash->{$attributeName} = { type => $type, relation => $relName,          $fieldHash->{$attributeName} = { type => $type, relation => $relName,
230                                           Notes => { content => $notes } };                                           Notes => { content => $notes } };
231            # Insure we have an index for this attribute.
232            my $index = ERDB::FindIndexForEntity($metadata, $entityName, $attributeName);
233            if (! defined($index)) {
234                push @{$entityData->{Indexes}}, { IndexFields => [ { name => $attributeName, order => 'ascending' } ],
235                                                  Notes       => "Alternate index provided for access by $attributeName." };
236            }
237          # Write the XML back out.          # Write the XML back out.
238          ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD);          ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD);
239      }      }
# Line 399  Line 407 
407          } else {          } else {
408              # Get the attribute's relation name.              # Get the attribute's relation name.
409              my $relName = $fieldHash->{$attributeName}->{relation};              my $relName = $fieldHash->{$attributeName}->{relation};
410                # Check for an index.
411                my $indexIdx = ERDB::FindIndexForEntity($metadata, $entityName, $attributeName);
412                if (defined($indexIdx)) {
413                    Trace("Index for $attributeName found at position $indexIdx for $entityName.") if T(3);
414                    delete $entityHash->{$entityName}->{Indexes}->[$indexIdx];
415                }
416              # Delete the attribute from the field hash.              # Delete the attribute from the field hash.
417              Trace("Deleting attribute $attributeName from $entityName.") if T(3);              Trace("Deleting attribute $attributeName from $entityName.") if T(3);
418              delete $fieldHash->{$attributeName};              delete $fieldHash->{$attributeName};
# Line 407  Line 421 
421              # Insure the relation does not exist in the database. This requires connecting              # Insure the relation does not exist in the database. This requires connecting
422              # since we may have to do a table drop.              # since we may have to do a table drop.
423              my $attrDB = CustomAttributes->new();              my $attrDB = CustomAttributes->new();
424                Trace("Dropping table $relName.") if T(3);
425              $attrDB->DropRelation($relName);              $attrDB->DropRelation($relName);
426          }          }
427      }      }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3