Project

General

Profile

« Previous | Next » 

Revision 5ea7ddcb

Added by Andreas Müller over 12 years ago

updates for markup import

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupDocumentImport.java
38 38
import org.springframework.security.authentication.AuthenticationManager;
39 39
import org.springframework.security.core.Authentication;
40 40
import org.springframework.stereotype.Component;
41
import org.springframework.transaction.TransactionStatus;
41 42

  
42 43
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
43 44
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade.DerivedUnitType;
......
85 86
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
86 87
import eu.etaxonomy.cdm.model.occurrence.Collection;
87 88
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
89
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
88 90
import eu.etaxonomy.cdm.model.occurrence.Specimen;
89 91
import eu.etaxonomy.cdm.model.reference.IArticle;
90 92
import eu.etaxonomy.cdm.model.reference.IJournal;
......
106 108
 * 
107 109
 */
108 110
@Component
109
public class MarkupDocumentImport extends MarkupImportBase implements
110
		ICdmIO<MarkupImportState> {
111
	private static final String TO_COUPLET = "toCouplet";
112

  
113
	private static final String TO_TAXON = "toTaxon";
114

  
115
	private static final String TO_KEY = "toKey";
116

  
117
	private static final String TEXT = "text";
118

  
119
	private static final String QUESTION = "question";
120

  
121
	private static final String COUPLET = "couplet";
122

  
123
	private static final String KEYNOTES = "keynotes";
124

  
125
	private static final String KEY_TITLE = "keyTitle";
126

  
127
	private static final String IS_SPOTCHARACTERS = "isSpotcharacters";
111
public class MarkupDocumentImport extends MarkupImportBase implements ICdmIO<MarkupImportState> {
112
	private static final String FREQUENCY = "frequency";
128 113

  
129
	private static final String REF_NUM = "refNum";
114
	private static final String TAXONTYPE = "taxontype";
130 115

  
131
	private static final String SERIALS_ABBREVIATIONS = "serialsAbbreviations";
116
	private static final String DEDICATION = "dedication";
132 117

  
133
	private static final String BIBLIOGRAPHY = "bibliography";
118
	private static final String QUOTE = "quote";
134 119

  
135
	private static final String HABITAT = "habitat";
136

  
137
	private static final String LIFE_CYCLE_PERIODS = "lifeCyclePeriods";
138

  
139
	private static final String DISTRIBUTION_LOCALITY = "distributionLocality";
140

  
141
	private static final String REFERENCE = "reference";
142

  
143
	private static final Logger logger = Logger
144
			.getLogger(MarkupDocumentImport.class);
120
	private static final Logger logger = Logger.getLogger(MarkupDocumentImport.class);
145 121

  
146 122
	private static final boolean CREATE_NEW = true;
147 123
	private static final boolean IS_IMAGE_GALLERY = true;
......
157 133
	private static final String ALTITUDE = "altitude";
158 134
	private static final String ANNOTATION = "annotation";
159 135
	private static final String AUTHOR = "author";
136
	private static final String BIBLIOGRAPHY = "bibliography";
160 137
	private static final String BIOGRAPHIES = "biographies";
161 138
	private static final String BOLD = "bold";
162 139
	private static final String BR = "br";
163 140
	private static final String CHAR = "char";
164 141
	private static final String CITATION = "citation";
165
	private static final String COLLECTION = "collection";
166 142
	private static final String COLLECTION_TYPE_STATUS = "collectionTypeStatus";
167 143
	private static final String COLLECTOR = "collector";
168 144
	private static final String COORDINATES = "coordinates";
145
	private static final String COUPLET = "couplet";
169 146
	private static final String DATES = "dates";
170 147
	private static final String DEFAULT_MEDIA_URL = "defaultMediaUrl";
171 148
	private static final String DESTROYED = "destroyed";
172 149
	private static final String DETAILS = "details";
173 150
	private static final String DISTRIBUTION_LIST = "distributionList";
151
	private static final String DISTRIBUTION_LOCALITY = "distributionLocality";
174 152
	private static final String EDITION = "edition";
175 153
	private static final String EDITORS = "editors";
176 154
	private static final String FEATURE = "feature";
......
185 163
	private static final String FIELD_NUM = "fieldNum";
186 164
	private static final String FULL_NAME = "fullName";
187 165
	private static final String FULL_TYPE = "fullType";
166
	private static final String GATHERING = "gathering";
188 167
	private static final String HEADING = "heading";
168
	private static final String HABITAT = "habitat";
189 169
	private static final String HABITAT_LIST = "habitatList";
190 170
	private static final String HOMONYM = "homonym";
191 171
	private static final String HOMOTYPES = "homotypes";
......
193 173
	private static final String INFRANK = "infrank";
194 174
	private static final String INFRAUT = "infraut";
195 175
	private static final String INFRPARAUT = "infrparaut";
176
	private static final String IS_SPOTCHARACTERS = "isSpotcharacters";
196 177
	private static final String ISSUE = "issue";
197 178
	private static final String ITALICS = "italics";
198 179
	private static final String KEY = "key";
180
	private static final String KEY_TITLE = "keyTitle";
181
	private static final String KEYNOTES = "keynotes";
182
	private static final String LIFE_CYCLE_PERIODS = "lifeCyclePeriods";
199 183
	private static final String LOCALITY = "locality";
200 184
	private static final String LOST = "lost";
201 185
	private static final String META_DATA = "metaData";
......
214 198
	private static final String PUBNAME = "pubname";
215 199
	private static final String PUBTITLE = "pubtitle";
216 200
	private static final String PUBTYPE = "pubtype";
201
	private static final String QUESTION = "question";
217 202
	private static final String RANK = "rank";
218 203
	private static final String REF = "ref";
204
	private static final String REF_NUM = "refNum";
219 205
	private static final String REF_PART = "refPart";
206
	private static final String REFERENCE = "reference";
220 207
	private static final String REFERENCES = "references";
221 208
	private static final String TAXON = "taxon";
222 209
	private static final String TAXONTITLE = "taxontitle";
210
	private static final String TEXT = "text";
223 211
	private static final String TEXT_SECTION = "textSection";
212
	private static final String TO_COUPLET = "toCouplet";
213
	private static final String TO_KEY = "toKey";
214
	private static final String TO_TAXON = "toTaxon";
224 215
	private static final String TYPE = "type";
225 216
	private static final String TYPE_STATUS = "typeStatus";
226 217
	private static final String TREATMENT = "treatment";
218
	private static final String SERIALS_ABBREVIATIONS = "serialsAbbreviations";
227 219
	private static final String SPECIMEN_TYPE = "specimenType";
228 220
	private static final String STATUS = "status";
229 221
	private static final String STRING = "string";
......
269 261
	}
270 262

  
271 263
	@Override
272
	public void doInvoke(MarkupImportState state) {
273
		fireProgressEvent("Start import markup document",
274
				"Before start of document");
275
		fireWarningEvent("Test a warning", "At start", 17);
276

  
264
	public void doInvoke(MarkupImportState state) { 
265
		fireProgressEvent("Start import markup document", "Before start of document");
266
		
277 267
		Queue<CdmBase> outputStream = new LinkedList<CdmBase>();
278 268

  
269
		TransactionStatus tx = startTransaction();
279 270
		// FIXME reset state
280 271
		doAllTheOldOtherStuff(state);
281 272

  
......
293 284
			// publication
294 285
			String elName = PUBLICATION;
295 286
			boolean hasPublication = false;
287
			
296 288
			while (reader.hasNext()) {
297 289
				XMLEvent nextEvent = reader.nextEvent();
298 290
				if (isStartingElement(nextEvent, elName)) {
......
308 300
					fireSchemaConflictEventExpectedStartTag(elName, reader);
309 301
				}
310 302
			}
303
			commitTransaction(tx);
311 304

  
312 305
			// //SAX
313 306
			// ImportHandlerBase handler= new PublicationHandler(this);
314 307
			// parseSAX(state, handler);
315 308

  
316 309
		} catch (FactoryConfigurationError e1) {
317
			fireWarningEvent(
318
					"Some error occurred while setting up xml factory. Data can't be imported",
319
					"Start", 16);
310
			fireWarningEvent("Some error occurred while setting up xml factory. Data can't be imported", "Start", 16);
320 311
			state.setUnsuccessfull();
321 312
		} catch (XMLStreamException e1) {
322
			fireWarningEvent(
323
					"An XMLStreamException occurred while parsing. Data can't be imported",
324
					"Start", 16);
313
			fireWarningEvent("An XMLStreamException occurred while parsing. Data can't be imported", "Start", 16);
325 314
			state.setUnsuccessfull();
326 315
			// } catch (ParserConfigurationException e) {
327 316
			// fireWarningEvent("A ParserConfigurationException occurred while parsing. Data can't be imported",
......
441 430
					keySet.add(key);
442 431
				}
443 432
				save(keySet, state);
433
				//unmatched key leads
434
				UnmatchedLeads unmatched = state.getUnmatchedLeads();
435
				if (unmatched.size() > 0){
436
					String message = "The following key leads are unmatched: %s";
437
					message = String.format(message, state.getUnmatchedLeads().toString());
438
					fireWarningEvent(message, next, 6);
439
				}
444 440
//				save(keyNodesToSave, state);
445 441

  
446 442
				return;
......
458 454
	private void doTaxonRelation(MarkupImportState state, Taxon taxon,
459 455
			Taxon lastTaxon, Location dataLocation) {
460 456

  
461
		Classification tree = makeTree(state);
457
		Classification tree = makeTree(state, dataLocation);
462 458
		if (lastTaxon == null) {
463 459
			tree.addChildTaxon(taxon, null, null, null);
464 460
			return;
......
494 490

  
495 491
	/**
496 492
	 * @param state
493
	 * @param dataLocation 
497 494
	 * @return
498 495
	 */
499
	private Classification makeTree(MarkupImportState state) {
496
	private Classification makeTree(MarkupImportState state, Location dataLocation) {
500 497
		Classification result = state.getTree(null);
501 498
		if (result == null) {
502 499
			UUID uuid = state.getConfig().getClassificationUuid();
503 500
			if (uuid == null) {
504
				logger.warn("No classification uuid is defined");
501
				String message = "No classification uuid is defined";
502
				fireWarningEvent(message, makeLocationStr(dataLocation), 6);
505 503
				result = createNewClassification(state);
506 504
			} else {
507 505
				result = getClassificationService().find(uuid);
......
523 521
		return result;
524 522
	}
525 523

  
526
	private Taxon handleTaxon(MarkupImportState state, XMLEventReader reader,
527
			StartElement parentEvent) throws XMLStreamException {
524
	private Taxon handleTaxon(MarkupImportState state, XMLEventReader reader, StartElement parentEvent) throws XMLStreamException {
528 525
		// TODO progress monitoring
529 526
		Map<String, Attribute> attributes = getAttributes(parentEvent);
530 527
		Taxon taxon = createTaxonAndName(state, attributes);
......
542 539
					checkMandatoryElement(hasNomenclature, parentEvent,	NOMENCLATURE);
543 540
					handleUnexpectedAttributes(parentEvent.getLocation(),attributes);
544 541
					
545
					makeKeyNodes(state, parentEvent);
542
					makeKeyNodes(state, parentEvent, taxonTitle);
546 543
					state.setCurrentTaxon(null);
547 544
					state.setCurrentTaxonNum(null);
548 545
					save(taxon, state);
......
620 617
		throw new IllegalStateException("<Taxon> has no closing tag");
621 618
	}
622 619

  
623
	private void makeKeyNodes(MarkupImportState state, XMLEvent event) {
620
	private void makeKeyNodes(MarkupImportState state, XMLEvent event, String taxonTitle) {
624 621
		Taxon taxon = state.getCurrentTaxon();
625 622
		String num = state.getCurrentTaxonNum();
626 623
		
627 624
		String nameString = CdmBase.deproxy(taxon.getName(), NonViralName.class).getNameCache();
625
//		String nameString = taxonTitle;
628 626
		
629 627
		//try to find matching lead nodes 
630 628
		UnmatchedLeadsKey leadsKey = UnmatchedLeadsKey.NewInstance(num, nameString);
631 629
		Set<PolytomousKeyNode> matchingNodes = handleMatchingNodes(state, taxon, leadsKey);
632
		//same without using the num
633
		if (num != null){
630
		
631
		if (num != null){//same without using the num
634 632
			UnmatchedLeadsKey noNumLeadsKey = UnmatchedLeadsKey.NewInstance("", nameString);
635
			//TODO inform about differences
636
			handleMatchingNodes(state, taxon, noNumLeadsKey);
633
			Set<PolytomousKeyNode> noNumMatchingNodes = handleMatchingNodes(state, taxon, noNumLeadsKey);
634
			if(noNumMatchingNodes.size() > 0){
635
				String message ="Taxon matches additional key node when not considering <num> attribute in taxontitle. This may be correct but may also indicate an error.";
636
				fireWarningEvent(message, event, 1);
637
			}
637 638
		}
639
		//report missing match, if num exists
638 640
		if (matchingNodes.isEmpty() && num != null){
639
			String message = "Taxon has num in taxontitle but no matching nodes exist: %s, Key: %s";
641
			String message = "Taxon has <num> attribute in taxontitle but no matching key nodes exist: %s, Key: %s";
640 642
			message = String.format(message, num, leadsKey.toString());
641 643
			fireWarningEvent(message, event, 1);
642 644
		}
......
659 661
		String isSpotcharacters = getAndRemoveAttributeValue(attributes, IS_SPOTCHARACTERS);
660 662
		if (isNotBlank(isSpotcharacters) ) {
661 663
			//TODO isSpotcharacters
662
			String message = "isSpotcharacters not yet implemented for <key>";
664
			String message = "Attribute isSpotcharacters not yet implemented for <key>";
663 665
			fireWarningEvent(message, parentEvent, 4);
664 666
		}
665 667
		
......
676 678
				return;
677 679
			} else if (isEndingElement(next, KEYNOTES)){
678 680
				popUnimplemented(next.asEndElement());
679
			} else if (next.isStartElement()) {
680
				if (isStartingElement(next, KEY_TITLE)) {
681
			} else if (isStartingElement(next, KEY_TITLE)) {
681 682
					handleKeyTitle(state, reader, next);
682
				} else if (isStartingElement(next, KEYNOTES)) {
683
					//TODO
684
					handleNotYetImplementedElement(next);
685
				} else if (isStartingElement(next, COUPLET)) {
686
					PolytomousKeyNode node = null;
687
					if (isFirstCouplet){
688
						node = key.getRoot();
689
						isFirstCouplet = false;
690
					}
691
					handleCouplet(state, reader, next, node);
692
				} else {
693
					handleUnexpectedStartElement(next.asStartElement());
683
			} else if (isStartingElement(next, KEYNOTES)) {
684
				//TODO
685
				handleNotYetImplementedElement(next);
686
			} else if (isStartingElement(next, COUPLET)) {
687
				PolytomousKeyNode node = null;
688
				if (isFirstCouplet){
689
					node = key.getRoot();
690
					isFirstCouplet = false;
694 691
				}
692
				handleCouplet(state, reader, next, node);
695 693
			} else {
696 694
				handleUnexpectedElement(next);
697 695
			}
698 696
		}
699 697
		throw new IllegalStateException("<key> has no closing tag");
700
		
701

  
702 698
	}
703 699

  
704 700
	/**
......
729 725
			if (isMyEndingElement(next, parentEvent)) {
730 726
				completeCouplet(state, parentEvent, parentNode, num, childList);
731 727
				return;
732
			} else if (isEndingElement(next, KEYNOTES)){
733
				popUnimplemented(next.asEndElement());
734 728
			} else if (isStartingElement(next, QUESTION)) {
735 729
				handleQuestion(state, reader, next, childList);
736 730
			} else if (isStartingElement(next, KEYNOTES)) {
737 731
				//TODO
738 732
				handleNotYetImplementedElement(next);
733
			} else if (isEndingElement(next, KEYNOTES)) {
734
				//TODO
735
				popUnimplemented(next.asEndElement());
739 736
			} else {
740 737
				handleUnexpectedElement(next);
741 738
			}
......
787 784
			XMLEvent next = readNoWhitespace(reader);
788 785
			if (isMyEndingElement(next, parentEvent)) {
789 786
				return;
790
			} else if (isEndingElement(next, TO_KEY)){
791
				//TODO
792
				popUnimplemented(next.asEndElement());
793
			} else if (isEndingElement(next, KEYNOTES)){
794
				//TODO
795
				popUnimplemented(next.asEndElement());
796
			
797 787
			} else if (isStartingElement(next, TEXT)) {
798 788
				String text = getCData(state, reader, next);
799 789
				KeyStatement statement = KeyStatement.NewInstance(text);
......
805 795
				handleToCouplet(state, reader, next, myNode);
806 796
			} else if (isStartingElement(next, TO_TAXON)) {
807 797
				handleToTaxon(state, reader, next, myNode);
798
			
808 799
			} else if (isStartingElement(next, TO_KEY)) {
809 800
				//TODO
810 801
				handleNotYetImplementedElement(next);
802
			} else if (isEndingElement(next, TO_KEY)){
803
				//TODO
804
				popUnimplemented(next.asEndElement());
811 805
			} else if (isStartingElement(next, KEYNOTES)) {
812 806
				//TODO
813 807
				handleNotYetImplementedElement(next);
808
			} else if (isEndingElement(next, KEYNOTES)){
809
				//TODO
810
				popUnimplemented(next.asEndElement());
814 811
			} else {
815 812
				handleUnexpectedElement(next);
816 813
			}
......
821 818
	private void handleToCouplet(MarkupImportState state, XMLEventReader reader, XMLEvent next, PolytomousKeyNode node) throws XMLStreamException {
822 819
		String num = getOnlyAttribute(next, NUM, true);
823 820
		String cData = getCData(state, reader, next, false);
824
		if (isNotBlank(cData)){
825
			String message = "CData ('%s') not handled";
821
		if (isNotBlank(cData) && ! cData.equals(num)){
822
			String message = "CData ('%s') not handled in <toCouplet>";
826 823
			message = String.format(message, cData);
827 824
			fireWarningEvent(message, next, 4);
828 825
		}
......
846 843
		if (strGoto == null){
847 844
			return "";
848 845
		}
849
		String strGenusName = CdmBase.deproxy(taxon.getName(), NonViralName.class).getGenusOrUninomial();
846
		
847
		NonViralName<?> name = CdmBase.deproxy(taxon.getName(), NonViralName.class);
848
		String strGenusName = name.getGenusOrUninomial();
849
		
850
		
850 851
		strGoto = strGoto.replaceAll("\\([^\\(\\)]*\\)", "");  //replace all brackets
851 852
		strGoto = strGoto.replaceAll("\\s+", " "); //replace multiple whitespaces by exactly one whitespace
852 853
		
......
857 858
			if (isGenusAbbrev(single, strGenusName)){
858 859
				split[i] = strGenusName;
859 860
			}
860
//			if (isInfraSpecificMarker(single)){
861
//				String strSpeciesName = CdmBase.deproxy(taxon.getName(), NonViralName.class).getSpecificEpithet();
862
//				split[i] = strGenusName + " " + strSpeciesName + " ";
863
//			}
861
			if (isInfraSpecificMarker(single)){
862
				String strSpeciesEpi = name.getSpecificEpithet();
863
				if (isBlank(result)){
864
					result += strGenusName + " " + strSpeciesEpi;
865
				}
866
			}
864 867
			result = (result + " " + split[i]).trim();
865 868
		}
866 869
		return result;
867 870
	}
868 871
	
872

  
873
	private boolean isInfraSpecificMarker(String single) {
874
		try {
875
			if (Rank.getRankByAbbreviation(single).isInfraSpecific()){
876
				return true;
877
			}else{
878
				return false;
879
			}
880
		} catch (UnknownCdmTypeException e) {
881
			return false;
882
		}
883
	}
884
	
869 885
	private boolean isGenusAbbrev(String single, String strGenusName) {
870 886
		if (! single.matches("[A-Z]\\.?")) {
871 887
			return false;
......
957 973
	 * @throws XMLStreamException
958 974
	 */
959 975
	private String makeNotesString(MarkupImportState state,	XMLEventReader reader, String text, XMLEvent next) throws XMLStreamException {
960
		Map<String, String> stringMap = handleString(state, reader,	next);
976
		Map<String, String> stringMap = handleString(state, reader,	next, null);
961 977
		if (stringMap.size() == 0){
962 978
			String message = "No text available in <notes>";
963 979
			fireWarningEvent(message, next, 4);
......
1110 1126
		// TODO handle attributes
1111 1127
		while (reader.hasNext()) {
1112 1128
			XMLEvent next = readNoWhitespace(reader);
1113
			if (next.isEndElement()) {
1114
				if (isMyEndingElement(next, parentEvent)) {
1115
					text = CdmUtils.removeBrackets(text);
1116
					if (checkMandatoryText(text, parentEvent)) {
1117
						text = normalize(text);
1118
						dataHolder.writer = text;
1119
						dataHolder.footnotes = footnotes;
1120

  
1121
						// Extension
1122
						UUID uuidWriterExtension = MarkupTransformer.uuidWriterExtension;
1123
						ExtensionType writerExtensionType = this
1124
								.getExtensionType(state, uuidWriterExtension,
1125
										"Writer", "writer", "writer");
1126
						Extension extension = Extension.NewInstance();
1127
						extension.setType(writerExtensionType);
1128
						extension.setValue(text);
1129
						dataHolder.extension = extension;
1130

  
1131
						// Annotation
1132
						UUID uuidWriterAnnotation = MarkupTransformer.uuidWriterAnnotation;
1133
						AnnotationType writerAnnotationType = this
1134
								.getAnnotationType(state, uuidWriterAnnotation,
1135
										"Writer", "writer", "writer", null);
1136
						Annotation annotation = Annotation.NewInstance(text,
1137
								writerAnnotationType, Language.DEFAULT());
1138
						dataHolder.annotation = annotation;
1139

  
1140
						return dataHolder;
1141
					} else {
1142
						return null;
1143
					}
1129
			if (isMyEndingElement(next, parentEvent)) {
1130
				text = CdmUtils.removeBrackets(text);
1131
				if (checkMandatoryText(text, parentEvent)) {
1132
					text = normalize(text);
1133
					dataHolder.writer = text;
1134
					dataHolder.footnotes = footnotes;
1135

  
1136
					// Extension
1137
					UUID uuidWriterExtension = MarkupTransformer.uuidWriterExtension;
1138
					ExtensionType writerExtensionType = this
1139
							.getExtensionType(state, uuidWriterExtension,
1140
									"Writer", "writer", "writer");
1141
					Extension extension = Extension.NewInstance();
1142
					extension.setType(writerExtensionType);
1143
					extension.setValue(text);
1144
					dataHolder.extension = extension;
1145

  
1146
					// Annotation
1147
					UUID uuidWriterAnnotation = MarkupTransformer.uuidWriterAnnotation;
1148
					AnnotationType writerAnnotationType = this.getAnnotationType(state, uuidWriterAnnotation, "Writer", "writer", "writer", null);
1149
					Annotation annotation = Annotation.NewInstance(text, writerAnnotationType, Language.DEFAULT());
1150
					dataHolder.annotation = annotation;
1151

  
1152
					return dataHolder;
1144 1153
				} else {
1145
					if (isEndingElement(next, FOOTNOTE)) {
1146
						// NOT YET IMPLEMENTED
1147
						popUnimplemented(next.asEndElement());
1148
					} else {
1149
						handleUnexpectedEndElement(next.asEndElement());
1150
						state.setUnsuccessfull();
1151
					}
1154
					return null;
1152 1155
				}
1153
			} else if (next.isStartElement()) {
1154
				if (isStartingElement(next, FOOTNOTE_REF)) {
1155
					FootnoteDataHolder footNote = handleFootnoteRef(state,
1156
							reader, next);
1157
					if (footNote.isRef()) {
1158
						footnotes.add(footNote);
1159
					} else {
1160
						logger.warn("Non ref footnotes not yet impelemnted");
1161
					}
1156
			} else if (isStartingElement(next, FOOTNOTE_REF)) {
1157
				FootnoteDataHolder footNote = handleFootnoteRef(state, reader, next);
1158
				if (footNote.isRef()) {
1159
					footnotes.add(footNote);
1162 1160
				} else {
1163
					handleUnexpectedStartElement(next);
1164
					state.setUnsuccessfull();
1161
					logger.warn("Non ref footnotes not yet impelemnted");
1165 1162
				}
1166 1163
			} else if (next.isCharacters()) {
1167 1164
				text += next.asCharacters().getData();
......
1171 1168
				state.setUnsuccessfull();
1172 1169
			}
1173 1170
		}
1174
		return null;
1171
		throw new IllegalStateException("<writer> has no end tag");
1175 1172
	}
1176 1173

  
1177 1174
	private void registerFootnotes(MarkupImportState state,
......
1402 1399
		throw new IllegalStateException("<figureRef> has no end tag");
1403 1400
	}
1404 1401

  
1405
	private FootnoteDataHolder handleFootnote(MarkupImportState state,
1406
			XMLEventReader reader, XMLEvent parentEvent)
1407
			throws XMLStreamException {
1402
	private FootnoteDataHolder handleFootnote(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
1408 1403
		FootnoteDataHolder result = new FootnoteDataHolder();
1409 1404
		Map<String, Attribute> attributes = getAttributes(parentEvent);
1410 1405
		result.id = getAndRemoveAttributeValue(attributes, ID);
......
1472 1467
		return;
1473 1468
	}
1474 1469

  
1475
	private String handleFootnoteString(MarkupImportState state,
1476
			XMLEventReader reader, XMLEvent parentEvent)
1477
			throws XMLStreamException {
1470
	private String handleFootnoteString(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
1478 1471
		boolean isTextMode = true;
1479 1472
		String text = "";
1480 1473
		while (reader.hasNext()) {
......
1484 1477
			} else if (next.isEndElement()) {
1485 1478
				if (isEndingElement(next, FULL_NAME)) {
1486 1479
					popUnimplemented(next.asEndElement());
1487
				} else if (isEndingElement(next, COLLECTION)) {
1488
					popUnimplemented(next.asEndElement());
1489 1480
				} else if (isEndingElement(next, BR)) {
1490 1481
					isTextMode = true;
1491 1482
				} else if (isHtml(next)) {
......
1496 1487
			} else if (next.isStartElement()) {
1497 1488
				if (isStartingElement(next, FULL_NAME)) {
1498 1489
					handleNotYetImplementedElement(next);
1499
				} else if (isStartingElement(next, COLLECTION)) {
1500
					handleNotYetImplementedElement(next);
1490
				} else if (isStartingElement(next, GATHERING)) {
1491
					text += handleInLineGathering(state, reader, next);
1501 1492
				} else if (isStartingElement(next, REFERENCES)) {
1502 1493
					text += " " + handleInLineReferences(state, reader, next)+ " ";
1503 1494
				} else if (isStartingElement(next, BR)) {
......
1513 1504
					String message = "footnoteString is not in text mode";
1514 1505
					fireWarningEvent(message, next, 6);
1515 1506
				} else {
1516
					text += next.asCharacters().getData().trim(); // getCData(state,
1517
																	// reader,
1518
																	// next);
1519
																	// does not
1520
																	// work as
1521
																	// we have
1522
																	// inner
1523
																	// tags like
1524
																	// <references>
1507
					text += next.asCharacters().getData().trim(); 
1508
					// getCData(state, reader, next); does not work as we have inner tags like <references>
1525 1509
				}
1526 1510
			} else {
1527 1511
				handleUnexpectedEndElement(next.asEndElement());
......
1531 1515

  
1532 1516
	}
1533 1517

  
1518
	private String handleInLineGathering(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
1519
		DerivedUnitFacade facade = DerivedUnitFacade.NewInstance(DerivedUnitType.DerivedUnit.FieldObservation);
1520
		handleGathering(state, reader, parentEvent, null, facade);
1521
		FieldObservation fieldObservation = facade.innerFieldObservation();
1522
		String result = "<cdm:specimen uuid='%s'>%s</specimen>";
1523
		result = String.format(result, fieldObservation.getUuid(), fieldObservation.getTitleCache());
1524
		save(fieldObservation, state);
1525
		return result;	
1526
	}
1527

  
1534 1528
	private String handleInLineReferences(MarkupImportState state,
1535 1529
			XMLEventReader reader, XMLEvent parentEvent)
1536 1530
			throws XMLStreamException {
......
1551 1545
				handleUnexpectedElement(next);
1552 1546
			}
1553 1547
		}
1554
		// TODO handle missing end element
1555 1548
		throw new IllegalStateException("<References> has no closing tag");
1556 1549
	}
1557 1550

  
1558
	private String handleInLineReference(MarkupImportState state,
1559
			XMLEventReader reader, XMLEvent parentEvent)
1560
			throws XMLStreamException {
1551
	private String handleInLineReference(MarkupImportState state,XMLEventReader reader, XMLEvent parentEvent)throws XMLStreamException {
1561 1552
		Reference<?> reference = handleReference(state, reader, parentEvent);
1562
		String result = "<ref uuid='%s'>%s</ref>";
1563
		result = String.format(result, reference.getUuid(),
1564
				reference.getTitleCache());
1553
		String result = "<cdm:ref uuid='%s'>%s</ref>";
1554
		result = String.format(result, reference.getUuid(), reference.getTitleCache());
1555
		save(reference, state);
1565 1556
		return result;
1566 1557
	}
1567 1558

  
1568
	private Reference<?> handleReference(MarkupImportState state,
1569
			XMLEventReader reader, XMLEvent parentEvent)
1570
			throws XMLStreamException {
1559
	private Reference<?> handleReference(MarkupImportState state,XMLEventReader reader, XMLEvent parentEvent)throws XMLStreamException {
1571 1560
		checkNoAttributes(parentEvent);
1572 1561

  
1573 1562
		boolean hasRefPart = false;
......
1780 1769
					// homotypicalGroup);
1781 1770
				} else if (isStartingElement(next, TYPE_STATUS)) {
1782 1771
					handleNotYetImplementedElement(next);
1783
				} else if (isStartingElement(next, COLLECTION)) {
1784
					handleCollection(state, reader, next, homotypicalGroup,
1785
							facade);
1772
				} else if (isStartingElement(next, GATHERING)) {
1773
					handleGathering(state, reader, next, homotypicalGroup, facade);
1786 1774
				} else if (isStartingElement(next, ORIGINAL_DETERMINATION)) {
1787 1775
					handleNotYetImplementedElement(next);
1788 1776
				} else if (isStartingElement(next, SPECIMEN_TYPE)) {
......
1866 1854
	}
1867 1855

  
1868 1856
	
1869
	private void handleCollection(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent, HomotypicalGroup homotypicalGroup, DerivedUnitFacade facade)
1870
			throws XMLStreamException {
1857
	private void handleGathering(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent, HomotypicalGroup homotypicalGroup, DerivedUnitFacade facade) throws XMLStreamException {
1871 1858
		checkNoAttributes(parentEvent);
1872 1859
		boolean hasCollector = false;
1873 1860
		boolean hasFieldNum = false;
......
1948 1935

  
1949 1936
	}
1950 1937

  
1951
	private void handleLocality(MarkupImportState state, XMLEventReader reader,
1952
			XMLEvent parentEvent, DerivedUnitFacade facade)
1953
			throws XMLStreamException {
1938
	private void handleLocality(MarkupImportState state, XMLEventReader reader,XMLEvent parentEvent, DerivedUnitFacade facade)throws XMLStreamException {
1954 1939
		String classValue = getClassOnlyAttribute(parentEvent);
1955 1940
		boolean isLocality = false;
1956 1941
		NamedAreaLevel areaLevel = null;
......
2072 2057
	 * @return
2073 2058
	 * @throws XMLStreamException
2074 2059
	 */
2075
	private NonViralName<?> handleNom(MarkupImportState state,
2076
			XMLEventReader reader, XMLEvent parentEvent,
2060
	private NonViralName<?> handleNom(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent,
2077 2061
			HomotypicalGroup homotypicalGroup) throws XMLStreamException {
2078 2062
		boolean isSynonym = false;
2079 2063
		boolean isNameType = state.isNameType();
......
2172 2156
		makeRankDecision(state, nameMap, name, event, infrank);
2173 2157

  
2174 2158
		// test consistency of rank and authors
2175
		testRankAuthorConsistency(name, event, authorStr, paraut, infrParAut,
2176
				infrAut);
2159
		testRankAuthorConsistency(name, event, authorStr, paraut, infrParAut,infrAut);
2177 2160

  
2178 2161
		// authors
2179
		makeNomenclaturalAuthors(name, event, authorStr, paraut, infrParAut,
2180
				infrAut);
2162
		makeNomenclaturalAuthors(name, event, authorStr, paraut, infrParAut,infrAut);
2181 2163

  
2182 2164
		// status
2183 2165
		// TODO handle pro parte, pro syn. etc.
......
2279 2261
	 * @param infrAut
2280 2262
	 */
2281 2263
	private void makeNomenclaturalAuthors(NonViralName name, XMLEvent event,
2282
			String authorStr, String paraut, String infrParAut, String infrAut) {
2283
		if (name.getRank().isInfraSpecific()) {
2264
				String authorStr, String paraut, String infrParAut, String infrAut) {
2265
		if (name.getRank() != null && name.getRank().isInfraSpecific()) {
2284 2266
			if (StringUtils.isNotBlank(infrAut)) {
2285 2267
				INomenclaturalAuthor[] authorAndEx = authorAndEx(infrAut, event);
2286 2268
				name.setCombinationAuthorTeam(authorAndEx[0]);
2287 2269
				name.setExCombinationAuthorTeam(authorAndEx[1]);
2288 2270
			}
2289 2271
			if (StringUtils.isNotBlank(infrParAut)) {
2290
				INomenclaturalAuthor[] authorAndEx = authorAndEx(infrParAut,
2291
						event);
2272
				INomenclaturalAuthor[] authorAndEx = authorAndEx(infrParAut, event);
2292 2273
				name.setBasionymAuthorTeam(authorAndEx[0]);
2293 2274
				name.setExBasionymAuthorTeam(authorAndEx[1]);
2294 2275
			}
2295 2276
		} else {
2277
			if (name.getRank() == null){
2278
				String message = "No rank defined. Check correct usage of authors!";
2279
				fireWarningEvent(message, event, 4);
2280
				if (isNotBlank(infrParAut) || isNotBlank(infrAut)){
2281
					authorStr = infrAut;
2282
					paraut = infrParAut;
2283
				}
2284
			}
2296 2285
			if (StringUtils.isNotBlank(authorStr)) {
2297
				INomenclaturalAuthor[] authorAndEx = authorAndEx(authorStr,
2298
						event);
2286
				INomenclaturalAuthor[] authorAndEx = authorAndEx(authorStr, event);
2299 2287
				name.setCombinationAuthorTeam(authorAndEx[0]);
2300 2288
				name.setExCombinationAuthorTeam(authorAndEx[1]);
2301 2289
			}
......
2326 2314
	}
2327 2315

  
2328 2316
	/**
2317
	 * Tests if the names rank is consistent with the given author strings.
2329 2318
	 * @param name
2330 2319
	 * @param event
2331 2320
	 * @param authorStr
......
2334 2323
	 * @param infrAut
2335 2324
	 */
2336 2325
	private void testRankAuthorConsistency(NonViralName name, XMLEvent event,
2337
			String authorStr, String paraut, String infrParAut, String infrAut) {
2326
					String authorStr, String paraut, String infrParAut, String infrAut) {
2327
		if (name.getRank() == null){
2328
			return;
2329
		}
2338 2330
		if (name.getRank().isInfraSpecific()) {
2339 2331
			if (StringUtils.isBlank(infrParAut)
2340 2332
					&& StringUtils.isNotBlank(infrAut)
2341
					&& (StringUtils.isNotBlank(paraut) || StringUtils
2342
							.isNotBlank(authorStr))) {
2333
					&& (StringUtils.isNotBlank(paraut) || StringUtils.isNotBlank(authorStr))) {
2343 2334
				String message = "Rank is infraspecicific but has only specific or higher author(s)";
2344 2335
				fireWarningEvent(message, event, 4);
2345 2336
			}
2346 2337
		} else {
2347 2338
			// is not infraspecific
2348
			if (StringUtils.isNotBlank(infrParAut)
2349
					|| StringUtils.isNotBlank(infrAut)) {
2339
			if (StringUtils.isNotBlank(infrParAut) 	|| StringUtils.isNotBlank(infrAut)) {
2350 2340
				String message = "Rank is not infraspecicific but name has infra author(s)";
2351 2341
				fireWarningEvent(message, event, 4);
2352 2342
			}
......
2480 2470

  
2481 2471
	}
2482 2472

  
2483
	private void handleRefPart(MarkupImportState state, XMLEventReader reader,
2484
			XMLEvent parentEvent, Map<String, String> refMap)
2485
			throws XMLStreamException {
2473
	private void handleRefPart(MarkupImportState state, XMLEventReader reader,XMLEvent parentEvent, Map<String, String> refMap) throws XMLStreamException {
2486 2474
		String classValue = getClassOnlyAttribute(parentEvent);
2487 2475

  
2488 2476
		String text = "";
......
2511 2499

  
2512 2500
	}
2513 2501

  
2514
	private Reference createReference(MarkupImportState state,
2515
			Map<String, String> refMap, XMLEvent parentEvent) {
2502
	private Reference createReference(MarkupImportState state, Map<String, String> refMap, XMLEvent parentEvent) {
2516 2503
		// TODO
2517 2504
		Reference reference;
2518 2505

  
......
2586 2573
		reference.setDatePublished(TimePeriod.parseString(year));
2587 2574

  
2588 2575
		// TODO
2589
		// ALTERNATEPUBTITLE
2590
		// ISSUE
2591
		// NOTES
2576
		String[] unhandledList = new String[]{ALTERNATEPUBTITLE, ISSUE, NOTES, STATUS};
2577
		for (String unhandled : unhandledList){
2578
			String value = getAndRemoveMapKey(refMap, unhandled);
2579
			if (isNotBlank(value)){
2580
				this.handleNotYetImplementedAttributeValue(parentEvent, CLASS, unhandled);
2581
			}
2582
		}
2583
		
2592 2584
		for (String key : refMap.keySet()) {
2593 2585
			if (!DETAILS.equalsIgnoreCase(key)) {
2594 2586
				this.fireUnexpectedAttributeValue(parentEvent, CLASS, key);
......
2638 2630
		}
2639 2631
	}
2640 2632

  
2641
	private void handleFeature(MarkupImportState state, XMLEventReader reader,
2642
			XMLEvent parentEvent) throws XMLStreamException {
2633
	private void handleFeature(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
2643 2634
		String classValue = getClassOnlyAttribute(parentEvent);
2644 2635
		Feature feature = makeFeature(classValue, state, parentEvent);
2645 2636
		Taxon taxon = state.getCurrentTaxon();
2646
		TaxonDescription taxonDescription = getTaxonDescription(taxon, state
2647
				.getConfig().getSourceReference(), NO_IMAGE_GALLERY, CREATE_NEW);
2637
		TaxonDescription taxonDescription = getTaxonDescription(taxon, state.getConfig().getSourceReference(), NO_IMAGE_GALLERY, CREATE_NEW);
2648 2638
		// TextData figureHolderTextData = null; //for use with one TextData for
2649 2639
		// all figure only
2650 2640

  
2651 2641
		boolean isDescription = feature.equals(Feature.DESCRIPTION());
2652 2642
		DescriptionElementBase lastDescriptionElement = null;
2643
		
2653 2644
		while (reader.hasNext()) {
2654 2645
			XMLEvent next = readNoWhitespace(reader);
2655
			if (next.isEndElement()) {
2656
				if (isMyEndingElement(next, parentEvent)) {
2657
					return;
2658
				} else {
2659
					if (isEndingElement(next, DISTRIBUTION_LIST)
2660
							|| isEndingElement(next, HABITAT_LIST)) {
2661
						// only handle list elements
2662
					} else {
2663
						handleUnexpectedEndElement(next.asEndElement());
2664
					}
2646
			if (isMyEndingElement(next, parentEvent)) {
2647
				return;
2648
			} else if (isEndingElement(next, DISTRIBUTION_LIST) || isEndingElement(next, HABITAT_LIST)) { 
2649
				// only handle list elements
2650
			} else if (isStartingElement(next, HEADING)) {
2651
				makeFeatureHeading(state, reader, classValue, feature, next);
2652
			} else if (isStartingElement(next, WRITER)) {
2653
				makeFeatureWriter(state, reader, feature, taxon, next);
2654
//			} else if (isStartingElement(next, DISTRIBUTION_LOCALITY)) {
2655
//				if (!feature.equals(Feature.DISTRIBUTION())) {
2656
//					String message = "Distribution locality only allowed for feature of type 'distribution'";
2657
//					fireWarningEvent(message, next, 4);
2658
//				}
2659
//				handleDistributionLocality(state, reader, next);
2660
			} else if (isStartingElement(next, DISTRIBUTION_LIST) || isStartingElement(next, HABITAT_LIST)) {
2661
				// only handle single list elements
2662
			} else if (isStartingElement(next, HABITAT)) {
2663
				if (!(feature.equals(Feature.HABITAT())
2664
						|| feature.equals(Feature.HABITAT_ECOLOGY()) 
2665
						|| feature.equals(Feature.ECOLOGY()))) {
2666
					String message = "Habitat only allowed for feature of type 'habitat','habitat ecology' or 'ecology'";
2667
					fireWarningEvent(message, next, 4);
2665 2668
				}
2666
			} else if (next.isStartElement()) {
2667
				if (isStartingElement(next, HEADING)) {
2668
					makeFeatureHeading(state, reader, classValue, feature, next);
2669
				} else if (isStartingElement(next, WRITER)) {
2670
					makeFeatureWriter(state, reader, feature, taxon, next);
2671
				} else if (isStartingElement(next, DISTRIBUTION_LOCALITY)) {
2672
					if (!feature.equals(Feature.DISTRIBUTION())) {
2673
						String message = "Distribution locality only allowed for feature of type 'distribution'";
2674
						fireWarningEvent(message, next, 4);
2675
					}
2676
					handleDistributionLocality(state, reader, next);
2677
				} else if (isStartingElement(next, DISTRIBUTION_LIST)
2678
						|| isStartingElement(next, HABITAT_LIST)) {
2679
					// only handle single list elements
2680
				} else if (isStartingElement(next, HABITAT)) {
2681
					if (!(feature.equals(Feature.HABITAT())
2682
							|| feature.equals(Feature.HABITAT_ECOLOGY()) || feature
2683
							.equals(Feature.ECOLOGY()))) {
2684
						String message = "Habitat only allowed for feature of type 'habitat','habitat ecology' or 'ecology'";
2685
						fireWarningEvent(message, next, 4);
2686
					}
2687
					handleHabitat(state, reader, next);
2688
				} else if (isStartingElement(next, CHAR)) {
2689
					TextData textData = handleChar(state, reader, next);
2690
					taxonDescription.addElement(textData);
2691
				} else if (isStartingElement(next, STRING)) {
2692
					lastDescriptionElement = makeFeatureString(state, reader,feature, taxonDescription, lastDescriptionElement,next);
2693
				} else if (isStartingElement(next, FIGURE_REF)) {
2694
					lastDescriptionElement = makeFeatureFigureRef(state, reader, taxonDescription, isDescription, lastDescriptionElement, next);
2695
				} else if (isStartingElement(next, REFERENCES)) {
2696
					// TODO details/microcitation ??
2697

  
2698
					List<Reference<?>> refs = handleReferences(state, reader, next);
2699
					if (!refs.isEmpty()) {
2700
						// TODO
2701
						Reference<?> descriptionRef = state.getConfig().getSourceReference();
2702
						TaxonDescription description = getTaxonDescription(taxon, descriptionRef, false, true);
2703
						TextData featurePlaceholder = getFeaturePlaceholder(state, description, feature, true);
2704
						for (Reference<?> citation : refs) {
2705
							featurePlaceholder.addSource(null, null, citation, null);
2706
						}
2707
					} else {
2708
						String message = "No reference found in references";
2709
						fireWarningEvent(message, next, 6);
2669
				handleHabitat(state, reader, next);
2670
			} else if (isStartingElement(next, CHAR)) {
2671
				TextData textData = handleChar(state, reader, next);
2672
				taxonDescription.addElement(textData);
2673
			} else if (isStartingElement(next, STRING)) {
2674
				lastDescriptionElement = makeFeatureString(state, reader,feature, taxonDescription, lastDescriptionElement,next);
2675
			} else if (isStartingElement(next, FIGURE_REF)) {
2676
				lastDescriptionElement = makeFeatureFigureRef(state, reader, taxonDescription, isDescription, lastDescriptionElement, next);
2677
			} else if (isStartingElement(next, REFERENCES)) {
2678
				// TODO details/microcitation ??
2679

  
2680
				List<Reference<?>> refs = handleReferences(state, reader, next);
2681
				if (!refs.isEmpty()) {
2682
					// TODO
2683
					Reference<?> descriptionRef = state.getConfig().getSourceReference();
2684
					TaxonDescription description = getTaxonDescription(taxon, descriptionRef, false, true);
2685
					TextData featurePlaceholder = getFeaturePlaceholder(state, description, feature, true);
2686
					for (Reference<?> citation : refs) {
2687
						featurePlaceholder.addSource(null, null, citation, null);
2710 2688
					}
2711 2689
				} else {
2712
					handleUnexpectedStartElement(next);
2690
					String message = "No reference found in references";
2691
					fireWarningEvent(message, next, 6);
2713 2692
				}
2693
			} else if (isStartingElement(next, NUM)) {
2694
				//TODO
2695
				handleNotYetImplementedElement(next);
2696
			} else if (isEndingElement(next, NUM)) {
2697
				//TODO
2698
				popUnimplemented(next.asEndElement());
2714 2699
			} else {
2715 2700
				handleUnexpectedElement(next);
2716 2701
			}
2717 2702
		}
2718
		// TODO handle missing end element
2719
		throw new IllegalStateException("Feature has no closing tag");
2703
		throw new IllegalStateException("<Feature> has no closing tag");
2720 2704
	}
2721 2705

  
2722 2706
	/**
......
2729 2713
	 * @return
2730 2714
	 * @throws XMLStreamException
2731 2715
	 */
2732
	private DescriptionElementBase makeFeatureFigureRef(
2733
			MarkupImportState state, XMLEventReader reader,
2734
			TaxonDescription taxonDescription, boolean isDescription,
2735
			DescriptionElementBase lastDescriptionElement, XMLEvent next)
2736
			throws XMLStreamException {
2716
	private DescriptionElementBase makeFeatureFigureRef(MarkupImportState state, XMLEventReader reader,TaxonDescription taxonDescription, 
2717
					boolean isDescription, DescriptionElementBase lastDescriptionElement, XMLEvent next)throws XMLStreamException {
2737 2718
		FigureDataHolder figureHolder = handleFigureRef(state, reader, next);
2738
		Feature figureFeature = getFeature(state,
2739
				MarkupTransformer.uuidFigures, "Figures", "Figures", "Fig.",
2740
				null);
2719
		Feature figureFeature = getFeature(state,MarkupTransformer.uuidFigures, "Figures", "Figures", "Fig.",null);
2741 2720
		if (isDescription) {
2742 2721
			TextData figureHolderTextData = null;
2743 2722
			// if (figureHolderTextData == null){
......
2750 2729
				figureHolderTextData.addAnnotation(annotation);
2751 2730
			}
2752 2731
			if (StringUtils.isNotBlank(figureHolder.figurePart)) {
2753
				String annotationText = "<figurePart>"
2754
						+ figureHolder.figurePart.trim() + "</figurePart>";
2755
				Annotation annotation = Annotation.NewInstance(annotationText,
2756
						AnnotationType.EDITORIAL(), Language.DEFAULT());
2732
				String annotationText = "<figurePart>"+ figureHolder.figurePart.trim() + "</figurePart>";
2733
				Annotation annotation = Annotation.NewInstance(annotationText,AnnotationType.EDITORIAL(), Language.DEFAULT());
2757 2734
				figureHolderTextData.addAnnotation(annotation);
2758 2735
			}
2759 2736
			// if (StringUtils.isNotBlank(figureText)){
......
2781 2758
	 * @param feature
2782 2759
	 * @param taxonDescription
2783 2760
	 * @param lastDescriptionElement
2761
	 * @param distributionList 
2784 2762
	 * @param next
2785 2763
	 * @return
2786 2764
	 * @throws XMLStreamException
2787 2765
	 */
2788
	private DescriptionElementBase makeFeatureString(MarkupImportState state,XMLEventReader reader, Feature feature,
2789
			TaxonDescription taxonDescription, DescriptionElementBase lastDescriptionElement, XMLEvent next)
2790
			throws XMLStreamException {
2791
		Map<String, String> subheadingMap = handleString(state, reader, next);
2766
	private DescriptionElementBase makeFeatureString(MarkupImportState state,XMLEventReader reader, Feature feature, 
2767
				TaxonDescription taxonDescription, DescriptionElementBase lastDescriptionElement, XMLEvent next) throws XMLStreamException {
2768
		Map<String, String> subheadingMap = handleString(state, reader, next, feature);
2792 2769
		for (String subheading : subheadingMap.keySet()) {
2793 2770
			Feature subheadingFeature = feature;
2794 2771
			if (StringUtils.isNotBlank(subheading) && subheadingMap.size() > 1) {
......
2812 2789
	 * @param next
2813 2790
	 * @throws XMLStreamException
2814 2791
	 */
2815
	private void makeFeatureWriter(MarkupImportState state,
2816
			XMLEventReader reader, Feature feature, Taxon taxon, XMLEvent next)
2817
			throws XMLStreamException {
2792
	private void makeFeatureWriter(MarkupImportState state,XMLEventReader reader, Feature feature, Taxon taxon, XMLEvent next) throws XMLStreamException {
2818 2793
		WriterDataHolder writer = handleWriter(state, reader, next);
2819 2794
		if (isNotBlank(writer.writer)) {
2820 2795
			// TODO
......
2839 2814
	 * @param next
2840 2815
	 * @throws XMLStreamException
2841 2816
	 */
2842
	private void makeFeatureHeading(MarkupImportState state,
2843
			XMLEventReader reader, String classValue, Feature feature,
2844
			XMLEvent next) throws XMLStreamException {
2817
	private void makeFeatureHeading(MarkupImportState state, XMLEventReader reader, String classValue, Feature feature, XMLEvent next) throws XMLStreamException {
2845 2818
		String heading = handleHeading(state, reader, next);
2846 2819
		if (StringUtils.isNotBlank(heading)) {
2847 2820
			if (!heading.equalsIgnoreCase(classValue)) {
......
2866 2839
		}
2867 2840
	}
2868 2841

  
2869
	private List<Reference<?>> handleReferences(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent)
2870
			throws XMLStreamException {
2842
	private List<Reference<?>> handleReferences(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
2871 2843
		// attributes
2872 2844
		Map<String, Attribute> attributes = getAttributes(parentEvent);
2873 2845
		String bibliography = getAndRemoveAttributeValue(attributes,
......
2937 2909
		throw new IllegalStateException("<References> has no closing tag");
2938 2910
	}
2939 2911

  
2940
	private void handleHabitat(MarkupImportState state, XMLEventReader reader,
2941
			XMLEvent parentEvent) throws XMLStreamException {
2912
	private void handleHabitat(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
2942 2913
		checkNoAttributes(parentEvent);
2943 2914
		Taxon taxon = state.getCurrentTaxon();
2944 2915
		// TODO which ref to take?
......
2979 2950
		throw new IllegalStateException("<Habitat> has no closing tag");
2980 2951
	}
2981 2952

  
2982
	private String getTaggedCData(MarkupImportState state,
2983
			XMLEventReader reader, XMLEvent parentEvent)
2984
			throws XMLStreamException {
2953
	private String getTaggedCData(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent) throws XMLStreamException {
2985 2954
		checkNoAttributes(parentEvent);
2986 2955

  
2987 2956
		String text = getXmlTag(parentEvent);
......
3004 2973

  
3005 2974
	}
3006 2975

  
3007
	private void handleDistributionLocality(MarkupImportState state,
3008
			XMLEventReader reader, XMLEvent parentEvent)
3009
			throws XMLStreamException {
3010
		String classValue = getClassOnlyAttribute(parentEvent);
2976
	private void handleDistributionLocality(MarkupImportState state,XMLEventReader reader, XMLEvent parentEvent)throws XMLStreamException {
2977
		Map<String, Attribute> attributes = getAttributes(parentEvent);
2978
		String classValue = getAndRemoveRequiredAttributeValue(parentEvent, attributes, CLASS);
2979
		String statusValue =getAndRemoveAttributeValue(attributes, STATUS);
2980
		String frequencyValue =getAndRemoveAttributeValue(attributes, FREQUENCY);
2981
		
3011 2982

  
3012 2983
		Taxon taxon = state.getCurrentTaxon();
3013 2984
		// TODO which ref to take?
3014
		Reference ref = state.getConfig().getSourceReference();
2985
		Reference<?> ref = state.getConfig().getSourceReference();
3015 2986

  
3016 2987
		String text = "";
3017 2988
		while (reader.hasNext()) {
3018 2989
			XMLEvent next = readNoWhitespace(reader);
3019 2990
			if (isMyEndingElement(next, parentEvent)) {
3020 2991
				if (StringUtils.isNotBlank(text)) {
3021
					TaxonDescription description = getTaxonDescription(taxon,
3022
							ref, false, true);
3023
					NamedAreaLevel level = makeNamedAreaLevel(state,
3024
							classValue, next);
2992
					TaxonDescription description = getTaxonDescription(taxon, ref, false, true);
2993
					NamedAreaLevel level = makeNamedAreaLevel(state,classValue, next);
3025 2994
					NamedArea area = createArea(text, level, state);
3026 2995

  
3027 2996
					PresenceAbsenceTermBase<?> status = null;
3028
					Distribution distribution = Distribution.NewInstance(area,
3029
							status);
2997
					try {
2998
						status = state.getTransformer().getPresenceTermByKey(statusValue);
2999
					} catch (UndefinedTransformerMethodException e) {
3000
						throw new RuntimeException(e);
3001
					}
3002
					Distribution distribution = Distribution.NewInstance(area,status);
3030 3003
					description.addElement(distribution);
3004
					if (isNotBlank(frequencyValue)){
3005
						String message = "The frequency attribute is currently not yet available in CDM";
3006
						fireWarningEvent(message, parentEvent, 6);
3007
					}
3031 3008
				} else {
3032 3009
					String message = "Empty distribution locality";
3033 3010
					fireWarningEvent(message, next, 4);
3034 3011
				}
3035 3012
				return;
3036
			} else if (next.isStartElement()) {
3037
				if (isStartingElement(next, COORDINATES)) {
3038
					handleNotYetImplementedElement(next);
3039
				} else {
3040
					handleUnexpectedStartElement(next.asStartElement());
3041
				}
3013
			} else if (isStartingElement(next, COORDINATES)) {
3014
				//TODO
3015
				handleNotYetImplementedElement(next);
3016
			} else if (isEndingElement(next, COORDINATES)) {
3017
				//TODO
3018
				popUnimplemented(next.asEndElement());
3042 3019
			} else if (next.isCharacters()) {
3043 3020
				text += next.asCharacters().getData();
3044 3021
			} else {
3045 3022
				handleUnexpectedEndElement(next.asEndElement());
3046 3023
			}
3047 3024
		}
3048
		throw new IllegalStateException(
3049
				"<DistributionLocality> has no closing tag");
3025
		throw new IllegalStateException("<DistributionLocality> has no closing tag");
3050 3026
	}
3051 3027

  
3052 3028
	/**
......
3061 3037
		try {
3062 3038
			level = state.getTransformer().getNamedAreaLevelByKey(levelString);
3063 3039
			if (level == null) {
3064
				UUID levelUuid = state.getTransformer().getNamedAreaLevelUuid(
3065
						levelString);
3040
				UUID levelUuid = state.getTransformer().getNamedAreaLevelUuid(levelString);
3066 3041
				if (levelUuid == null) {
3067 3042
					String message = "Unknown distribution locality class (named area level): %s. Create new level instead.";
3068 3043
					message = String.format(message, levelString);
......
3077 3052
		return level;
3078 3053
	}
3079 3054

  
3080
	private String handleHeading(MarkupImportState state,
3081
			XMLEventReader reader, XMLEvent parentEvent)
3082
			throws XMLStreamException {
3055
	private String handleHeading(MarkupImportState state,XMLEventReader reader, XMLEvent parentEvent)throws XMLStreamException {
3083 3056
		checkNoAttributes(parentEvent);
3084 3057

  
3085 3058
		String text = "";
......
3103 3076

  
3104 3077
	}
3105 3078

  
3106
	private Map<String, String> handleString(MarkupImportState state,
3107
			XMLEventReader reader, XMLEvent parentEvent)
3108
			throws XMLStreamException {
3079
	/**
3080
	 * Handle string
3081
	 * @param state
3082
	 * @param reader
3083
	 * @param parentEvent
3084
	 * @param feature only needed for distributionLocalities
3085
	 * @return
3086
	 * @throws XMLStreamException
3087
	 */
3088
	private Map<String, String> handleString(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent, Feature feature)throws XMLStreamException {
3109 3089
		// attributes
3110 3090
		String classValue = getClassOnlyAttribute(parentEvent, false);
3111 3091
		if (StringUtils.isNotBlank(classValue)) {
......
3135 3115
				text = putCurrentSubheading(subHeadingMap,currentSubheading, text);
3136 3116
				// TODO footnotes
3137 3117
				currentSubheading = getCData(state, reader, next).trim();
3118
			} else if (isStartingElement(next, DISTRIBUTION_LOCALITY)) {
3119
				if (feature != null && !feature.equals(Feature.DISTRIBUTION())) {
3120
					String message = "Distribution locality only allowed for feature of type 'distribution'";
3121
					fireWarningEvent(message, next, 4);
3122
				}
3123
				handleDistributionLocality(state, reader, next);
3124
			
3138 3125
			} else if (next.isCharacters()) {
3139 3126
				if (!isTextMode) {
3140 3127
					String message = "String is not in text mode";
......
3142 3129
				} else {
3143 3130
					text += next.asCharacters().getData();
3144 3131
				}
3145
			} else if (isStartingElement(next, COLLECTION)) {
3132
			} else if (isStartingElement(next, HEADING)) {
3133
				//TODO
3134
				handleNotYetImplementedElement(next);
3135
			} else if (isEndingElement(next, HEADING)) {
3136
				//TODO
3137
				popUnimplemented(next.asEndElement());
3138
			} else if (isStartingElement(next, QUOTE)) {
3139
				//TODO
3140
				handleNotYetImplementedElement(next);
3141
			} else if (isEndingElement(next, QUOTE)) {
3142
				//TODO
3143
				popUnimplemented(next.asEndElement());
3144
			} else if (isStartingElement(next, DEDICATION)) {
3145
				//TODO
3146
				handleNotYetImplementedElement(next);
3147
			} else if (isEndingElement(next, DEDICATION)) {
3148
				//TODO
3149
				popUnimplemented(next.asEndElement());
3150
			} else if (isStartingElement(next, TAXONTYPE)) {
3151
				//TODO
3152
				handleNotYetImplementedElement(next);
3153
			} else if (isEndingElement(next, TAXONTYPE)) {
3154
				//TODO
3155
				popUnimplemented(next.asEndElement());
3156
			} else if (isStartingElement(next, FULL_NAME)) {
3157
				//TODO
3158
				handleNotYetImplementedElement(next);
3159
			} else if (isEndingElement(next, FULL_NAME)) {
3160
				//TODO
3161
				popUnimplemented(next.asEndElement());
3162
			}else if (isStartingElement(next, REFERENCES)) {
3163
				//TODO
3164
				handleNotYetImplementedElement(next);
3165
			} else if (isEndingElement(next, REFERENCES)) {
3166
				//TODO
3167
				popUnimplemented(next.asEndElement());
3168
			} else if (isStartingElement(next, GATHERING)) {
3146 3169
				//TODO
3147 3170
				handleNotYetImplementedElement(next);
3148
			} else if (isEndingElement(next, COLLECTION)) {
3171
			} else if (isEndingElement(next, GATHERING)) {
3149 3172
				//TODO
3150 3173
				popUnimplemented(next.asEndElement());
3151 3174
			} else if (isStartingElement(next, ANNOTATION)) {
......
3154 3177
			} else if (isEndingElement(next, ANNOTATION)) {
3155 3178
				//TODO
3156 3179
				popUnimplemented(next.asEndElement());
3180
			} else if (isStartingElement(next, HABITAT)) {
3181
				//TODO
3182
				handleNotYetImplementedElement(next);
3183
			} else if (isEndingElement(next, HABITAT)) {
3184
				//TODO
3185
				popUnimplemented(next.asEndElement());
3186
			} else if (isStartingElement(next, FIGURE_REF)) {
3187
				//TODO
3188
				handleNotYetImplementedElement(next);
3189
			} else if (isEndingElement(next, FIGURE_REF)) {
3190
				//TODO
3191
				popUnimplemented(next.asEndElement());
3192
			} else if (isStartingElement(next, FIGURE)) {
3193
				//TODO
3194
				handleNotYetImplementedElement(next);
3195
			} else if (isEndingElement(next, FIGURE)) {
3196
				//TODO
3197
				popUnimplemented(next.asEndElement());
3198
			} else if (isStartingElement(next, FOOTNOTE_REF)) {
3199
				//TODO
3200
				handleNotYetImplementedElement(next);
3201
			} else if (isEndingElement(next, FOOTNOTE_REF)) {
3202
				//TODO
3203
				popUnimplemented(next.asEndElement());
3204
			} else if (isStartingElement(next, FOOTNOTE)) {
3205
				//TODO
3206
				handleNotYetImplementedElement(next);
3207
			} else if (isEndingElement(next, FOOTNOTE)) {
3208
				//TODO
3209
				popUnimplemented(next.asEndElement());
3210
			} else if (isStartingElement(next, WRITER)) {
3211
				//TODO
3212
				handleNotYetImplementedElement(next);
3213
			} else if (isEndingElement(next, WRITER)) {
3214
				//TODO
3215
				popUnimplemented(next.asEndElement());
3216
			} else if (isStartingElement(next, DATES)) {
3217
				//TODO
3218
				handleNotYetImplementedElement(next);
3219
			} else if (isEndingElement(next, DATES)) {
3220
				//TODO
3221
				popUnimplemented(next.asEndElement());
3157 3222
			} else {
3158 3223
				handleUnexpectedElement(next);
3159 3224
			}
......
3240 3305
				TextData textData = TextData.NewInstance(feature);
3241 3306
				textData.putText(Language.DEFAULT(), text);
3242 3307
				return textData;
3308
			} else if (isStartingElement(next, FIGURE_REF)) {
3309
				//TODO
3310
				handleNotYetImplementedElement(next);
3311
			} else if (isEndingElement(next, FIGURE_REF)) {
3312
				//TODO
3313
				popUnimplemented(next.asEndElement());
3243 3314
			} else if (next.isStartElement()) {
3244 3315
				if (isStartingElement(next, ANNOTATION)) {
3245 3316
					handleNotYetImplementedElement(next);
......
3266 3337
	 * @return
3267 3338
	 * @throws UndefinedTransformerMethodException
3268 3339
	 */
3269
	private Feature makeFeature(String classValue, MarkupImportState state,
3270
			XMLEvent parentEvent) {
3340
	private Feature makeFeature(String classValue, MarkupImportState state, XMLEvent parentEvent) {
3271 3341
		UUID uuid;
3272 3342
		try {
3273
			Feature feature = state.getTransformer()
3274
					.getFeatureByKey(classValue);
3343
			Feature feature = state.getTransformer().getFeatureByKey(classValue);
3275 3344
			if (feature != null) {
3276 3345
				return feature;
3277 3346
			}
3278 3347
			uuid = state.getTransformer().getFeatureUuid(classValue);
3279 3348
			if (uuid == null) {
3280 3349
				// TODO
3281
				logger.warn("Uuid is null for " + classValue);
3350
				String message = "Uuid is not defined for %s";
3351
				message = String.format(message, classValue);
3352
				fireWarningEvent(message, parentEvent, 8);
3282 3353
			}
3283 3354
			String featureText = StringUtils.capitalize(classValue);
3284 3355

  
3285 3356
			// TODO eFlora vocabulary
3286 3357
			TermVocabulary<Feature> voc = null;
3287
			feature = getFeature(state, uuid, featureText, featureText,
3288
					classValue, voc);
3358
			feature = getFeature(state, uuid, featureText, featureText, classValue, voc);
3289 3359
			if (feature == null) {
3290
				throw new NullPointerException(classValue
3291
						+ " not recognized as a feature");
3360
				throw new NullPointerException(classValue + " not recognized as a feature");
3292 3361
			}
3293 3362
			return feature;
3294 3363
		} catch (Exception e) {
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupTransformer.java
19 19
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
20 20
import eu.etaxonomy.cdm.model.common.MarkerType;
21 21
import eu.etaxonomy.cdm.model.description.Feature;
22
import eu.etaxonomy.cdm.model.description.PresenceTerm;
22 23
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
23 24

  
24 25
/**
......
60 61
	public static final UUID uuidFigure = UUID.fromString("5165cd6a-9b31-4a1f-8b30-04ab740c502c");
61 62
	public static final UUID uuidFigures = UUID.fromString("6dfb4e78-c67e-410c-8989-c1fb1295abf6");
62 63
	
64
	
65
	
66
	
63 67
	public static final UUID uuidExtractedHabitat = UUID.fromString("d80511d2-a76c-48b8-b3aa-5fbd4a58fe5c");
64
	public static final UUID uuidHabit = UUID.fromString("03487108-173a-4335-92be-05076af29155");
68
//	public static final UUID uuidHabit = UUID.fromString("03487108-173a-4335-92be-05076af29155");
65 69
	public static final UUID uuidHabitat = UUID.fromString("fb16929f-bc9c-456f-9d40-dec987b36438");
66 70
	public static final UUID uuidHabitatEcology = UUID.fromString("9fdc4663-4d56-47d0-90b5-c0bf251bafbb");
67 71
	
68 72
	public static final UUID uuidChromosomes = UUID.fromString("c4a60319-4978-4692-9545-58d60cf8379e");
73
	public static final UUID uuidPhylogeny = UUID.fromString("8bcffbeb-a849-4222-83f9-bfcbbc3baef9");
74
	public static final UUID uuidHistory = UUID.fromString("6f9f0316-1c27-4e17-b96a-51332521f74e");
75
	public static final UUID uuidCultivation = UUID.fromString("f10f34fb-53b9-43c2-bfd6-05ea475e8e0f");
69 76
	
70 77
	public static final UUID uuidNote = UUID.fromString("b9af1489-6b68-497f-8d4b-260a9f886827");
71 78
	public static final UUID uuidNotes = UUID.fromString("e31bb420-f39e-493d-b452-dd5e63dda443");
......
155 162
	public static final UUID uuidPerianth = UUID.fromString("bd1480bb-ce44-495f-a462-98db4ac80530");
156 163
	public static final UUID uuidScales = UUID.fromString("bd1480bb-ce44-495f-a462-98db4ac80530");
157 164
	public static final UUID uuidPerigoneTube = UUID.fromString("d1799423-31ce-4525-b0ba-8d7cc9240abf");
165
	public static final UUID uuidPerigoneLobes = UUID.fromString("e309e1e3-8f60-4478-9b89-ca5069bc1622");
166
	public static final UUID uuidPerigone = UUID.fromString("f026fc87-5fc6-4559-a7e5-e8832c20033d");
158 167
	public static final UUID uuidCorolla = UUID.fromString("9ff17ff9-cb59-4ad7-bfa1-1d67935e567f");
159 168
	public static final UUID uuidAnnulus = UUID.fromString("d9b93acb-9b49-45ef-8661-09e00081931f");
160 169
	public static final UUID uuidFemaleFlowers = UUID.fromString("2e06cea2-5993-417c-8d0d-81cb571aa17a");
......
217 226
	public UUID getFeatureUuid(String key) 	throws UndefinedTransformerMethodException {
218 227
		if (CdmUtils.isEmpty(key)){return null;
219 228

  
229
		
230
		}else if (key.equalsIgnoreCase("cultivation")){return uuidCultivation;
231
		}else if (key.equalsIgnoreCase("history")){return uuidHistory;
232
		}else if (key.equalsIgnoreCase("phylogeny")){return uuidPhylogeny;
220 233
		}else if (key.equalsIgnoreCase("Chromosomes")){return uuidChromosomes;
221
		}else if (key.equalsIgnoreCase("habit")){return uuidHabit;
222 234
		}else if (key.equalsIgnoreCase("Habitat")){return uuidHabitat;
223 235
		}else if (key.equalsIgnoreCase("Habitat & Ecology")){return uuidHabitatEcology;
224 236
		}else if (key.equalsIgnoreCase("Leaflets")){return uuidLeaflets;
225 237
		}else if (key.equalsIgnoreCase("Leaves")){return uuidLeaves;
226 238
		}else if (key.equalsIgnoreCase("Branchlets")){return uuidBranchlets;
227 239
		}else if (key.equalsIgnoreCase("lifeform")){return uuidLifeform;
240
		}else if (key.equalsIgnoreCase("habit")){return uuidLifeform;
228 241
		}else if (key.equalsIgnoreCase("Inflorescences")){return uuidInflorescences;
229 242
		}else if (key.equalsIgnoreCase("Flowers")){return uuidFlowers;
230 243
		}else if (key.equalsIgnoreCase("Sepals")){return uuidSepals;
......
258 271
		}else if (key.equalsIgnoreCase("Fruit")){return uuidFruit;
259 272
		}else if (key.equalsIgnoreCase("Branch")){return uuidBranch;
260 273
		}else if (key.equalsIgnoreCase("Inflorescence")){return uuidInflorescence;
261
		}else if (key.equalsIgnoreCase("male inflorescences")){return uuidMaleInflorescences;
262
		}else if (key.equalsIgnoreCase("female inflorescences")){return uuidFemaleInflorescences;
274
		}else if (key.equalsIgnoreCase("Male inflorescences")){return uuidMaleInflorescences;
275
		}else if (key.equalsIgnoreCase("Female inflorescences")){return uuidFemaleInflorescences;
263 276
		
264 277
		}else if (key.equalsIgnoreCase("Calyx")){return uuidCalyx;
265 278
		}else if (key.equalsIgnoreCase("Seedling")){return uuidSeedling;
......
286 299
		}else if (key.equalsIgnoreCase("perianth")){return uuidPerianth;
287 300
		}else if (key.equalsIgnoreCase("scales")){return uuidScales;
288 301
		}else if (key.equalsIgnoreCase("perigone tube")){return uuidPerigoneTube;
302
		}else if (key.equalsIgnoreCase("perigone")){return uuidPerigone;
303
		}else if (key.equalsIgnoreCase("perigone lobes")){return uuidPerigoneLobes;
304
		
289 305
		}else if (key.equalsIgnoreCase("corolla")){return uuidCorolla;
290 306
		}else if (key.equalsIgnoreCase("annulus")){return uuidAnnulus;
291 307
		}else if (key.equalsIgnoreCase("female flowers")){return uuidFemaleFlowers;
......
328 344
		}else if (key.equalsIgnoreCase("Flower morphology")){return uuidFlowerMorphology;
329 345
		}else if (key.equalsIgnoreCase("Pollination")){return uuidPollination;
330 346
		}else if (key.equalsIgnoreCase("Life cycle")){return uuidLifeCycle;
347
		}else if (key.equalsIgnoreCase("lifehistory")){return uuidLifeCycle;
331 348
		}else if (key.equalsIgnoreCase("Fruits and embryology")){return uuidFruitsAndEmbryology;
332 349
		}else if (key.equalsIgnoreCase("Dispersal")){return uuidDispersal;
333 350
		}else if (key.equalsIgnoreCase("Phytochemistry")){return uuidPhytochemistry;
......
405 422
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getNamedAreaLevelUuid(java.lang.String)
406 423
	 */
407 424
	@Override
408
	public UUID getNamedAreaLevelUuid(String key)
409
			throws UndefinedTransformerMethodException {
425
	public UUID getNamedAreaLevelUuid(String key) throws UndefinedTransformerMethodException {
410 426
		if (CdmUtils.isEmpty(key)){return null;
411 427
		}else if (key.equalsIgnoreCase("region")){return uuidRegion;
412 428
		}else if (key.equalsIgnoreCase("world")){return uuidWorld;
......
419 435
			return null;
420 436
		}
421 437
	}
438

  
439
	/* (non-Javadoc)
440
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getPresenceTermByKey(java.lang.String)
441
	 */
442
	@Override
443
	public PresenceTerm getPresenceTermByKey(String key) throws UndefinedTransformerMethodException {
444
		if (CdmUtils.isEmpty(key)){return null;
445
		}else if (key.equalsIgnoreCase("endemic")){return PresenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA();
446
		}else if (key.equalsIgnoreCase("cultivated")){return PresenceTerm.CULTIVATED();
447
		}else{
448
			return null;
449
		}
450
	}
451

  
452
	/* (non-Javadoc)
453
	 * @see eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase#getPresenceTermUuid(java.lang.String)
454
	 */
455
	@Override
456
	public UUID getPresenceTermUuid(String key) throws UndefinedTransformerMethodException {
457
		if (CdmUtils.isEmpty(key)){return null;
458
//		}else if (key.equalsIgnoreCase("region")){return uuidRegion;
459
		}else{
460
			return null;
461
		}
462
	}
422 463
	
423 464
	
424 465
	
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/UnmatchedLeads.java
54 54
		//taxonKey
55 55
		String numAndTaxon;
56 56

  
57
		
57 58
		public boolean isInnerLead(){
58 59
			return (key != null);
59 60
		}
......
160 161
		return false;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff