From 4913a3fe032c201304566ad2f2fe635b2763ec24 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Mon, 21 Oct 2019 16:56:44 +0200 Subject: [PATCH] Added the possibility of having partial harvesting --- pom.xml | 18 ++++----- .../AccountingDataHarvesterPlugin.java | 19 +++++++-- .../gcube/dataharvest/utils/DateUtils.java | 24 ++++++++---- .../AccountingDataHarvesterPluginTest.java | 39 ++++++++++--------- target/.gitignore | 2 - 5 files changed, 61 insertions(+), 41 deletions(-) delete mode 100644 target/.gitignore diff --git a/pom.xml b/pom.xml index c9ccdee..7701f2e 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ 4.0.0 org.gcube.accounting accounting-dashboard-harvester-se-plugin - 1.2.0 + 1.2.1-SNAPSHOT Accounting Dashboard Harvester SmartExecutor Plugin Accounting Dashboard Harvester SmartExecutor Plugin @@ -51,7 +51,7 @@ org.gcube.vremanagement smart-executor-api - [1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [1.5.0, 2.0.0-SNAPSHOT) provided @@ -68,7 +68,7 @@ org.gcube.vremanagement smart-executor-client - [1.3.0-SNAPSHOT,2.0.0-SNAPSHOT) + [1.3.0,2.0.0-SNAPSHOT) provided @@ -84,7 +84,7 @@ org.gcube.portlets.admin rmp-common-library - [2.7.2-SNAPSHOT,3.0.0-SNAPSHOT) + [2.7.2,3.0.0-SNAPSHOT) com.google.apis @@ -100,13 +100,13 @@ org.gcube.common storagehub-client-library - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [1.0.0, 2.0.0-SNAPSHOT) org.gcube.data-publishing gcat-client - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [1.0.0, 2.0.0-SNAPSHOT) @@ -166,12 +166,12 @@ org.gcube.accounting accounting-analytics - [2.0.0-SNAPSHOT,3.0.0-SNAPSHOT) + [2.0.0,3.0.0-SNAPSHOT) org.gcube.accounting accounting-analytics-persistence-couchbase - [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + [1.0.0,2.0.0-SNAPSHOT) @@ -183,7 +183,7 @@ org.gcube.accounting accounting-summary-access - [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + [1.0.0,2.0.0-SNAPSHOT) diff --git a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java index 68ecb46..de9bc3d 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java @@ -50,6 +50,14 @@ public class AccountingDataHarvesterPlugin extends Plugin accountingRecords = new ArrayList<>(); for(Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); ContextTest.setContextByName(ROOT); VREAccessesHarvester vreAccessesHarvester = new VREAccessesHarvester(start, end); @@ -409,8 +410,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // Date start = DateUtils.getStartCalendar(2015, Calendar.FEBRUARY, 1).getTime(); // Date end = DateUtils.getStartCalendar(2019, Calendar.FEBRUARY, 1).getTime(); - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(null); accountingDataHarvesterPlugin.getConfigParameters(); @@ -501,7 +502,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { Calendar from = DateUtils.getStartCalendar(2018, Calendar.JUNE, 1); Date start = from.getTime(); - Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1); + Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1, false); logger.debug("Harvesting Social Interaction from {} to {}", DateUtils.format(start), DateUtils.format(end)); @@ -546,8 +547,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end); List accountingRecords = methodInvocationHarvester.getAccountingRecords(); @@ -616,7 +617,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { for(Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); TagMeMethodInvocationHarvester methodInvocationHarvester = new TagMeMethodInvocationHarvester(start, end); @@ -653,8 +654,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); VREUsersHarvester vreUsersHarvester = new VREUsersHarvester(start, end); List harvested = vreUsersHarvester.getAccountingRecords(); @@ -678,8 +679,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); SortedSet contexts = getContexts(); @@ -709,8 +710,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // Date start = DateUtils.getStartCalendar(2015, Calendar.FEBRUARY, 1).getTime(); // Date end = DateUtils.getStartCalendar(2019, Calendar.FEBRUARY, 1).getTime(); - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(null); accountingDataHarvesterPlugin.getConfigParameters(); @@ -740,8 +741,8 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // Date start = DateUtils.getStartCalendar(2015, Calendar.FEBRUARY, 1).getTime(); // Date end = DateUtils.getStartCalendar(2019, Calendar.FEBRUARY, 1).getTime(); - Date start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); + Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); AccountingDataHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDataHarvesterPlugin(null); accountingDataHarvesterPlugin.getConfigParameters(); diff --git a/target/.gitignore b/target/.gitignore deleted file mode 100644 index 4569837..0000000 --- a/target/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/classes/ -/test-classes/