[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.7, Wed Nov 15 12:04:05 2006 UTC revision 1.9, Thu Nov 16 22:09:33 2006 UTC
# Line 197  Line 197 
197  sub StoreAttributeKey {  sub StoreAttributeKey {
198      # Get the parameters.      # Get the parameters.
199      my ($entityName, $attributeName, $type, $notes) = @_;      my ($entityName, $attributeName, $type, $notes) = @_;
200        # Declare the return variable.
201        my $retVal;
202      # Get the data type hash.      # Get the data type hash.
203      my %types = ERDB::GetDataTypes();      my %types = ERDB::GetDataTypes();
204      # Validate the initial input values.      # Validate the initial input values.
# Line 217  Line 219 
219          # Okay, we're ready to begin. Get the entity hash and the field hash.          # Okay, we're ready to begin. Get the entity hash and the field hash.
220          my $entityData = $entityHash->{$entityName};          my $entityData = $entityHash->{$entityName};
221          my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName);          my $fieldHash = ERDB::GetEntityFieldHash($metadata, $entityName);
222            # Compare the old attribute data to the new data.
223            my $bigChange = 1;
224            if (exists $fieldHash->{$attributeName} && $fieldHash->{$attributeName}->{type} eq $type) {
225                $bigChange = 0;
226            }
227          # Compute the attribute's relation name.          # Compute the attribute's relation name.
228          my $relName = join("", $entityName, map { ucfirst $_ } split(/-|_/, $attributeName));          my $relName = join("", $entityName, map { ucfirst $_ } split(/-|_/, $attributeName));
229          # Store the attribute's field data. Note the use of the "content" hash for          # Store the attribute's field data. Note the use of the "content" hash for
# Line 232  Line 239 
239          }          }
240          # Write the XML back out.          # Write the XML back out.
241          ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD);          ERDB::WriteMetaXML($metadata, $FIG_Config::attrDBD);
     }  
242      # Open a database with the new XML.      # Open a database with the new XML.
243      my $retVal = CustomAttributes->new();          $retVal = CustomAttributes->new();
244            # Create the table if there has been a significant change.
245            if ($bigChange) {
246                $retVal->CreateTable($relName);
247            }
248        }
249      return $retVal;      return $retVal;
250  }  }
251    
# Line 1121  Line 1132 
1132          my $filter = "";          my $filter = "";
1133          my @params = ();          my @params = ();
1134          if (defined($actualObjectID)) {          if (defined($actualObjectID)) {
1135              # Here the caller wants to filter on object ID.              # Here the caller wants to filter on object ID. Check for a pattern.
1136              $filter = "$entityType(id) = ? AND ";              my $comparator = ($actualObjectID =~ /%/ ? "LIKE" : "=");
1137                # Update the filter and the parameter list.
1138                $filter = "$entityType(id) $comparator ? AND ";
1139              push @params, $actualObjectID;              push @params, $actualObjectID;
1140          }          }
1141          # It's time to begin making queries. We process one attribute key at a time, because          # It's time to begin making queries. We process one attribute key at a time, because
# Line 1366  Line 1379 
1379          my %secondaries = $self->GetSecondaryFields($entityType);          my %secondaries = $self->GetSecondaryFields($entityType);
1380          if (exists $secondaries{$key}) {          if (exists $secondaries{$key}) {
1381              # We found it, so delete all the values of the key.              # We found it, so delete all the values of the key.
1382              $self->DeleteValue($entityName, undef, $key);              $self->DeleteValue($entityType, undef, $key);
1383          }          }
1384      }      }
1385      # Return a 1, for backward compatability.      # Return a 1, for backward compatability.
1386      return 1;      return 1;
1387  }  }
1388    
1389    =head3 GetAttributeKeys
1390    
1391    C<< my @keyList = $attrDB->GetAttributeKeys($entityName); >>
1392    
1393    Return a list of the attribute keys for a particular entity type.
1394    
1395    =over 4
1396    
1397    =item entityName
1398    
1399    Name of the entity whose keys are desired.
1400    
1401    =item RETURN
1402    
1403    Returns a list of the attribute keys for the specified entity.
1404    
1405    =back
1406    
1407    =cut
1408    
1409    sub GetAttributeKeys {
1410        # Get the parameters.
1411        my ($self, $entityName) = @_;
1412        # Get the entity's secondary fields.
1413        my %keyList = $self->GetSecondaryFields($entityName);
1414        # Return the keys.
1415        return sort keys %keyList;
1416    }
1417    
1418  1;  1;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.9

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3