Refactoring
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@126269 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9f3397483b
commit
effe6b280a
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.accounting.analytics.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DuplicatedKeyFilterException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated serial Version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -327144230654860518L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with {@code null} as its detail message.
|
||||||
|
* The cause is not initialized, and may subsequently be initialized by a
|
||||||
|
* call to {@link #initCause}.
|
||||||
|
*/
|
||||||
|
public DuplicatedKeyFilterException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message. The cause
|
||||||
|
* is not initialized, and may subsequently be initialized by a call to
|
||||||
|
* initCause.
|
||||||
|
* @param message the detail message. The detail message is saved for later
|
||||||
|
* retrieval by the getMessage() method.
|
||||||
|
*/
|
||||||
|
public DuplicatedKeyFilterException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified cause and a detail
|
||||||
|
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
|
||||||
|
* typically contains the class and detail message of <tt>cause</tt>).
|
||||||
|
* This constructor is useful for exceptions that are little more than
|
||||||
|
* wrappers for other throwables (for example, {@link
|
||||||
|
* java.security.PrivilegedActionException}).
|
||||||
|
*
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public DuplicatedKeyFilterException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message and
|
||||||
|
* cause. <p>Note that the detail message associated with
|
||||||
|
* {@code cause} is <i>not</i> automatically incorporated in
|
||||||
|
* this exception's detail message.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public DuplicatedKeyFilterException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.accounting.analytics.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class KeyException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated serial Version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -327144230654860518L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with {@code null} as its detail message.
|
||||||
|
* The cause is not initialized, and may subsequently be initialized by a
|
||||||
|
* call to {@link #initCause}.
|
||||||
|
*/
|
||||||
|
public KeyException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message. The cause
|
||||||
|
* is not initialized, and may subsequently be initialized by a call to
|
||||||
|
* initCause.
|
||||||
|
* @param message the detail message. The detail message is saved for later
|
||||||
|
* retrieval by the getMessage() method.
|
||||||
|
*/
|
||||||
|
public KeyException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified cause and a detail
|
||||||
|
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
|
||||||
|
* typically contains the class and detail message of <tt>cause</tt>).
|
||||||
|
* This constructor is useful for exceptions that are little more than
|
||||||
|
* wrappers for other throwables (for example, {@link
|
||||||
|
* java.security.PrivilegedActionException}).
|
||||||
|
*
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public KeyException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message and
|
||||||
|
* cause. <p>Note that the detail message associated with
|
||||||
|
* {@code cause} is <i>not</i> automatically incorporated in
|
||||||
|
* this exception's detail message.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public KeyException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.accounting.analytics.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ValueException extends Exception {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated serial Version UID
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -327144230654860518L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with {@code null} as its detail message.
|
||||||
|
* The cause is not initialized, and may subsequently be initialized by a
|
||||||
|
* call to {@link #initCause}.
|
||||||
|
*/
|
||||||
|
public ValueException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message. The cause
|
||||||
|
* is not initialized, and may subsequently be initialized by a call to
|
||||||
|
* initCause.
|
||||||
|
* @param message the detail message. The detail message is saved for later
|
||||||
|
* retrieval by the getMessage() method.
|
||||||
|
*/
|
||||||
|
public ValueException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified cause and a detail
|
||||||
|
* message of <tt>(cause==null ? null : cause.toString())</tt> (which
|
||||||
|
* typically contains the class and detail message of <tt>cause</tt>).
|
||||||
|
* This constructor is useful for exceptions that are little more than
|
||||||
|
* wrappers for other throwables (for example, {@link
|
||||||
|
* java.security.PrivilegedActionException}).
|
||||||
|
*
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public ValueException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new exception with the specified detail message and
|
||||||
|
* cause. <p>Note that the detail message associated with
|
||||||
|
* {@code cause} is <i>not</i> automatically incorporated in
|
||||||
|
* this exception's detail message.
|
||||||
|
*
|
||||||
|
* @param message the detail message (which is saved for later retrieval
|
||||||
|
* by the {@link #getMessage()} method).
|
||||||
|
* @param cause the cause (which is saved for later retrieval by the
|
||||||
|
* {@link #getCause()} method). (A <tt>null</tt> value is
|
||||||
|
* permitted, and indicates that the cause is nonexistent or
|
||||||
|
* unknown.)
|
||||||
|
*/
|
||||||
|
public ValueException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,16 +12,19 @@ import org.gcube.accounting.analytics.Filter;
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
import org.gcube.accounting.analytics.NumberedFilter;
|
import org.gcube.accounting.analytics.NumberedFilter;
|
||||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||||
|
import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException;
|
||||||
|
import org.gcube.accounting.analytics.exception.KeyException;
|
||||||
|
import org.gcube.accounting.analytics.exception.ValueException;
|
||||||
import org.gcube.documentstore.records.AggregatedRecord;
|
import org.gcube.documentstore.records.AggregatedRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*/
|
*/
|
||||||
public abstract class AccountingPersistenceBackendQuery {
|
public interface AccountingPersistenceBackendQuery {
|
||||||
|
|
||||||
public static final int KEY_VALUES_LIMIT = 25;
|
public static final int KEY_VALUES_LIMIT = 25;
|
||||||
|
|
||||||
protected abstract void prepareConnection(
|
public void prepareConnection(
|
||||||
AccountingPersistenceBackendQueryConfiguration configuration)
|
AccountingPersistenceBackendQueryConfiguration configuration)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
@ -43,13 +46,16 @@ public abstract class AccountingPersistenceBackendQuery {
|
||||||
* than one filter with the same key an Exception is thrown.
|
* than one filter with the same key an Exception is thrown.
|
||||||
* @return the Map containing for each date in the required interval the
|
* @return the Map containing for each date in the required interval the
|
||||||
* requested data
|
* requested data
|
||||||
|
* @throws DuplicatedKeyFilterException
|
||||||
|
* @throws KeyException
|
||||||
|
* @throws ValueException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* if fails
|
|
||||||
*/
|
*/
|
||||||
public abstract SortedMap<Calendar, Info> getTimeSeries(
|
public SortedMap<Calendar, Info> getTimeSeries(
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters)
|
TemporalConstraint temporalConstraint, List<Filter> filters)
|
||||||
throws Exception;
|
throws DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a SortedMap containing the TimeSeries for top values for a certain
|
* Return a SortedMap containing the TimeSeries for top values for a certain
|
||||||
|
@ -63,73 +69,47 @@ public abstract class AccountingPersistenceBackendQuery {
|
||||||
* @param temporalConstraint
|
* @param temporalConstraint
|
||||||
* the TemporalConstraint (interval and aggregation)
|
* the TemporalConstraint (interval and aggregation)
|
||||||
* @param filters
|
* @param filters
|
||||||
* list of filter to obtain the time series. If null or empty
|
* list of filter to obtain the time series of top values. If
|
||||||
* list get all data for the interested Record Class with the
|
* null or empty list get all data for the interested Record
|
||||||
* applying temporal constraint. All Filter (except one) must
|
* Class with the applying temporal constraint. All Filter must
|
||||||
* have not null and not empty key and value. One Filter must
|
* have not null and not empty key and value. The filters are
|
||||||
* have not null and not empty key and a null value. The filters
|
* must be related to different keys and are in AND. If the list
|
||||||
* are must be related to different keys and are in AND. If the
|
* contains more than one filter with the same key an Exception
|
||||||
* list contains more than one filter with the same key an
|
* is thrown.
|
||||||
* Exception is thrown. If the list contains more than one filter
|
* @param topKey
|
||||||
* with null value an Exception is thrown.
|
* @param orderingProperty
|
||||||
* @return a SortedMap
|
* @return a SortedMap
|
||||||
|
* @throws DuplicatedKeyFilterException
|
||||||
|
* @throws KeyException
|
||||||
|
* @throws ValueException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* if fails
|
|
||||||
*/
|
*/
|
||||||
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>>
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
getTopValues(Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters)
|
|
||||||
throws Exception {
|
|
||||||
String orderingProperty = AccountingPersistenceQuery
|
|
||||||
.getDefaultOrderingProperties(clz);
|
|
||||||
return getTopValues(clz, temporalConstraint, filters,
|
|
||||||
orderingProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
String orderingProperty) throws Exception;
|
String topKey, String orderingProperty)
|
||||||
|
throws DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of possible values for a key for a certain usageRecord
|
|
||||||
* taking in account all Filters. The value for a certain key is identified
|
|
||||||
* adding a Filter with a null value. Only one Filter with null value is
|
|
||||||
* allowed otherwise an Exception is thrown. The values are ordered from the
|
|
||||||
* most occurred value.
|
|
||||||
*
|
*
|
||||||
* @param clz
|
* @param clz
|
||||||
* the Usage Record Class of interest
|
|
||||||
* @param temporalConstraint
|
* @param temporalConstraint
|
||||||
* the TemporalConstraint (interval and aggregation)
|
|
||||||
* @param filters
|
* @param filters
|
||||||
* list of filter to obtain the time series. If null or empty
|
* @param topKey
|
||||||
* list get all data for the interested Record Class with the
|
* @param orderingProperty
|
||||||
* applying temporal constraint. All Filter (except one) must
|
* @return
|
||||||
* have not null and not empty key and value. One Filter must
|
* @throws DuplicatedKeyFilterException
|
||||||
* have not null and not empty key and a null value. The filters
|
* @throws KeyException
|
||||||
* are must be related to different keys and are in AND. If the
|
* @throws ValueException
|
||||||
* list contains more than one filter with the same key an
|
|
||||||
* Exception is thrown. If the list contains more than one filter
|
|
||||||
* with null value an Exception is thrown.
|
|
||||||
* @return a SortedSet containing the list of possible values
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* if fails
|
|
||||||
*/
|
*/
|
||||||
public SortedSet<NumberedFilter> getNextPossibleValues(
|
public SortedSet<NumberedFilter> getNextPossibleValues(
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters)
|
|
||||||
throws Exception {
|
|
||||||
String orderingProperty = AccountingPersistenceQuery
|
|
||||||
.getDefaultOrderingProperties(clz);
|
|
||||||
return getNextPossibleValues(clz, temporalConstraint,
|
|
||||||
filters, orderingProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract SortedSet<NumberedFilter> getNextPossibleValues(
|
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
String orderingProperty) throws Exception;
|
String topKey, String orderingProperty) throws
|
||||||
|
DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the connection to persistence
|
* Close the connection to persistence
|
||||||
|
@ -137,6 +117,6 @@ public abstract class AccountingPersistenceBackendQuery {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* if the close fails
|
* if the close fails
|
||||||
*/
|
*/
|
||||||
public abstract void close() throws Exception;
|
public void close() throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,15 @@ import java.util.SortedSet;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import javax.activity.InvalidActivityException;
|
||||||
|
|
||||||
import org.gcube.accounting.analytics.Filter;
|
import org.gcube.accounting.analytics.Filter;
|
||||||
import org.gcube.accounting.analytics.Info;
|
import org.gcube.accounting.analytics.Info;
|
||||||
import org.gcube.accounting.analytics.NumberedFilter;
|
import org.gcube.accounting.analytics.NumberedFilter;
|
||||||
import org.gcube.accounting.analytics.TemporalConstraint;
|
import org.gcube.accounting.analytics.TemporalConstraint;
|
||||||
|
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.UsageRecord;
|
import org.gcube.accounting.datamodel.UsageRecord;
|
||||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||||
import org.gcube.documentstore.records.AggregatedRecord;
|
import org.gcube.documentstore.records.AggregatedRecord;
|
||||||
|
@ -28,7 +33,7 @@ import org.json.JSONObject;
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AccountingPersistenceQuery {
|
public class AccountingPersistenceQuery implements AccountingPersistenceBackendQuery {
|
||||||
|
|
||||||
private static final AccountingPersistenceQuery accountingPersistenceQuery;
|
private static final AccountingPersistenceQuery accountingPersistenceQuery;
|
||||||
|
|
||||||
|
@ -68,7 +73,8 @@ public class AccountingPersistenceQuery {
|
||||||
return getQuerableKeys(instance);
|
return getQuerableKeys(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultOrderingProperties(Class<? extends AggregatedRecord<?, ?>> clz){
|
public static String getDefaultOrderingProperties(
|
||||||
|
Class<? extends AggregatedRecord<?, ?>> clz){
|
||||||
if(clz.isAssignableFrom(AggregatedStorageUsageRecord.class)){
|
if(clz.isAssignableFrom(AggregatedStorageUsageRecord.class)){
|
||||||
return AggregatedStorageUsageRecord.DATA_VOLUME;
|
return AggregatedStorageUsageRecord.DATA_VOLUME;
|
||||||
}
|
}
|
||||||
|
@ -119,10 +125,23 @@ public class AccountingPersistenceQuery {
|
||||||
return unpaddedData;
|
return unpaddedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public SortedMap<Calendar, Info> getTimeSeries(
|
||||||
|
Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
|
TemporalConstraint temporalConstraint, List<Filter> filters)
|
||||||
|
throws DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception {
|
||||||
|
|
||||||
|
return this.getTimeSeries(clz, temporalConstraint, filters, false);
|
||||||
|
}
|
||||||
|
|
||||||
public SortedMap<Calendar, Info> getTimeSeries(
|
public SortedMap<Calendar, Info> getTimeSeries(
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
boolean pad) throws Exception {
|
boolean pad) throws DuplicatedKeyFilterException, KeyException,
|
||||||
|
ValueException, Exception {
|
||||||
SortedMap<Calendar, Info> ret =
|
SortedMap<Calendar, Info> ret =
|
||||||
AccountingPersistenceBackendQueryFactory.getInstance()
|
AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getTimeSeries(clz, temporalConstraint,
|
.getTimeSeries(clz, temporalConstraint,
|
||||||
|
@ -138,7 +157,9 @@ public class AccountingPersistenceQuery {
|
||||||
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
||||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
String orderingProperty, boolean pad, int limit) throws Exception {
|
String topKey, String orderingProperty, boolean pad, int limit)
|
||||||
|
throws DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception {
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> got;
|
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> got;
|
||||||
|
|
||||||
|
@ -148,15 +169,17 @@ public class AccountingPersistenceQuery {
|
||||||
|
|
||||||
got = AccountingPersistenceBackendQueryFactory.getInstance()
|
got = AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
.getTopValues(clz, temporalConstraint,
|
.getTopValues(clz, temporalConstraint,
|
||||||
filters, orderingProperty);
|
filters, topKey, orderingProperty);
|
||||||
|
|
||||||
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> ret = new TreeMap<NumberedFilter, SortedMap<Calendar,Info>>();
|
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> ret =
|
||||||
|
new TreeMap<NumberedFilter, SortedMap<Calendar,Info>>();
|
||||||
|
|
||||||
if(pad){
|
if(pad){
|
||||||
int count = got.size() > limit ? limit : got.size();
|
int count = got.size() > limit ? limit : got.size();
|
||||||
while(--count >= 0){
|
while(--count >= 0){
|
||||||
for(NumberedFilter nf : got.keySet()){
|
for(NumberedFilter nf : got.keySet()){
|
||||||
SortedMap<Calendar, Info> m = padMap(got.get(nf), temporalConstraint);
|
SortedMap<Calendar, Info> m =
|
||||||
|
padMap(got.get(nf), temporalConstraint);
|
||||||
ret.put(nf, m);
|
ret.put(nf, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,31 +190,76 @@ public class AccountingPersistenceQuery {
|
||||||
|
|
||||||
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters)
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
throws Exception {
|
String topKey) throws DuplicatedKeyFilterException,
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
KeyException, ValueException, Exception {
|
||||||
.getTopValues(clz, temporalConstraint,
|
String orderingProperty = AccountingPersistenceQuery
|
||||||
filters);
|
.getDefaultOrderingProperties(clz);
|
||||||
|
|
||||||
|
return this.getTopValues(clz, temporalConstraint, filters, topKey,
|
||||||
|
orderingProperty, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(
|
||||||
|
Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
|
String topKey, String orderingProperty) throws
|
||||||
|
DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception {
|
||||||
|
return this.getTopValues(clz, temporalConstraint, filters, topKey,
|
||||||
|
orderingProperty, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet<NumberedFilter> getNextPossibleValues(
|
public SortedSet<NumberedFilter> getNextPossibleValues(
|
||||||
Class<? extends AggregatedRecord<?,?>> clz,
|
Class<? extends AggregatedRecord<?,?>> clz,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters)
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
throws Exception {
|
String topKey) throws DuplicatedKeyFilterException, KeyException,
|
||||||
return AccountingPersistenceBackendQueryFactory.getInstance()
|
ValueException, Exception {
|
||||||
.getNextPossibleValues(clz,
|
|
||||||
temporalConstraint, filters);
|
String orderingProperty = AccountingPersistenceQuery
|
||||||
|
.getDefaultOrderingProperties(clz);
|
||||||
|
|
||||||
|
return this.getNextPossibleValues(clz, temporalConstraint, filters,
|
||||||
|
topKey, orderingProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SortedSet<NumberedFilter> getNextPossibleValues(
|
||||||
|
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||||
|
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||||
|
String topKey, String orderingProperty) throws
|
||||||
|
DuplicatedKeyFilterException, KeyException, ValueException,
|
||||||
|
Exception {
|
||||||
|
|
||||||
|
return AccountingPersistenceBackendQueryFactory.getInstance()
|
||||||
|
.getNextPossibleValues(clz, temporalConstraint, filters,
|
||||||
|
topKey, orderingProperty);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the connection to persistence
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
* if the close fails
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void close() throws Exception {
|
public void close() throws Exception {
|
||||||
AccountingPersistenceBackendQueryFactory.getInstance().close();
|
AccountingPersistenceBackendQueryFactory.getInstance().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void prepareConnection(
|
||||||
|
AccountingPersistenceBackendQueryConfiguration configuration)
|
||||||
|
throws Exception {
|
||||||
|
throw new InvalidActivityException();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue