release 2.5.0
add method getRecord add method getSpaceProvidersIds add method getSpaceTimeSeries git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@148335 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
98515db867
commit
e54578a510
2
pom.xml
2
pom.xml
|
@ -9,7 +9,7 @@
|
|||
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-analytics</artifactId>
|
||||
<version>2.4.0-SNAPSHOT</version>
|
||||
<version>2.5.0-SNAPSHOT</version>
|
||||
<name>accounting-analytics</name>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.accounting.analytics.UsageValue;
|
|||
import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException;
|
||||
import org.gcube.accounting.analytics.exception.KeyException;
|
||||
import org.gcube.accounting.analytics.exception.ValueException;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
||||
import org.gcube.documentstore.records.AggregatedRecord;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -299,5 +300,34 @@ public interface AccountingPersistenceBackendQuery {
|
|||
throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Return a record
|
||||
* @param recordId
|
||||
* @param recordType
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getRecord(String recordId, String type ) throws Exception;
|
||||
|
||||
/**
|
||||
* Return a list of type storage usage
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public SortedSet<String> getSpaceProvidersIds() throws Exception;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public SortedMap<Filter, SortedMap<Calendar, Long>> getSpaceTimeSeries(
|
||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||
List<String> providersId) throws Exception;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.activity.InvalidActivityException;
|
||||
|
||||
|
@ -22,6 +23,8 @@ import org.gcube.accounting.analytics.UsageValue;
|
|||
import org.gcube.accounting.analytics.exception.DuplicatedKeyFilterException;
|
||||
import org.gcube.accounting.analytics.exception.KeyException;
|
||||
import org.gcube.accounting.analytics.exception.ValueException;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
|
||||
import org.gcube.documentstore.records.AggregatedRecord;
|
||||
import org.json.JSONException;
|
||||
|
@ -59,7 +62,20 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
|||
Class<? extends AggregatedRecord<?,?>> clz)
|
||||
throws Exception {
|
||||
AggregatedRecord<?,?> instance = clz.newInstance();
|
||||
return instance.getQuerableKeys();
|
||||
|
||||
//limit filterky for accounting storage status (used from portlet accounting for tad space)
|
||||
if (clz.equals(AggregatedStorageStatusRecord.class)){
|
||||
SortedSet<String> storageStatus= new TreeSet<>();
|
||||
storageStatus.add(AggregatedStorageStatusRecord.CONSUMER_ID);
|
||||
storageStatus.add(AggregatedStorageStatusRecord.DATA_SERVICEID);
|
||||
return storageStatus;
|
||||
}
|
||||
else{
|
||||
return instance.getQuerableKeys();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String getDefaultOrderingProperties(
|
||||
|
@ -387,8 +403,78 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
|
|||
|
||||
|
||||
|
||||
public String getRecord(String recordId, String type ) throws Exception {
|
||||
String record= AccountingPersistenceBackendQueryFactory.getInstance().getRecord(recordId,type);
|
||||
return record;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public SortedSet<String> getSpaceProvidersIds() throws Exception{
|
||||
SortedSet<String> providersId= AccountingPersistenceBackendQueryFactory.getInstance().getSpaceProvidersIds();
|
||||
return providersId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedMap<Filter, SortedMap<Calendar, Long>> getSpaceTimeSeries(
|
||||
Class<? extends AggregatedRecord<?, ?>> clz,
|
||||
TemporalConstraint temporalConstraint, List<Filter> filters,
|
||||
List<String> providersId)
|
||||
throws Exception {
|
||||
|
||||
|
||||
SortedMap<Filter, SortedMap<Calendar, Long>> spaceTimeSeries=
|
||||
AccountingPersistenceBackendQueryFactory.getInstance().getSpaceTimeSeries(clz, temporalConstraint, filters, providersId);
|
||||
|
||||
|
||||
|
||||
|
||||
int count = spaceTimeSeries.size();
|
||||
Filter firstRemovalKey = null;
|
||||
for(Filter nf : spaceTimeSeries.keySet()){
|
||||
if(--count>=0){
|
||||
padMapStorage(spaceTimeSeries.get(nf), temporalConstraint);
|
||||
}else{
|
||||
if(firstRemovalKey==null){
|
||||
firstRemovalKey = nf;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(firstRemovalKey!=null){
|
||||
return spaceTimeSeries.subMap(spaceTimeSeries.firstKey(), firstRemovalKey);
|
||||
}
|
||||
return spaceTimeSeries;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public SortedMap<Calendar, Long> padMapStorage(
|
||||
SortedMap<Calendar, Long> unpaddedData,
|
||||
TemporalConstraint temporalConstraint) throws Exception {
|
||||
SortedSet<Calendar> sequence = temporalConstraint.getCalendarSequence();
|
||||
Long longValuePre = null;
|
||||
for (Calendar progressTime : sequence) {
|
||||
Long longValue = unpaddedData.get(progressTime);
|
||||
|
||||
if (longValue == null) {
|
||||
unpaddedData.put(progressTime, longValuePre);
|
||||
}else{
|
||||
longValuePre=longValue;
|
||||
}
|
||||
|
||||
}
|
||||
return unpaddedData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,12 @@ package org.gcube.accounting.analytics;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.gcube.accounting.analytics.TemporalConstraint.AggregationMode;
|
||||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery;
|
||||
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
|
||||
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -104,6 +108,13 @@ public class TemporalConstraintTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQuerableKeys() throws Exception{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue