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
b73d9b55
Commit
b73d9b55
authored
Jan 10, 2018
by
Adam Kucera
Browse files
refactoring + preparation to final implementation of the DA API
parent
7596c4a3
Changes
12
Hide whitespace changes
Inline
Side-by-side
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/DataPointsEndpoint.java
View file @
b73d9b55
...
...
@@ -20,12 +20,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
cz.muni.fi.lasaris.sbms.data.api.request.GroupedAddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.request.AddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.response.AggregateResponse
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.RawValue
;
import
cz.muni.fi.lasaris.sbms.data.logic.ProviderManager
;
import
cz.muni.fi.lasaris.sbms.data.logic.DataCollector
;
import
cz.muni.fi.lasaris.sbms.data.logic.
DP
DataCollector
;
//TODO http://stackoverflow.com/questions/14202257/design-restful-query-api-with-a-long-list-of-query-parameters
...
...
@@ -34,12 +34,12 @@ import cz.muni.fi.lasaris.sbms.data.logic.DataCollector;
public
class
DataPointsEndpoint
{
final
static
Logger
logger
=
Logger
.
getLogger
(
DataPointsEndpoint
.
class
);
private
DataCollector
dc
=
new
DataCollector
();
private
DP
DataCollector
dc
=
new
DP
DataCollector
();
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
lice
Response
getDataPoints
(
public
S
napshot
Response
getDataPoints
(
@QueryParam
(
"ids"
)
String
json
,
@QueryParam
(
"cache"
)
String
cache
)
{
...
...
@@ -51,11 +51,11 @@ public class DataPointsEndpoint {
logger
.
debug
(
json
);
AddressRequest
readSpecs
=
m
.
readValue
(
json
,
AddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
S
lice
Response
result
=
dc
.
getDataPointValues
(
readSpecs
,
allowCache
(
cache
));
S
napshot
Response
result
=
dc
.
getDataPointValues
(
readSpecs
,
allowCache
(
cache
));
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
...
...
@@ -88,7 +88,7 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/grouped"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
lice
Response
getGroupedDataPoints
(
public
S
napshot
Response
getGroupedDataPoints
(
@QueryParam
(
"ids"
)
String
json
,
@QueryParam
(
"cache"
)
String
cache
)
{
...
...
@@ -100,7 +100,7 @@ public class DataPointsEndpoint {
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointGroupedValues
(
readSpecs
,
allowCache
(
cache
));
}
catch
(
IOException
e
)
{
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -131,12 +131,12 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/{id}"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
lice
Response
getDataPoint
(
public
S
napshot
Response
getDataPoint
(
@PathParam
(
"id"
)
String
idP
,
@QueryParam
(
"cache"
)
String
cache
)
{
Address
a
=
new
Address
(
idP
);
RawValue
v
=
ProviderManager
.
getDataPointsProvider
(
a
.
getProtocol
()).
getDataPointValue
(
a
,
allowCache
(
cache
));
return
new
S
lice
Response
(
a
,
v
);
return
new
S
napshot
Response
(
a
,
v
);
}
private
boolean
allowCache
(
String
cache
)
{
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/TrendsEndpoint.java
View file @
b73d9b55
...
...
@@ -5,10 +5,12 @@ import java.time.Duration;
import
java.time.ZonedDateTime
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.TemporalUnit
;
import
java.util.Arrays
;
import
javax.annotation.security.RolesAllowed
;
import
javax.ws.rs.DefaultValue
;
import
javax.ws.rs.GET
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
...
...
@@ -17,155 +19,109 @@ import javax.ws.rs.core.MediaType;
import
org.apache.log4j.Logger
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
cz.muni.fi.lasaris.sbms.data.api.request.GroupedAddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.request.TrendsRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.request.AddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.response.AggregateResponse
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
eriesOfValues
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.SliceResponse
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationWindow
;
import
cz.muni.fi.lasaris.sbms.data.entities.Interpolation
;
import
cz.muni.fi.lasaris.sbms.data.entities.Sampling
;
import
cz.muni.fi.lasaris.sbms.data.entities.SeriesSpecs
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.Trend
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.RawValue
;
import
cz.muni.fi.lasaris.sbms.data.logic.DataCollector
;
import
cz.muni.fi.lasaris.sbms.data.logic.
DP
DataCollector
;
import
cz.muni.fi.lasaris.sbms.data.logic.ProviderManager
;
import
cz.muni.fi.lasaris.sbms.data.logic.TrendsDataCollector
;
import
cz.muni.fi.lasaris.sbms.data.util.Aggregator
;
public
class
TrendsEndpoint
{
final
static
Logger
logger
=
Logger
.
getLogger
(
TrendsEndpoint
.
class
);
private
DataCollector
dc
;
private
Trends
DataCollector
dc
;
private
ObjectMapper
m
;
public
TrendsEndpoint
()
{
dc
=
new
DataCollector
();
dc
=
new
Trends
DataCollector
();
m
=
new
ObjectMapper
();
m
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
}
//
TODO
http://stackoverflow.com/questions/14202257/design-restful-query-api-with-a-long-list-of-query-parameters
// http://stackoverflow.com/questions/14202257/design-restful-query-api-with-a-long-list-of-query-parameters
/*
// Methods 4, 6
@RolesAllowed({"user","admin"})
@GET
@Path("/serie/{id}")
@Produces(MediaType.APPLICATION_JSON)
public
S
lice
Response
get
Trends
(
@QueryParam
(
"id
s
"
)
String
json
,
public S
eriesOfValues
Response get
Func
(
@QueryParam("id") String
id
,
@QueryParam("start") String start,
@QueryParam("end") String end,
@QueryParam("sampling.cron") String samplingCron,
@QueryParam("sampling.duration") Long samplingDur,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"interpolation"
)
Interpolation
interpolation
@QueryParam("sampling.interpolation") Interpolation interpolation,
@QueryParam("aggregation.function") String aggregation,
@QueryParam("aggregation.window") String window,
) {
try
{
logger
.
debug
(
"Processing request..."
);
logger
.
debug
(
json
);
TrendsRequest
readSpecs
=
getReadSpecs
(
json
,
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
,
null
);
logger
.
debug
(
readSpecs
);
SliceResponse
result
=
dc
.
getTrends
(
readSpecs
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
SliceResponse
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
Address a = new Address(id);
Trend v = ProviderManager.getTrendsProvider(a.getProtocol()).getTrend(a, getSeriesSpecs(start, end, samplingCron, samplingDur, interpolation));
return new SeriesOfValuesResponse(a, v);
}
*/
// Method 4
@RolesAllowed
({
"user"
,
"admin"
})
@
GE
T
@Path
(
"/
aggregated
"
)
@
POS
T
@Path
(
"/
si
"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
AggregateResponse
getAggregatedTrends
(
@QueryParam
(
"ids"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
public
SeriesOfValuesResponse
getSI
(
@QueryParam
(
"id"
)
String
id
,
@QueryParam
(
"start"
)
String
start
,
@QueryParam
(
"end"
)
String
end
)
{
ObjectMapper
m
=
new
ObjectMapper
();
try
{
logger
.
debug
(
"Processing request..."
);
logger
.
debug
(
json
);
AddressRequest
readSpecs
=
m
.
readValue
(
json
,
AddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointsAggregation
(
readSpecs
,
agg
);
}
catch
(
IOException
e
)
{
return
AggregateResponse
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Path
(
"/grouped"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
SliceResponse
getGroupedDataPoints
(
@QueryParam
(
"json"
)
String
json
)
{
ObjectMapper
m
=
new
ObjectMapper
();
try
{
logger
.
debug
(
"Processing request..."
);
logger
.
debug
(
json
);
GroupedAddressRequest
readSpecs
=
m
.
readValue
(
json
,
GroupedAddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointGroupedValues
(
readSpecs
);
}
catch
(
IOException
e
)
{
return
SliceResponse
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
TrendsRequest
r
=
getReadSpecsSingle
(
id
,
start
,
end
,
null
,
null
,
null
,
null
,
null
);
Trend
v
=
dc
.
getTrend
(
r
);
return
new
SeriesOfValuesResponse
(
r
.
getAddress
(),
v
);
}
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Path
(
"/group-aggregated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
AggregateResponse
getGroupedAggregatedDataPoints
(
@QueryParam
(
"json"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
)
{
ObjectMapper
m
=
new
ObjectMapper
();
try
{
logger
.
debug
(
"Processing request..."
);
logger
.
debug
(
json
);
GroupedAddressRequest
readSpecs
=
m
.
readValue
(
json
,
GroupedAddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
AggregateResponse
result
=
dc
.
getDataPointGroupAggregations
(
readSpecs
,
agg
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
AggregateResponse
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
private
TrendsRequest
getReadSpecsSingle
(
String
id
,
String
start
,
String
end
,
String
samplingCron
,
Long
samplingDur
,
Interpolation
interpolation
,
AggregationFunction
aggregation
,
AggregationWindow
window
)
{
TrendsRequest
readSpecs
=
getReadSpecsBase
(
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
,
aggregation
,
window
);
AddressRequest
ar
=
new
AddressRequest
();
ar
.
setAddresses
(
Arrays
.
asList
(
new
Address
[]
{
new
Address
(
id
)}));
readSpecs
.
setAddressSpecs
(
ar
);
return
readSpecs
;
}
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Path
(
"/{id}"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
SliceResponse
getTrend
(
@QueryParam
(
"id"
)
String
id
,
@QueryParam
(
"start"
)
String
start
,
@QueryParam
(
"end"
)
String
end
,
@QueryParam
(
"sampling.cron"
)
String
samplingCron
,
@QueryParam
(
"sampling.duration"
)
Long
samplingDur
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"interpolation"
)
Interpolation
interpolation
)
{
Address
a
=
new
Address
(
id
);
Trend
v
=
ProviderManager
.
getTrendsProvider
(
a
.
getProtocol
()).
getTrend
(
a
,
getSeriesSpecs
(
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
));
return
new
SliceResponse
(
a
,
v
);
private
TrendsRequest
getReadSpecsMulti
(
String
json
,
boolean
grouping
,
String
start
,
String
end
,
String
samplingCron
,
Long
samplingDur
,
Interpolation
interpolation
,
AggregationFunction
aggregation
,
AggregationWindow
window
)
throws
JsonParseException
,
JsonMappingException
,
IOException
{
TrendsRequest
readSpecs
=
getReadSpecsBase
(
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
,
aggregation
,
window
);
readSpecs
.
setAddressSpecs
(
m
.
readValue
(
json
,
AddressRequest
.
class
));
return
readSpecs
;
}
private
TrendsRequest
getReadSpecs
(
String
json
,
String
start
,
String
end
,
String
samplingCron
,
Long
samplingDur
,
Interpolation
interpolation
,
AggregationFunction
aggregation
)
{
private
TrendsRequest
getReadSpecsBase
(
String
start
,
String
end
,
String
samplingCron
,
Long
samplingDur
,
Interpolation
interpolation
,
AggregationFunction
aggregation
,
AggregationWindow
window
)
{
TrendsRequest
readSpecs
=
new
TrendsRequest
();
readSpecs
.
setAddressesSpecs
(
m
.
readValue
(
json
,
AddressRequest
.
class
));
SeriesSpecs
s
=
getSeriesSpecs
(
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
);
readSpecs
.
setSeriesSpecs
(
s
);
readSpecs
.
setAggregation
(
aggregation
);
readSpecs
.
setAggregation
(
aggregation
,
window
);
return
readSpecs
;
}
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/request/TrendsRequest.java
0 → 100644
View file @
b73d9b55
package
cz.muni.fi.lasaris.sbms.data.api.request
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationWindow
;
import
cz.muni.fi.lasaris.sbms.data.entities.SeriesSpecs
;
public
class
TrendsRequest
{
public
void
setAddressSpecs
(
AddressRequest
ar
)
{
// TODO Auto-generated method stub
}
public
Address
getAddress
()
{
// TODO Auto-generated method stub
return
null
;
}
public
void
setSeriesSpecs
(
SeriesSpecs
s
)
{
// TODO Auto-generated method stub
}
public
void
setAggregation
(
AggregationFunction
aggregation
,
AggregationWindow
window
)
{
// TODO Auto-generated method stub
}
}
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/AggregateResponse.java
View file @
b73d9b55
...
...
@@ -8,6 +8,8 @@ import cz.muni.fi.lasaris.sbms.data.entities.containers.Aggregation;
import
cz.muni.fi.lasaris.sbms.data.entities.values.AggregatedValue
;
public
class
AggregateResponse
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
String
error
;
private
Map
<
String
,
AggregatedValue
>
results
;
...
...
@@ -31,7 +33,7 @@ public class AggregateResponse {
public
AggregateResponse
(
AggregatedValue
v
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
AggregatedValue
>();
this
.
results
.
put
(
"value"
,
v
);
this
.
results
.
put
(
DEFAULT_GROUPING
,
v
);
}
public
AggregateResponse
(
Aggregation
<
AddressGroup
>
a
)
{
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/SeriesOfValuesResponse.java
View file @
b73d9b55
...
...
@@ -8,7 +8,7 @@ import cz.muni.fi.lasaris.sbms.data.entities.containers.Series;
import
cz.muni.fi.lasaris.sbms.data.entities.values.Value
;
public
class
SeriesOfValuesResponse
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
String
error
;
private
Map
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>
results
;
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/SliceResponse.java
View file @
b73d9b55
...
...
@@ -4,17 +4,17 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.S
napshot
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.
Raw
Value
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.S
lice
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.
Interpolated
Value
;
public
class
SliceResponse
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
String
error
;
private
Map
<
String
,
S
napshot
>
results
;
private
Map
<
String
,
S
lice
>
results
;
public
Map
<
String
,
S
napshot
>
getResults
()
{
public
Map
<
String
,
S
lice
>
getResults
()
{
return
this
.
results
;
}
...
...
@@ -28,17 +28,17 @@ public class SliceResponse {
this
.
results
=
null
;
}
public
SliceResponse
(
Map
<
String
,
S
napshot
>
data
)
{
public
SliceResponse
(
Map
<
String
,
S
lice
>
data
)
{
this
.
results
=
data
;
}
public
SliceResponse
(
S
napshot
data
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
S
napshot
>();
public
SliceResponse
(
S
lice
data
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
S
lice
>();
this
.
results
.
put
(
DEFAULT_GROUPING
,
data
);
}
public
SliceResponse
(
Address
a
,
Raw
Value
v
)
{
this
(
new
S
napshot
());
public
SliceResponse
(
Address
a
,
Interpolated
Value
v
)
{
this
(
new
S
lice
());
this
.
results
.
get
(
DEFAULT_GROUPING
).
add
(
a
,
v
);
}
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/SnapshotResponse.java
0 → 100644
View file @
b73d9b55
package
cz.muni.fi.lasaris.sbms.data.api.response
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.Snapshot
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.RawValue
;
public
class
SnapshotResponse
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
String
error
;
private
Map
<
String
,
Snapshot
>
results
;
public
Map
<
String
,
Snapshot
>
getResults
()
{
return
this
.
results
;
}
public
static
SnapshotResponse
getErrorResponse
(
String
error
)
{
SnapshotResponse
r
=
new
SnapshotResponse
();
r
.
setError
(
error
);
return
r
;
}
private
SnapshotResponse
()
{
this
.
results
=
null
;
}
public
SnapshotResponse
(
Map
<
String
,
Snapshot
>
data
)
{
this
.
results
=
data
;
}
public
SnapshotResponse
(
Snapshot
data
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
Snapshot
>();
this
.
results
.
put
(
DEFAULT_GROUPING
,
data
);
}
public
SnapshotResponse
(
Address
a
,
RawValue
v
)
{
this
(
new
Snapshot
());
this
.
results
.
get
(
DEFAULT_GROUPING
).
add
(
a
,
v
);
}
public
String
getError
()
{
return
error
;
}
public
void
setError
(
String
error
)
{
this
.
error
=
error
;
}
}
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/logic/DataCollector.java
→
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/logic/
DP
DataCollector.java
View file @
b73d9b55
...
...
@@ -13,7 +13,7 @@ import org.apache.log4j.Logger;
import
cz.muni.fi.lasaris.sbms.data.api.request.GroupedAddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.request.AddressRequest
;
import
cz.muni.fi.lasaris.sbms.data.api.response.AggregateResponse
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.AggregationFunction
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.Snapshot
;
...
...
@@ -23,12 +23,12 @@ import cz.muni.fi.lasaris.sbms.data.util.Aggregator;
public
class
DataCollector
{
public
class
DP
DataCollector
{
final
static
Logger
logger
=
Logger
.
getLogger
(
DataCollector
.
class
);
final
static
Logger
logger
=
Logger
.
getLogger
(
DP
DataCollector
.
class
);
public
S
lice
Response
getDataPointValues
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
lice
Response
(
getDataPointValuesSnapshot
(
readSpecs
,
allowCache
));
public
S
napshot
Response
getDataPointValues
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
napshot
Response
(
getDataPointValuesSnapshot
(
readSpecs
,
allowCache
));
}
private
Snapshot
getDataPointValuesSnapshot
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
...
...
@@ -96,9 +96,9 @@ NavigableMap<String, AddressRequest> protocols = readSpecs.getProtocols();
}
public
S
lice
Response
getDataPointGroupedValues
(
GroupedAddressRequest
readSpecs
,
public
S
napshot
Response
getDataPointGroupedValues
(
GroupedAddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
lice
Response
(
getDataPointGroupedValuesMap
(
readSpecs
,
allowCache
));
return
new
S
napshot
Response
(
getDataPointGroupedValuesMap
(
readSpecs
,
allowCache
));
}
private
Map
<
String
,
Snapshot
>
getDataPointGroupedValuesMap
(
GroupedAddressRequest
readSpecs
,
...
...
@@ -113,13 +113,13 @@ NavigableMap<String, AddressRequest> protocols = readSpecs.getProtocols();
AtomicInteger
counter
=
new
AtomicInteger
(
0
);
int
count
=
protocols
.
keySet
().
size
();
List
<
S
lice
Response
>
results
=
Collections
.
synchronizedList
(
new
LinkedList
<
S
lice
Response
>());
List
<
S
napshot
Response
>
results
=
Collections
.
synchronizedList
(
new
LinkedList
<
S
napshot
Response
>());
for
(
String
protocol
:
protocols
.
keySet
())
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
S
lice
Response
rs
=
new
S
lice
Response
(
ProviderManager
.
getDataPointsProvider
(
protocol
).
getDataPointGroupedValues
(
protocols
.
get
(
protocol
).
getGroups
(),
allowCache
));
S
napshot
Response
rs
=
new
S
napshot
Response
(
ProviderManager
.
getDataPointsProvider
(
protocol
).
getDataPointGroupedValues
(
protocols
.
get
(
protocol
).
getGroups
(),
allowCache
));
synchronized
(
results
)
{
results
.
add
(
rs
);
counter
.
incrementAndGet
();
...
...
@@ -145,7 +145,7 @@ NavigableMap<String, AddressRequest> protocols = readSpecs.getProtocols();
}
synchronized
(
results
)
{
for
(
S
lice
Response
r
:
results
)
{
for
(
S
napshot
Response
r
:
results
)
{
for
(
String
group
:
r
.
getResults
().
keySet
())
{
result
.
get
(
group
).
addAll
(
r
.
getResults
().
get
(
group
).
getData
());
}
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/logic/TrendsDataCollector.java
0 → 100644
View file @
b73d9b55
package
cz.muni.fi.lasaris.sbms.data.logic
;
import
cz.muni.fi.lasaris.sbms.data.api.request.TrendsRequest
;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.Trend
;
public
class
TrendsDataCollector
{
public
Trend
getTrend
(
TrendsRequest
r
)
{
// TODO Auto-generated method stub
return
null
;
}
}
ProviderInterfaces/src/main/java/cz/muni/fi/lasaris/sbms/data/entities/containers/AbstractSliceContainer.java
0 → 100644
View file @
b73d9b55
package
cz.muni.fi.lasaris.sbms.data.entities.containers
;
import
java.util.Map
;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.Value
;
public
abstract
class
AbstractSliceContainer
<
V
extends
Value
>
extends
CompositeDataContainer
<
Address
,
V
>
{
public
AbstractSliceContainer
()
{
super
();
}
public
AbstractSliceContainer
(
Map
<
Address
,
V
>
data
)
{
super
(
data
);
}
}
ProviderInterfaces/src/main/java/cz/muni/fi/lasaris/sbms/data/entities/containers/Slice.java
View file @
b73d9b55
...
...
@@ -11,7 +11,7 @@ import cz.muni.fi.lasaris.sbms.data.entities.values.InterpolatedValue;
import
cz.muni.fi.lasaris.sbms.data.entities.values.Value
;
import
cz.muni.fi.lasaris.sbms.data.util.Sampler
;
public
class
Slice
extends
CompositeData
Container
<
Address
,
InterpolatedValue
>
{
public
class
Slice
extends
AbstractSlice
Container
<
InterpolatedValue
>
{
public
Slice
()
{
super
();
...
...
ProviderInterfaces/src/main/java/cz/muni/fi/lasaris/sbms/data/entities/containers/Snapshot.java
View file @
b73d9b55
...
...
@@ -5,7 +5,7 @@ import java.util.Map;
import
cz.muni.fi.lasaris.sbms.data.entities.Address
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.RawValue
;
public
class
Snapshot
extends
CompositeData
Container
<
Address
,
RawValue
>
{
public
class
Snapshot
extends
AbstractSlice
Container
<
RawValue
>
{
public
Snapshot
()
{
super
();
}
...
...
Write
Preview