view 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
line wrap: on
line source

import sadi
from rdflib import *

hello=Namespace("http://sadiframework.org/examples/hello.owl#")
foaf=Namespace("http://xmlns.com/foaf/0.1/")

class ExampleService(sadi.Service):
    label = "Hello, world"
    serviceDescriptionText = 'A simple "Hello, World" service that reads a name and attaches a greeting.'
    comment = 'A simple "Hello, World" service that reads a name and attaches a greeting.'
    serviceNameText = "Hello, world (python)"
    name = "example"

    def getOrganization(self):
        result = self.Organization()
        result.add(RDFS.label,Literal("Example Organization"))
        result.add(sadi.mygrid.authoritative, Literal(False))
        result.add(sadi.dc.creator, URIRef('mailto:john.smith@example.com'))
        return result

    def getInputClass(self):
        return hello.NamedIndividual

    def getOutputClass(self):
        return hello.GreetedIndividual

    def process(self, input, output):
        output.set(hello.greeting, Literal("Hello, "+input.value(foaf.name).value))

resource = ExampleService()

if __name__ == "__main__":
    sadi.serve(resource, port=9090)