Added test for fix of old records persisted using double instead of long for creationTime, startTime, endTime and instead of int for duration and fixed bugs

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-aggregator-se-plugin@162675 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-01-26 15:02:43 +00:00
parent f705b73ca9
commit 61359077fa
1 changed files with 34 additions and 16 deletions

View File

@ -129,22 +129,6 @@ public class Aggregator {
}
Boolean aggregated = false;
if(content.containsKey(AggregatedRecord.AGGREGATED)){
aggregated = content.getBoolean(AggregatedRecord.AGGREGATED);
}
if(!aggregated){
String recordType = content.getString(Record.RECORD_TYPE);
content.put(Record.RECORD_TYPE, SINGLE + recordType);
}
String recordType = content.getString(Record.RECORD_TYPE);
if(recordType.contains(SIMPLE)){
recordType = recordType.replace(SIMPLE, SINGLE);
content.put(Record.RECORD_TYPE, recordType);
}
if(content.containsKey(AggregatedRecord.CREATION_TIME)) {
Object object = content.get(AggregatedRecord.CREATION_TIME);
@ -155,6 +139,7 @@ public class Aggregator {
}
if(content.containsKey(AggregatedRecord.START_TIME)) {
aggregated = true;
Object object = content.get(AggregatedRecord.START_TIME);
if(object instanceof Double) {
Double d = ((Double) object);
@ -163,6 +148,7 @@ public class Aggregator {
}
if(content.containsKey(AggregatedRecord.END_TIME)) {
aggregated = true;
Object object = content.get(AggregatedRecord.END_TIME);
if(object instanceof Double) {
Double d = ((Double) object);
@ -176,6 +162,38 @@ public class Aggregator {
Double d = ((Double) object);
content.put(AggregatedRecord.OPERATION_COUNT, d.intValue());
}
if(content.getInt(AggregatedRecord.OPERATION_COUNT)>1) {
aggregated = true;
}
}
if(aggregated) {
content.put(AggregatedRecord.AGGREGATED, true);
}
String recordType = content.getString(Record.RECORD_TYPE);
if(!aggregated){
if(recordType.startsWith(SIMPLE)){
recordType = recordType.replace(SIMPLE, SINGLE);
content.put(Record.RECORD_TYPE, recordType);
}
if(!recordType.startsWith(SINGLE)) {
recordType = SINGLE + recordType;
content.put(Record.RECORD_TYPE, recordType);
}
}else {
if(recordType.startsWith(SIMPLE)){
recordType = recordType.replace(SIMPLE, "");
content.put(Record.RECORD_TYPE, recordType);
}
if(recordType.startsWith(SINGLE)) {
recordType = recordType.replace(SINGLE, "");
content.put(Record.RECORD_TYPE, recordType);
}
}
String record = content.toString();