Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Adam Kučera
semanticBMS
Commits
5ef24f0d
Commit
5ef24f0d
authored
Jan 05, 2018
by
Admin
Browse files
refactoring + response types added
parent
acae79c0
Changes
7
Hide whitespace changes
Inline
Side-by-side
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/DataPointsEndpoint.java
View file @
5ef24f0d
...
...
@@ -19,8 +19,8 @@ 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.Aggregat
ion
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.Aggregat
e
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
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
;
...
...
@@ -39,7 +39,7 @@ public class DataPointsEndpoint {
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getDataPoints
(
public
S
lice
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
napshot
Response
result
=
dc
.
getDataPointValues
(
readSpecs
,
allowCache
(
cache
));
S
lice
Response
result
=
dc
.
getDataPointValues
(
readSpecs
,
allowCache
(
cache
));
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
S
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
...
...
@@ -66,7 +66,7 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/aggregated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Aggregat
ion
Response
getAggregatedDataPoints
(
public
Aggregat
e
Response
getAggregatedDataPoints
(
@QueryParam
(
"ids"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
,
@QueryParam
(
"cache"
)
String
cache
...
...
@@ -79,7 +79,7 @@ public class DataPointsEndpoint {
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointsAggregation
(
readSpecs
,
agg
,
allowCache
(
cache
));
}
catch
(
IOException
e
)
{
return
Aggregat
ion
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
Aggregat
e
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -88,7 +88,7 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/grouped"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getGroupedDataPoints
(
public
S
lice
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
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -108,7 +108,7 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/group-aggregated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Aggregat
ion
Response
getGroupedAggregatedDataPoints
(
public
Aggregat
e
Response
getGroupedAggregatedDataPoints
(
@QueryParam
(
"ids"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
,
@QueryParam
(
"cache"
)
String
cache
...
...
@@ -119,11 +119,11 @@ public class DataPointsEndpoint {
logger
.
debug
(
json
);
GroupedAddressRequest
readSpecs
=
m
.
readValue
(
json
,
GroupedAddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
Aggregat
ion
Response
result
=
dc
.
getDataPointGroupAggregations
(
readSpecs
,
agg
,
allowCache
(
cache
));
Aggregat
e
Response
result
=
dc
.
getDataPointGroupAggregations
(
readSpecs
,
agg
,
allowCache
(
cache
));
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
Aggregat
ion
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
Aggregat
e
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -131,12 +131,12 @@ public class DataPointsEndpoint {
@GET
@Path
(
"/{id}"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getDataPoint
(
public
S
lice
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
napshot
Response
(
a
,
v
);
return
new
S
lice
Response
(
a
,
v
);
}
private
boolean
allowCache
(
String
cache
)
{
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/TrendsEndpoint.java
View file @
5ef24f0d
...
...
@@ -22,9 +22,9 @@ 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.Aggregat
ion
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.Aggregat
e
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
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.Interpolation
;
...
...
@@ -55,7 +55,7 @@ public class TrendsEndpoint {
@RolesAllowed
({
"user"
,
"admin"
})
@GET
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getTrends
(
public
S
lice
Response
getTrends
(
@QueryParam
(
"ids"
)
String
json
,
@QueryParam
(
"start"
)
String
start
,
@QueryParam
(
"end"
)
String
end
,
...
...
@@ -68,11 +68,11 @@ public class TrendsEndpoint {
logger
.
debug
(
json
);
TrendsRequest
readSpecs
=
getReadSpecs
(
json
,
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
,
null
);
logger
.
debug
(
readSpecs
);
S
napshot
Response
result
=
dc
.
getTrends
(
readSpecs
);
S
lice
Response
result
=
dc
.
getTrends
(
readSpecs
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
S
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
...
...
@@ -83,8 +83,8 @@ public class TrendsEndpoint {
@GET
@Path
(
"/aggregated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Aggregat
ion
Response
getAggregated
DataPoint
s
(
@QueryParam
(
"
json
"
)
String
json
,
public
Aggregat
e
Response
getAggregated
Trend
s
(
@QueryParam
(
"
ids
"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
)
{
ObjectMapper
m
=
new
ObjectMapper
();
...
...
@@ -95,7 +95,7 @@ public class TrendsEndpoint {
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointsAggregation
(
readSpecs
,
agg
);
}
catch
(
IOException
e
)
{
return
Aggregat
ion
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
Aggregat
e
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -104,7 +104,7 @@ public class TrendsEndpoint {
@GET
@Path
(
"/grouped"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getGroupedDataPoints
(
public
S
lice
Response
getGroupedDataPoints
(
@QueryParam
(
"json"
)
String
json
)
{
ObjectMapper
m
=
new
ObjectMapper
();
...
...
@@ -115,7 +115,7 @@ public class TrendsEndpoint {
logger
.
debug
(
readSpecs
);
return
dc
.
getDataPointGroupedValues
(
readSpecs
);
}
catch
(
IOException
e
)
{
return
S
napshot
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
S
lice
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -123,7 +123,7 @@ public class TrendsEndpoint {
@GET
@Path
(
"/group-aggregated"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
Aggregat
ion
Response
getGroupedAggregatedDataPoints
(
public
Aggregat
e
Response
getGroupedAggregatedDataPoints
(
@QueryParam
(
"json"
)
String
json
,
@DefaultValue
(
"NONE"
)
@QueryParam
(
"aggregation"
)
AggregationFunction
agg
)
{
...
...
@@ -133,11 +133,11 @@ public class TrendsEndpoint {
logger
.
debug
(
json
);
GroupedAddressRequest
readSpecs
=
m
.
readValue
(
json
,
GroupedAddressRequest
.
class
);
logger
.
debug
(
readSpecs
);
Aggregat
ion
Response
result
=
dc
.
getDataPointGroupAggregations
(
readSpecs
,
agg
);
Aggregat
e
Response
result
=
dc
.
getDataPointGroupAggregations
(
readSpecs
,
agg
);
logger
.
debug
(
result
);
return
result
;
}
catch
(
IOException
e
)
{
return
Aggregat
ion
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
return
Aggregat
e
Response
.
getErrorResponse
(
"Unable to parse query:"
+
e
);
}
}
...
...
@@ -145,7 +145,7 @@ public class TrendsEndpoint {
@GET
@Path
(
"/{id}"
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
public
S
napshot
Response
getTrend
(
public
S
lice
Response
getTrend
(
@QueryParam
(
"id"
)
String
id
,
@QueryParam
(
"start"
)
String
start
,
@QueryParam
(
"end"
)
String
end
,
...
...
@@ -155,7 +155,7 @@ public class TrendsEndpoint {
)
{
Address
a
=
new
Address
(
id
);
Trend
v
=
ProviderManager
.
getTrendsProvider
(
a
.
getProtocol
()).
getTrend
(
a
,
getSeriesSpecs
(
start
,
end
,
samplingCron
,
samplingDur
,
interpolation
));
return
new
S
napshot
Response
(
a
,
v
);
return
new
S
lice
Response
(
a
,
v
);
}
private
TrendsRequest
getReadSpecs
(
String
json
,
String
start
,
String
end
,
String
samplingCron
,
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/Aggregat
ion
Response.java
→
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/Aggregat
e
Response.java
View file @
5ef24f0d
...
...
@@ -7,7 +7,7 @@ import cz.muni.fi.lasaris.sbms.data.entities.AddressGroup;
import
cz.muni.fi.lasaris.sbms.data.entities.containers.Aggregation
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.AggregatedValue
;
public
class
Aggregat
ion
Response
{
public
class
Aggregat
e
Response
{
private
String
error
;
private
Map
<
String
,
AggregatedValue
>
results
;
...
...
@@ -15,26 +15,26 @@ public class AggregationResponse {
return
this
.
results
;
}
public
static
Aggregat
ion
Response
getErrorResponse
(
String
error
)
{
Aggregat
ion
Response
r
=
new
Aggregat
ion
Response
();
public
static
Aggregat
e
Response
getErrorResponse
(
String
error
)
{
Aggregat
e
Response
r
=
new
Aggregat
e
Response
();
r
.
setError
(
error
);
return
r
;
}
private
Aggregat
ion
Response
()
{
private
Aggregat
e
Response
()
{
this
.
results
=
null
;
}
public
Aggregat
ion
Response
(
Map
<
String
,
AggregatedValue
>
data
)
{
public
Aggregat
e
Response
(
Map
<
String
,
AggregatedValue
>
data
)
{
this
.
results
=
data
;
}
public
Aggregat
ion
Response
(
AggregatedValue
v
)
{
public
Aggregat
e
Response
(
AggregatedValue
v
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
AggregatedValue
>();
this
.
results
.
put
(
"value"
,
v
);
}
public
Aggregat
ion
Response
(
Aggregation
<
AddressGroup
>
a
)
{
public
Aggregat
e
Response
(
Aggregation
<
AddressGroup
>
a
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
AggregatedValue
>();
a
.
forEach
((
k
,
v
)
->
this
.
results
.
put
(
k
.
getName
(),
v
));
}
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/SeriesOfValuesResponse.java
0 → 100644
View file @
5ef24f0d
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.Series
;
import
cz.muni.fi.lasaris.sbms.data.entities.values.Value
;
public
class
SeriesOfValuesResponse
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
private
String
error
;
private
Map
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>
results
;
public
Map
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>
getResults
()
{
return
this
.
results
;
}
public
static
SeriesOfValuesResponse
getErrorResponse
(
String
error
)
{
SeriesOfValuesResponse
r
=
new
SeriesOfValuesResponse
();
r
.
setError
(
error
);
return
r
;
}
private
SeriesOfValuesResponse
()
{
this
.
results
=
null
;
}
public
SeriesOfValuesResponse
(
Map
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>
data
,
boolean
groups
)
{
this
.
results
=
data
;
}
public
SeriesOfValuesResponse
(
Map
<
Address
,
Series
<?
extends
Value
>>
data
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>();
this
.
results
.
put
(
DEFAULT_GROUPING
,
data
);
}
public
SeriesOfValuesResponse
(
Address
a
,
Series
<?
extends
Value
>
v
)
{
this
(
new
LinkedHashMap
<
String
,
Map
<
Address
,
Series
<?
extends
Value
>>>(),
true
);
this
.
results
.
put
(
DEFAULT_GROUPING
,
new
LinkedHashMap
<
Address
,
Series
<?
extends
Value
>>());
this
.
results
.
get
(
DEFAULT_GROUPING
).
put
(
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/api/response/S
napshot
Response.java
→
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/api/response/S
lice
Response.java
View file @
5ef24f0d
...
...
@@ -7,7 +7,7 @@ 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
S
napshot
Response
{
public
class
S
lice
Response
{
private
static
final
String
DEFAULT_GROUPING
=
"noGrouping"
;
...
...
@@ -18,26 +18,26 @@ public class SnapshotResponse {
return
this
.
results
;
}
public
static
S
napshot
Response
getErrorResponse
(
String
error
)
{
S
napshot
Response
r
=
new
S
napshot
Response
();
public
static
S
lice
Response
getErrorResponse
(
String
error
)
{
S
lice
Response
r
=
new
S
lice
Response
();
r
.
setError
(
error
);
return
r
;
}
private
S
napshot
Response
()
{
private
S
lice
Response
()
{
this
.
results
=
null
;
}
public
S
napshot
Response
(
Map
<
String
,
Snapshot
>
data
)
{
public
S
lice
Response
(
Map
<
String
,
Snapshot
>
data
)
{
this
.
results
=
data
;
}
public
S
napshot
Response
(
Snapshot
data
)
{
public
S
lice
Response
(
Snapshot
data
)
{
this
.
results
=
new
LinkedHashMap
<
String
,
Snapshot
>();
this
.
results
.
put
(
DEFAULT_GROUPING
,
data
);
}
public
S
napshot
Response
(
Address
a
,
RawValue
v
)
{
public
S
lice
Response
(
Address
a
,
RawValue
v
)
{
this
(
new
Snapshot
());
this
.
results
.
get
(
DEFAULT_GROUPING
).
add
(
a
,
v
);
...
...
DataAccessAPI/src/main/java/cz/muni/fi/lasaris/sbms/data/logic/DataCollector.java
View file @
5ef24f0d
...
...
@@ -12,8 +12,8 @@ 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.Aggregat
ion
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
napshot
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.Aggregat
e
Response
;
import
cz.muni.fi.lasaris.sbms.data.api.response.S
lice
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
;
...
...
@@ -27,8 +27,8 @@ public class DataCollector {
final
static
Logger
logger
=
Logger
.
getLogger
(
DataCollector
.
class
);
public
S
napshot
Response
getDataPointValues
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
napshot
Response
(
getDataPointValuesSnapshot
(
readSpecs
,
allowCache
));
public
S
lice
Response
getDataPointValues
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
lice
Response
(
getDataPointValuesSnapshot
(
readSpecs
,
allowCache
));
}
private
Snapshot
getDataPointValuesSnapshot
(
AddressRequest
readSpecs
,
boolean
allowCache
)
{
...
...
@@ -80,25 +80,25 @@ NavigableMap<String, AddressRequest> protocols = readSpecs.getProtocols();
return
result
;
}
public
Aggregat
ion
Response
getDataPointsAggregation
(
AddressRequest
readSpecs
,
AggregationFunction
aggregation
,
public
Aggregat
e
Response
getDataPointsAggregation
(
AddressRequest
readSpecs
,
AggregationFunction
aggregation
,
boolean
allowCache
)
{
NavigableMap
<
String
,
AddressRequest
>
protocols
=
readSpecs
.
getProtocols
();
if
(
protocols
.
size
()
==
1
)
{
return
new
Aggregat
ion
Response
(
ProviderManager
.
getDataPointsProvider
(
protocols
.
firstKey
())
return
new
Aggregat
e
Response
(
ProviderManager
.
getDataPointsProvider
(
protocols
.
firstKey
())
.
getDataPointsAggregation
(
protocols
.
get
(
protocols
.
firstKey
()).
getAddresses
(),
aggregation
,
allowCache
));
}
Snapshot
data
=
getDataPointValuesSnapshot
(
readSpecs
,
allowCache
);
return
new
Aggregat
ion
Response
(
computeAggregation
(
data
.
getData
(),
aggregation
));
return
new
Aggregat
e
Response
(
computeAggregation
(
data
.
getData
(),
aggregation
));
}
public
S
napshot
Response
getDataPointGroupedValues
(
GroupedAddressRequest
readSpecs
,
public
S
lice
Response
getDataPointGroupedValues
(
GroupedAddressRequest
readSpecs
,
boolean
allowCache
)
{
return
new
S
napshot
Response
(
getDataPointGroupedValuesMap
(
readSpecs
,
allowCache
));
return
new
S
lice
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
napshot
Response
>
results
=
Collections
.
synchronizedList
(
new
LinkedList
<
S
napshot
Response
>());
List
<
S
lice
Response
>
results
=
Collections
.
synchronizedList
(
new
LinkedList
<
S
lice
Response
>());
for
(
String
protocol
:
protocols
.
keySet
())
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
S
napshot
Response
rs
=
new
S
napshot
Response
(
ProviderManager
.
getDataPointsProvider
(
protocol
).
getDataPointGroupedValues
(
protocols
.
get
(
protocol
).
getGroups
(),
allowCache
));
S
lice
Response
rs
=
new
S
lice
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
napshot
Response
r
:
results
)
{
for
(
S
lice
Response
r
:
results
)
{
for
(
String
group
:
r
.
getResults
().
keySet
())
{
result
.
get
(
group
).
addAll
(
r
.
getResults
().
get
(
group
).
getData
());
}
...
...
@@ -155,19 +155,19 @@ NavigableMap<String, AddressRequest> protocols = readSpecs.getProtocols();
return
result
;
}
public
Aggregat
ion
Response
getDataPointGroupAggregations
(
GroupedAddressRequest
readSpecs
,
public
Aggregat
e
Response
getDataPointGroupAggregations
(
GroupedAddressRequest
readSpecs
,
AggregationFunction
aggregation
,
boolean
allowCache
)
{
NavigableMap
<
String
,
GroupedAddressRequest
>
protocols
=
readSpecs
.
getProtocols
();
if
(
protocols
.
size
()
==
1
)
{
return
new
Aggregat
ion
Response
(
ProviderManager
.
getDataPointsProvider
(
protocols
.
firstKey
())
return
new
Aggregat
e
Response
(
ProviderManager
.
getDataPointsProvider
(
protocols
.
firstKey
())
.
getDataPointGroupAggregations
(
protocols
.
get
(
protocols
.
firstKey
()).
getGroups
(),
aggregation
,
allowCache
));
}
Map
<
String
,
Snapshot
>
data
=
getDataPointGroupedValuesMap
(
readSpecs
,
allowCache
);
return
new
Aggregat
ion
Response
(
computeGroupAggregations
(
data
,
aggregation
));
return
new
Aggregat
e
Response
(
computeGroupAggregations
(
data
,
aggregation
));
}
private
Map
<
String
,
AggregatedValue
>
computeGroupAggregations
(
Map
<
String
,
Snapshot
>
data
,
AggregationFunction
aggregation
)
{
...
...
ProviderInterfaces/src/main/java/cz/muni/fi/lasaris/sbms/data/entities/AggregationWindow.java
0 → 100644
View file @
5ef24f0d
package
cz.muni.fi.lasaris.sbms.data.entities
;
public
enum
AggregationWindow
{
NONE
,
DAY
,
HOUR
,
WEEK
,
MONTH
,
YEAR
;
public
static
AggregationWindow
fromString
(
String
s
)
{
s
=
s
.
toUpperCase
().
trim
();
if
(
s
.
equals
(
"DAY"
))
{
return
AggregationWindow
.
DAY
;
}
if
(
s
.
equals
(
"HOUR"
))
{
return
AggregationWindow
.
HOUR
;
}
if
(
s
.
equals
(
"WEEK"
))
{
return
AggregationWindow
.
WEEK
;
}
if
(
s
.
equals
(
"MONTH"
))
{
return
AggregationWindow
.
MONTH
;
}
if
(
s
.
equals
(
"YEAR"
))
{
return
AggregationWindow
.
YEAR
;
}
if
(
s
.
equals
(
"NONE"
))
{
return
AggregationWindow
.
NONE
;
}
throw
new
IllegalArgumentException
(
"Unknown window type."
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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