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:
Luca Frosini 2015-09-07 14:36:08 +00:00
parent d6d850913a
commit bba1228989
5 changed files with 74 additions and 24 deletions

View File

@ -13,8 +13,8 @@ public class Filter {
protected String value;
/**
* @param key
* @param value
* @param key the key to filter
* @param value the value fo the key to filter
*/
public Filter(String key, String value) {
this.key = key;

View File

@ -19,8 +19,8 @@ public class Info {
protected JSONObject value;
/**
* @param calendar
* @param value
* @param date the date
* @param value the JSON value
*/
public Info(Date date, JSONObject value) {
super();

View File

@ -35,6 +35,11 @@ public class ResourceRecordQuery {
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() {
if(resourceRecords==null){
resourceRecords = new HashMap<Class<? extends SingleUsageRecord>, Set<String>>();
@ -57,10 +62,25 @@ public class ResourceRecordQuery {
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 {
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 {
ScopeProvider.instance.set(scope);
this.accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance();
@ -81,17 +101,24 @@ public class ResourceRecordQuery {
return jsonObject;
}
public static List<Info> getPaddedResults(Map<Calendar, Info> unpaddedResults, TemporalConstraint temporalConstraint) throws JSONException{
JSONObject jsonObject = getPaddingJSONObject(unpaddedResults);
/**
* Pad the data
* @param unpaddedData the data to be pad
* @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<Calendar> sequence = temporalConstraint.getCalendarSequence();
for(Calendar progressTime : sequence){
if(unpaddedResults.get(progressTime)!=null){
paddedResults.add(unpaddedResults.get(progressTime));
if(unpaddedData.get(progressTime)!=null){
paddedResults.add(unpaddedData.get(progressTime));
}else{
Date date = new Date(progressTime.getTimeInMillis());
Info info = new Info(date, jsonObject);
@ -104,12 +131,13 @@ public class ResourceRecordQuery {
/**
* Return results with padding if pad is set to true.
* @param usageRecordType
* @param temporalConstraint
* @param filters
* @param pad
* @return
* @throws Exception
* @param usageRecordType the UsageRecord type to query
* @param temporalConstraint the temporal interval and the granularity
* @param filters the list keys to filter (in AND)
* @param pad indicate is the results have to be padded with zeros when
* there is no data available at certain data points of sequence
* @return the requested list of Info
* @throws Exception if fails
*/
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
TemporalConstraint temporalConstraint, List<Filter> filters, boolean pad) throws Exception {
@ -117,17 +145,16 @@ public class ResourceRecordQuery {
if(!pad){
return new ArrayList<Info>(unpaddedResults.values());
}
return getPaddedResults(unpaddedResults, temporalConstraint);
}
/**
* Return unpadded result
* @param usageRecordType
* @param temporalConstraint
* @param filters
* @return
* @throws Exception
* Return unpadded results
* @param usageRecordType the UsageRecord type to query
* @param temporalConstraint the temporal interval and the granularity
* @param filters the list keys to filter (in AND)
* @return the requested list of Info
* @throws Exception if fails
*/
public List<Info> getInfo(@SuppressWarnings("rawtypes") Class<? extends AggregatedUsageRecord> usageRecordType,
TemporalConstraint temporalConstraint, List<Filter> filters) throws Exception{

View File

@ -22,12 +22,22 @@ public class TemporalConstraint {
private static final Logger logger = LoggerFactory.getLogger(TemporalConstraint.class);
private static final String UTC_TIME_ZONE = "UTC";
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 {
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 {
YEAR(Calendar.YEAR),
MONTH(Calendar.MONTH),
@ -53,6 +63,11 @@ public class TemporalConstraint {
protected long endTime;
protected AggregationMode aggregationMode;
/**
* @param startTime StartTime
* @param endTime End Time
* @param aggregationMode Aggregation Mode
*/
public TemporalConstraint(long startTime, long endTime, AggregationMode aggregationMode){
this.startTime = startTime;
this.endTime = endTime;

View File

@ -14,14 +14,22 @@ public class NoAvailableScopeException extends Exception {
*/
private static final long serialVersionUID = -327144230654860518L;
public NoAvailableScopeException() {
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) {
super(message);
}
public NoAvailableScopeException(Throwable cause) {
super(cause);
}