Alessandro Pieve 2016-09-30 09:25:51 +00:00
parent 9fdb501787
commit 09c3c4df95
2 changed files with 24 additions and 7 deletions

View File

@ -340,6 +340,12 @@ AccountingPersistenceBackendQuery {
protected String getDesignDocId( protected String getDesignDocId(
Class<? extends AggregatedRecord<?,?>> recordClass) Class<? extends AggregatedRecord<?,?>> recordClass)
throws InstantiationException, IllegalAccessException { throws InstantiationException, IllegalAccessException {
String getDesigndocid=String.format("%s%s", MAP_REDUCE__DESIGN, recordClass
.newInstance().getRecordType());
logger.debug("use a designDocID"+getDesigndocid);
return String.format("%s%s", MAP_REDUCE__DESIGN, recordClass return String.format("%s%s", MAP_REDUCE__DESIGN, recordClass
.newInstance().getRecordType()); .newInstance().getRecordType());
} }
@ -707,11 +713,13 @@ AccountingPersistenceBackendQuery {
try { try {
JsonObject jsonObject = row.value(); JsonObject jsonObject = row.value();
//logger.trace("JsonObject : {}", row.value()+" key"+key); //logger.trace("JsonObject : {}", row.value()+" key"+key);
logger.warn("pre"+jsonObject.toString()+" key :"+key); //logger.warn("pre"+jsonObject.toString()+" key :"+key);
//verify for a not null value //verify for a not null value
String value = jsonObject.getString(key); String value = jsonObject.getString(key);
Number n = jsonObject.getDouble(orderingProperty); Number n = jsonObject.getDouble(orderingProperty);
if (n==null)
n=0;
logger.trace("pre:{}, key:{}, value:{}, n:{},orderingProperty:{}",jsonObject.toString(),key, value, n, orderingProperty);
NumberedFilter numberedFilter = NumberedFilter numberedFilter =
new NumberedFilter(key, value, n, orderingProperty); new NumberedFilter(key, value, n, orderingProperty);

View File

@ -22,7 +22,6 @@ 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;
@ -79,6 +78,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
@Before @Before
public void before() throws Exception{ public void before() throws Exception{
//ScopeProvider.instance.set("/gcube/devNext/NextNext");
ScopeProvider.instance.set("/gcube/devNext"); ScopeProvider.instance.set("/gcube/devNext");
AccountingPersistenceBackendQueryConfiguration configuration = new AccountingPersistenceBackendQueryConfiguration configuration = new
@ -130,7 +130,7 @@ public class AccountingPersistenceQueryCouchBaseTest {
} }
@Test @Test
public void getQuerableKey() throws Exception{ public void getQuerableKeyJob() throws Exception{
SortedSet<String> keys; SortedSet<String> keys;
keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class); keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedJobUsageRecord.class);
@ -140,8 +140,6 @@ public class AccountingPersistenceQueryCouchBaseTest {
} }
} }
logger.debug("List FilterKeys:" + keys.toString()); logger.debug("List FilterKeys:" + keys.toString());
} }
@Test @Test
@ -169,7 +167,18 @@ public class AccountingPersistenceQueryCouchBaseTest {
logger.debug("Result final{}", set); logger.debug("Result final{}", set);
} }
@Test
public void getQuerableKeyService() throws Exception{
SortedSet<String> keys;
keys = AccountingPersistenceQuery.getQuerableKeys(AggregatedServiceUsageRecord.class);
for (String key : keys) {
if (key != null && !key.isEmpty()) {
logger.debug("key:" +key);
}
}
logger.debug("List FilterKeys:" + keys.toString());
}
public static SortedMap<Calendar, Info> padMap( public static SortedMap<Calendar, Info> padMap(
SortedMap<Calendar, Info> unpaddedData, SortedMap<Calendar, Info> unpaddedData,