[Bug #812] changes Map for SortedMap in PredefinedDatabaseSnapshots
it changes Map for SortedMap to maintain the ordering in criterion types collection. FEA : ItEr68S04BugFixing
This commit is contained in:
parent
5a98c3871a
commit
c6ad404b8c
6 changed files with 32 additions and 14 deletions
|
|
@ -231,6 +231,7 @@ class NotBlockingAutoUpdatedSnapshot<T> implements IAutoUpdatedSnapshot<T> {
|
|||
return callable.call();
|
||||
} catch (Exception e) {
|
||||
error = e;
|
||||
LOG.error("error executing snapshot " + name);
|
||||
throw e;
|
||||
} finally {
|
||||
long timeExecuting = System.currentTimeMillis() - start;
|
||||
|
|
|
|||
|
|
@ -21,10 +21,12 @@ package org.navalplanner.business.hibernate.notification;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
|
@ -92,9 +94,9 @@ public class PredefinedDatabaseSnapshots {
|
|||
@Autowired
|
||||
private ISnapshotRefresherService snapshotRefresherService;
|
||||
|
||||
private IAutoUpdatedSnapshot<Map<CriterionType, List<Criterion>>> criterionsMap;
|
||||
private IAutoUpdatedSnapshot<SortedMap<CriterionType, List<Criterion>>> criterionsMap;
|
||||
|
||||
public Map<CriterionType, List<Criterion>> snapshotCriterionsMap() {
|
||||
public SortedMap<CriterionType, List<Criterion>> snapshotCriterionsMap() {
|
||||
return criterionsMap.getValue();
|
||||
}
|
||||
|
||||
|
|
@ -237,11 +239,13 @@ public class PredefinedDatabaseSnapshots {
|
|||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
private Callable<Map<CriterionType, List<Criterion>>> calculateCriterionsMap() {
|
||||
return new Callable<Map<CriterionType, List<Criterion>>>() {
|
||||
private Callable<SortedMap<CriterionType, List<Criterion>>> calculateCriterionsMap() {
|
||||
return new Callable<SortedMap<CriterionType, List<Criterion>>>() {
|
||||
@Override
|
||||
public Map<CriterionType, List<Criterion>> call() throws Exception {
|
||||
Map<CriterionType, List<Criterion>> result = new HashMap<CriterionType, List<Criterion>>();
|
||||
public SortedMap<CriterionType, List<Criterion>> call()
|
||||
throws Exception {
|
||||
SortedMap<CriterionType, List<Criterion>> result = new TreeMap<CriterionType, List<Criterion>>(
|
||||
getComparatorByName());
|
||||
for (CriterionType criterionType : criterionTypeDAO
|
||||
.getSortedCriterionTypes()) {
|
||||
if (criterionType.isEnabled()) {
|
||||
|
|
@ -255,6 +259,15 @@ public class PredefinedDatabaseSnapshots {
|
|||
};
|
||||
}
|
||||
|
||||
private Comparator<CriterionType> getComparatorByName(){
|
||||
return new Comparator<CriterionType>() {
|
||||
@Override
|
||||
public int compare(CriterionType arg0, CriterionType arg1) {
|
||||
return (arg0.getName().compareTo(arg1.getName()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ILabelTypeDAO labelTypeDAO;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package org.navalplanner.web.common.components.finders;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.navalplanner.business.hibernate.notification.PredefinedDatabaseSnapshots;
|
||||
|
|
@ -78,7 +79,7 @@ public class OrderElementsMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
}
|
||||
|
||||
private List<FilterPair> fillWithFirstTenFiltersCriterions() {
|
||||
Map<CriterionType, List<Criterion>> mapCriterions = getMapCriterions();
|
||||
SortedMap<CriterionType, List<Criterion>> mapCriterions = getMapCriterions();
|
||||
Iterator<CriterionType> iteratorCriterionType = mapCriterions.keySet()
|
||||
.iterator();
|
||||
while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
|
||||
|
|
@ -95,7 +96,7 @@ public class OrderElementsMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
return getListMatching();
|
||||
}
|
||||
|
||||
private Map<CriterionType, List<Criterion>> getMapCriterions() {
|
||||
private SortedMap<CriterionType, List<Criterion>> getMapCriterions() {
|
||||
return databaseSnapshots.snapshotCriterionsMap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package org.navalplanner.web.common.components.finders;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
|
|
@ -82,7 +83,7 @@ public class OrdersMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
}
|
||||
|
||||
private List<FilterPair> fillWithFirstTenFiltersCriterions() {
|
||||
Map<CriterionType, List<Criterion>> mapCriterions = getMapCriterions();
|
||||
SortedMap<CriterionType, List<Criterion>> mapCriterions = getMapCriterions();
|
||||
Iterator<CriterionType> iteratorCriterionType = mapCriterions.keySet()
|
||||
.iterator();
|
||||
while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
|
||||
|
|
@ -99,7 +100,7 @@ public class OrdersMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
return getListMatching();
|
||||
}
|
||||
|
||||
private Map<CriterionType, List<Criterion>> getMapCriterions() {
|
||||
private SortedMap<CriterionType, List<Criterion>> getMapCriterions() {
|
||||
return databaseSnapshots.snapshotCriterionsMap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.navalplanner.business.hibernate.notification.PredefinedDatabaseSnapshots;
|
||||
|
|
@ -99,7 +100,7 @@ public class ResourceAllocationMultipleFiltersFinder extends
|
|||
}
|
||||
|
||||
private List<FilterPair> fillWithFirstTenFiltersCriterions() {
|
||||
Map<CriterionType, List<Criterion>> mapCriterions = getCriterionsMap();
|
||||
SortedMap<CriterionType, List<Criterion>> mapCriterions = getCriterionsMap();
|
||||
Iterator<CriterionType> iteratorCriterionType = mapCriterions.keySet()
|
||||
.iterator();
|
||||
while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
|
||||
|
|
@ -116,7 +117,7 @@ public class ResourceAllocationMultipleFiltersFinder extends
|
|||
return getListMatching();
|
||||
}
|
||||
|
||||
private Map<CriterionType, List<Criterion>> getCriterionsMap() {
|
||||
private SortedMap<CriterionType, List<Criterion>> getCriterionsMap() {
|
||||
return this.databaseSnapshots.snapshotCriterionsMap();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package org.navalplanner.web.common.components.finders;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
|
|
@ -56,7 +57,7 @@ public class ResourcesMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
}
|
||||
|
||||
private List<FilterPair> fillWithFirstTenFiltersCriterions() {
|
||||
Map<CriterionType, List<Criterion>> criterionsMap = getCriterionsMap();
|
||||
SortedMap<CriterionType, List<Criterion>> criterionsMap = getCriterionsMap();
|
||||
Iterator<CriterionType> iteratorCriterionType = criterionsMap.keySet()
|
||||
.iterator();
|
||||
while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
|
||||
|
|
@ -70,7 +71,7 @@ public class ResourcesMultipleFiltersFinder extends MultipleFiltersFinder {
|
|||
return getListMatching();
|
||||
}
|
||||
|
||||
private Map<CriterionType, List<Criterion>> getCriterionsMap() {
|
||||
private SortedMap<CriterionType, List<Criterion>> getCriterionsMap() {
|
||||
return databaseSnapshots.snapshotCriterionsMap();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue