Revision 441eb4b5
Added by Andreas Müller over 6 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/stream/StreamImportBase.java | ||
---|---|---|
27 | 27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
28 | 28 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
29 | 29 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
30 |
import eu.etaxonomy.cdm.model.common.Language; |
|
30 | 31 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
31 | 32 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
32 | 33 |
import eu.etaxonomy.cdm.model.description.Feature; |
34 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
33 | 35 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
34 | 36 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
35 | 37 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
... | ... | |
38 | 40 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
39 | 41 |
|
40 | 42 |
/** |
41 |
* |
|
42 | 43 |
* @author a.mueller |
43 | 44 |
* |
45 |
* @param <CONFIG> |
|
46 |
* @param <STATE> |
|
44 | 47 |
*/ |
45 | 48 |
public abstract class StreamImportBase<CONFIG extends StreamImportConfiguratorBase, STATE extends StreamImportStateBase<CONFIG,StreamImportBase>> |
46 | 49 |
extends CdmImportBase<CONFIG, STATE>{ |
... | ... | |
92 | 95 |
handleResults(state, partStream, location); |
93 | 96 |
commitTransaction(tx); |
94 | 97 |
} catch (Exception e) { |
98 |
e.printStackTrace(); |
|
95 | 99 |
String message = "An exception occurred while handling partition: " + e; |
96 | 100 |
String codeLocation; |
97 | 101 |
if (e.getStackTrace().length > 0){ |
... | ... | |
164 | 168 |
IdentifiableEntity<?> entity = CdmBase.deproxy(cdmBase, IdentifiableEntity.class); |
165 | 169 |
|
166 | 170 |
String namespace = mappedCdmBase.getNamespace(); |
167 |
state.putMapping(namespace,mappedCdmBase.getSourceId(), entity); |
|
171 |
state.putMapping(namespace, mappedCdmBase.getSourceId(), entity);
|
|
168 | 172 |
} |
169 | 173 |
} |
170 | 174 |
} |
... | ... | |
280 | 284 |
} |
281 | 285 |
|
282 | 286 |
|
283 |
//Make public to allow to use by converters |
|
284 |
@Override |
|
285 |
public Feature getFeature(STATE state, UUID uuid, String label, String description, String labelAbbrev, TermVocabulary<Feature> voc) { |
|
286 |
return super.getFeature(state, uuid, label, description, labelAbbrev, voc); |
|
287 |
} |
|
288 |
|
|
289 | 287 |
/** |
290 | 288 |
* Saves a new term. Immediate saving is required to avoid by Transient-Object-Exceptions. |
291 | 289 |
* @param newTerm |
... | ... | |
295 | 293 |
} |
296 | 294 |
|
297 | 295 |
|
296 |
//Make public to allow to use by converters |
|
297 |
@Override |
|
298 |
public Feature getFeature(STATE state, UUID uuid, String label, String description, String labelAbbrev, TermVocabulary<Feature> voc) { |
|
299 |
return super.getFeature(state, uuid, label, description, labelAbbrev, voc); |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* {@inheritDoc} |
|
304 |
* |
|
305 |
* If uuid is null a random one is created. |
|
306 |
*/ |
|
307 |
@Override |
|
308 |
public Language getLanguage(STATE state, |
|
309 |
UUID uuid, String label, String text, String labelAbbrev, TermVocabulary voc) { |
|
310 |
if (uuid == null){ |
|
311 |
uuid = UUID.randomUUID(); |
|
312 |
} |
|
313 |
return super.getLanguage(state, uuid, label, text, labelAbbrev, voc); |
|
314 |
} |
|
315 |
|
|
316 |
public NamedArea getNamedArea(STATE state, UUID namedAreaUuid, |
|
317 |
String label, String description, String abbrevLabel, TermVocabulary voc) { |
|
318 |
return super.getNamedArea(state, namedAreaUuid, label, description, abbrevLabel, |
|
319 |
null, null, voc, null); |
|
320 |
} |
|
321 |
|
|
322 |
|
|
298 | 323 |
|
299 | 324 |
} |
Also available in: Unified diff
ref #6887 handle languages in DwCA CoL import