Search in sources :

Example 21 with Bindings

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

the class LCDProducer method justText.

private static void justText(Producer client) {
    Bindings bind = new Bindings();
    while (true) {
        bind = new Bindings();
        bind.addBinding("value", new RDFTermLiteral("Let Things Talk"));
        client.update(bind);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        bind = new Bindings();
        bind.addBinding("value", new RDFTermLiteral("Vaimee!"));
        client.update(bind);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 22 with Bindings

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

the class MQTTAdapter method messageArrived.

@Override
public void messageArrived(String topic, MqttMessage value) throws Exception {
    logger.info(topic + " " + value.toString());
    Bindings bindings = new Bindings();
    bindings.addBinding("topic", new RDFTermLiteral(topic));
    bindings.addBinding("value", new RDFTermLiteral(value.toString()));
    bindings.addBinding("broker", new RDFTermLiteral(serverURI));
    update(bindings);
}
Also used : Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 23 with Bindings

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

the class MQTTServerMonitoring method addObservation.

private static void addObservation(Entry<String, JsonElement> mapping) {
    String topic = mapping.getKey();
    String observation = mapping.getValue().getAsJsonObject().get("observation").getAsString();
    String unit = mapping.getValue().getAsJsonObject().get("unit").getAsString();
    String location = mapping.getValue().getAsJsonObject().get("location").getAsString();
    String comment = mapping.getValue().getAsJsonObject().get("comment").getAsString();
    String label = mapping.getValue().getAsJsonObject().get("label").getAsString();
    Bindings bindings = new Bindings();
    bindings.addBinding("observation", new RDFTermURI(observation));
    bindings.addBinding("comment", new RDFTermLiteral(comment));
    bindings.addBinding("label", new RDFTermLiteral(label));
    bindings.addBinding("location", new RDFTermURI(location));
    bindings.addBinding("unit", new RDFTermURI(unit));
    bindings.addBinding("topic", new RDFTermLiteral(topic));
    logger.info("Add observation: " + bindings);
    mqttInitializer.update(bindings);
}
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 24 with Bindings

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

the class MQTTSmartifier method updateObservationValue.

private void updateObservationValue(String observation, String value) {
    Bindings bindings = new Bindings();
    bindings.addBinding("observation", new RDFTermURI(observation));
    bindings.addBinding("value", new RDFTermLiteral(value));
    logger.info("Update observation: " + bindings);
    update(bindings);
}
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 25 with Bindings

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

the class GarbageCollector method subscribe.

public boolean subscribe() {
    Response ret;
    ret = super.subscribe(null);
    if (ret.isError())
        return false;
    SubscribeResponse results = (SubscribeResponse) ret;
    for (Bindings binding : results.getBindingsResults().getBindings()) {
        numbers += Integer.parseInt(binding.getBindingValue("numbers"));
        logger.info("Total numbers: " + numbers);
    }
    if (numbers >= getApplicationProfile().getExtendedData().get("gcnumbers").getAsInt()) {
        logger.info("Collecting triples...");
        update(null);
    }
    return true;
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) 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