Revision bb03b5f4
Added by Andreas Müller almost 2 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/sdd/ikeyplus/IkeyPlusImport.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.io.sdd.ikeyplus; |
10 | 10 |
|
11 |
import eu.etaxonomy.cdm.common.URI; |
|
12 | 11 |
import java.util.Collection; |
13 | 12 |
import java.util.HashMap; |
14 | 13 |
import java.util.HashSet; |
... | ... | |
16 | 15 |
import java.util.Map; |
17 | 16 |
import java.util.Set; |
18 | 17 |
|
19 |
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger; |
|
18 |
import org.apache.logging.log4j.LogManager; |
|
19 |
import org.apache.logging.log4j.Logger; |
|
20 | 20 |
import org.springframework.stereotype.Component; |
21 | 21 |
|
22 | 22 |
import eu.etaxonomy.cdm.common.CdmUtils; |
23 |
import eu.etaxonomy.cdm.common.URI; |
|
23 | 24 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
24 | 25 |
import eu.etaxonomy.cdm.model.description.Feature; |
25 | 26 |
import eu.etaxonomy.cdm.model.description.KeyStatement; |
... | ... | |
44 | 45 |
/** |
45 | 46 |
* @author andreas |
46 | 47 |
* @since Sep 18, 2012 |
47 |
* |
|
48 | 48 |
*/ |
49 | 49 |
@Component |
50 | 50 |
public class IkeyPlusImport extends CdmImportBase<IkeyPlusImportConfigurator, IkeyPlusImportState>{ |
... | ... | |
71 | 71 |
|
72 | 72 |
} |
73 | 73 |
|
74 |
/** |
|
75 |
* @param sddUri |
|
76 |
* @param utils |
|
77 |
* @return |
|
78 |
* @throws Exception |
|
79 |
*/ |
|
80 |
/** |
|
81 |
* @param sddUri |
|
82 |
* @param utils |
|
83 |
* @return |
|
84 |
* @throws Exception |
|
85 |
*/ |
|
86 | 74 |
public PolytomousKey getKey(URI sddUri, Utils utils) throws Exception { |
87 | 75 |
|
88 | 76 |
//TODO move below into configurator |
... | ... | |
96 | 84 |
|
97 | 85 |
SDDSaxParser sDDSaxParser = new SDDSaxParser(sddUri.toString(), utils); |
98 | 86 |
|
99 |
|
|
100 | 87 |
DataSet data = sDDSaxParser.getDataset(); |
101 | 88 |
|
102 | 89 |
IdentificationKeyGenerator IkeyGenerator; |
... | ... | |
126 | 113 |
|
127 | 114 |
persistNewEntities(); |
128 | 115 |
|
129 |
|
|
130 | 116 |
return null; |
131 |
|
|
132 |
|
|
133 | 117 |
} |
134 | 118 |
|
135 | 119 |
private void persistNewEntities() { |
136 | 120 |
|
137 |
|
|
138 | 121 |
// persist features |
139 | 122 |
Collection features = featureMap.values(); |
140 | 123 |
getTermService().saveOrUpdate(features); |
... | ... | |
154 | 137 |
boolean isRootNode = (parentNode == null); |
155 | 138 |
|
156 | 139 |
|
157 |
Set<PolytomousKeyNode> pkNodeSet = new HashSet<PolytomousKeyNode>();
|
|
140 |
Set<PolytomousKeyNode> pkNodeSet = new HashSet<>(); |
|
158 | 141 |
if(node == null){ |
159 | 142 |
return pkNodeSet; |
160 | 143 |
} |
161 | 144 |
|
162 | 145 |
KeyStatement statement = getKeyStatementFrom(node); |
163 | 146 |
|
164 |
|
|
165 | 147 |
//node.getNodeDescription(); // not needed here, contains warnings etc |
166 | 148 |
|
167 | 149 |
// ---- do the children or taxa |
... | ... | |
206 | 188 |
} |
207 | 189 |
} |
208 | 190 |
|
209 |
|
|
210 | 191 |
return pkNodeSet; |
211 | 192 |
} |
212 | 193 |
|
213 |
/** |
|
214 |
* @param feature |
|
215 |
* @param statement |
|
216 |
* @return |
|
217 |
*/ |
|
218 | 194 |
public PolytomousKeyNode createPkNode(Feature feature, KeyStatement statement) { |
219 | 195 |
PolytomousKeyNode pkNode; |
220 | 196 |
pkNode = PolytomousKeyNode.NewInstance(); |
... | ... | |
224 | 200 |
return pkNode; |
225 | 201 |
} |
226 | 202 |
|
227 |
/** |
|
228 |
* @param node |
|
229 |
* @return |
|
230 |
*/ |
|
231 | 203 |
public KeyStatement getKeyStatementFrom(SingleAccessKeyNode node) { |
232 | 204 |
String label; |
233 | 205 |
if(node.getCharacterState() instanceof QuantitativeMeasure){ |
... | ... | |
244 | 216 |
} |
245 | 217 |
} |
246 | 218 |
|
247 |
/** |
|
248 |
* @param character |
|
249 |
* @return |
|
250 |
*/ |
|
251 | 219 |
private Feature getFeatureFrom(ICharacter character) { |
252 | 220 |
|
253 |
|
|
254 | 221 |
if(!featureMap.containsKey(character.getId())){ |
255 | 222 |
|
256 | 223 |
String featureLabel = character.getName(); |
... | ... | |
274 | 241 |
} |
275 | 242 |
} |
276 | 243 |
|
277 |
|
|
278 | 244 |
@Override |
279 | 245 |
protected boolean doCheck(IkeyPlusImportState state) { |
280 | 246 |
// TODO Auto-generated method stub |
... | ... | |
286 | 252 |
// TODO Auto-generated method stub |
287 | 253 |
return false; |
288 | 254 |
} |
289 |
|
|
290 |
} |
|
255 |
} |
Also available in: Unified diff
cleanup and remove strange IkeyPlusImport properties files in io/src/test/resources/main