refs #200: Create accouting-lib library

https://support.d4science.org/issues/200
Fixing tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@115777 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-07-02 09:53:53 +00:00
parent 76cb6970c8
commit 5bfc630489
3 changed files with 9 additions and 8 deletions

View File

@ -24,7 +24,6 @@ public class StorageUsageRecordAggregationStrategy extends AggregationStrategy<S
this.aggregationField.add(StorageUsageRecord.PROVIDER_URI);
this.aggregationField.add(StorageUsageRecord.OPERATION_TYPE);
this.aggregationField.add(StorageUsageRecord.DATA_TYPE);
this.aggregationField.add(StorageUsageRecord.QUALIFIER);
}
protected StorageUsageRecord reallyAggregate(StorageUsageRecord record)

View File

@ -22,20 +22,25 @@ public abstract class AggregationStrategy<T extends AggregatedUsageRecord<T, B>,
protected Set<String> aggregationField;
protected void cleanExtraFields(){
Set<String> requiredFields = ((BasicUsageRecord) t).getRequiredFields();
Set<String> neededFields = ((BasicUsageRecord) t).requiredFields;
neededFields.addAll(((BasicUsageRecord) t).aggregatedFields);
Set<String> keysToRemove = new HashSet<String>();
for(String propertyName : t.getResourceProperties().keySet()){
if(!requiredFields.contains(propertyName)){
Set<String> propertyKeys = ((BasicUsageRecord) t).resourceProperties.keySet();
for(String propertyName : propertyKeys){
if(!neededFields.contains(propertyName)){
keysToRemove.add(propertyName);
}
}
for(String keyToRemove : keysToRemove){
t.getResourceProperties().remove(keyToRemove);
((BasicUsageRecord) t).resourceProperties.remove(keyToRemove);
}
}
public AggregationStrategy(T t){
this.t = t;
cleanExtraFields();
this.aggregationField = new HashSet<String>();
this.aggregationField.add(BasicUsageRecord.CONSUMER_ID);
this.aggregationField.add(BasicUsageRecord.USAGE_RECORD_TYPE);
@ -102,8 +107,6 @@ public abstract class AggregationStrategy<T extends AggregatedUsageRecord<T, B>,
((BasicUsageRecord) t).setCreationTime(newCreationTime);
cleanExtraFields();
return t;
}catch(NotAggregatableRecordsExceptions e){
throw e;

View File

@ -127,7 +127,6 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
@AggregatedField @ValidInteger
protected static final String OPERATION_COUNT = "operationCount";
protected Set<String> aggregatedFields;
protected static Set<Field> getAllFields(Class<?> type) {