Class: ExampleService
Class Method Summary
collapse
classes, extended, included, process_input
#input_classes, #input_objects, #output_classes, #process_input, #process_object, #service_description, #service_name, #service_owl
#parse_string
Class Method Details
.owl_prefix ⇒ Object
71
72
73
|
# File 'lib/sadi-rb/example_service.rb', line 71
def owl_prefix
"http://sadiframework.org/examples/hello.owl#"
end
|
.process_object(in_graph, object) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/sadi-rb/example_service.rb', line 75
def process_object(in_graph, object)
out_graph = RDF::Graph.new
name = RDF::Query.execute(in_graph) do
pattern [object, RDF::FOAF.name, :name]
end
name = name.first.name
owl_vocab = RDF::Vocabulary.new(owl_prefix)
out_graph << RDF::Statement.new(object, RDF.type, output_classes.first)
out_graph << RDF::Statement.new(object, owl_vocab.greeting, "Hello, #{name}!")
out_graph
end
|
.service_description ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/sadi-rb/example_service.rb', line 8
def service_description
str = "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n<http://sadiframework.org/examples/hello> a <http://www.mygrid.org.uk/mygrid-moby-service#serviceDescription>;\n rdfs:label \"Hello, world\"^^xsd:string;\n <http://www.mygrid.org.uk/mygrid-moby-service#hasOperation> [ a <http://www.mygrid.org.uk/mygrid-moby-service#operation>;\n <http://www.mygrid.org.uk/mygrid-moby-service#hasUnitTest> [ a <http://www.mygrid.org.uk/mygrid-moby-service#unitTest>;\n <http://www.mygrid.org.uk/mygrid-moby-service#exampleInput> <http://sadiframework.org/examples/t/hello.input.1.rdf>;\n <http://www.mygrid.org.uk/mygrid-moby-service#exampleOutput> <http://sadiframework.org/examples/t/hello.output.1.rdf>];\n <http://www.mygrid.org.uk/mygrid-moby-service#inputParameter> [ a <http://www.mygrid.org.uk/mygrid-moby-service#parameter>;\n <http://www.mygrid.org.uk/mygrid-moby-service#objectType> <http://sadiframework.org/examples/hello.owl#NamedIndividual>];\n <http://www.mygrid.org.uk/mygrid-moby-service#outputParameter> [ a <http://www.mygrid.org.uk/mygrid-moby-service#parameter>;\n <http://www.mygrid.org.uk/mygrid-moby-service#objectType> <http://sadiframework.org/examples/hello.owl#GreetedIndividual>]];\n <http://www.mygrid.org.uk/mygrid-moby-service#hasServiceDescriptionText> \"A simple \\\"Hello, World\\\" service that reads a name and attaches a greeting.\"^^xsd:string;\n <http://www.mygrid.org.uk/mygrid-moby-service#hasServiceNameText> \"Hello, world\"^^xsd:string;\n <http://www.mygrid.org.uk/mygrid-moby-service#providedBy> [ a <http://www.mygrid.org.uk/mygrid-moby-service#organisation>;\n <http://protege.stanford.edu/plugins/owl/dc/protege-dc.owl#creator> \"[email protected]\"^^xsd:string;\n <http://www.mygrid.org.uk/mygrid-moby-service#authoritative> true];\n rdfs:comment \"A simple \\\"Hello, World\\\" service that reads a name and attaches a greeting.\"^^xsd:string .\n EOS\n\n parse_string(str, :ttl)\nend\n"
|
.service_name ⇒ Object
4
5
6
|
# File 'lib/sadi-rb/example_service.rb', line 4
def service_name
"hello"
end
|
.service_owl ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/sadi-rb/example_service.rb', line 35
def service_owl
str = "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n@prefix owl: <http://www.w3.org/2002/07/owl#> .\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n<> a owl:Ontology .\n\n<#GreetedIndividual> a owl:Class;\n owl:equivalentClass [ a owl:Restriction;\n owl:onProperty <#greeting>;\n owl:someValuesFrom xsd:string] .\n\n<#NamedIndividual> a owl:Class;\n owl:equivalentClass [ a owl:Restriction;\n owl:minCardinality \"1\"^^xsd:int;\n owl:onProperty foaf:name] .\n\n<#SecondaryParameters> a owl:Class;\n owl:equivalentClass [ a owl:Restriction;\n owl:minCardinality \"1\"^^xsd:int;\n owl:onProperty <#lang>] .\n\n<#greeting> a owl:DatatypeProperty .\n\n<#lang> a owl:DatatypeProperty .\n\nfoaf:name a owl:DatatypeProperty;\n rdfs:isDefinedBy foaf:index.rdf .\n EOS\n\n parse_string(str, :ttl)\nend\n"
|