Revision 7691ed2a
Added by Andreas Müller almost 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/berlinModelImport/TreeCreator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
15 | 15 |
|
16 | 16 |
import org.apache.log4j.Logger; |
17 | 17 |
|
18 |
import eu.etaxonomy.cdm.app.berlinModelImport.TreeCreator; |
|
19 | 18 |
import eu.etaxonomy.cdm.model.description.Feature; |
20 | 19 |
import eu.etaxonomy.cdm.model.term.FeatureNode; |
21 | 20 |
import eu.etaxonomy.cdm.model.term.FeatureTree; |
... | ... | |
23 | 22 |
/** |
24 | 23 |
* @author a.mueller |
25 | 24 |
* @since 03.07.2008 |
26 |
* @version 1.0 |
|
27 | 25 |
*/ |
28 | 26 |
public class TreeCreator { |
29 | 27 |
@SuppressWarnings("unused") |
30 | 28 |
private static final Logger logger = Logger.getLogger(TreeCreator.class); |
31 | 29 |
|
32 |
public static FeatureTree flatTree(UUID featureTreeUuid, Map<Integer, Feature> featureMap, Object[] featureKeyList){ |
|
33 |
FeatureTree result = FeatureTree.NewInstance(featureTreeUuid); |
|
34 |
FeatureNode root = result.getRoot(); |
|
35 |
|
|
30 |
public static FeatureTree<Feature> flatTree(UUID featureTreeUuid, Map<Integer, Feature> featureMap, Object[] featureKeyList){
|
|
31 |
FeatureTree<Feature> result = FeatureTree.NewInstance(featureTreeUuid);
|
|
32 |
FeatureNode<Feature> root = result.getRoot();
|
|
33 |
|
|
36 | 34 |
for (Object featureKey : featureKeyList){ |
37 | 35 |
Feature feature = featureMap.get(featureKey); |
38 | 36 |
if (feature != null){ |
39 |
FeatureNode child = FeatureNode.NewInstance(feature); |
|
40 |
root.addChild(child); |
|
37 |
root.addChild(feature); |
|
41 | 38 |
} |
42 | 39 |
} |
43 | 40 |
return result; |
44 | 41 |
} |
45 |
|
|
46 |
|
|
42 |
|
|
43 |
|
|
47 | 44 |
/** |
48 | 45 |
* @param args |
49 | 46 |
*/ |
... | ... | |
52 | 49 |
map.put(1, Feature.DISTRIBUTION()); |
53 | 50 |
map.put(2, Feature.ECOLOGY()); |
54 | 51 |
|
55 |
Object[] strFeatureList = new Integer[]{1,2};
|
|
52 |
Object[] strFeatureList = new Integer[]{1,2}; |
|
56 | 53 |
|
57 |
FeatureTree tree = TreeCreator.flatTree(UUID.randomUUID(), map, strFeatureList); |
|
54 |
FeatureTree<Feature> tree = TreeCreator.flatTree(UUID.randomUUID(), map, strFeatureList);
|
|
58 | 55 |
System.out.println(tree.getRootChildren()); |
59 | 56 |
} |
60 | 57 |
} |
Also available in: Unified diff
ref #8257 remove factory method for term node creation in app-import