Using base class
This commit is contained in:
parent
f04987da10
commit
bf5e518232
|
@ -1,6 +1,5 @@
|
|||
package org.gcube.accounting.analytics.persistence.postgresql;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -14,20 +13,19 @@ import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
|
|||
import org.gcube.accounting.analytics.TemporalConstraint.CalendarEnum;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.utility.postgresql.PostgreSQLQuery;
|
||||
import org.gcube.accounting.utility.postgresql.RecordToDBFields;
|
||||
import org.gcube.accounting.utility.postgresql.RecordToDBMapping;
|
||||
import org.gcube.documentstore.records.AggregatedRecord;
|
||||
|
||||
public class Query {
|
||||
public class Query extends PostgreSQLQuery {
|
||||
|
||||
public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS Z";
|
||||
public static final String DATE_OF_TIMESERIES_AS_FIELD = AggregatedRecord.START_TIME;
|
||||
|
||||
private Class<? extends AggregatedRecord<?, ?>> clz;
|
||||
private final RecordToDBFields recordToDBMapper;
|
||||
|
||||
private List<String> requestedTableField;
|
||||
private StringBuffer stringBuffer;
|
||||
|
||||
protected TemporalConstraint temporalConstraint;
|
||||
protected List<Filter> filters;
|
||||
|
@ -66,12 +64,6 @@ public class Query {
|
|||
return recordToDBMapper;
|
||||
}
|
||||
|
||||
private void appendString(String string) {
|
||||
stringBuffer.append("'");
|
||||
stringBuffer.append(string);
|
||||
stringBuffer.append("'");
|
||||
}
|
||||
|
||||
protected String getTableField(String fieldName) {
|
||||
return recordToDBMapper.getTableField(fieldName);
|
||||
}
|
||||
|
@ -86,28 +78,6 @@ public class Query {
|
|||
return date;
|
||||
}
|
||||
|
||||
protected void appendValue(Serializable serializable) {
|
||||
if(serializable instanceof Number) {
|
||||
stringBuffer.append(serializable.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if(serializable instanceof Calendar) {
|
||||
Calendar calendar = (Calendar) serializable;
|
||||
appendString(getFormattedDate(calendar));
|
||||
return;
|
||||
}
|
||||
|
||||
if(serializable instanceof Enum) {
|
||||
Enum<?> e = (Enum<?>) serializable;
|
||||
appendString(e.name());
|
||||
return;
|
||||
}
|
||||
|
||||
// String, URI etc
|
||||
appendString(serializable.toString());
|
||||
}
|
||||
|
||||
protected void addFilters() {
|
||||
if(filters!=null && filters.size()>0) {
|
||||
// The first filter if the time_bucket
|
||||
|
|
Loading…
Reference in New Issue