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;
}
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;
}
Aggregations