Project

General

Profile

Download (2.85 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.strategy.parser;
10

    
11
import org.apache.commons.lang3.StringUtils;
12

    
13
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
14
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
15

    
16
/**
17
 * @author a.mueller
18
 * @since 25.07.2011
19
 */
20
public class SpecimenTypeParser {
21

    
22
	public static class TypeInfo{
23
		public SpecimenTypeDesignationStatus status;
24
		public String collectionString;
25
		public boolean notDesignated;
26
		public boolean notSeen;
27
	}
28

    
29
	/**
30
	 * see also CentralAfricaFernsTaxonParser#handleTypeLocationPart
31
	 */
32
	public static final String typeTypePattern = "(?i)(holo|lecto|iso|isolecto|syn|isosyn|neo|isoneo|type)\\.?";
33
	public static final String collectionPattern = "^[A-Z]+(\\-[A-Z]+)?";
34
	public static final String notSeen = "(n\\.v\\.|not\\s+seen)";
35

    
36

    
37

    
38
	public static SpecimenTypeDesignationStatus parseSpecimenTypeStatus(String type) throws UnknownCdmTypeException {
39
		//TODO also compare with NameTypeParser
40
		//TODO further types
41

    
42
		if (StringUtils.isBlank(type)){
43
			return null;
44
		}else if (type.endsWith("type") && ! type.equalsIgnoreCase("type")){
45
			type = type.substring(0, type.length() -4 );
46
		}else if (type.endsWith("types") && ! type.equalsIgnoreCase("types")){
47
			type = type.substring(0, type.length() -5 );
48
		}
49

    
50
		SpecimenTypeDesignationStatus status;
51
		if (type.equalsIgnoreCase("iso")){
52
			status = SpecimenTypeDesignationStatus.ISOTYPE();
53
		}else if (type.equalsIgnoreCase("isolecto")){
54
			status = SpecimenTypeDesignationStatus.ISOLECTOTYPE();
55
		}else if (type.equalsIgnoreCase("syn")){
56
			status = SpecimenTypeDesignationStatus.SYNTYPE();
57
		}else if (type.equalsIgnoreCase("holo")){
58
			status = SpecimenTypeDesignationStatus.HOLOTYPE();
59
		}else if (type.equalsIgnoreCase("lecto")){
60
			status = SpecimenTypeDesignationStatus.LECTOTYPE();
61
		}else if (type.equalsIgnoreCase("isosyn")){
62
			status = SpecimenTypeDesignationStatus.ISOSYNTYPE();
63
		}else if (type.equalsIgnoreCase("neo")){
64
			status = SpecimenTypeDesignationStatus.NEOTYPE();
65
		}else if (type.equalsIgnoreCase("isoneo")){
66
			status = SpecimenTypeDesignationStatus.ISONEOTYPE();
67
		}else if (type.equalsIgnoreCase("para")){
68
            status = SpecimenTypeDesignationStatus.PARATYPE();
69
		}else if (type.equalsIgnoreCase("isopara")){
70
            status = SpecimenTypeDesignationStatus.ISOPARATYPE();
71
        }else if (type.equalsIgnoreCase("type")){
72
			status = SpecimenTypeDesignationStatus.TYPE();
73
		}else{
74
			String message = "Type Status not supported: " + type;
75
			throw new UnknownCdmTypeException(message);
76
		}
77
		return status;
78
	}
79
}
(8-8/9)