annotate localhost_SADI_service/localhost_SADI.py @ 2:977c838e3442 draft default tip

New dir structure, README improved, tests added and RDF merge tool created
author mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
date Fri, 25 Apr 2014 14:41:12 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
1 import sadi
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
2 from rdflib import *
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
3
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
4 hello=Namespace("http://sadiframework.org/examples/hello.owl#")
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
5 foaf=Namespace("http://xmlns.com/foaf/0.1/")
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
6
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
7 class ExampleService(sadi.Service):
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
8 label = "Hello, world"
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
9 serviceDescriptionText = 'A simple "Hello, World" service that reads a name and attaches a greeting.'
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
10 comment = 'A simple "Hello, World" service that reads a name and attaches a greeting.'
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
11 serviceNameText = "Hello, world (python)"
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
12 name = "example"
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
13
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
14 def getOrganization(self):
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
15 result = self.Organization()
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
16 result.add(RDFS.label,Literal("Example Organization"))
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
17 result.add(sadi.mygrid.authoritative, Literal(False))
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
18 result.add(sadi.dc.creator, URIRef('mailto:john.smith@example.com'))
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
19 return result
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
20
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
21 def getInputClass(self):
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
22 return hello.NamedIndividual
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
23
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
24 def getOutputClass(self):
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
25 return hello.GreetedIndividual
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
26
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
27 def process(self, input, output):
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
28 output.set(hello.greeting, Literal("Hello, "+input.value(foaf.name).value))
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
29
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
30 resource = ExampleService()
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
31
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
32 if __name__ == "__main__":
977c838e3442 New dir structure, README improved, tests added and RDF merge tool created
mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
parents:
diff changeset
33 sadi.serve(resource, port=9090)