Fixed bug on ordering and padding

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@126308 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-03-25 15:22:59 +00:00
parent effe6b280a
commit cb956fb1de
1 changed files with 21 additions and 13 deletions

View File

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import javax.activity.InvalidActivityException; import javax.activity.InvalidActivityException;
@ -168,24 +167,33 @@ public class AccountingPersistenceQuery implements AccountingPersistenceBackendQ
} }
got = AccountingPersistenceBackendQueryFactory.getInstance() got = AccountingPersistenceBackendQueryFactory.getInstance()
.getTopValues(clz, temporalConstraint, .getTopValues(clz, temporalConstraint, filters, topKey,
filters, topKey, orderingProperty); orderingProperty);
SortedMap<NumberedFilter, SortedMap<Calendar, Info>> ret =
new TreeMap<NumberedFilter, SortedMap<Calendar,Info>>(); int count = got.size() > limit ? limit : got.size();
if(pad){ NumberedFilter firstRemovalKey = null;
int count = got.size() > limit ? limit : got.size();
while(--count >= 0){ for(NumberedFilter nf : got.keySet()){
for(NumberedFilter nf : got.keySet()){ if(--count>=0 || limit<=0){
SortedMap<Calendar, Info> m = if(pad){
padMap(got.get(nf), temporalConstraint); padMap(got.get(nf), temporalConstraint);
ret.put(nf, m); }
}else{
if(firstRemovalKey==null){
firstRemovalKey = nf;
}else{
break;
} }
} }
} }
return ret; if(firstRemovalKey!=null){
return got.subMap(got.firstKey(), firstRemovalKey);
}
return got;
} }
public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues( public SortedMap<NumberedFilter, SortedMap<Calendar, Info>> getTopValues(