Commit c05884d8 authored by Tobias Käfer's avatar Tobias Käfer
Browse files

iteration

parent f762afd3
Pipeline #29595 failed with stages
...@@ -17,21 +17,22 @@ ...@@ -17,21 +17,22 @@
</style> </style>
<script language="javascript"> <script language="javascript">
var ldpcHost = "tok450s.lan:8080"
var ldpcPath = "/ldbbc/"
var ldpc = "http://" + ldpcHost + ldpcPath;
var instance = { var instance = {
"@id" : "#it", "@id" : "#it",
"@type" : "wild:WorkflowInstance", "@type" : "wild:WorkflowInstance",
"wild:hasWorkflowModel" : "http://ldp.local/ldpc/iswcdemo-model.ttl#wfm", "wild:hasWorkflowModel" : "http://tok450s.lan/ldbbc/demoworkflow_new.ttl#wfm",
"wild:hasState": "wild:uninitialised", "wild:hasState": "wild:uninitialised"
"wild:hasInput": "#input"
}; };
var context = { var context = {
"name": "http://xmlns.com/foaf/0.1/name", "name": "http://xmlns.com/foaf/0.1/name",
"home": "http://people.aifb.kit.edu/co1683/2018/iswcdemo/vocab#home", // "home": "http://people.aifb.kit.edu/co1683/2018/iswcdemo/vocab#home",
"wild": "http://purl.org/wild/vocab#", "wild": "http://purl.org/wild/vocab#",
"wild:hasWorkflowModel": { "@type": "@id" }, "wild:hasWorkflowModel": { "@type": "@id" },
"wild:hasState": { "@type": "@id" }, "wild:hasState": { "@type": "@id" }
"wild:hasInput": { "@type": "@id" }
}; };
// Convert a HTML form to JSON // Convert a HTML form to JSON
...@@ -48,29 +49,56 @@ function getJSON(event) { ...@@ -48,29 +49,56 @@ function getJSON(event) {
// preventing the default action of the button event // preventing the default action of the button event
event.preventDefault(); event.preventDefault();
// reading the form contents into a JSON object // // reading the form contents into a JSON object
var input = {}; // var input = {};
formToJSON(event.target.elements, input); // formToJSON(event.target.elements, input);
// building a JSON-LD object from the object // building a JSON-LD object from the object
var jsonld = { var jsonld = {
"@context": context , "@context": context ,
"@graph": [ "@graph": [
instance, instance
input // input
] ]
}; };
// displaying the POST request to be made using the JSON-LD object // displaying the POST request to be made using the JSON-LD object
document.getElementById('JSON').innerHTML = document.getElementById('JSON').innerHTML =
"<pre>" "<pre>"
+ "POST /ldpc/ HTTP/1.1\n" + "POST " + ldpcPath + " HTTP/1.1\n"
+ "Host: ldp.local\n" + "Host: " + ldpcHost + "\n"
+ "Content-type: application/ld+json\n" + "Content-type: application/ld+json\n"
+ "\n" + "\n"
+ JSON.stringify(jsonld, null, 2) + JSON.stringify(jsonld, null, 2)
+ "</pre>"; + "</pre>";
} }
function sendJSON(event) {
// preventing the default action of the button event
event.preventDefault();
// // reading the form contents into a JSON object
// var input = {};
// formToJSON(event.target.elements, input);
// building a JSON-LD object from the object
var jsonld = {
"@context": context ,
"@graph": [
instance
// input
]
};
$.ajax({
type: "POST",
url: ldpc,
contentType: "application/ld+json",
data: JSON.stringify(jsonld, null, 2),
processData: false,
error: () => { window.alert("request failed") }
});
}
</script> </script>
</head> </head>
...@@ -82,10 +110,10 @@ function getJSON(event) { ...@@ -82,10 +110,10 @@ function getJSON(event) {
</nav> </nav>
<h3>Demo: Using Workflows to Build Compositions of Read-Write Linked Data APIs on the Web of Things</h3> <h3>Demo: Using Workflows to Build Compositions of Read-Write Linked Data APIs on the Web of Things</h3>
<p>Add a workflow instance using the following information:</p> <!-- <p>Add a workflow instance using the following information:</p> -->
<form id="name-and-town" class="text-left"> <form id="name-and-town" class="text-center">
<div class="form-group"> <!-- <div class="form-group">
<input name="@id" type="hidden" value="#input"></input> <input name="@id" type="hidden" value="#input"></input>
<label for="name">Name:</label> <label for="name">Name:</label>
<input id="name" name="name" class="form-control"></input> <input id="name" name="name" class="form-control"></input>
...@@ -93,13 +121,29 @@ function getJSON(event) { ...@@ -93,13 +121,29 @@ function getJSON(event) {
<div class="form-group"> <div class="form-group">
<label for="home">Hometown:</label> <label for="home">Hometown:</label>
<input id="home" name="home" class="form-control"></input><br> <input id="home" name="home" class="form-control"></input><br>
</div> -->
<button type="submit" class="btn">Show Workflow Instance Request</button>
</form>
<br />
<form id="submit-workflow" class="text-center">
<!-- <div class="form-group">
<input name="@id" type="hidden" value="#input"></input>
<label for="name">Name:</label>
<input id="name" name="name" class="form-control"></input>
</div> </div>
<button type="submit" class="btn btn-primary">Create Workflow Instance</button> <div class="form-group">
<label for="home">Hometown:</label>
<input id="home" name="home" class="form-control"></input><br>
</div> -->
<button type="submit" class="btn btn-primary">Submit Workflow Instance</button>
</form> </form>
<script language="javascript"> <script language="javascript">
// register the code with the form // register the code with the form
document.getElementById('name-and-town').addEventListener("submit", getJSON); document.getElementById('name-and-town').addEventListener("submit", getJSON);
document.getElementById('submit-workflow').addEventListener("submit", sendJSON);
</script> </script>
<br /> <br />
......
...@@ -6,4 +6,3 @@ ...@@ -6,4 +6,3 @@
{ <http://tok450s.lan:8080/ldbbc/> ldp:contains ?y . } => { [] http:mthd http_m:GET; http:requestURI ?y . } . { <http://tok450s.lan:8080/ldbbc/> ldp:contains ?y . } => { [] http:mthd http_m:GET; http:requestURI ?y . } .
{ _:h http:mthd http_m:GET ; http:requestURI <http://tok450s.lan:5001/> . } # optimise for workflow activity activeness
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
# Prefixes for the components of the demo: # Prefixes for the components of the demo:
@prefix speaker: <http://t2-speaker.lan/#> . @prefix speaker: <http://t2-speaker.lan/#> .
@prefix weather: <http://weather-api.lan/#> .
@prefix light: <http://t2-ambient.lan/light#> . @prefix light: <http://t2-ambient.lan/light#> .
@prefix rfid-smiley: <http://t2-rest-smiley.lan/#> . @prefix rfid-smiley: <http://t2-rest-smiley.lan/#> .
@prefix rfid-frownie: <http://t2-rest-frownie.lan/#> . @prefix rfid-frownie: <http://t2-rest-frownie.lan/#> .
...@@ -35,29 +34,47 @@ ...@@ -35,29 +34,47 @@
# #
<#root> a :SequentialActivity ; <#root> a :SequentialActivity ;
:hasChildActivities ( <#darkness> <#weatherQuestion> <#weatherAnswerConditionalSplit> ) . :hasChildActivities ( <#darknessQuestion> <#darknessConditionalSplit> ) .
<#darkness> a :AtomicActivity ; <#darknessQuestion> a :AtomicActivity ;
:hasPostcondition <#it-is-dark> ; # implicit waiting :hasPostcondition <#speakerQuiet> ;
:hasHttpRequest :hasHttpRequest
[ a http:Request ; [ a http:Request ;
http:mthd http_m:POST ; http:mthd http_m:POST ;
http:requestURI speaker:spk ; http:requestURI speaker:spk ;
http:body "{\"http://schema.org/text\":{\"@value\":\"Hello, user! Please make it dark!\",\"@language\":\"en\"}}" ] . http:body "{\"http://schema.org/text\":{\"@value\":\"Hello, user! Are you going to make it dark?\",\"@language\":\"en\"}}" ] .
<#weatherQuestion> a :AtomicActivity ; <#darknessConditionalSplit> a :ConditionalActivity ;
:hasPostcondition <#speakerQuiet> ; :hasChildActivities ( <#dark> <#bright> ) .
<#dark> a :ConditionalActivity ;
:hasPrecondition <#darknessPromisePreCondition> ;
:hasChildActivities ( <#dark-correct> <#dark-incorrect> ) .
<#bright> a :ConditionalActivity ;
:hasPrecondition <#brightnessPromisePreCondition> ;
:hasChildActivities ( <#bright-correct> <#bright-incorrect> ) .
<#dark-correct> a :AtomicActivity ;
:hasPrecondition <#dark-correct-pc> ; # implicit waiting
:hasPostcondition <#speakerQuiet> ;
:hasHttpRequest :hasHttpRequest
[ a http:Request ; [ a http:Request ;
http:mthd http_m:POST ; http:mthd http_m:POST ;
http:requestURI speaker:spk ; http:requestURI speaker:spk ;
http:body "{\"http://schema.org/text\":{\"@value\":\"How is the weather at home?\",\"@language\":\"en\"}}" ] . http:body "{\"http://schema.org/text\":{\"@value\":\"Well Done!\",\"@language\":\"en\"}}" ] .
<#weatherAnswerConditionalSplit> a :ConditionalActivity ; <#dark-incorrect> a :AtomicActivity ;
:hasChildActivities ( <#well-done> <#oh-dear> ) . :hasPrecondition <#dark-incorrect-pc> ; # implicit waiting
:hasPostcondition <#speakerQuiet> ;
:hasHttpRequest
[ a http:Request ;
http:mthd http_m:POST ;
http:requestURI speaker:spk ;
http:body "{\"http://schema.org/text\":{\"@value\":\"Oh dear, you have no clue!\",\"@language\":\"en\"}}" ] .
<#well-done> a :AtomicActivity ; <#bright-correct> a :AtomicActivity ;
:hasPrecondition <#good-good> , <#bad-bad> ; # one must be fulfilled, implicit waiting :hasPrecondition <#bright-correct-pc> ; # implicit waiting
:hasPostcondition <#speakerQuiet> ; :hasPostcondition <#speakerQuiet> ;
:hasHttpRequest :hasHttpRequest
[ a http:Request ; [ a http:Request ;
...@@ -65,8 +82,8 @@ ...@@ -65,8 +82,8 @@
http:requestURI speaker:spk ; http:requestURI speaker:spk ;
http:body "{\"http://schema.org/text\":{\"@value\":\"Well Done!\",\"@language\":\"en\"}}" ] . http:body "{\"http://schema.org/text\":{\"@value\":\"Well Done!\",\"@language\":\"en\"}}" ] .
<#oh-dear> a :AtomicActivity ; <#bright-incorrect> a :AtomicActivity ;
:hasPrecondition <#bad-good> , <#good-bad> ; # one must be fulfilled, implicit waiting :hasPrecondition <#bright-incorrect-pc> ; # implicit waiting
:hasPostcondition <#speakerQuiet> ; :hasPostcondition <#speakerQuiet> ;
:hasHttpRequest :hasHttpRequest
[ a http:Request ; [ a http:Request ;
...@@ -85,37 +102,54 @@ ...@@ -85,37 +102,54 @@
sp:predicate <http://example.org/speaking> ; sp:predicate <http://example.org/speaking> ;
sp:object "false"^^xsd:boolean ]) . sp:object "false"^^xsd:boolean ]) .
<#good-good> a sp:Ask ; <#darknessPromisePreCondition> a sp:Ask ;
sp:where ( sp:where (
[ sp:subject rfid-frownie:sensor ; [ sp:subject rfid-frownie:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "true"^^xsd:boolean ] sp:object "true"^^xsd:boolean ]
[ sp:subject weather:api ; [ sp:subject rfid-smiley:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "good" ] ) . sp:object "false"^^xsd:boolean ] ) .
<#bad-bad> a sp:Ask ; <#brightnessPromisePreCondition> a sp:Ask ;
sp:where ( sp:where (
[ sp:subject rfid:sensor ; [ sp:subject rfid-smiley:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "bad" ] sp:object "true"^^xsd:boolean ]
[ sp:subject weather:api ; [ sp:subject rfid-frownie:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "bad" ] ) . sp:object "false"^^xsd:boolean ] ) .
<#good-bad> a sp:Ask ;
<#dark-correct-pc> a sp:Ask ;
sp:where ( sp:where (
[ sp:subject rfid:sensor ; [ sp:subject rfid:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "good" ] sp:object "true"^^xsd:boolean ]
[ sp:subject weather:api ; [ sp:subject light:sensor ;
sp:predicate <http://example.org/isBright> ;
sp:object "false"^^xsd:boolean ] ) .
<#dark-incorrect-pc> a sp:Ask ;
sp:where (
[ sp:subject rfid:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "bad" ] ) . sp:object "true"^^xsd:boolean ]
<#bad-good> a sp:Ask ; [ sp:subject light:sensor ;
sp:predicate <http://example.org/isBright> ;
sp:object "true"^^xsd:boolean ] ) .
<#bright-correct-pc> a sp:Ask ;
sp:where ( sp:where (
[ sp:subject rfid:sensor ; [ sp:subject rfid:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "bad" ] sp:object "true"^^xsd:boolean ]
[ sp:subject weather:api ; [ sp:subject light:sensor ;
sp:predicate <http://example.org/isBright> ;
sp:object "true"^^xsd:boolean ] ) .
<#bright-incorrect-pc> a sp:Ask ;
sp:where (
[ sp:subject rfid:sensor ;
sp:predicate rdf:value ; sp:predicate rdf:value ;
sp:object "good" ] ) . sp:object "true"^^xsd:boolean ]
[ sp:subject light:sensor ;
sp:predicate <http://example.org/isBright> ;
sp:object "false"^^xsd:boolean ] ) .
<#truePostCondition> a sp:Ask ; sparql-result:boolean "true"^^xsd:boolean . <#truePostCondition> a sp:Ask ; sparql-result:boolean "true"^^xsd:boolean .
@prefix http: <http://www.w3.org/2011/http#>.
@prefix http_m: <http://www.w3.org/2011/http-methods#>.
@prefix ldp: <http://www.w3.org/ns/ldp#> .
{ _:h http:mthd http_m:GET ; http:requestURI <http://t2-rest-frownie.lan/> . }
...@@ -8,4 +8,5 @@ ...@@ -8,4 +8,5 @@
{ _:h http:mthd http_m:GET ; http:requestURI <http://t2-ambient-relay.lan:8080/ambient/light> . } { _:h http:mthd http_m:GET ; http:requestURI <http://t2-ambient-relay.lan:8080/ambient/light> . }
{ <http://t2-ambient-relay.lan:8080/ambient/light#value> <http://example.org/hasLightValue> ?val . ?val math:lessThan "0.08"^^xsd:double . } => { <http://tok450s.lan:8080/rwldresources/testworkflow.ttl#bPostCon> sparql-results:boolean "true"^^xsd:boolean . } . { ?x <http://example.org/hasLightValue> ?val . ?val math:lessThan "0.08"^^xsd:double . } => { ?x <http://example.org/isBright> "false"^^xsd:boolean . } .
{ ?x <http://example.org/hasLightValue> ?val . ?val math:notLessThan "0.08"^^xsd:double . } => { ?x <http://example.org/isBright> "true"^^xsd:boolean . } .
...@@ -6,5 +6,5 @@ curl -f -X PUT -T demoworkflow.ttl http://tok450s.lan:8080/ldbbc/ -Hcontent-type ...@@ -6,5 +6,5 @@ curl -f -X PUT -T demoworkflow.ttl http://tok450s.lan:8080/ldbbc/ -Hcontent-type
curl -f -X PUT -T wild-vocab.ttl http://tok450s.lan:8080/ldbbc/wild-vocab.ttl -L -Hcontent-type:text/turtle || exit 3 curl -f -X PUT -T wild-vocab.ttl http://tok450s.lan:8080/ldbbc/wild-vocab.ttl -L -Hcontent-type:text/turtle || exit 3
curl -f -X PUT -T list-vocab.ttl http://tok450s.lan:8080/ldbbc/list-vocab.ttl -L -Hcontent-type:text/turtle || exit 4 curl -f -X PUT -T list-vocab.ttl http://tok450s.lan:8080/ldbbc/list-vocab.ttl -L -Hcontent-type:text/turtle || exit 4
JAVA_OPTS=-Dldfu.optimiser=OFF $ldf -p data-retrieval.n3 -p wild-semantics.n3 -p list-semantics.n3 -p selected_ontology_semantics.n3 -p spin_sparql_ask_where_query_processing.n3 -n 100 # fish-sync... JAVA_OPTS=-Dldfu.optimiser=OFF $ldf -p data-retrieval-ldpc.n3 -p wild-semantics.n3 -p list-semantics.n3 -p selected_ontology_semantics.n3 -p spin_sparql_ask_where_query_processing.n3 -n 100 # fish-sync...
@prefix http: <http://www.w3.org/2011/http#>.
@prefix http_m: <http://www.w3.org/2011/http-methods#>.
@prefix ldp: <http://www.w3.org/ns/ldp#> .
{ _:h http:mthd http_m:GET ; http:requestURI <http://t2-rest-smiley.lan/> . }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment