Project

General

Profile

« Previous | Next » 

Revision 3262d093

Added by Patrick Plitzner almost 8 years ago

Refactored term import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/in/BfnXmlImportFeature.java
84 84

  
85 85
		List contentXML = elDataSet.getContent();
86 86
		Element currentElement = null;
87

  
87 88
		for(Object object:contentXML){
88 89

  
89 90
			if(object instanceof Element){
......
106 107
						if(elFeature.getAttributeValue(BfnXmlConstants.ATT_STANDARDNAME, bfnNamespace).equalsIgnoreCase("RL Kat.")){
107 108
							makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
108 109
						}
109
						String featureLabel = "Kat. +/-";
110
						if(elFeature.getAttributeValue(BfnXmlConstants.ATT_STANDARDNAME).equalsIgnoreCase(featureLabel)){
110
						if(elFeature.getAttributeValue(BfnXmlConstants.ATT_STANDARDNAME).equalsIgnoreCase("Kat. +/-")){
111 111
							makeFeature(vocabularyService, featureList,success, obligatory, bfnNamespace,elFeature, state);
112 112
						}else
113 113
						if(elFeature.getAttributeValue(BfnXmlConstants.ATT_STANDARDNAME).equalsIgnoreCase("aktuelle Bestandsstituation")){
......
209 209
			String childElementName = BfnXmlConstants.EL_LWERT;
210 210
			createOrUpdateStates(bfnNamespace, elListValues, childElementName, redListCat, state);
211 211
		}
212
		createOrUpdateTermVocabulary(TermType.Feature, vocabularyService, redListCat, "RedList Feature");
212
		createOrUpdateTermVocabulary(TermType.Feature, vocabularyService, redListCat, BfnXmlConstants.VOC_REDLIST_FEATURES);
213 213
	}
214 214

  
215 215
	/**
216 216
	 * @param vocabularyService
217 217
	 * @param term
218 218
	 */
219
	@SuppressWarnings({ "unchecked", "rawtypes" })
219
	@SuppressWarnings({ "rawtypes" })
220 220
	private TermVocabulary createOrUpdateTermVocabulary(TermType termType, IVocabularyService vocabularyService, DefinedTermBase term, String strTermVocabulary) {
221
		TermVocabulary termVocabulary = null;
222
		List<TermVocabulary> vocList = vocabularyService.list(TermVocabulary.class, null, null, null, VOC_CLASSIFICATION_INIT_STRATEGY);
223
		for(TermVocabulary tv : vocList){
224
			if(tv.getTitleCache().equalsIgnoreCase(strTermVocabulary)){
225
				termVocabulary = tv;
226
			}
227
		}
228
		if(termVocabulary == null){
229
			termVocabulary = TermVocabulary.NewInstance(termType, strTermVocabulary, strTermVocabulary, strTermVocabulary, null);
230
		}
221

  
222
        //create/get red list feature vocabulary
223
        TermVocabulary<DefinedTermBase> termVocabulary = getVocabulary(termType, BfnXmlConstants.vocRLFeatures, BfnXmlConstants.VOC_REDLIST_FEATURES, BfnXmlConstants.VOC_REDLIST_FEATURES, BfnXmlConstants.VOC_REDLIST_FEATURES, null, false, null);
231 224
		termVocabulary.addTerm(term);
232 225
		vocabularyService.saveOrUpdate(termVocabulary);
233 226

  
......
260 253
			UUID stateTermUuid = null;
261 254
			UUID vocabularyStateUuid = null;
262 255
			try {
263
				vocabularyStateUuid = BfnXmlTransformer.getRedlistVocabularyUUID(redListCat.toString());
256
				vocabularyStateUuid = BfnXmlTransformer.getRedlistVocabularyUUID(redListCat.getLabel());
264 257
			} catch (UnknownCdmTypeException e1) {
265 258
				vocabularyStateUuid = UUID.randomUUID();
266 259
				logger.warn("Element: " + listValue + "\n"+ e1);

Also available in: Unified diff