Search in sources :

Example 1 with Bindings

use of it.unibo.arces.wot.sepa.commons.sparql.Bindings in project SEPA by arces-wot.

the class ITProtocolTest method VerifiedUTF8Update.

@Test
public void VerifiedUTF8Update() {
    Update();
    final Response response = SubmitQuery(client, TestQueries.UTF8_RESULT_QUERY);
    assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
    QueryResponse queryResponse = (QueryResponse) response;
    List<Bindings> results = queryResponse.getBindingsResults().getBindings();
    assertTrue("Query results empty", results.size() > 0);
    Bindings bindings = results.get(0);
    assertTrue("Binding variable is not a literal", bindings.isLiteral("o"));
    String value = bindings.getBindingValue("o");
    assertEquals("Incorrect utf-8 value", "測試", value);
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) Test(org.junit.Test)

Example 2 with Bindings

use of it.unibo.arces.wot.sepa.commons.sparql.Bindings in project SEPA by arces-wot.

the class ApplicationProfile method updateBindings.

/**
 *	 <pre>"forcedBindings" : {
 *					"variable_1" : {
 *						"type" : "literal" ,
 *						"value" : ""}
 *					 ,
 *					"variable_2" : {
 *						"type" : "literal" ,
 *						"value" : ""}
 *					 ,
 *					"variable_N" : {
 *						"type" : "uri" ,
 *						"value" : ""}
 *				}</pre>
 */
public Bindings updateBindings(String selectedValue) {
    JsonElement elem;
    Bindings ret = new Bindings();
    if ((elem = doc.get("updates")) != null)
        if ((elem = elem.getAsJsonObject().get(selectedValue)) != null)
            if ((elem = elem.getAsJsonObject().get("forcedBindings")) != null) {
                for (Entry<String, JsonElement> binding : elem.getAsJsonObject().entrySet()) {
                    JsonObject value = binding.getValue().getAsJsonObject();
                    RDFTerm bindingValue = null;
                    if (value.get("type") != null) {
                        if (value.get("type").getAsString().equals("uri")) {
                            bindingValue = new RDFTermURI(value.get("value").getAsString());
                        } else {
                            bindingValue = new RDFTermLiteral(value.get("value").getAsString());
                        }
                    }
                    ret.addBinding(binding.getKey(), bindingValue);
                }
            }
    return ret;
}
Also used : JsonElement(com.google.gson.JsonElement) RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) JsonObject(com.google.gson.JsonObject) RDFTerm(it.unibo.arces.wot.sepa.commons.sparql.RDFTerm) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 3 with Bindings

use of it.unibo.arces.wot.sepa.commons.sparql.Bindings in project SEPA by arces-wot.

the class EventListener method startListeningForEvent.

public void startListeningForEvent(String eventURI) throws SEPAProtocolException, SEPASecurityException {
    if (allEventListener.containsKey(eventURI))
        return;
    AllEventListener listener = new AllEventListener(eventURI);
    allEventListener.put(eventURI, listener);
    Bindings bindings = new Bindings();
    bindings.addBinding("event", new RDFTermURI(eventURI));
    allEventListener.get(eventURI).subscribe(bindings);
}
Also used : RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings)

Example 4 with Bindings

use of it.unibo.arces.wot.sepa.commons.sparql.Bindings in project SEPA by arces-wot.

the class ActionPublisher method post.

public void post(String value, String dataTypeURI) {
    Bindings bind = new Bindings();
    bind.addBinding("action", new RDFTermURI(action));
    bind.addBinding("value", new RDFTermLiteral(value));
    publisherWithInput.update(bind);
}
Also used : RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 5 with Bindings

use of it.unibo.arces.wot.sepa.commons.sparql.Bindings in project SEPA by arces-wot.

the class ActionPublisher method post.

public void post() {
    Bindings bind = new Bindings();
    bind.addBinding("action", new RDFTermURI(action));
    bind.addBinding("newInstance", new RDFTermURI("wot:" + UUID.randomUUID()));
    update(bind);
}
Also used : RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings)

Aggregations

Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)34 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)21 RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)19 Response (it.unibo.arces.wot.sepa.commons.response.Response)12 ErrorResponse (it.unibo.arces.wot.sepa.commons.response.ErrorResponse)11 SubscribeResponse (it.unibo.arces.wot.sepa.commons.response.SubscribeResponse)9 QueryResponse (it.unibo.arces.wot.sepa.commons.response.QueryResponse)4 UpdateResponse (it.unibo.arces.wot.sepa.commons.response.UpdateResponse)4 JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 SEPAProtocolException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException)2 ARBindingsResults (it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults)2 BindingsResults (it.unibo.arces.wot.sepa.commons.sparql.BindingsResults)2 RDFTerm (it.unibo.arces.wot.sepa.commons.sparql.RDFTerm)2 Producer (it.unibo.arces.wot.sepa.pattern.Producer)2 SEPAPropertiesException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException)1 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)1 QueryRequest (it.unibo.arces.wot.sepa.commons.request.QueryRequest)1 Notification (it.unibo.arces.wot.sepa.commons.response.Notification)1 ApplicationProfile (it.unibo.arces.wot.sepa.pattern.ApplicationProfile)1