From 23b4ffe784344432e43488f1a03976dfec9b9f7c Mon Sep 17 00:00:00 2001 From: Alessandro Pieve Date: Thu, 8 Sep 2016 08:46:05 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@131198 82a268e6-3cf1-43bd-a215-b396298e98cf --- .project | 4 ++-- .settings/org.eclipse.wst.common.component | 6 ++++++ .../org.eclipse.wst.common.project.facet.core.xml | 5 +++++ .settings/org.eclipse.wst.validation.prefs | 2 ++ pom.xml | 3 ++- .../gcube/accounting/analytics/NumberedFilter.java | 3 --- .../accounting/analytics/TemporalConstraint.java | 4 ++-- .../AccountingPersistenceBackendQueryFactory.java | 11 +++++++---- .../persistence/AccountingPersistenceQuery.java | 12 ++---------- src/{test => main}/resources/logback-test.xml | 2 +- 10 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 .settings/org.eclipse.wst.validation.prefs rename src/{test => main}/resources/logback-test.xml (82%) diff --git a/.project b/.project index 98dfdfb..b12b1b6 100644 --- a/.project +++ b/.project @@ -16,12 +16,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..998d910 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,6 @@ + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..1b22d70 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/pom.xml b/pom.xml index 28cc78b..754669a 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.accounting accounting-analytics - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT accounting-analytics @@ -78,6 +78,7 @@ 1.0.13 test + diff --git a/src/main/java/org/gcube/accounting/analytics/NumberedFilter.java b/src/main/java/org/gcube/accounting/analytics/NumberedFilter.java index a6f9f48..5a680c1 100644 --- a/src/main/java/org/gcube/accounting/analytics/NumberedFilter.java +++ b/src/main/java/org/gcube/accounting/analytics/NumberedFilter.java @@ -74,9 +74,6 @@ public class NumberedFilter extends Filter { public int compareTo(NumberedFilter numberedFilter) { int compareResult = this.d.compareTo(numberedFilter.d); - if(compareResult==0){ - super.compareTo(numberedFilter); - } return compareResult; } diff --git a/src/main/java/org/gcube/accounting/analytics/TemporalConstraint.java b/src/main/java/org/gcube/accounting/analytics/TemporalConstraint.java index 544b22b..ccd270b 100644 --- a/src/main/java/org/gcube/accounting/analytics/TemporalConstraint.java +++ b/src/main/java/org/gcube/accounting/analytics/TemporalConstraint.java @@ -162,11 +162,11 @@ public class TemporalConstraint { int calendarValue = calendarValues[aggregationMode.ordinal()].getCalendarValue(); Calendar alignedStartTime = getAlignedStartTime(); - logger.trace("Aligned StartTime : {}", timeInMillisToString(alignedStartTime.getTimeInMillis())); + //logger.trace("Aligned StartTime : {}", timeInMillisToString(alignedStartTime.getTimeInMillis())); Calendar alignedEndTime = getAlignedEndTime(); long alignedEndTimeInMillis = alignedEndTime.getTimeInMillis(); - logger.trace("Aligned EndTime : {}", timeInMillisToString(alignedEndTime.getTimeInMillis())); + //logger.trace("Aligned EndTime : {}", timeInMillisToString(alignedEndTime.getTimeInMillis())); Calendar progressTime = Calendar.getInstance(); progressTime.setTimeZone(DEFAULT_TIME_ZONE); diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java index 6cd285f..6323694 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java @@ -41,6 +41,7 @@ public abstract class AccountingPersistenceBackendQueryFactory { } AccountingPersistenceBackendQuery accountingPersistenceQuery = accountingPersistenceQueries.get(scope); + logger.debug("Scope {}", scope); if(accountingPersistenceQuery==null){ try { @@ -49,24 +50,26 @@ public abstract class AccountingPersistenceBackendQueryFactory { Class foundClass=null; try { foundClass = found.getClass(); + logger.debug("Testing foundClass{}", foundClass.toString()); String foundClassName = foundClass.getSimpleName(); - logger.debug("Testing {}", foundClassName); + logger.debug("Testing foundClassName{}", foundClassName); AccountingPersistenceBackendQueryConfiguration configuration = new AccountingPersistenceBackendQueryConfiguration(foundClass); found.prepareConnection(configuration); accountingPersistenceQuery = found; break; } catch (Exception e) { - logger.error(String.format("%s not initialized correctly. It will not be used", foundClass.getSimpleName())); - + logger.error(String.format("%s not initialized correctly. It will not be used", foundClass.getSimpleName()),e); + e.printStackTrace(); } } } catch(Exception e){ logger.error(String.format("service loader or not initialized correctly.")); + e.printStackTrace(); throw new NoUsableAccountingPersistenceQueryFound(e.getLocalizedMessage()); } if(accountingPersistenceQuery==null){ - logger.error(String.format("accountingPersistenceQuery null")); + logger.error(String.format("accountingPersistenceQuery null")); throw new NoUsableAccountingPersistenceQueryFound(); } diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java index 27f3cb1..84e621b 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java @@ -168,10 +168,6 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ String topKey, String orderingProperty, boolean pad, int limit) throws DuplicatedKeyFilterException, KeyException, ValueException, Exception { - - - - SortedMap> got; if(orderingProperty==null){ @@ -182,15 +178,13 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ .getTopValues(clz, temporalConstraint, filters, topKey, orderingProperty); - int count = got.size() > limit ? limit : got.size(); - NumberedFilter firstRemovalKey = null; - for(NumberedFilter nf : got.keySet()){ if(--count>=0 || limit<=0){ if(pad){ - padMap(got.get(nf), temporalConstraint); + padMap(got.get(nf), temporalConstraint); + } }else{ if(firstRemovalKey==null){ @@ -200,11 +194,9 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ } } } - if(firstRemovalKey!=null){ return got.subMap(got.firstKey(), firstRemovalKey); } - return got; } diff --git a/src/test/resources/logback-test.xml b/src/main/resources/logback-test.xml similarity index 82% rename from src/test/resources/logback-test.xml rename to src/main/resources/logback-test.xml index 4f36cc8..9a440a7 100644 --- a/src/test/resources/logback-test.xml +++ b/src/main/resources/logback-test.xml @@ -7,7 +7,7 @@ - +