Commit f7be2a0d authored by akucera's avatar akucera
Browse files

server full influence support

client basic influence support
parent 54917e8f
<div id="params" class="form-group"></div>
\ No newline at end of file
......@@ -153,7 +153,9 @@ var translation = {
'group' : 'Skupina',
'Data Points' : 'Datové body',
'Trends' : 'Historická data',
'Relations' : 'Vztahy'
'Relations' : 'Vztahy',
'Influencing' : 'Ovlivňující',
'Influenced' : 'Ovlivňované'
}
},
......
......@@ -168,7 +168,7 @@ function SBMSPage(custom) {
break;
// lists
case "sbms-enum":
app+= '<select id="' + id + '" class="form-control selectpickerfield" data-live-search="true"></select>'
app+= '<select id="' + id + '" class="form-control selectpicker field" data-live-search="true"></select>'
break;
// free text
default:
......
......@@ -104,6 +104,7 @@ var p = new SBMSPage ({
$('input[name=fieldsC]').prop("checked", false);
});
$("button#send").off("click");
$("button#send").click(p.sendQuery);
p.loadList("fields/data." + addressType, [p.createList, function() { $('input[name=fieldsC]:eq(0)').prop("checked", true); } ], [ "#fields", "checkbox", "fieldsC" ]);
......@@ -118,7 +119,29 @@ var p = new SBMSPage ({
]);
},
initQueryRelations : function() {
initQueryRelationsIg : function() {
p.endpoint = "relations/influencing";
p.initQueryRelations("influencing");
},
initQueryRelationsId : function() {
p.endpoint = "relations/influenced";
p.initQueryRelations("influenced");
},
initQueryRelations : function(relType) {
$("button#send").off("click");
$("button#send").click(p.sendQuery);
p.loadList("fields/filter." + relType,
p.createParams, ["#params", true,
function() {$("#treeSelect").dialog("open") },
function() {$("#treeSelect").dialog("close") },
function() {$("#fsSelect").dialog("open") },
function() { },
"extFrame",
"tree"
]);
},
makeTableFromJSON: function(data, fieldsSelector, target) {
......@@ -199,7 +222,7 @@ var p = new SBMSPage ({
var data = {};
data.fields = $('input[name=fieldsC]:checked').map(function() {
return $( this ).val();//.replace("datapoint.","");
return $( this ).val();
}).get().join(",");
var grouping = $('input[name=groupsR]:checked', '#queryForm').val();
if(grouping != null) {
......@@ -287,9 +310,12 @@ var p = new SBMSPage ({
<li role="presentation" class="opNav" id="navQueryTrends"
data-init-func="initQueryTrends"
data-incl-file="inclQueryDP.html"><a href="#QueryTrends" data-i18n="Trends">Trends</a></li>
<li role="presentation" class="opNav" id="navQueryRelations"
data-init-func="initQueryRelations"
data-incl-file="inclQueryRelations.html"><a href="#QueryRelations" data-i18n="Relations">Relations</a></li>
<li role="presentation" class="opNav" id="navQueryRelationsIg"
data-init-func="initQueryRelationsIg"
data-incl-file="inclQueryRelations.html"><a href="#QueryRelationsIg"><span data-i18n="Relations">Relations</span> &ndash; <span data-i18n="Influencing">Influencing</span></a></li>
<li role="presentation" class="opNav" id="navQueryRelationsId"
data-init-func="initQueryRelationsId"
data-incl-file="inclQueryRelations.html"><a href="#QueryRelationsId"><span data-i18n="Relations">Relations</span> &ndash; <span data-i18n="Influenced">Influenced</span></a></li>
</ul>
<div id="content"></div>
......
......@@ -4,10 +4,10 @@
<uri id="User Edited Redirect" name="http://is.muni.cz/www/255658/sbms/v1_0/SemanticBIM" uri="SemanticBIM.rdf"/>
<uri id="User Edited Redirect" name="http://purl.oclc.org/NET/muo/muo#" uri="muo-vocab.rdf"/>
<group id="Folder Repository, directory=, recursive=true, Auto-Update=true, version=2" prefer="public" xml:base="">
<uri id="Automatically generated entry, Timestamp=1465829895865" name="http://purl.oclc.org/NET/muo/ucum/" uri="ucum-instances.rdf"/>
<uri id="Automatically generated entry, Timestamp=1465829895865" name="http://purl.oclc.org/NET/ssnx/ssn" uri="ssn.rdf"/>
<uri id="Automatically generated entry, Timestamp=1465829895865" name="http://www.loa.istc.cnr.it/ontologies/DUL.owl" uri="DUL.rdf"/>
<uri id="Automatically generated entry, Timestamp=1465829895865" name="duplicate:http://www.w3.org/2002/07/owl" uri="SemanticBIM.rdf"/>
<uri id="Automatically generated entry, Timestamp=1465829895865" name="duplicate:http://www.w3.org/2002/07/owl" uri="SemanticBMS.rdf"/>
<uri id="Automatically generated entry, Timestamp=1468246645207" name="http://purl.oclc.org/NET/muo/ucum/" uri="ucum-instances.rdf"/>
<uri id="Automatically generated entry, Timestamp=1468246645207" name="http://purl.oclc.org/NET/ssnx/ssn" uri="ssn.rdf"/>
<uri id="Automatically generated entry, Timestamp=1468246645207" name="http://www.loa.istc.cnr.it/ontologies/DUL.owl" uri="DUL.rdf"/>
<uri id="Automatically generated entry, Timestamp=1468246645207" name="duplicate:http://www.w3.org/2002/07/owl" uri="SemanticBIM.rdf"/>
<uri id="Automatically generated entry, Timestamp=1468246645207" name="duplicate:http://www.w3.org/2002/07/owl" uri="SemanticBMS.rdf"/>
</group>
</catalog>
......@@ -64,6 +64,36 @@ public class FieldsEndpoint {
return r;
}
@GET
@Path("/filter.influenced")
@Produces(MediaType.APPLICATION_JSON)
public TypeResponse getInfluencedFilterFieldTypes() {
TypeResponse r = new TypeResponse();
r.setName("filter.trend");
r.getMembers().addAll(Fields.INFLUENCED_FILTER_FIELDS);
return r;
}
@GET
@Path("/filter.influencing")
@Produces(MediaType.APPLICATION_JSON)
public TypeResponse getInfluencingFilterFieldTypes() {
TypeResponse r = new TypeResponse();
r.setName("filter.trend");
r.getMembers().addAll(Fields.INFLUENCING_FILTER_FIELDS);
return r;
}
@GET
@Path("/data.influence")
@Produces(MediaType.APPLICATION_JSON)
public TypeResponse getInfluenceDataFieldTypes() {
TypeResponse r = new TypeResponse();
r.setName("data.influence");
r.getMembers().addAll(Fields.INFLUENCE_DATA_FIELDS);
return r;
}
@GET
@Path("/insert.dataPoint")
@Produces(MediaType.APPLICATION_JSON)
......
......@@ -29,7 +29,6 @@ import cz.muni.fi.lasaris.sbms.api.request.AddressRequest;
import cz.muni.fi.lasaris.sbms.api.request.AlgorithmRequest;
import cz.muni.fi.lasaris.sbms.api.request.Insert;
import cz.muni.fi.lasaris.sbms.api.response.AddressResponse;
import cz.muni.fi.lasaris.sbms.api.response.GroupedResponse;
import cz.muni.fi.lasaris.sbms.api.response.InfluenceResponse;
import cz.muni.fi.lasaris.sbms.model.Fields;
import cz.muni.fi.lasaris.sbms.model.ModelUpdater;
......@@ -83,7 +82,7 @@ public class RelationsEndpoint {
i.getProperty().setQuality(propQualityP);
}
a.setInfluenced(i);
r.getResponseFields().addAll(Fields.INFLUENCE_FIELDS);
r.getResponseFields().addAll(Fields.INFLUENCE_DATA_FIELDS);
return QueryParser.getInfluencingResponse(r);
}
......@@ -94,10 +93,10 @@ public class RelationsEndpoint {
@QueryParam("bmsId") String bmsIdP) {
if(StringUtils.isBlank(bmsIdP)) {
GroupedResponse.getErrorResponse("bmsId must be set");
return InfluenceResponse.getErrorResponse("bmsId must be set");
}
AddressRequest r = new AddressRequest(new Address(bmsIdP));
r.getResponseFields().addAll(Fields.INFLUENCE_FIELDS);
r.getResponseFields().addAll(Fields.INFLUENCE_DATA_FIELDS);
return QueryParser.getInfluencedResponse(r);
}
......@@ -108,7 +107,7 @@ public class RelationsEndpoint {
@QueryParam("bmsId") String bmsIdP) {
if(StringUtils.isBlank(bmsIdP)) {
GroupedResponse.getErrorResponse("bmsId must be set");
return AddressResponse.getErrorResponse("bmsId must be set");
}
AlgorithmRequest r = new AlgorithmRequest(new Algorithm(bmsIdP));
r.getResponseFields().addAll(Fields.USED_FIELDS);
......@@ -122,7 +121,7 @@ public class RelationsEndpoint {
@QueryParam("bmsId") String bmsIdP) {
if(StringUtils.isBlank(bmsIdP)) {
GroupedResponse.getErrorResponse("bmsId must be set");
return AddressResponse.getErrorResponse("bmsId must be set");
}
AlgorithmRequest r = new AlgorithmRequest(new Algorithm());
r.getAlgorithm().setUsedAddress(new Address(bmsIdP));
......
......@@ -2,11 +2,11 @@ package cz.muni.fi.lasaris.sbms.api.entities;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Influence implements Groupable {
public class Influence implements Groupable, Comparable<Influence> {
private ObservedProperty property;
private Scope scope;
public Influence() {
public Influence(){
}
public Influence(ObservedProperty property, Scope scope) {
......@@ -47,6 +47,14 @@ public class Influence implements Groupable {
this.group = group;
}
@Override
public int compareTo(Influence o) {
// TODO add better implementation
return this.toString().compareTo(o.toString());
}
}
......@@ -3,8 +3,14 @@ package cz.muni.fi.lasaris.sbms.api.response;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonInclude;
import cz.muni.fi.lasaris.sbms.api.entities.Address;
@XmlRootElement
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AddressResponse {
private String error;
......
......@@ -3,8 +3,14 @@ package cz.muni.fi.lasaris.sbms.api.response;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonInclude;
import cz.muni.fi.lasaris.sbms.api.entities.Influence;
@XmlRootElement
@JsonInclude(JsonInclude.Include.NON_NULL)
public class InfluenceResponse {
private String error;
......
......@@ -349,12 +349,12 @@ public class BodyBuilders {
}
if(a.getPublisher() != null || fields.contains(gsv("publisher.bimId"))) {
if(a.getPublisher() != null || fields.contains("publisher.bimId")) {
body.addTriplePattern(Triple.create(Var.alloc("address"),
NodeFactory.createURI(NS.sbms + "publishedByDevice"),
Var.alloc("publisher")));
if(fields.contains(gsv("publisher.bimId"))) {
if(fields.contains("publisher.bimId")) {
body.addTriplePattern(Triple.create(Var.alloc("publisher"),
NodeFactory.createURI(NS.sbim + "hasBIMId"),
Var.alloc(gsv("publisher.bimId"))));
......@@ -368,49 +368,58 @@ public class BodyBuilders {
}
if(a.getInfluenced() != null) {
if(a.getInfluenced() != null
|| fields.contains("influenced.property.quality")
|| fields.contains("influenced.property.domain")
|| fields.contains("influenced.scope.bimId")
|| fields.contains("influenced.scope.type")
) {
body.addTriplePattern(Triple.create(Var.alloc("address"),
NodeFactory.createURI(NS.sbms + "influences"),
Var.alloc(gsv("influenced.property"))));
Var.alloc("influencedproperty")));
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.scope")),
body.addTriplePattern(Triple.create(Var.alloc("influencedscope"),
NodeFactory.createURI(NS.sbms + "hasProperty"),
Var.alloc(gsv("influenced.property"))));
Var.alloc("influencedproperty")));
if(a.getInfluenced().getScope() != null && a.getInfluenced().getScope().getBimId() != null) {
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.scope")),
if(a.getInfluenced() != null
&& a.getInfluenced().getScope() != null
&& a.getInfluenced().getScope().getBimId() != null) {
body.addTriplePattern(Triple.create(Var.alloc("influencedscope"),
NodeFactory.createURI(NS.sbim + "hasBIMId"),
NodeFactory.createLiteral(a.getInfluenced().getScope().getBimId())));
}
if(fields.contains("influenced.scope.bimId")) {
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.scope")),
body.addTriplePattern(Triple.create(Var.alloc("influencedscope"),
NodeFactory.createURI(NS.sbim + "hasBIMId"),
Var.alloc(gsv("influenced.scope.bimId"))));
}
if(fields.contains("influenced.scope.type")) {
setTypeClause(body, gsv("influenced.scope"), gsv("influenced.scope.type"), NS.dul + "PhysicalObject", NS.sbms + "Scope");
setTypeClause(body, "influencedscope", gsv("influenced.scope.type"), NS.dul + "PhysicalObject", NS.sbms + "Scope");
}
if(a.getInfluenced().getProperty() != null && a.getInfluenced().getProperty().getDomain() != null &&
if(a.getInfluenced() != null
&& a.getInfluenced().getProperty() != null
&& a.getInfluenced().getProperty().getDomain() != null &&
a.getInfluenced().getProperty().getQuality() != null) {
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.property")),
body.addTriplePattern(Triple.create(Var.alloc("influencedproperty"),
NodeFactory.createURI(NS.sbms + "hasPropertyDomain"),
NodeFactory.createURI(NS.ucum + a.getInfluenced().getProperty().getQuality())));
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.property")),
body.addTriplePattern(Triple.create(Var.alloc("influencedproperty"),
NodeFactory.createURI(NS.sbms + "hasPhysicalQuality"),
NodeFactory.createURI(NS.sbms + a.getInfluenced().getProperty().getDomain())));
}
if(fields.contains("influenced.property.domain")) {
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.property")),
body.addTriplePattern(Triple.create(Var.alloc("influencedproperty"),
NodeFactory.createURI(NS.sbms + "hasPropertyDomain"),
Var.alloc(gsv("influenced.property.domain"))));
}
if(fields.contains("influenced.property.quality")) {
body.addTriplePattern(Triple.create(Var.alloc(gsv("influenced.property")),
body.addTriplePattern(Triple.create(Var.alloc("influencedproperty"),
NodeFactory.createURI(NS.sbms + "hasPhysicalQuality"),
Var.alloc(gsv("influenced.property.quality"))));
}
......
......@@ -97,7 +97,7 @@ public class Fields {
"dataPoint.publisher.bimId"
}));
public static final List<String> INFLUENCE_FIELDS = Collections.unmodifiableList(Arrays.asList(new String[]{
public static final List<String> INFLUENCE_DATA_FIELDS = Collections.unmodifiableList(Arrays.asList(new String[]{
"bmsId",
"type",
"publisher.bimId",
......@@ -107,6 +107,16 @@ public class Fields {
"influenced.property.domain"
}));
public static final List<String> INFLUENCED_FILTER_FIELDS = Collections.unmodifiableList(Arrays.asList(new String[]{
"bmsId"
}));
public static final List<String> INFLUENCING_FILTER_FIELDS = Collections.unmodifiableList(Arrays.asList(new String[]{
"influenced.scope.bimId",
"influenced.property.quality",
"influenced.property.domain"
}));
public static final List<String> USED_FIELDS = Collections.unmodifiableList(Arrays.asList(new String[]{
"bmsId",
"used.bmsId",
......
......@@ -38,6 +38,7 @@ public class QueryParser {
logger.debug(qs.toString());
response.addResult(ObjectBuilders.createDataPoint(qs, request.getResponseFields(), request.getGrouping()));
}
logger.debug("Query returned.");
return response;
}
......@@ -145,7 +146,6 @@ public class QueryParser {
q.setQuerySelectType(); // Make it a select query
for(String field : request.getResponseFields()) {
logger.debug(field);
q.addResultVar(gsv(field));
}
......@@ -165,14 +165,26 @@ public class QueryParser {
public static String getSPARQLvar(String field) {
if(sparqlVars == null) {
sparqlVars = new HashMap<String,String>();
for(String f : Fields.DATAPOINT_DATA_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.DATAPOINT_FILTER_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.TREND_DATA_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.TREND_FILTER_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
sparqlVars.put("trend.bmsId", "trendbmsId");
for(String f : Fields.INFLUENCE_FIELDS) {
for(String f : Fields.INFLUENCE_DATA_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.INFLUENCED_FILTER_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.INFLUENCING_FILTER_FIELDS) {
sparqlVars.put(f, f.replace(".", ""));
}
for(String f : Fields.USED_FIELDS) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment