From 3d53d85865f8557f09e32a684231d8834ef7d0c8 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Wed, 13 Jun 2018 17:40:02 +0000 Subject: [PATCH] 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 --- .../harvester/MethodInvocationHarvester.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) 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()) {