Project

General

Profile

Revision cb4b3b25

IDcb4b3b258285b7dac4105a3c2202da95b1485aad
Parent 6efe4dfc
Child e39c28b0

Added by Andreas Müller almost 4 years ago

ref #6410 handle hybridClass attribute

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupImportBase.java
394 394

  
395 395
	/**
396 396
	 * Returns the value of a given attribute name and removes the attribute from the attributes map.
397
	 * @param attributes
398
	 * @param attrName
399
	 * @return
397
	 * Returns <code>null</code> if attribute does not exist.
398
	 * @param attributes the list of all attributes
399
	 * @param attrName the requested attribute name
400
	 * @return the value for the attribute
400 401
	 */
401 402
	protected String getAndRemoveAttributeValue(Map<String, Attribute> attributes, String attrName) {
402 403
		return getAndRemoveAttributeValue(null, attributes, attrName, false, 1);
......
1170 1171
	}
1171 1172

  
1172 1173
	protected void handleFullName(MarkupImportState state, XMLEventReader reader,
1173
			INonViralName name, XMLEvent next) throws XMLStreamException {
1174
			INonViralName name, XMLEvent event) throws XMLStreamException {
1174 1175
		String fullNameStr;
1175
		Map<String, Attribute> attrs = getAttributes(next);
1176
		String rankStr = getAndRemoveRequiredAttributeValue(next,
1177
				attrs, "rank");
1176
		Map<String, Attribute> attrs = getAttributes(event);
1177
		String rankStr = getAndRemoveRequiredAttributeValue(event, attrs, "rank");
1178
		String hybridClass = getAndRemoveAttributeValue(attrs, "hybridClass");
1179

  
1178 1180
		Rank rank = makeRank(state, rankStr, false);
1179 1181
		name.setRank(rank);
1180 1182
		if (rank == null) {
1181 1183
			String message = "Rank was computed as null. This must not be.";
1182
			fireWarningEvent(message, next, 6);
1184
			fireWarningEvent(message, event, 6);
1183 1185
			name.setRank(Rank.UNKNOWN_RANK());
1184 1186
		}
1185 1187
		if (!attrs.isEmpty()) {
1186
			handleUnexpectedAttributes(next.getLocation(), attrs);
1188
			handleUnexpectedAttributes(event.getLocation(), attrs);
1187 1189
		}
1188
//		next = readNoWhitespace(reader);
1189
		fullNameStr = getCData(state, reader, next, false);
1190
		fullNameStr = getCData(state, reader, event, false);
1190 1191
		NonViralNameParserImpl.NewInstance().parseFullName(name, fullNameStr, rank, false);
1191
//		name.setTitleCache(fullNameStr, true);
1192
		if (hybridClass != null ){
1193
		    if ("hybrid formula".equals(hybridClass)){
1194
		        if (!name.isHybridFormula()){
1195
		            fireWarningEvent("Hybrid formula is not set though requested: " + fullNameStr, event, 4);
1196
		        }
1197
		    }else if ("hybrid".equals(hybridClass)){
1198
                if (!name.isHybridName()){
1199
                    fireWarningEvent("Hybrid name is recognized: " + fullNameStr, event, 4);
1200
                }
1201
            }else{
1202
                handleNotYetImplementedAttributeValue(event, "hybridClass", hybridClass);
1203
            }
1204
		}
1192 1205
	}
1193 1206

  
1194 1207

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)