diff --git a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java index 7488094..fb916b1 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java @@ -206,7 +206,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin { start = DateUtils.getPreviousPeriod(aggregationType, partialHarvesting).getTime(); } - end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1, partialHarvesting); + end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1); logger.debug("Harvesting from {} to {} (ReRun:{} - GetVREUsers:{} - DryRun:{})", DateUtils.format(start), DateUtils.format(end), reRun, getVREUsers, dryRun); diff --git a/src/main/java/org/gcube/dataharvest/utils/DateUtils.java b/src/main/java/org/gcube/dataharvest/utils/DateUtils.java index fb62719..529d574 100644 --- a/src/main/java/org/gcube/dataharvest/utils/DateUtils.java +++ b/src/main/java/org/gcube/dataharvest/utils/DateUtils.java @@ -97,13 +97,10 @@ public class DateUtils { return aggregationStartCalendar; } - public static Date getEndDateFromStartDate(AggregationType aggregationType, Date startDate, int offset, boolean partialHarvesting) { + public static Date getEndDateFromStartDate(AggregationType aggregationType, Date startDate, int offset) { Calendar aggregationEndDate = getUTCCalendarInstance(); - if(!partialHarvesting) { - aggregationEndDate.setTimeInMillis(startDate.getTime()); - aggregationEndDate.add(aggregationType.getCalendarField(), offset); - //aggregationEndDate.add(Calendar.MILLISECOND, -1); - } + aggregationEndDate.setTimeInMillis(startDate.getTime()); + aggregationEndDate.add(aggregationType.getCalendarField(), offset); return aggregationEndDate.getTime(); } @@ -113,8 +110,6 @@ public class DateUtils { return calendar; } - /* OLD functions of Eric Perrone (ISTI - CNR) */ - public static String format(Date date) { return DateUtils.LAUNCH_DATE_FORMAT.format(date); } diff --git a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterJupyterTest.java b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterJupyterTest.java index 06a0e07..136b47b 100644 --- a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterJupyterTest.java +++ b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterJupyterTest.java @@ -95,7 +95,7 @@ public class AccountingDataHarvesterJupyterTest extends ContextTest { for (Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); ContextTest.setContextByName(ROOT); JupyterAccessesHarvester jupyterAccessesHarvester = new JupyterAccessesHarvester(start, end); diff --git a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java index 6e6d2e7..ac60a69 100644 --- a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java +++ b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java @@ -238,7 +238,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { while (from.before(runbeforeDate)) { Date start = from.getTime(); - Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1); logger.debug("Harvesting from {} to {}", DateUtils.format(start), DateUtils.format(end)); @@ -326,7 +326,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { Date start = DateUtils.getStartCalendar(2018, Calendar.MARCH, 1).getTime(); // start = DateUtils.getPreviousPeriod(measureType).getTime(); - Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1); logger.info("\n\n\n"); @@ -388,7 +388,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { List accountingRecords = new ArrayList<>(); for (Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); ContextTest.setContextByName(ROOT); VREAccessesHarvester vreAccessesHarvester = new VREAccessesHarvester(start, end); @@ -432,7 +432,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // 1).getTime(); Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); accountingDataHarvesterPlugin.getConfigParameters(); @@ -522,7 +522,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, false); + Date end = DateUtils.getEndDateFromStartDate(aggregationType, start, 1); logger.debug("Harvesting Social Interaction from {} to {}", DateUtils.format(start), DateUtils.format(end)); @@ -570,7 +570,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end); List accountingRecords = methodInvocationHarvester.getAccountingRecords(); @@ -590,8 +590,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AccountingDao dao = getAccountingDao(); List starts = new ArrayList<>(); - starts.add(DateUtils.getStartCalendar(2021, Calendar.APRIL, 1).getTime()); - starts.add(DateUtils.getStartCalendar(2021, Calendar.MAY, 1).getTime()); + starts.add(DateUtils.getStartCalendar(2021, Calendar.JULY, 1).getTime()); AggregationType measureType = AggregationType.MONTHLY; @@ -609,7 +608,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { List accountingRecords = new ArrayList<>(); for (Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); MethodInvocationHarvester methodInvocationHarvester = new MethodInvocationHarvester(start, end); @@ -637,7 +636,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { logger.debug("Going to insert {}", accountingRecords); ContextTest.setContextByName(ROOT); - dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1])); + // dao.insertRecords(accountingRecords.toArray(new AccountingRecord[1])); } catch (Exception e) { logger.error("", e); @@ -701,7 +700,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { for (Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); TagMeMethodInvocationHarvester methodInvocationHarvester = new TagMeMethodInvocationHarvester(start, end); @@ -739,7 +738,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); VREUsersHarvester vreUsersHarvester = new VREUsersHarvester(start, end); List harvested = vreUsersHarvester.getAccountingRecords(); @@ -766,7 +765,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AggregationType measureType = AggregationType.MONTHLY; Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); SortedSet contexts = getContexts(); @@ -800,7 +799,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // 1).getTime(); Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); accountingDataHarvesterPlugin.getConfigParameters(); @@ -831,7 +830,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { Date start = DateUtils.getStartCalendar(2017, Calendar.MAY, 1).getTime(); Date finalEnd = DateUtils.getStartCalendar(2020, Calendar.MAY, 1).getTime(); - Date end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1); ScopeBean scopeBean = new ScopeBean(context); logger.debug("FullName {} - Name {}", scopeBean.toString(), scopeBean.name()); @@ -846,7 +845,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { Thread.sleep(TimeUnit.SECONDS.toMillis(90)); start = end; - end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1, false); + end = DateUtils.getEndDateFromStartDate(AggregationType.MONTHLY, start, 1); } } catch (Exception e) { @@ -905,7 +904,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { // 1).getTime(); Date start = DateUtils.getPreviousPeriod(measureType, false).getTime(); - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); accountingDataHarvesterPlugin.getConfigParameters(); diff --git a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterRStudioTest.java b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterRStudioTest.java index 45b2d57..33ff7a9 100644 --- a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterRStudioTest.java +++ b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterRStudioTest.java @@ -99,7 +99,7 @@ public class AccountingDataHarvesterRStudioTest extends ContextTest { for (Date start : starts) { - Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1, false); + Date end = DateUtils.getEndDateFromStartDate(measureType, start, 1); ContextTest.setContextByName(ROOT); RStudioAccessesHarvester rstudioAccessesHarvester = new RStudioAccessesHarvester(start, end);