[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Thu Jul 29 00:36:55 UTC 2004
mwilkinson
Wed Jul 28 20:36:54 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY/lsid/authority
In directory pub.open-bio.org:/tmp/cvs-serv16881/MOBY/lsid/authority
Modified Files:
ServiceInstanceResolver.pm
Log Message:
the LSID resolver for service instance LSID's now uses the same modules as the RESOURCES script, and should output identically formatted RDF
moby-live/Perl/MOBY/lsid/authority ServiceInstanceResolver.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm 2004/01/15 20:59:38 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/lsid/authority/ServiceInstanceResolver.pm 2004/07/29 00:36:54 1.4
@@ -5,6 +5,35 @@
use XML::DOM;
use MOBY::lsid::authority::RDFConfigure qw(:all);
use MOBY::Client::Central;
+use MOBY::RDF::ServiceInstanceRDF;
+
+use RDF::Core;
+use RDF::Core::Model;
+use RDF::Core::Literal;
+use RDF::Core::Statement;
+use RDF::Core::Model::Serializer;
+use RDF::Core::Storage::Memory;
+use RDF::Core::Constants qw(:xml :rdf :rdfs);
+use constant OBJ => 'http://biomoby.org/RESOURCES/MOBY-S/Objects#';
+use constant SRV => 'http://biomoby.org/RESOURCES/MOBY-S/Services#';
+use constant NS => 'http://biomoby.org/RESOURCES/MOBY-S/Namespaces#';
+use constant MP => 'http://biomoby.org/RESOURCES/MOBY-S/Predicates#';
+use constant SI => 'http://biomoby.org/RESOURCES/MOBY-S/ServiceInstances#';
+use constant DC => 'http://purl.org/dc/elements/1.1/';
+
+sub xmlNamespaces {
+ return {
+ RDF_NS() => 'rdf',
+ RDFS_NS() => 'rdfs',
+ OBJ() => 'mobyObject',
+ NS() => 'mobyNamespace',
+ SRV() => 'mobyService',
+ MP() => 'mobyPred',
+ SI() => 'serviceInstances',
+ DC() => 'dc',
+ }
+}
+
@ISA = qw(Exporter);
@EXPORT_OK = qw(
@@ -14,8 +43,21 @@
resolve_ServiceInstance
)]);
+sub _serialize {
+ my ($model) = @_;
+ my $xml = '';
+
+ my $serializer = new RDF::Core::Model::Serializer(
+ Model=>$model,
+ Output=>\$xml,
+ getNamespaces => \&xmlNamespaces, # this only works with a patch!!!!!!!!!!!!!!!!
+ );
+ $serializer->serialize;
+ print "$xml\n";
+}
sub resolve_ServiceInstance {
+
my ($ls) = @_;
my $lsid= LS::ID->new($ls)->canonical;
unless ($lsid) {
@@ -37,175 +79,20 @@
unless ($si && ${$si}[0]){
_die('UNKNOWN_LSID');
}
- my $service = shift(@{$si});
- # LSID is now fully validated. Carry on with metadata.
- $RDF_PREFIX?1:1;
- $mdata= $RDF_PREFIX;
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'rdf:type', # rdf:Type
- 'i3csp:bioMobyService'
- );
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'i3csp:name', # i3c:Name
- $service->name
- );
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'dc:title', # dc:Title
- $service->name
- );
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'dc:label', # dc:Label
- $service->name
- );
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'i3csp:publishedBy', # i3d:publishedBy
- $service->authority
- );
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'i3csp:authoritative', # i3c:authoritative
- $service->authoritative
- );
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'i3csp:description', # i3c:description
- $service->description
- );
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'i3csp:endpoint', # i3c:endpoint
- $service->URL
- );
-
- $mdata.= rdfLiteral(
- $lsid->as_string,
- 'dc:contributor', # dc:contributor
- $service->contactEmail
- );
-
- $mdata.= rdfResource(
- $lsid->as_string,
- 'i3csp:performsTask', # i3csp:performsTask
- 'urn:lsid:biomoby.org:servicetype:'.($service->type)
- );
-
-
- my $inputs = $service->input;
- my @inputs = @{$inputs};
+ my $storage = new RDF::Core::Storage::Memory;
+ my $model = new RDF::Core::Model (Storage => $storage);
- my $outputs = $service->output;
- my @outputs = @{$outputs};
-
- $mdata .= rdfBnode(
- $lsid->as_string,
- 'i3csp:primaryInput', # primaryInput bnode
- 'primaryInput'
- );
- my $in=0;
- foreach (@inputs){
- ++$in;
- $mdata .= rdfBnodeBnode(
- 'primaryInput',
- 'i3csp:primaryParameter', # primaryParameter bnode
- "primaryParameter$in"
- );
- $mdata .= rdfBnodeLiteral(
- "primaryParameter$in",
- 'i3csp:parameterName',
- $_->articleName
- );
- if ($_->isSimple){
- $mdata .= rdfBnodeResource(
- "primaryParameter$in",
- 'i3csp:parameterType',
- 'i3csp:mobySimpleType'
- );
- $mdata .= rdfBnodeResource(
- "primaryParameter$in",
- 'i3csp:parameterClass',
- 'urn:lsid:biomoby.org:objectclass:'.($_->objectType)
- );
- } else {
- $mdata .= rdfBnodeResource(
- "primaryParameter$in",
- 'i3csp:parameterType',
- 'i3csp:mobyCollectionType'
- );
- my $simps = $_->Simples;
- foreach my $simp(@{$simps}){
- $mdata .= rdfBnodeResource(
- "primaryParameter$in",
- 'i3csp:parameterClass',
- 'urn:lsid:biomoby.org:objectclass:'.($simp->objectType)
- );
- }
- }
- }
-
- $mdata .= rdfBnode(
- $lsid->as_string,
- 'i3csp:primaryOutput', # primaryInput bnode
- 'primaryOutput'
- );
- my $out= $in; # switch for readability
- foreach (@outputs){
- ++$out;
- $mdata .= rdfBnodeBnode(
- 'primaryOutput',
- 'i3csp:primaryParameter', # primaryParameter bnode
- "primaryParameter$out"
- );
- $mdata .= rdfBnodeLiteral(
- "primaryParameter$out",
- 'i3csp:parameterName',
- $_->articleName
- );
- if ($_->isSimple){
- $mdata .= rdfBnodeResource(
- "primaryParameter$out",
- 'i3csp:parameterType',
- 'i3csp:mobySimpleType'
- );
- $mdata .= rdfBnodeResource(
- "primaryParameter$out",
- 'i3csp:parameterClass',
- 'urn:lsid:biomoby.org:objectclass:'.($_->objectType)
- );
- } else {
- $mdata .= rdfBnodeResource(
- "primaryParameter$out",
- 'i3csp:parameterType',
- 'i3csp:mobyCollectionType'
- );
- my $simps = $_->Simples;
- foreach my $simp(@{$simps}){
- $mdata .= rdfBnodeResource(
- "primaryParameter$out",
- 'i3csp:parameterClass',
- 'urn:lsid:biomoby.org:objectclass:'.($simp->objectType)
- );
- }
- }
+ foreach my $service(@{$si}){
+ my $ServInstRDF = MOBY::RDF::ServiceInstanceRDF->new(
+ model => $model,
+ service_instance => $service,
+ );
}
-
- # +++++++++++ now we need the secondaries ++++++++
- $mdata.= $RDF_SUFFIX;
- $RDF_SUFFIX?1:1;
-
- unless ($mdata) {
- _die ('NO_METADATA_AVAILABLE');
- }
- return $mdata;
+ print header(-type => 'application/rdf+xml', -expires => 'now');
+ _serialize($model);
+ exit 1;
}
+
+1;
More information about the MOBY-guts
mailing list