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

Diff of /Sprout/ERDB.pm

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

revision 1.97, Wed May 7 23:08:19 2008 UTC revision 1.98, Mon Jul 7 19:05:55 2008 UTC
# Line 390  Line 390 
390                                    Entities => 'Entity',                                    Entities => 'Entity',
391                                    Fields => 'Field',                                    Fields => 'Field',
392                                    Indexes => 'Index',                                    Indexes => 'Index',
393                                    IndexFields => 'IndexField'                                    IndexFields => 'IndexField',
394                                      Issues => 'Issue',
395                                      Shapes => 'Shape'
396                                  },                                  },
397                    KeyAttr =>    { Relationship => 'name',                    KeyAttr =>    { Relationship => 'name',
398                                    Entity => 'name',                                    Entity => 'name',
399                                    Field => 'name'                                    Field => 'name',
400                                      Shape => 'name'
401                                  },                                  },
402                    SuppressEmpty => 1,                    SuppressEmpty => 1,
403                   );                   );
404    
405  my %XmlInOpts  = (  my %XmlInOpts  = (
406                    ForceArray => ['Field', 'Index', 'IndexField', 'Relationship', 'Entity'],                    ForceArray => [qw(Field Index IndexField Relationship Entity Shape)],
407                    ForceContent => 1,                    ForceContent => 1,
408                    NormalizeSpace => 2,                    NormalizeSpace => 2,
409                   );                   );
# Line 679  Line 682 
682      # Get the entity and relationship lists.      # Get the entity and relationship lists.
683      my $entityList = $metadata->{Entities};      my $entityList = $metadata->{Entities};
684      my $relationshipList = $metadata->{Relationships};      my $relationshipList = $metadata->{Relationships};
685        my $shapeList = $metadata->{Shapes};
686      # Start with the introductory text.      # Start with the introductory text.
687      push @retVal, WikiTools::Heading(2, "Introduction");      push @retVal, WikiTools::Heading(2, "Introduction");
688      if (my $notes = $metadata->{Notes}) {      if (my $notes = $metadata->{Notes}) {
689          push @retVal, WikiNote($notes->{content});          push @retVal, WikiNote($notes->{content});
690      }      }
691        # Generate issue list.
692        if (my $issues = $metadata->{Issues}) {
693            push @retVal, WikiTools::Heading(3, 'Issues');
694            push @retVal, WikiTools::List(map { $_->{content} } @{$issues});
695        }
696      # Start the entity section.      # Start the entity section.
697      push @retVal, WikiTools::Heading(2, "Entities");      push @retVal, WikiTools::Heading(2, "Entities");
698      # Loop through the entities. Note that unlike the situation with HTML, we      # Loop through the entities. Note that unlike the situation with HTML, we
# Line 695  Line 704 
704          # Get the entity data.          # Get the entity data.
705          my $entityData = $entityList->{$key};          my $entityData = $entityList->{$key};
706          # Plant the notes here, if there are any.          # Plant the notes here, if there are any.
707          if (my $notes = $entityData->{Notes}) {          push @retVal, _ObjectNotes($entityData);
             push @retVal, "", WikiNote($notes->{content});  
         }  
708          # Get the entity's relations.          # Get the entity's relations.
709          my $relationList = $entityData->{Relations};          my $relationList = $entityData->{Relations};
710          # Loop through the relations, displaying them.          # Loop through the relations, displaying them.
# Line 740  Line 747 
747          if ($arity eq "11") {          if ($arity eq "11") {
748              push @listElements, "Each $boldCode$fromEntity$boldCode relates to at most one $boldCode$toEntity$boldCode.";              push @listElements, "Each $boldCode$fromEntity$boldCode relates to at most one $boldCode$toEntity$boldCode.";
749          } else {          } else {
750              push @listElements, "Each $boldCode$fromEntity$boldCode relates to multiple $boldCode${toEntity}s$boldCode.\n";              push @listElements, "Each $boldCode$fromEntity$boldCode relates to multiple $boldCode${toEntity}s$boldCode.";
751              if ($arity eq "MM" && $fromEntity ne $toEntity) {              if ($arity eq "MM" && $fromEntity ne $toEntity) {
752                  push @listElements, "Each $boldCode$toEntity$boldCode relates to multiple $boldCode${fromEntity}s$boldCode.\n";                  push @listElements, "Each $boldCode$toEntity$boldCode relates to multiple $boldCode${fromEntity}s$boldCode.";
753              }              }
754          }          }
755          push @retVal, WikiTools::List(@listElements);          push @retVal, WikiTools::List(@listElements);
756          # Plant the notes here, if there are any.          # Plant the notes here, if there are any.
757          if (my $notes = $relationshipData->{Notes}) {          push @retVal, _ObjectNotes($relationshipData);
             push @retVal, "", WikiNote($notes->{content});  
         }  
758          # Finally, the relationship table.          # Finally, the relationship table.
759          my $wikiString = _WikiRelationTable($key, $relationshipData->{Relations}->{$key});          my $wikiString = _WikiRelationTable($key, $relationshipData->{Relations}->{$key});
760          push @retVal, $wikiString;          push @retVal, $wikiString;
761      }      }
762        # Now loop through the miscellaneous shapes.
763        if ($shapeList) {
764            push @retVal, WikiTools::Heading(2, "Miscellaneous");
765            for my $shape (sort keys %$shapeList) {
766                push @retVal, WikiTools::Heading(3, $shape);
767                my $shapeData = $shapeList->{$shape};
768                push @retVal, _ObjectNotes($shapeData);
769            }
770        }
771      # All done. Return the lines.      # All done. Return the lines.
772      return @retVal;      return @retVal;
773  }  }
# Line 5430  Line 5444 
5444      return $retVal;      return $retVal;
5445  }  }
5446    
5447  =head2 HTML Documentation Utility Methods  =head2 Documentation Utility Methods
5448    
5449  =head3 _ComputeRelationshipSentence  =head3 _ComputeRelationshipSentence
5450    
# Line 5551  Line 5565 
5565          # Push this row onto the table list.          # Push this row onto the table list.
5566          push @rows, \@row;          push @rows, \@row;
5567      }      }
5568      # Store the rows as a Wiki table.      # Store the rows as a Wiki table with a level-4 heading.
5569      my $retVal = WikiTools::Table(@rows);      my $retVal = join("\n\n", WikiTools::Heading(4, "$relationName Table"),
5570                          WikiTools::Table(@rows));
5571      # Now we show the relation's indexes. These are formatted as another      # Now we show the relation's indexes. These are formatted as another
5572      # table.      # table.
5573      @rows = ();      @rows = ();
# Line 5583  Line 5598 
5598      $retVal .= "\n\n" . WikiTools::Table(@rows);      $retVal .= "\n\n" . WikiTools::Table(@rows);
5599  }  }
5600    
   
5601  =head3 _ShowRelationTable  =head3 _ShowRelationTable
5602    
5603  Generate the HTML string for a particular relation. The relation's data will be formatted as an HTML  Generate the HTML string for a particular relation. The relation's data will be formatted as an HTML
# Line 5757  Line 5771 
5771      return $htmlString;      return $htmlString;
5772  }  }
5773    
5774    =head3 _ObjectNotes
5775    
5776        my @noteParagraphs = _ObjectNotes($objectData);
5777    
5778    Return a list of the notes and asides for an entity or relationship in
5779    Wiki format.
5780    
5781    =over 4
5782    
5783    =item objectData
5784    
5785    The metadata for the desired entity or relationship.
5786    
5787    =item RETURN
5788    
5789    Returns a list of text paragraphs in Wiki markup form.
5790    
5791    =back
5792    
5793    =cut
5794    
5795    sub _ObjectNotes {
5796        # Get the parameters.
5797        my ($objectData) = @_;
5798        # Declare the return variable.
5799        my @retVal;
5800        # Loop through the types of notes.
5801        for my $noteType (qw(Notes Asides)) {
5802            my $text = $objectData->{$noteType};
5803            if ($text) {
5804                push @retVal, "", WikiNote($text->{content});
5805            }
5806        }
5807        # Return the result.
5808        return @retVal;
5809    }
5810    
5811  1;  1;

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.98

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3