Revision 165e1209
Added by Andreas Müller over 4 years ago
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/EfloraActivatorBase.java | ||
---|---|---|
1 | 1 |
/** |
2 |
*
|
|
2 |
* |
|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.cdm.app.eflora; |
5 | 5 |
|
... | ... | |
26 | 26 |
import eu.etaxonomy.cdm.io.markup.MarkupImportConfigurator; |
27 | 27 |
import eu.etaxonomy.cdm.io.markup.MarkupImportState; |
28 | 28 |
import eu.etaxonomy.cdm.model.description.Feature; |
29 |
import eu.etaxonomy.cdm.model.term.FeatureNode;
|
|
30 |
import eu.etaxonomy.cdm.model.term.FeatureTree;
|
|
29 |
import eu.etaxonomy.cdm.model.term.TermNode;
|
|
30 |
import eu.etaxonomy.cdm.model.term.TermTree;
|
|
31 | 31 |
|
32 | 32 |
/** |
33 | 33 |
* @author a.mueller |
... | ... | |
35 | 35 |
*/ |
36 | 36 |
public class EfloraActivatorBase { |
37 | 37 |
private static final Logger logger = Logger.getLogger(EfloraActivatorBase.class); |
38 |
|
|
38 |
|
|
39 | 39 |
protected MarkupImportConfigurator config; |
40 | 40 |
protected CdmDefaultImport<MarkupImportConfigurator> myImport; |
41 | 41 |
protected IIoObserver observer = new LoggingIoObserver(); |
... | ... | |
49 | 49 |
config = MarkupImportConfigurator.NewInstance(source, cdmDestination); |
50 | 50 |
config.setObservers(observerList); |
51 | 51 |
config.setCheck(check); |
52 |
|
|
53 |
myImport = new CdmDefaultImport<MarkupImportConfigurator>();
|
|
54 |
|
|
52 |
|
|
53 |
myImport = new CdmDefaultImport<MarkupImportConfigurator>(); |
|
54 |
|
|
55 | 55 |
return config; |
56 | 56 |
} |
57 |
|
|
58 |
protected FeatureTree makeAutomatedFeatureTree(ICdmRepository app,
|
|
57 |
|
|
58 |
protected TermTree<Feature> makeAutomatedFeatureTree(ICdmRepository app,
|
|
59 | 59 |
MarkupImportState state, UUID featureTreeUuid, String featureTreeTitle){ |
60 | 60 |
System.out.println("Start creating automated Feature Tree"); |
61 |
FeatureTree tree = FeatureTree.NewInstance(featureTreeUuid);
|
|
61 |
TermTree<Feature> tree = TermTree.NewFeatureInstance(featureTreeUuid);
|
|
62 | 62 |
tree.setTitleCache(featureTreeTitle, true); |
63 |
FeatureNode root = tree.getRoot();
|
|
64 |
|
|
63 |
TermNode<Feature> root = tree.getRoot();
|
|
64 |
|
|
65 | 65 |
ITermService termService = app.getTermService(); |
66 | 66 |
FeatureSorter sorter = new FeatureSorter(); |
67 |
FeatureNode descriptionNode = null;
|
|
68 |
|
|
67 |
TermNode<Feature> descriptionNode = null;
|
|
68 |
|
|
69 | 69 |
//general features |
70 | 70 |
Map<String, List<FeatureSorterInfo>> generalList = state.getGeneralFeatureSorterListMap(); |
71 | 71 |
List<UUID> uuidList = sorter.getSortOrder(generalList); |
72 | 72 |
Map<UUID, Feature> map = makeUuidMap(uuidList, termService); |
73 | 73 |
for (UUID key : uuidList){ |
74 | 74 |
Feature feature = map.get(key); |
75 |
FeatureNode node = FeatureNode.NewInstance(feature); |
|
76 |
root.addChild(node); |
|
75 |
TermNode<Feature> node = root.addChild(feature); |
|
77 | 76 |
if (feature.equals(Feature.DESCRIPTION())){ |
78 | 77 |
descriptionNode = node; |
79 | 78 |
} |
80 | 79 |
} |
81 |
FeatureNode newNode = FeatureNode.NewInstance(Feature.CITATION()); |
|
82 |
root.addChild(newNode); |
|
83 |
|
|
84 |
|
|
80 |
TermNode<Feature> newNode = root.addChild(Feature.CITATION()); |
|
81 |
|
|
82 |
|
|
85 | 83 |
//description features |
86 | 84 |
if (descriptionNode != null){ |
87 | 85 |
Map<String, List<FeatureSorterInfo>> charList = state.getCharFeatureSorterListMap(); |
... | ... | |
89 | 87 |
map = makeUuidMap(uuidList, termService); |
90 | 88 |
for (UUID key : uuidList){ |
91 | 89 |
Feature feature = map.get(key); |
92 |
descriptionNode.addChild(FeatureNode.NewInstance(feature));
|
|
90 |
descriptionNode.addChild(feature);
|
|
93 | 91 |
} |
94 | 92 |
}else{ |
95 | 93 |
logger.warn("No description node found. Could not create feature nodes for description features."); |
... | ... | |
97 | 95 |
|
98 | 96 |
//save tree |
99 | 97 |
app.getFeatureTreeService().saveOrUpdate(tree); |
100 |
|
|
98 |
|
|
101 | 99 |
System.out.println("End creating automated Feature Tree"); |
102 |
|
|
100 |
|
|
103 | 101 |
return tree; |
104 | 102 |
} |
105 |
|
|
103 |
|
|
106 | 104 |
private Map<UUID,Feature> makeUuidMap(Collection<UUID> uuids, ITermService termService){ |
107 | 105 |
HashSet<UUID> uuidSet = new HashSet<UUID>(); |
108 | 106 |
uuidSet.addAll(uuids); |
109 | 107 |
List<Feature> featureSet = (List)termService.find(uuidSet); |
110 |
|
|
108 |
|
|
111 | 109 |
Map<UUID,Feature> result = new HashMap<UUID, Feature>(); |
112 | 110 |
for (Feature feature : featureSet){ |
113 | 111 |
result.put(feature.getUuid(), feature); |
114 | 112 |
} |
115 | 113 |
return result; |
116 | 114 |
} |
117 |
|
|
118 |
|
|
115 |
|
|
116 |
|
|
119 | 117 |
/** |
120 | 118 |
* @param markupConfig |
121 | 119 |
* @param myImport |
Also available in: Unified diff
ref #6794 , ref #7099 adapt app-import, pesi, eflora to modelchanges