Alessandro Pieve 2016-09-29 08:38:53 +00:00
parent 1aef4d0ed7
commit 0453c2faa8
2 changed files with 17 additions and 6 deletions

View File

@ -614,7 +614,9 @@ AccountingPersistenceBackendQuery {
as(orderingProperty)); as(orderingProperty));
selectExpressions.add(x(getSpecializedProperty(clz,key)).as(key)); //selectExpressions.add(x(getSpecializedProperty(clz,key)).as(key));
selectExpressions.add(x("(CASE WHEN " + getSpecializedProperty(clz,key) +
" IS NOT NULL THEN "+getSpecializedProperty(clz,key)+" ELSE 'UNKONW' END )").as(key));
//add where expression //add where expression
Expression whereExpression = Expression whereExpression =

View File

@ -22,6 +22,7 @@ import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQu
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedJobUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord; import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.json.JSONException; import org.json.JSONException;
@ -130,17 +131,25 @@ public class AccountingPersistenceQueryCouchBaseTest {
@Test @Test
public void getQuerableKey() throws Exception{ public void getQuerableKey() throws Exception{
SortedSet<String> keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class); SortedSet<String> keys;
logger.debug("keys:"+keys);
keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class);
for (String key : keys) {
if (key != null && !key.isEmpty()) {
logger.debug("key:" +key);
}
}
logger.debug("List FilterKeys:" + keys.toString());
} }
@Test @Test
public void testTopService() throws Exception { public void testTopService() throws Exception {
Calendar startTime = Calendar.getInstance(); Calendar startTime = Calendar.getInstance();
startTime.set(2016, Calendar.AUGUST, 25); startTime.set(2015, Calendar.AUGUST, 25);
Calendar endTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance();
endTime.set(2016, Calendar.AUGUST, 28,23,59); endTime.set(2016, Calendar.SEPTEMBER, 28,23,59);
List<Filter> filters = new ArrayList<Filter>(); List<Filter> filters = new ArrayList<Filter>();
@ -155,7 +164,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set = SortedMap<NumberedFilter, SortedMap<Calendar, Info>> set =
accountingPersistenceQueryCouchBase.getTopValues( accountingPersistenceQueryCouchBase.getTopValues(
clz, temporalConstraint, filters, clz, temporalConstraint, filters,
AggregatedServiceUsageRecord.HOST, null); AggregatedServiceUsageRecord.CALLERQUALIFIER, null);
logger.debug("Result final{}", set); logger.debug("Result final{}", set);