Added logic to harvesting methods invocation by using Service Usage Records before 31/12/2017 and using JobUSageRecords from 01/01/2018
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@169181 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f27b583949
commit
3d53d85865
|
@ -15,6 +15,8 @@ import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
|
|||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
|
||||
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedData;
|
||||
import org.gcube.dataharvest.datamodel.HarvestedDataKey;
|
||||
import org.gcube.dataharvest.utils.DateUtils;
|
||||
|
@ -47,19 +49,26 @@ public class MethodInvocationHarvester extends BasicHarvester {
|
|||
TemporalConstraint temporalConstraint = new TemporalConstraint(start.getTime(), end.getTime(),
|
||||
AggregationMode.MONTHLY);
|
||||
|
||||
List<Filter> filters = new ArrayList<>();
|
||||
//filters.add(new Filter(ServiceUsageRecord.SERVICE_NAME, DATAMINER_SERVICE_NAME));
|
||||
|
||||
String context = Utils.getCurrentContext();
|
||||
|
||||
List<String> contexts = new ArrayList<>();
|
||||
contexts.add(context);
|
||||
|
||||
//SortedMap<Filter,SortedMap<Calendar,Info>> result = accountingPersistenceQuery.getContextTimeSeries(
|
||||
// AggregatedServiceUsageRecord.class, temporalConstraint, filters, contexts, true);
|
||||
SortedMap<Filter,SortedMap<Calendar,Info>> result = null;
|
||||
List<Filter> filters = new ArrayList<>();
|
||||
|
||||
SortedMap<Filter,SortedMap<Calendar,Info>> result = accountingPersistenceQuery.getContextTimeSeries(
|
||||
Date newMethodInvocationHarvesterStartDate = DateUtils.getStartCalendar(2017, Calendar.DECEMBER, 31).getTime();
|
||||
|
||||
if(start.after(newMethodInvocationHarvesterStartDate)) {
|
||||
// From 01/01/2018 accounting Method Invocation using JobUsageRecord
|
||||
result = accountingPersistenceQuery.getContextTimeSeries(
|
||||
AggregatedJobUsageRecord.class, temporalConstraint, filters, contexts, true);
|
||||
} else {
|
||||
// Before 31/12/2017 accounting Method Invocation using ServiceUsageRecord
|
||||
filters.add(new Filter(ServiceUsageRecord.SERVICE_NAME, DATAMINER_SERVICE_NAME));
|
||||
result = accountingPersistenceQuery.getContextTimeSeries(
|
||||
AggregatedServiceUsageRecord.class, temporalConstraint, filters, contexts, true);
|
||||
}
|
||||
|
||||
if(result != null) {
|
||||
for(Filter filter : result.keySet()) {
|
||||
|
|
Loading…
Reference in New Issue