[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Wed Jul 28 23:41:39 UTC 2004


mwilkinson
Wed Jul 28 19:41:39 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF
In directory pub.open-bio.org:/tmp/cvs-serv16557/RDF

Modified Files:
	InOutArticlesRDF.pm 
Log Message:
adding a class variable counter for the various node factories so that all inputs in the database don't end up getting added to a single service in the RDF >>grin<<

moby-live/Perl/MOBY/RDF InOutArticlesRDF.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm	2004/07/28 23:12:11	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/InOutArticlesRDF.pm	2004/07/28 23:41:39	1.4
@@ -1,6 +1,7 @@
 package MOBY::RDF::InOutArticlesRDF;
 use strict;
 use RDF::Core::NodeFactory;
+use RDF::Core::Statement;
 
 require Exporter;
 our @ISA = qw(Exporter);
@@ -14,6 +15,35 @@
 use constant SI => 'http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#';
 use constant DC => 'http://purl.org/dc/elements/1.1/';
 
+{
+    my $inputcounter = 1;
+    my $outputcounter = 1;
+    my $simplecounter = 1;
+    my $collectioncounter = 1;    
+
+    sub nextinput {
+        ++$inputcounter;
+        $inputcounter = 1 if $inputcounter==100000;
+        return $inputcounter;
+    }
+    sub nextoutput {
+        ++$outputcounter;
+        $outputcounter = 1 if $outputcounter==100000;
+        return $outputcounter;
+    }
+    sub nextsimple {
+        ++$simplecounter;
+        $simplecounter = 1 if $simplecounter==100000;
+        return $simplecounter;
+    }
+    sub nextcollection {
+        ++$collectioncounter;
+        $collectioncounter = 1 if $collectioncounter==100000;
+        return $collectioncounter;
+    }
+    
+}
+
 sub type {
     my ($self, @args) = @_;
     $args[0] && ($self->{type} = $args[0]);
@@ -46,7 +76,7 @@
     return 0 unless $args{'model'} && (ref($args{'model'}) =~ /rdf::core/i);
     return 0 unless $args{'type'} && ( ($args{'type'} =~ /consumes/i) || ($args{'type'} =~ /produces/i) );
     return 0 unless $args{'subject'} && (ref($args{'subject'}) =~ /rdf::core/i);
-    return 0 unless $args{'araticles'} && (ref($args{'articles'}) =~ /array/i);
+    return 0 unless $args{'articles'} && (ref($args{'articles'}) =~ /array/i);
     return 1 unless ${$args{'articles'}}[0];  # if there ARE no articles, this is a valid result!
     
     my $caller_is_obj = ref($caller);
@@ -61,10 +91,10 @@
     my $subject = $self->subject;
     my $model = $self->model;
     
-    $self->{inputfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:input', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
-    $self->{outputfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:output', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
-    $self->{simplefactory} = new RDF::Core::NodeFactory( GenPrefix => '_:simple', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
-    $self->{collectionfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:collection', GenCounter => 0,BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
+    $self->{inputfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:input', GenCounter => &inputcounter(),BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
+    $self->{outputfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:output', GenCounter => &outputcounter(),BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
+    $self->{simplefactory} = new RDF::Core::NodeFactory( GenPrefix => '_:simple', GenCounter => &simplecounter(),BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
+    $self->{collectionfactory} = new RDF::Core::NodeFactory( GenPrefix => '_:collection', GenCounter => &collectioncounter(),BaseURI=>'http://www.biomoby.org/nil');# BaseURI=>'http://www.foo.org/');
 
 	$self->{Bag} = new RDF::Core::Resource(RDF_NS,'Bag');
     
@@ -91,8 +121,9 @@
     my @articles = $self->articles;
     my $Bag = $self->{Bag};
 
-    my $li = 1;
+    my $li = 0;
     foreach my $IN(@articles){
+        ++$li;
         my $LI = $Thingy->new(RDF_NS, "_$li");
         my $input = $self->{inputfactory}->newResource;
         my $statement = new RDF::Core::Statement($Thingy, $LI, $input);
@@ -111,9 +142,10 @@
             _addClassLiteral($model, MP, $input, 'articleName',  $IN->articleName) if $IN->articleName; 
     
             my $simps = $IN->Simples;
+            my $lli=0;
             foreach my $simp(@{$simps}){
-                my $li = 1;
-                my $LI = $input->new(RDF_NS, "_$li");
+                ++$lli;
+                my $LI = $input->new(RDF_NS, "_$lli");
                 my $collection_member = $self->{inputfactory}->newResource;
                 my $statement = new RDF::Core::Statement($input, $LI, $collection_member);
                 $model->addStmt($statement);




More information about the MOBY-guts mailing list