Search in sources :

Example 1 with RDFTermLiteral

use of it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral 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 2 with RDFTermLiteral

use of it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral 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 3 with RDFTermLiteral

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

the class ThingDescription method addPropertyChangedEvent.

public void addPropertyChangedEvent(String event, String name, String dataType) {
    Bindings bind = new Bindings();
    bind.addBinding("thing", thing);
    bind.addBinding("event", new RDFTermURI(event));
    bind.addBinding("name", new RDFTermLiteral(name));
    bind.addBinding("dataType", new RDFTermURI(dataType));
    propertyChangeEvents.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 4 with RDFTermLiteral

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

the class ThingDescription method addAction.

public void addAction(String action, String name, String protocol) {
    Bindings bind = new Bindings();
    bind.addBinding("thing", thing);
    bind.addBinding("action", new RDFTermURI(action));
    bind.addBinding("name", new RDFTermLiteral(name));
    bind.addBinding("protocol", new RDFTermURI(protocol));
    actions.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 RDFTermLiteral

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

the class SmartLightingBenchmark method updateLamp.

protected boolean updateLamp(int nRoad, int nLamp, Integer dimming) {
    String lampURI = "bench:Lamp_" + nRoad + "_" + nLamp;
    Bindings bindings = new Bindings();
    bindings.addBinding("lamp", new RDFTermURI(lampURI));
    bindings.addBinding("dimming", new RDFTermLiteral(dimming.toString()));
    long startTime = System.nanoTime();
    Response ret = lampUpdater.update(bindings);
    long stopTime = System.nanoTime();
    logger.info("UPDATE LAMP " + lampURI + " " + (stopTime - startTime));
    return ret.getClass().equals(UpdateResponse.class);
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) UpdateResponse(it.unibo.arces.wot.sepa.commons.response.UpdateResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) 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)

Aggregations

RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)25 Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)20 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)17 ErrorResponse (it.unibo.arces.wot.sepa.commons.response.ErrorResponse)7 Response (it.unibo.arces.wot.sepa.commons.response.Response)7 SubscribeResponse (it.unibo.arces.wot.sepa.commons.response.SubscribeResponse)5 RDFTerm (it.unibo.arces.wot.sepa.commons.sparql.RDFTerm)5 JsonElement (com.google.gson.JsonElement)4 SEPAPropertiesException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException)3 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)3 UpdateResponse (it.unibo.arces.wot.sepa.commons.response.UpdateResponse)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 JsonObject (com.google.gson.JsonObject)2 SEPABindingsException (it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException)2 RDFTermBNode (it.unibo.arces.wot.sepa.commons.sparql.RDFTermBNode)2 Producer (it.unibo.arces.wot.sepa.pattern.Producer)2 URISyntaxException (java.net.URISyntaxException)2 SEPAProtocolException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException)1 QueryResponse (it.unibo.arces.wot.sepa.commons.response.QueryResponse)1