Search in sources :

Example 1 with RDFTerm

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

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

the class ApplicationProfile method subscribeBindings.

public Bindings subscribeBindings(String selectedValue) {
    JsonElement elem;
    Bindings ret = new Bindings();
    if ((elem = doc.get("queries")) != 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)

Aggregations

JsonElement (com.google.gson.JsonElement)2 JsonObject (com.google.gson.JsonObject)2 Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)2 RDFTerm (it.unibo.arces.wot.sepa.commons.sparql.RDFTerm)2 RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)2 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)2