Revision bcecdba2
Added by Andreas Müller almost 12 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/dwca/in/GbifDescriptionCsv2CdmConverter.java | ||
---|---|---|
14 | 14 |
import java.util.List; |
15 | 15 |
import java.util.Map; |
16 | 16 |
import java.util.Set; |
17 |
import java.util.UUID; |
|
17 | 18 |
|
18 | 19 |
import org.apache.log4j.Logger; |
19 | 20 |
|
21 |
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException; |
|
20 | 22 |
import eu.etaxonomy.cdm.io.dwca.TermUri; |
21 | 23 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
24 |
import eu.etaxonomy.cdm.model.description.Feature; |
|
22 | 25 |
import eu.etaxonomy.cdm.model.reference.Reference; |
23 | 26 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
24 | 27 |
|
... | ... | |
58 | 61 |
fireWarningEvent(message, item, 12); |
59 | 62 |
} |
60 | 63 |
|
64 |
Feature feature = getFeatureByDcType(item); |
|
65 |
|
|
66 |
|
|
61 | 67 |
String message = "Not yet implemented"; |
62 | 68 |
fireWarningEvent(message, item, 15); |
63 | 69 |
return new ListReader<MappedCdmBase>(resultList); |
64 | 70 |
} |
65 | 71 |
|
66 | 72 |
|
73 |
private Feature getFeatureByDcType(CsvStreamItem item) { |
|
74 |
String type = item.get(TermUri.DC_TYPE); |
|
75 |
|
|
76 |
Feature feature; |
|
77 |
try { |
|
78 |
feature = state.getTransformer().getFeatureByKey(type); |
|
79 |
if (feature != null){ |
|
80 |
return feature; |
|
81 |
} |
|
82 |
String namespace = Feature.class.getSimpleName(); |
|
83 |
List<Feature> features = state.get(namespace, type, Feature.class); |
|
84 |
if (features.size() > 1){ |
|
85 |
String message = "There is more than 1 cdm entity matching given locationId '%s'. I take an arbitrary one."; |
|
86 |
fireWarningEvent(String.format(message, item), item, 4); |
|
87 |
return features.iterator().next(); |
|
88 |
} |
|
89 |
UUID featureUuid = state.getTransformer().getFeatureUuid(type); |
|
90 |
feature = state.getCurrentIO().getFeature(state, featureUuid, type, type, null, null); |
|
91 |
if (feature == null){ |
|
92 |
feature = Feature.NewInstance(type, type, null); |
|
93 |
feature.setSupportsTextData(true); |
|
94 |
state.putMapping(namespace, type, feature); |
|
95 |
} |
|
96 |
return feature; |
|
97 |
} catch (UndefinedTransformerMethodException e) { |
|
98 |
String message = "GetFeature not yet supported by DwcA-Transformer. This should not have happend. Please contact your application developer."; |
|
99 |
fireWarningEvent(message, item, 8); |
|
100 |
return null; |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
104 |
|
|
67 | 105 |
@Override |
68 | 106 |
public String getSourceId(CsvStreamItem item) { |
69 | 107 |
String id = item.get(CORE_ID); |
Also available in: Unified diff
implement getFeature for DwCA import