Revision 4d8fb1a4
Added by Alexander Oppermann about 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlImportMetaData.java | ||
---|---|---|
35 | 35 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
36 | 36 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
37 | 37 |
import eu.etaxonomy.cdm.io.common.MapWrapper; |
38 |
import eu.etaxonomy.cdm.io.common.Source; |
|
38 | 39 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
39 | 40 |
import eu.etaxonomy.cdm.model.common.Language; |
40 | 41 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
41 | 42 |
import eu.etaxonomy.cdm.model.common.TermType; |
42 | 43 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
44 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
43 | 45 |
import eu.etaxonomy.cdm.model.common.VocabularyEnum; |
44 | 46 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
45 | 47 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
... | ... | |
64 | 66 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
65 | 67 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
66 | 68 |
import eu.etaxonomy.cdm.strategy.parser.ParserProblem; |
69 |
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser; |
|
67 | 70 |
/** |
68 | 71 |
* |
69 | 72 |
* @author a.oppermann |
... | ... | |
73 | 76 |
@Component |
74 | 77 |
public class BfnXmlImportMetaData extends BfnXmlImportBase implements ICdmIO<BfnXmlImportState> { |
75 | 78 |
private static final Logger logger = Logger.getLogger(BfnXmlImportMetaData.class); |
79 |
private String sourceFileName; |
|
80 |
private String debVersion; |
|
81 |
private String timeStamp; |
|
76 | 82 |
|
77 | 83 |
public BfnXmlImportMetaData(){ |
78 | 84 |
super(); |
... | ... | |
87 | 93 |
|
88 | 94 |
@Override |
89 | 95 |
public void doInvoke(BfnXmlImportState state){ |
90 |
logger.info("start import MetaData...");
|
|
96 |
logger.warn("start import MetaData...");
|
|
91 | 97 |
|
92 | 98 |
|
93 | 99 |
ResultWrapper<Boolean> success = ResultWrapper.NewInstance(true); |
... | ... | |
95 | 101 |
BfnXmlImportConfigurator config = state.getConfig(); |
96 | 102 |
Element elDataSet = getDataSetElement(config); |
97 | 103 |
Namespace bfnNamespace = config.getBfnXmlNamespace(); |
104 |
//create complete source object |
|
105 |
if(elDataSet.getName().equalsIgnoreCase("DEBExport")){ |
|
106 |
sourceFileName = elDataSet.getAttributeValue("source"); |
|
107 |
debVersion = elDataSet.getAttributeValue("debversion"); |
|
108 |
timeStamp = elDataSet.getAttributeValue("timestamp"); |
|
109 |
|
|
110 |
Reference sourceReference = ReferenceFactory.newGeneric(); |
|
111 |
sourceReference.setTitle(sourceFileName); |
|
112 |
TimePeriod parsedTimePeriod = TimePeriodParser.parseString(timeStamp); |
|
113 |
sourceReference.setDatePublished(parsedTimePeriod); |
|
114 |
state.setCompleteSourceRef(sourceReference); |
|
115 |
} |
|
98 | 116 |
|
99 | 117 |
List contentXML = elDataSet.getContent(); |
100 | 118 |
Element currentElement = null; |
101 | 119 |
for(Object object:contentXML){ |
102 | 120 |
|
121 |
|
|
103 | 122 |
if(object instanceof Element){ |
104 | 123 |
currentElement = (Element)object; |
105 | 124 |
|
... | ... | |
114 | 133 |
if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_A")){ |
115 | 134 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
116 | 135 |
String kurzlitA = children.get(0).getTextNormalize(); |
117 |
Reference sourceReference = ReferenceFactory.newDatabase();
|
|
136 |
Reference sourceReference = ReferenceFactory.newGeneric();
|
|
118 | 137 |
sourceReference.setTitle(kurzlitA); |
119 | 138 |
state.setFirstListSecRef(sourceReference); |
120 | 139 |
|
121 | 140 |
} |
141 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_A")){ |
|
142 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
143 |
String klassifikation_A = children.get(0).getTextNormalize(); |
|
144 |
state.setFirstClassificationName(klassifikation_A); |
|
145 |
|
|
146 |
} |
|
122 | 147 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("KurzLit_B")){ |
123 | 148 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
124 | 149 |
String kurzlitB = children.get(0).getTextNormalize(); |
125 |
Reference sourceReference = ReferenceFactory.newDatabase();
|
|
150 |
Reference sourceReference = ReferenceFactory.newGeneric();
|
|
126 | 151 |
sourceReference.setTitle(kurzlitB); |
127 | 152 |
state.setSecondListSecRef(sourceReference); |
128 | 153 |
} |
154 |
else if( elMetaData.getAttributeValue("standardname").equalsIgnoreCase("Klassifikation_B")){ |
|
155 |
List<Element> children = (List<Element>)elMetaData.getChildren(); |
|
156 |
String klassifikation_B = children.get(0).getTextNormalize(); |
|
157 |
state.setSecondClassificationName(klassifikation_B); |
|
158 |
|
|
159 |
} |
|
160 |
|
|
129 | 161 |
} |
130 | 162 |
|
163 |
logger.warn("end import MetaData ..."); |
|
131 | 164 |
commitTransaction(tx); |
132 | 165 |
|
133 |
logger.info("end import MetaData ..."); |
|
134 | 166 |
|
135 | 167 |
|
136 | 168 |
|
Also available in: Unified diff
Adapted Redlist Import to new XML Schema...