diff --git a/pom.xml b/pom.xml
index 4d45b7d..40a35da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
org.gcube.accounting
accounting-analytics
- 2.4.0-SNAPSHOT
+ 2.5.0-SNAPSHOT
accounting-analytics
diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java
index 832e7d0..accc767 100644
--- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java
+++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQuery.java
@@ -16,6 +16,7 @@ import org.gcube.accounting.analytics.UsageValue;
import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException;
import org.gcube.accounting.analytics.exception.KeyException;
import org.gcube.accounting.analytics.exception.ValueException;
+import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.documentstore.records.AggregatedRecord;
import org.json.JSONObject;
@@ -299,5 +300,34 @@ public interface AccountingPersistenceBackendQuery {
throws Exception;
+ /**
+ * Return a record
+ * @param recordId
+ * @param recordType
+ * @return
+ * @throws Exception
+ */
+ public String getRecord(String recordId, String type ) throws Exception;
+
+ /**
+ * Return a list of type storage usage
+ * @return
+ * @throws Exception
+ */
+ public SortedSet getSpaceProvidersIds() throws Exception;
+
+
+
+
+
+
+
+ public SortedMap> getSpaceTimeSeries(
+ Class extends AggregatedRecord, ?>> clz,
+ TemporalConstraint temporalConstraint, List filters,
+ List providersId) throws Exception;
+
+
+
}
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 3600e12..73d79c2 100644
--- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java
+++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java
@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
+import java.util.TreeSet;
import javax.activity.InvalidActivityException;
@@ -22,6 +23,8 @@ import org.gcube.accounting.analytics.UsageValue;
import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException;
import org.gcube.accounting.analytics.exception.KeyException;
import org.gcube.accounting.analytics.exception.ValueException;
+import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
+import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.documentstore.records.AggregatedRecord;
import org.json.JSONException;
@@ -59,7 +62,20 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
Class extends AggregatedRecord,?>> clz)
throws Exception {
AggregatedRecord,?> instance = clz.newInstance();
- return instance.getQuerableKeys();
+
+ //limit filterky for accounting storage status (used from portlet accounting for tad space)
+ if (clz.equals(AggregatedStorageStatusRecord.class)){
+ SortedSet storageStatus= new TreeSet<>();
+ storageStatus.add(AggregatedStorageStatusRecord.CONSUMER_ID);
+ storageStatus.add(AggregatedStorageStatusRecord.DATA_SERVICEID);
+ return storageStatus;
+ }
+ else{
+ return instance.getQuerableKeys();
+ }
+
+
+
}
public static String getDefaultOrderingProperties(
@@ -387,8 +403,78 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
+ public String getRecord(String recordId, String type ) throws Exception {
+ String record= AccountingPersistenceBackendQueryFactory.getInstance().getRecord(recordId,type);
+ return record;
+
+ }
+
+
+ @Override
+ public SortedSet getSpaceProvidersIds() throws Exception{
+ SortedSet providersId= AccountingPersistenceBackendQueryFactory.getInstance().getSpaceProvidersIds();
+ return providersId;
+
+ }
+
+ @Override
+ public SortedMap> getSpaceTimeSeries(
+ Class extends AggregatedRecord, ?>> clz,
+ TemporalConstraint temporalConstraint, List filters,
+ List providersId)
+ throws Exception {
+
+
+ SortedMap> spaceTimeSeries=
+ AccountingPersistenceBackendQueryFactory.getInstance().getSpaceTimeSeries(clz, temporalConstraint, filters, providersId);
+
+
+
+
+ int count = spaceTimeSeries.size();
+ Filter firstRemovalKey = null;
+ for(Filter nf : spaceTimeSeries.keySet()){
+ if(--count>=0){
+ padMapStorage(spaceTimeSeries.get(nf), temporalConstraint);
+ }else{
+ if(firstRemovalKey==null){
+ firstRemovalKey = nf;
+ }else{
+ break;
+ }
+ }
+ }
+ if(firstRemovalKey!=null){
+ return spaceTimeSeries.subMap(spaceTimeSeries.firstKey(), firstRemovalKey);
+ }
+ return spaceTimeSeries;
+
+
+
+ }
+
+
+ public SortedMap padMapStorage(
+ SortedMap unpaddedData,
+ TemporalConstraint temporalConstraint) throws Exception {
+ SortedSet sequence = temporalConstraint.getCalendarSequence();
+ Long longValuePre = null;
+ for (Calendar progressTime : sequence) {
+ Long longValue = unpaddedData.get(progressTime);
+
+ if (longValue == null) {
+ unpaddedData.put(progressTime, longValuePre);
+ }else{
+ longValuePre=longValue;
+ }
+
+ }
+ return unpaddedData;
+ }
+
+
}
diff --git a/src/test/java/org/gcube/accounting/analytics/TemporalConstraintTest.java b/src/test/java/org/gcube/accounting/analytics/TemporalConstraintTest.java
index 9ca7931..cf610ef 100644
--- a/src/test/java/org/gcube/accounting/analytics/TemporalConstraintTest.java
+++ b/src/test/java/org/gcube/accounting/analytics/TemporalConstraintTest.java
@@ -5,8 +5,12 @@ package org.gcube.accounting.analytics;
import java.util.Calendar;
import java.util.Collection;
+import java.util.SortedSet;
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
+import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery;
+import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
+import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
@@ -104,6 +108,13 @@ public class TemporalConstraintTest {
}
}
+ @Test
+ public void testGetQuerableKeys() throws Exception{
+
+
+ }
+
+
}