diff --git a/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java b/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java index 7260062..8016963 100644 --- a/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java @@ -159,4 +159,14 @@ public class ResourceRecordQuery { return getInfo(usageRecordType, temporalConstraint, filters, false); } + /** + * Return the list of key valid for queries a certain usage record type + * @param usageRecordType the usage record type + * @return a set containing the list of key + * @throws Exception if fails + */ + public Set getFilterKeys(@SuppressWarnings("rawtypes") Class usageRecordType) throws Exception{ + return accountingPersistenceQuery.getKeys(usageRecordType); + } + } 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 ece13f0..42c6484 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceQuery.java @@ -6,6 +6,7 @@ package org.gcube.accounting.analytics.persistence; import java.util.Calendar; import java.util.List; import java.util.Map; +import java.util.Set; import org.gcube.accounting.analytics.Filter; import org.gcube.accounting.analytics.Info; @@ -27,6 +28,19 @@ public abstract class AccountingPersistenceQuery { protected abstract Map reallyQuery(@SuppressWarnings("rawtypes") Class usageRecordType, TemporalConstraint temporalConstraint, List filters) throws Exception; + /** + * Query the persistence obtaining a Map where the date is the key and + * the #Info is the value. The result is relative to an Usage Record Type, + * respect a TemporalConstraint and can be applied one or more filters. + * @param usageRecordType the Usage Record Type of interest + * @param temporalConstraint the TemporalConstraint (interval and aggregation) + * @param filters the filter for the query. If null or empty string get all + * data. The filters are evaluated in the order the are presented and are + * considered in AND + * @return the Map containing for each date in the required interval the + * requested data + * @throws Exception if fails + */ public Map query(@SuppressWarnings("rawtypes") Class usageRecordType, TemporalConstraint temporalConstraint, List filters) throws Exception{ logger.trace("Request query: UsageRecordType={}, {}={}, {}s={}", usageRecordType.newInstance().getUsageRecordType(), @@ -35,5 +49,13 @@ public abstract class AccountingPersistenceQuery { return reallyQuery(usageRecordType, temporalConstraint, filters); } + /** + * Return the list of key valid for queries a certain usage record type + * @param usageRecordType the usage record type + * @return a set containing the list of key + * @throws Exception if fails + */ + public abstract Set getKeys(@SuppressWarnings("rawtypes") Class usageRecordType) throws Exception; + public abstract void close() throws Exception; }