Search in sources :

Example 31 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class SEPATest method requestAccessTokenTest.

protected static boolean requestAccessTokenTest() {
    Response response;
    response = client.requestToken();
    logger.debug(response.toString());
    return !response.getClass().equals(ErrorResponse.class);
}
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) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse)

Example 32 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class SEPATest method registrationTest.

protected static boolean registrationTest(String id) {
    Response response;
    response = client.register(id);
    return !response.getClass().equals(ErrorResponse.class);
}
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) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse)

Example 33 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class MessageSender method sendMessage.

public boolean sendMessage(String receiver, String text) {
    message.addBinding("receiver", new RDFTermLiteral(receiver));
    message.addBinding("text", new RDFTermLiteral(text));
    Response ret = update(message);
    return ret.isUpdateResponse();
}
Also used : SubscribeResponse(it.unibo.arces.wot.sepa.commons.response.SubscribeResponse) Response(it.unibo.arces.wot.sepa.commons.response.Response) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 34 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response 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)

Example 35 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class MeanCalculator method start.

public boolean start() {
    Response ret;
    ret = subscribe(null);
    if (ret.isError())
        return false;
    mean = 0;
    counter = 0;
    // Update!
    forcedBindings.addBinding("counter", new RDFTermLiteral(String.format("%d", counter)));
    forcedBindings.addBinding("value", new RDFTermLiteral(String.format("%.3f", mean)));
    update(forcedBindings);
    return true;
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Aggregations

Response (it.unibo.arces.wot.sepa.commons.response.Response)40 ErrorResponse (it.unibo.arces.wot.sepa.commons.response.ErrorResponse)31 SubscribeResponse (it.unibo.arces.wot.sepa.commons.response.SubscribeResponse)19 QueryResponse (it.unibo.arces.wot.sepa.commons.response.QueryResponse)15 Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)12 Test (org.junit.Test)8 RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)7 UpdateResponse (it.unibo.arces.wot.sepa.commons.response.UpdateResponse)6 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)5 JsonObject (com.google.gson.JsonObject)3 SubscribeRequest (it.unibo.arces.wot.sepa.commons.request.SubscribeRequest)3 ARBindingsResults (it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults)3 BindingsResults (it.unibo.arces.wot.sepa.commons.sparql.BindingsResults)3 IOException (java.io.IOException)3 Header (org.apache.http.Header)3 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 QueryRequest (it.unibo.arces.wot.sepa.commons.request.QueryRequest)2 UnsubscribeRequest (it.unibo.arces.wot.sepa.commons.request.UnsubscribeRequest)2 UpdateRequest (it.unibo.arces.wot.sepa.commons.request.UpdateRequest)2