Project

General

Profile

« Previous | Next » 

Revision 786696e3

Added by Andreas Müller over 10 years ago

merge trunk into cdm3.3 branch

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/FeatureSorter.java
9 9
import java.util.HashSet;
10 10
import java.util.Iterator;
11 11
import java.util.List;
12
import java.util.ListIterator;
13 12
import java.util.Map;
14 13
import java.util.Set;
15 14
import java.util.UUID;
16 15

  
17 16
/**
18 17
 * This class is supposed to find the best sorting order for features (descriptive and other).
18
 * Currently it is not yet very sophisticated.
19
 * 
19 20
 * @author a.mueller
20 21
 *
21 22
 */
......
62 63
			Map<UUID,FeatureStatistic> statisticMap = computeStatistic(listMap);
63 64
			FeatureStatistic best = findBest(statisticMap);
64 65
			result.add(best.uuid);
65
			removeFromLists(listMap, best.uuid);
66
			Map<String, List<FeatureSorterInfo>> subFeatures = removeFromLists(listMap, best.uuid);
67
			List<UUID> subFeatureOrder = getSortOrder(subFeatures);
68
			result.addAll(subFeatureOrder);
66 69
		}
67 70
		return result;
68 71
	}
......
88 91
	 * @param orderLists
89 92
	 * @param uuid
90 93
	 */
91
	private void removeFromLists(Map<String, List<FeatureSorterInfo>> orderLists, UUID uuid) {
94
	private Map<String, List<FeatureSorterInfo>> removeFromLists(Map<String, List<FeatureSorterInfo>> orderListsMap, UUID uuid) {
95
		Map<String, List<FeatureSorterInfo>> childLists = new HashMap<String, List<FeatureSorterInfo>>();
92 96
		
93
		Set<String> keySet = orderLists.keySet();
97
		Set<String> keySet = orderListsMap.keySet();
94 98
		Iterator<String> keySetIterator = keySet.iterator();
95 99
		while (keySetIterator.hasNext()){
96 100
			String key = keySetIterator.next();
97
			List<FeatureSorterInfo> list = orderLists.get(key);			
101
			List<FeatureSorterInfo> list = orderListsMap.get(key);			
98 102
			Iterator<FeatureSorterInfo> it = list.listIterator();
99 103
			while (it.hasNext()){
100 104
				FeatureSorterInfo info = it.next();
101 105
				if (info.getUuid().equals(uuid)){
106
					if (! info.getSubFeatures().isEmpty()){
107
						childLists.put(key, info.getSubFeatures());
108
					}
102 109
					it.remove();
103 110
					if (list.isEmpty()){
104 111
						keySetIterator.remove();
......
106 113
				}
107 114
			}
108 115
		}
116
		return childLists;
109 117
	}
110 118

  
111 119

  

Also available in: Unified diff