Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Adam Kučera
semanticBMS
Commits
2731375d
Commit
2731375d
authored
Jul 11, 2016
by
akucera
Browse files
changes in TrendDP - preparation for client implementation
parent
aa54d9ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/api/TrendsEndpoint.java
View file @
2731375d
...
...
@@ -25,6 +25,7 @@ import cz.muni.fi.lasaris.sbms.api.entities.Scope;
import
cz.muni.fi.lasaris.sbms.api.entities.Sensing
;
import
cz.muni.fi.lasaris.sbms.api.entities.Source
;
import
cz.muni.fi.lasaris.sbms.api.entities.Trend
;
import
cz.muni.fi.lasaris.sbms.api.request.DataPointsRequest
;
import
cz.muni.fi.lasaris.sbms.api.request.Insert
;
import
cz.muni.fi.lasaris.sbms.api.request.TrendsRequest
;
import
cz.muni.fi.lasaris.sbms.api.response.GroupedResponse
;
...
...
@@ -40,22 +41,23 @@ final static Logger logger = Logger.getLogger(TrendsEndpoint.class);
@GET
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
GroupedResponse
getTrends
(
@QueryParam
(
"bmsId"
)
String
dpIdP
,
@QueryParam
(
"type"
)
String
dptP
,
@QueryParam
(
"source.bimId"
)
String
sourceIdP
,
@QueryParam
(
"source.type"
)
String
sourceTypeP
,
@QueryParam
(
"source.location"
)
String
sourceLocP
,
@QueryParam
(
"scope.bimId"
)
String
scopeIdP
,
@QueryParam
(
"scope.type"
)
String
scopeTypeP
,
@QueryParam
(
"scope.location"
)
String
scopeLocP
,
@QueryParam
(
"sensing.type"
)
String
sensingTypeP
,
@QueryParam
(
"sensing.window"
)
String
sensingWindowP
,
@QueryParam
(
"property.domain"
)
String
propDomP
,
@QueryParam
(
"property.quality"
)
String
propQualityP
,
@QueryParam
(
"publisher.bimId"
)
String
publisherP
,
@QueryParam
(
"influenced.scope.bimId"
)
String
inflScopeIdP
,
@QueryParam
(
"influenced.property.quality"
)
String
inflQualityP
,
@QueryParam
(
"influenced.property.domain"
)
String
inflDomainP
,
@QueryParam
(
"bmsId"
)
String
IdP
,
@QueryParam
(
"dataPoint.bmsId"
)
String
dpIdP
,
@QueryParam
(
"dataPoint.type"
)
String
dptP
,
@QueryParam
(
"dataPoint.source.bimId"
)
String
sourceIdP
,
@QueryParam
(
"dataPoint.source.type"
)
String
sourceTypeP
,
@QueryParam
(
"dataPoint.source.location"
)
String
sourceLocP
,
@QueryParam
(
"dataPoint.scope.bimId"
)
String
scopeIdP
,
@QueryParam
(
"dataPoint.scope.type"
)
String
scopeTypeP
,
@QueryParam
(
"dataPoint.scope.location"
)
String
scopeLocP
,
@QueryParam
(
"dataPoint.sensing.type"
)
String
sensingTypeP
,
@QueryParam
(
"dataPoint.sensing.window"
)
String
sensingWindowP
,
@QueryParam
(
"dataPoint.property.domain"
)
String
propDomP
,
@QueryParam
(
"dataPoint.property.quality"
)
String
propQualityP
,
@QueryParam
(
"dataPoint.publisher.bimId"
)
String
publisherP
,
@QueryParam
(
"dataPoint.influenced.scope.bimId"
)
String
inflScopeIdP
,
@QueryParam
(
"dataPoint.influenced.property.quality"
)
String
inflQualityP
,
@QueryParam
(
"dataPoint.influenced.property.domain"
)
String
inflDomainP
,
@QueryParam
(
"fields"
)
String
fieldsP
,
@QueryParam
(
"grouping"
)
String
groupingP
)
{
...
...
@@ -65,6 +67,10 @@ final static Logger logger = Logger.getLogger(TrendsEndpoint.class);
t
.
setDataPoint
(
dp
);
dpr
.
setTrend
(
t
);
if
(
IdP
!=
null
)
{
t
.
setBmsId
(
IdP
);
}
if
(
dpIdP
!=
null
)
{
dp
.
setBmsId
(
dpIdP
);
}
...
...
@@ -121,6 +127,28 @@ final static Logger logger = Logger.getLogger(TrendsEndpoint.class);
}
}
@GET
@Path
(
"/{bmsId}"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
GroupedResponse
getDataPoint
(
@PathParam
(
"bmsId"
)
String
bmsIdP
,
@QueryParam
(
"fields"
)
String
fieldsP
)
{
TrendsRequest
tr
=
new
TrendsRequest
();
Trend
t
=
new
Trend
();
t
.
setBmsId
(
bmsIdP
);
tr
.
setTrend
(
t
);
tr
.
parseResponseFields
(
fieldsP
);
try
{
return
QueryParser
.
getTrendsResponse
(
tr
);
}
catch
(
Exception
e
){
logger
.
error
(
e
,
e
);
return
GroupedResponse
.
getErrorResponse
(
e
.
toString
());
}
}
@Context
private
UriInfo
uriInfo
;
...
...
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/api/TypesEndpoint.java
View file @
2731375d
...
...
@@ -152,22 +152,42 @@ public class TypesEndpoint {
}
@GET
@Path
(
"/field.filter"
)
@Path
(
"/field.filter
.dataPoint
"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
TypeResponse
getFilterFieldTypes
()
{
public
TypeResponse
get
DP
FilterFieldTypes
()
{
TypeResponse
r
=
new
TypeResponse
();
r
.
setName
(
"field.filter"
);
r
.
getMembers
().
addAll
(
Fields
.
FILTER_FIELDS
);
r
.
getMembers
().
addAll
(
Fields
.
DATAPOINT_
FILTER_FIELDS
);
return
r
;
}
@GET
@Path
(
"/field.data"
)
@Path
(
"/field.data
.dataPoint
"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
TypeResponse
getDataFieldTypes
()
{
public
TypeResponse
getD
PD
ataFieldTypes
()
{
TypeResponse
r
=
new
TypeResponse
();
r
.
setName
(
"field.data"
);
r
.
getMembers
().
addAll
(
Fields
.
DATA_FIELDS
);
r
.
getMembers
().
addAll
(
Fields
.
DATAPOINT_DATA_FIELDS
);
return
r
;
}
@GET
@Path
(
"/field.filter.trend"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
TypeResponse
getTrendFilterFieldTypes
()
{
TypeResponse
r
=
new
TypeResponse
();
r
.
setName
(
"field.filter"
);
r
.
getMembers
().
addAll
(
Fields
.
TREND_FILTER_FIELDS
);
return
r
;
}
@GET
@Path
(
"/field.data.trend"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
TypeResponse
getTrendDataFieldTypes
()
{
TypeResponse
r
=
new
TypeResponse
();
r
.
setName
(
"field.data"
);
r
.
getMembers
().
addAll
(
Fields
.
TREND_DATA_FIELDS
);
return
r
;
}
...
...
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/api/request/TrendsRequest.java
View file @
2731375d
package
cz.muni.fi.lasaris.sbms.api.request
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cz.muni.fi.lasaris.sbms.api.entities.Trend
;
public
class
TrendsRequest
extends
GroupableRequest
{
...
...
@@ -15,7 +18,20 @@ public class TrendsRequest extends GroupableRequest {
public
void
setTrend
(
Trend
trend
)
{
this
.
trend
=
trend
;
}
private
List
<
String
>
ufl
;
public
List
<
String
>
getDPFields
()
{
if
(
this
.
responseFields
==
null
)
return
null
;
if
(
ufl
==
null
||
ufl
.
size
()
!=
this
.
responseFields
.
size
())
{
ufl
=
new
ArrayList
<
String
>(
this
.
responseFields
.
size
());
for
(
String
f
:
this
.
getResponseFields
())
{
if
(
f
.
startsWith
(
"datapoint."
))
{
ufl
.
add
(
f
.
substring
(
10
));
}
// removing datapoint.
}
}
return
ufl
;
}
@Override
public
String
getIdentityField
()
{
...
...
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/model/BodyBuilders.java
View file @
2731375d
...
...
@@ -288,7 +288,7 @@ public class BodyBuilders {
// GROUPING
if
(
request
.
getGrouping
()
!=
null
&&
Fields
.
GROUPINGS
.
contains
(
request
.
getGrouping
()))
{
switch
(
request
.
getGrouping
())
{
case
"data
p
oint.type"
:
case
"data
P
oint.type"
:
setTypeClause
(
body
,
"datapoint"
,
"group"
,
NS
.
sbms
+
"DataPoint"
,
NS
.
sbms
+
"DataPoint"
);
break
;
case
"source.type"
:
...
...
@@ -480,7 +480,8 @@ public class BodyBuilders {
DataPointsRequest
r
=
new
DataPointsRequest
();
r
.
setGrouping
(
request
.
getGrouping
());
r
.
setDataPoint
(
request
.
getTrend
().
getDataPoint
());
r
.
getResponseFields
().
addAll
(
request
.
getResponseFields
());
r
.
getResponseFields
().
addAll
(
request
.
getDPFields
());
ElementGroup
body
=
getQueryBody
(
r
);
body
.
addTriplePattern
(
Triple
.
create
(
Var
.
alloc
(
"trend"
),
NodeFactory
.
createURI
(
NS
.
sbms
+
"trends"
),
...
...
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/model/Fields.java
View file @
2731375d
...
...
@@ -21,10 +21,12 @@ public class Fields {
"source.floor"
,
"source.building"
,
"source.site"
,
"data
p
oint.type"
"data
P
oint.type"
}));
public
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
public
static
final
List
<
String
>
FILTER_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
public
static
final
List
<
String
>
DATAPOINT_FILTER_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
"bmsId"
,
"type"
,
"source.bimId"
,
...
...
@@ -42,7 +44,7 @@ public class Fields {
"influenced.property.quality"
,
"influenced.property.domain"
}));
public
static
final
List
<
String
>
DATA_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
public
static
final
List
<
String
>
DATAPOINT_
DATA_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
"bmsId"
,
"type"
,
"source.bimId"
,
...
...
@@ -58,6 +60,43 @@ public class Fields {
"publisher.bimId"
}));
public
static
final
List
<
String
>
TREND_FILTER_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
"bmsId"
,
"dataPoint.bmsId"
,
"dataPoint.type"
,
"dataPoint.source.bimId"
,
"dataPoint.source.type"
,
"dataPoint.source.location"
,
"dataPoint.scope.bimId"
,
"dataPoint.scope.type"
,
"dataPoint.scope.location"
,
"dataPoint.sensing.type"
,
"dataPoint.sensing.window"
,
"dataPoint.property.domain"
,
"dataPoint.property.quality"
,
"dataPoint.publisher.bimId"
,
"dataPoint.influenced.scope.bimId"
,
"dataPoint.influenced.property.quality"
,
"dataPoint.influenced.property.domain"
}));
public
static
final
List
<
String
>
TREND_DATA_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
"bmsId"
,
"dataPoint.bmsId"
,
"dataPoint.type"
,
"dataPoint.source.bimId"
,
"dataPoint.source.type"
,
"dataPoint.source.location"
,
"dataPoint.scope.bimId"
,
"dataPoint.scope.type"
,
"dataPoint.scope.location"
,
"dataPoint.sensing.type"
,
"dataPoint.sensing.window"
,
"dataPoint.property.domain"
,
"dataPoint.property.quality"
,
"dataPoint.publisher.bimId"
}));
public
static
final
List
<
String
>
INFLUENCE_FIELDS
=
Collections
.
unmodifiableList
(
Arrays
.
asList
(
new
String
[]{
"bmsId"
,
"type"
,
...
...
SemanticBMSServer/src/main/java/cz/muni/fi/lasaris/sbms/model/QueryParser.java
View file @
2731375d
...
...
@@ -112,7 +112,7 @@ public class QueryParser {
{
logger
.
debug
(
qs
.
toString
());
response
.
addResult
(
ObjectBuilders
.
createTrend
(
ObjectBuilders
.
createDataPoint
(
qs
,
request
.
get
Response
Fields
(),
request
.
getGrouping
()),
ObjectBuilders
.
createDataPoint
(
qs
,
request
.
get
DP
Fields
(),
request
.
getGrouping
()),
qs
,
request
.
getResponseFields
(),
request
.
getGrouping
()));
}
return
response
;
...
...
@@ -164,7 +164,7 @@ public class QueryParser {
public
static
String
getSPARQLvar
(
String
field
)
{
if
(
sparqlVars
==
null
)
{
sparqlVars
=
new
HashMap
<
String
,
String
>();
for
(
String
f
:
Fields
.
FILTER_FIELDS
)
{
for
(
String
f
:
Fields
.
DATAPOINT_
FILTER_FIELDS
)
{
sparqlVars
.
put
(
f
,
f
.
replace
(
"."
,
""
));
}
for
(
String
f
:
Fields
.
INFLUENCE_FIELDS
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment