[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.35, Wed Sep 3 20:53:19 2008 UTC revision 1.38, Sat Oct 18 09:52:21 2008 UTC
# Line 1083  Line 1083 
1083  sub GetAttributes {  sub GetAttributes {
1084      # Get the parameters.      # Get the parameters.
1085      my ($self, $objectID, $key, @values) = @_;      my ($self, $objectID, $key, @values) = @_;
1086        # Declare the return variable.
1087        my @retVal = ();
1088        # Insure we have at least some sort of filtering going on.
1089        if (! grep { defined $_ } $objectID, $key, @values) {
1090            Confess("No filters specified in GetAttributes call.");
1091        } else {
1092      # This hash will map value-table fields to patterns. We use it to build the      # This hash will map value-table fields to patterns. We use it to build the
1093      # SQL statement.      # SQL statement.
1094      my %data;      my %data;
# Line 1092  Line 1098 
1098      # in the normal way. If the user specifies a generic search or exact match for      # in the normal way. If the user specifies a generic search or exact match for
1099      # every alternative value (remember, the values may be specified as a list),      # every alternative value (remember, the values may be specified as a list),
1100      # then we can create SQL filtering for it. If any of the values are specified      # then we can create SQL filtering for it. If any of the values are specified
1101      # as a regular expression, however, that's a problem, because we need to read          # as a regular expression, however, that's more complicated, because
1102      # every value to verify a match.          # we need to read every value to verify a match.
1103      if (@values > 0) {      if (@values > 0) {
1104          # Get the first value and put its alternatives in an array.          # Get the first value and put its alternatives in an array.
1105          my $valueParm = $values[0];          my $valueParm = $values[0];
# Line 1161  Line 1167 
1167              }              }
1168          }          }
1169      }      }
     # Declare the return variable.  
     my @retVal = ();  
1170      # Now we loop through the tables of interest, performing queries.      # Now we loop through the tables of interest, performing queries.
1171      # Loop through the tables.      # Loop through the tables.
1172      for my $table (keys %tables) {      for my $table (keys %tables) {
# Line 1227  Line 1231 
1231                          # Here we have to select on both keys.                          # Here we have to select on both keys.
1232                          my ($subClause, $subValue) = _WherePart($table, 'subkey', $subKey);                          my ($subClause, $subValue) = _WherePart($table, 'subkey', $subKey);
1233                          push @pairFilters, "($realClause AND $subClause)";                          push @pairFilters, "($realClause AND $subClause)";
1234                          push @parms, $subValue;                              push @parms, $realValue, $subValue;
1235                      }                      }
1236                  }                  }
1237                  # Join the pair filters together to make a giant key filter.                  # Join the pair filters together to make a giant key filter.
# Line 1243  Line 1247 
1247              push @retVal, $self->_QueryResults($query, $table, @values);              push @retVal, $self->_QueryResults($query, $table, @values);
1248          }          }
1249      }      }
1250        }
1251      # The above loop ran the query for each necessary value table and merged the      # The above loop ran the query for each necessary value table and merged the
1252      # results into @retVal. Now we return the rows found.      # results into @retVal. Now we return the rows found.
1253      return @retVal;      return @retVal;
# Line 1993  Line 1998 
1998                                                                  ]);                                                                  ]);
1999          # Form the key from the real key and the sub key.          # Form the key from the real key and the sub key.
2000          my $key = $self->JoinKey($realKey, $subKey);          my $key = $self->JoinKey($realKey, $subKey);
         # Check for a duplicate.  
         my $wholeThing = join($self->{splitter}, $id, $key, $valueString);  
         if (! $dupHash{$wholeThing}) {  
             # It's okay, we're not a duplicate. Insure we don't duplicate this result.  
             $dupHash{$wholeThing} = 1;  
2001              # Break the value into sections.              # Break the value into sections.
2002              my @sections = split($self->{splitter}, $valueString);              my @sections = split($self->{splitter}, $valueString);
2003              # Match each section against the incoming values. We'll assume we're              # Match each section against the incoming values. We'll assume we're
# Line 2018  Line 2018 
2018                      $matching = _CheckSQLPattern($values[$i], $sections[$i]);                      $matching = _CheckSQLPattern($values[$i], $sections[$i]);
2019                  }                  }
2020              }              }
2021              # If we match, output this row to the return list.          # If we match, consider writing this row to the return list.
2022              if ($matching) {              if ($matching) {
2023                # Check for a duplicate.
2024                my $wholeThing = join($self->{splitter}, $id, $key, $valueString);
2025                if (! $dupHash{$wholeThing}) {
2026                    # It's okay, we're not a duplicate. Insure we don't duplicate this result.
2027                    $dupHash{$wholeThing} = 1;
2028                  push @retVal, [$id, $key, @sections];                  push @retVal, [$id, $key, @sections];
2029              }              }
2030          }          }

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.38

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3