Improving javadoc
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@118921 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d6d850913a
commit
bba1228989
|
@ -13,8 +13,8 @@ public class Filter {
|
||||||
protected String value;
|
protected String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param key
|
* @param key the key to filter
|
||||||
* @param value
|
* @param value the value fo the key to filter
|
||||||
*/
|
*/
|
||||||
public Filter(String key, String value) {
|
public Filter(String key, String value) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
|
@ -19,8 +19,8 @@ public class Info {
|
||||||
protected JSONObject value;
|
protected JSONObject value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param calendar
|
* @param date the date
|
||||||
* @param value
|
* @param value the JSON value
|
||||||
*/
|
*/
|
||||||
public Info(Date date, JSONObject value) {
|
public Info(Date date, JSONObject value) {
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -35,6 +35,11 @@ public class ResourceRecordQuery {
|
||||||
|
|
||||||
protected static Map<Class<? extends SingleUsageRecord>, Set<String>> resourceRecords = null;
|
protected static Map<Class<? extends SingleUsageRecord>, Set<String>> resourceRecords = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a Map containing a set of required fields for each Resource
|
||||||
|
* Records Types
|
||||||
|
* @return the Map
|
||||||
|
*/
|
||||||
public static Map<Class<? extends SingleUsageRecord>, Set<String>> getResourceRecordsTypes() {
|
public static Map<Class<? extends SingleUsageRecord>, Set<String>> getResourceRecordsTypes() {
|
||||||
if(resourceRecords==null){
|
if(resourceRecords==null){
|
||||||
resourceRecords = new HashMap<Class<? extends SingleUsageRecord>, Set<String>>();
|
resourceRecords = new HashMap<Class<? extends SingleUsageRecord>, Set<String>>();
|
||||||
|
@ -57,10 +62,25 @@ public class ResourceRecordQuery {
|
||||||
|
|
||||||
protected AccountingPersistenceQuery accountingPersistenceQuery;
|
protected AccountingPersistenceQuery accountingPersistenceQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate the ResourceRecord for the current scope
|
||||||
|
* @throws NoAvailableScopeException if there is not possible to query in
|
||||||
|
* the current scope
|
||||||
|
* @throws NoUsableAccountingPersistenceQueryFound if there is no available
|
||||||
|
* instance which can query in that scope
|
||||||
|
*/
|
||||||
public ResourceRecordQuery() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound {
|
public ResourceRecordQuery() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound {
|
||||||
this.accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance();
|
this.accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate the ResourceRecord for the provided scope
|
||||||
|
* @param scope the scope
|
||||||
|
* @throws NoAvailableScopeException if there is not possible to query in
|
||||||
|
* that scope
|
||||||
|
* @throws NoUsableAccountingPersistenceQueryFound if there is no available
|
||||||
|
* instance which can query in that scope
|
||||||
|
*/
|
||||||
public ResourceRecordQuery(String scope) throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound {
|
public ResourceRecordQuery(String scope) throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound {
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
this.accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance();
|
this.accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance();
|
||||||
|
@ -81,17 +101,24 @@ public class ResourceRecordQuery {
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pad the data
|
||||||
public static List<Info> getPaddedResults(Map<Calendar, Info> unpaddedResults, TemporalConstraint temporalConstraint) throws JSONException{
|
* @param unpaddedData the data to be pad
|
||||||
JSONObject jsonObject = getPaddingJSONObject(unpaddedResults);
|
* @param temporalConstraint temporalConstraint the temporal interval and
|
||||||
|
* the granularity of the data to pad
|
||||||
|
* @return the data padded taking in account the TemporalConstraint
|
||||||
|
* @throws Exception if fails
|
||||||
|
*/
|
||||||
|
public static List<Info> getPaddedResults(Map<Calendar, Info> unpaddedData,
|
||||||
|
TemporalConstraint temporalConstraint) throws Exception {
|
||||||
|
JSONObject jsonObject = getPaddingJSONObject(unpaddedData);
|
||||||
|
|
||||||
List<Info> paddedResults = new ArrayList<Info>();
|
List<Info> paddedResults = new ArrayList<Info>();
|
||||||
List<Calendar> sequence = temporalConstraint.getCalendarSequence();
|
List<Calendar> sequence = temporalConstraint.getCalendarSequence();
|
||||||
|
|
||||||
for(Calendar progressTime : sequence){
|
for(Calendar progressTime : sequence){
|
||||||
if(unpaddedResults.get(progressTime)!=null){
|
if(unpaddedData.get(progressTime)!=null){
|
||||||
paddedResults.add(unpaddedResults.get(progressTime));
|
paddedResults.add(unpaddedData.get(progressTime));
|
||||||
}else{
|
}else{
|
||||||
Date date = new Date(progressTime.getTimeInMillis());
|
Date date = new Date(progressTime.getTimeInMillis());
|
||||||
Info info = new Info(date, jsonObject);
|
Info info = new Info(date, jsonObject);
|
||||||
|
@ -104,12 +131,13 @@ public class ResourceRecordQuery {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return results with padding if pad is set to true.
|
* Return results with padding if pad is set to true.
|
||||||
* @param usageRecordType
|
* @param usageRecordType the UsageRecord type to query
|
||||||
* @param temporalConstraint
|
* @param temporalConstraint the temporal interval and the granularity
|
||||||
* @param filters
|
* @param filters the list keys to filter (in AND)
|
||||||
* @param pad
|
* @param pad indicate is the results have to be padded with zeros when
|
||||||
* @return
|
* there is no data available at certain data points of sequence
|
||||||
* @throws Exception
|
* @return the requested list of Info
|
||||||
|
* @throws Exception if fails
|
||||||
*/
|
*/
|
||||||
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
|
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters, boolean pad) throws Exception {
|
TemporalConstraint temporalConstraint, List<Filter> filters, boolean pad) throws Exception {
|
||||||
|
@ -117,17 +145,16 @@ public class ResourceRecordQuery {
|
||||||
if(!pad){
|
if(!pad){
|
||||||
return new ArrayList<Info>(unpaddedResults.values());
|
return new ArrayList<Info>(unpaddedResults.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
return getPaddedResults(unpaddedResults, temporalConstraint);
|
return getPaddedResults(unpaddedResults, temporalConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return unpadded result
|
* Return unpadded results
|
||||||
* @param usageRecordType
|
* @param usageRecordType the UsageRecord type to query
|
||||||
* @param temporalConstraint
|
* @param temporalConstraint the temporal interval and the granularity
|
||||||
* @param filters
|
* @param filters the list keys to filter (in AND)
|
||||||
* @return
|
* @return the requested list of Info
|
||||||
* @throws Exception
|
* @throws Exception if fails
|
||||||
*/
|
*/
|
||||||
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
|
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
|
||||||
TemporalConstraint temporalConstraint, List<Filter> filters) throws Exception{
|
TemporalConstraint temporalConstraint, List<Filter> filters) throws Exception{
|
||||||
|
|
|
@ -22,12 +22,22 @@ public class TemporalConstraint {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TemporalConstraint.class);
|
private static final Logger logger = LoggerFactory.getLogger(TemporalConstraint.class);
|
||||||
|
|
||||||
private static final String UTC_TIME_ZONE = "UTC";
|
private static final String UTC_TIME_ZONE = "UTC";
|
||||||
|
|
||||||
public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getTimeZone(UTC_TIME_ZONE);
|
public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getTimeZone(UTC_TIME_ZONE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valid Aggregation Mode
|
||||||
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
*/
|
||||||
public enum AggregationMode {
|
public enum AggregationMode {
|
||||||
YEARLY, MONTHLY, DAILY, HOURLY, MINUTELY, SECONDLY, MILLISECONDLY
|
YEARLY, MONTHLY, DAILY, HOURLY, MINUTELY, SECONDLY, MILLISECONDLY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to map the Calendar constant to an enum value which has the same
|
||||||
|
* ordinal of {@link AggregationMode}
|
||||||
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
*/
|
||||||
public enum CalendarEnum {
|
public enum CalendarEnum {
|
||||||
YEAR(Calendar.YEAR),
|
YEAR(Calendar.YEAR),
|
||||||
MONTH(Calendar.MONTH),
|
MONTH(Calendar.MONTH),
|
||||||
|
@ -53,6 +63,11 @@ public class TemporalConstraint {
|
||||||
protected long endTime;
|
protected long endTime;
|
||||||
protected AggregationMode aggregationMode;
|
protected AggregationMode aggregationMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startTime StartTime
|
||||||
|
* @param endTime End Time
|
||||||
|
* @param aggregationMode Aggregation Mode
|
||||||
|
*/
|
||||||
public TemporalConstraint(long startTime, long endTime, AggregationMode aggregationMode){
|
public TemporalConstraint(long startTime, long endTime, AggregationMode aggregationMode){
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
|
|
|
@ -14,14 +14,22 @@ public class NoAvailableScopeException extends Exception {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -327144230654860518L;
|
private static final long serialVersionUID = -327144230654860518L;
|
||||||
|
|
||||||
|
|
||||||
public NoAvailableScopeException() {
|
public NoAvailableScopeException() {
|
||||||
super();
|
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 NoAvailableScopeException(String message) {
|
public NoAvailableScopeException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NoAvailableScopeException(Throwable cause) {
|
public NoAvailableScopeException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue