[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Jul 29 16:11:41 UTC 2004


mwilkinson
Thu Jul 29 12:11:40 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF
In directory pub.open-bio.org:/tmp/cvs-serv19324/MOBY/RDF

Modified Files:
	InOutArticlesRDF.pm 
Log Message:
adding support for secondaries into the RDF generating routines

moby-live/Perl/MOBY/RDF InOutArticlesRDF.pm,1.6,1.7
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm	2004/07/29 00:22:21	1.6
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm	2004/07/29 16:11:40	1.7
@@ -15,11 +15,13 @@
 use constant SI => 'http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#';
 use constant DC => 'http://purl.org/dc/elements/1.1/';
 
-{
+{   # these need to be class variables, since this module is loaded multiple times, but the newResouce counter has to increment nevertheless.
+    
     my $inputfactory ||= new RDF::Core::NodeFactory( GenPrefix => '_:input', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
     my $outputfactory ||= new RDF::Core::NodeFactory( GenPrefix => '_:output', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
     my $simplefactory ||= new RDF::Core::NodeFactory( GenPrefix => '_:simple', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
     my $collectionfactory ||= new RDF::Core::NodeFactory( GenPrefix => '_:collection', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
+    my $secondaryfactory ||= new RDF::Core::NodeFactory( GenPrefix => '_:secondary', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
 
     sub nextinput {
         return $inputfactory->newResource
@@ -33,9 +35,14 @@
     sub nextcollection {
         return $collectionfactory->newResource
     }
+    sub nextsecondary {
+        return $secondaryfactory->newResource
+    }
     
 }
 
+
+
 sub type {
     my ($self, @args) = @_;
     $args[0] && ($self->{type} = $args[0]);
@@ -116,7 +123,7 @@
     my $li = 0;
     foreach my $IN(@articles){
         ++$li;
-        my $LI = $Thingy->new(RDF_NS, "_$li");
+        my $LI = $Thingy->new(RDF_NS, "_$li");  # <rdf:li> nodes - need to be numbered :_1, :_2, etc
         my $input = &nextsimple;
         my $statement = new RDF::Core::Statement($Thingy, $LI, $input);
         $model->addStmt($statement);
@@ -125,18 +132,18 @@
 
         if ($IN->isSimple){
             &_addSimple($model, $input, $IN);
-        } else {   # COLLECTION
+        } elsif ($IN->isCollection) {   # COLLECTION - is just a bag of simples
             my $type = $input->new(RDF_NS,'type');
             my $statement = new RDF::Core::Statement($input, $type, $Bag);
             $model->addStmt($statement);
             # <type  rdf:Bag>
-            _addClassLiteral($model, MP, $input, 'articleName',  $IN->articleName) if $IN->articleName; 
+            _addClassLiteral($model, MP, $input, 'articleName',  $IN->articleName) if $IN->articleName; # the bag has an articlename
     
             my $simps = $IN->Simples;
             my $lli=0;
             foreach my $simp(@{$simps}){
                 ++$lli;
-                my $LI = $input->new(RDF_NS, "_$lli");
+                my $LI = $input->new(RDF_NS, "_$lli");  # <rdf:li> nodes - need to be numbered :_1, :_2, etc; these connect to the individual simples
                 my $collection_member = &nextcollection;
                 my $statement = new RDF::Core::Statement($input, $LI, $collection_member);
                 $model->addStmt($statement);
@@ -144,6 +151,10 @@
 
                 &_addSimple($model, $collection_member, $simp);
             }
+        } elsif ($IN->isSecondary) {
+            &_addSecondary($model, $input, $IN);
+        } else {
+            print STDERR "the InOutArticlesRDF got a service instance input or output that was not a simple, collection, nor secondary???\n";
         }
     }
 }
@@ -166,6 +177,27 @@
 }
 
 
+#| secondary_input_id  | int(10) unsigned                            |      | PRI | NULL    | auto_increment |
+#| default_value       | text                                        | YES  |     | NULL    |                |
+#| maximum_value       | decimal(10,0)                               | YES  |     | NULL    |                |
+#| minimum_value       | decimal(10,0)                               | YES  |     | NULL    |                |
+#| enum_value          | text                                        | YES  |     | NULL    |                |
+#| datatype            | enum('String','Integer','DateTime','Float') | YES  |     | NULL    |                |
+#| article_name        | varchar(255)                                | YES  |     | NULL    |                |
+#| service_instance_id | int(10) unsigned                            |      |     | 0       |                |
+sub _addSecondary {
+    my ($model, $article, $ART) = @_;  #  (RDF::COre::Model,  $RDF::Core::Resource,  $MOBY::Client::SimpleArticle)
+    _addClassLiteral($model, MP, $article, 'article_name',  $ART->articleName) if $ART->articleName;
+    _addClassLiteral($model, MP, $article, 'default_value',  $ART->default) if $ART->default;
+    _addClassLiteral($model, MP, $article, 'datatype',  $ART->datatype) if $ART->datatype;
+    _addClassLiteral($model, MP, $article, 'max',  $ART->max) if $ART->max;
+    _addClassLiteral($model, MP, $article, 'min',  $ART->min) if $ART->min;
+    my @enums = $ART->enum;
+    foreach (@enums){
+        _addClassLiteral($model, MP, $article, 'enum',  $_) if defined $_;
+    }
+        
+}
 
 sub _addResource {
     my ($model, $ns, $predicate, $subject, $ons, $object) = @_;




More information about the MOBY-guts mailing list