diff --git a/src/main/java/org/gcube/dataharvest/harvester/MethodInvocationHarvester.java b/src/main/java/org/gcube/dataharvest/harvester/MethodInvocationHarvester.java index 775bcd7..c3f02ae 100644 --- a/src/main/java/org/gcube/dataharvest/harvester/MethodInvocationHarvester.java +++ b/src/main/java/org/gcube/dataharvest/harvester/MethodInvocationHarvester.java @@ -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 filters = new ArrayList<>(); - //filters.add(new Filter(ServiceUsageRecord.SERVICE_NAME, DATAMINER_SERVICE_NAME)); - String context = Utils.getCurrentContext(); List contexts = new ArrayList<>(); contexts.add(context); - - //SortedMap> result = accountingPersistenceQuery.getContextTimeSeries( - // AggregatedServiceUsageRecord.class, temporalConstraint, filters, contexts, true); - - SortedMap> result = accountingPersistenceQuery.getContextTimeSeries( + + SortedMap> result = null; + List filters = new ArrayList<>(); + + 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()) {