Project

General

Profile

Download (3.8 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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.taxeditor.parser;
10

    
11
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
12
import eu.etaxonomy.cdm.model.name.TaxonName;
13
import eu.etaxonomy.cdm.model.reference.Reference;
14
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
15
import eu.etaxonomy.cdm.strategy.match.MatchException;
16
import eu.etaxonomy.cdm.strategy.match.MatchMode;
17
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
18

    
19
/**
20
 * This class defines the MatchStrategies that will be used by the ParseHandler.
21
 *
22
 * @author n.hoffmann
23
 * @created Jan 22, 2010
24
 */
25
public class MatchStrategyConfigurator {
26

    
27
	/**
28
	 * <p>NonViralNameMatchStrategy</p>
29
	 *
30
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
31
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
32
	 */
33
	public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
34
		return getDefaultNonViralNameMatchStrategy();// PreferencesUtil.getMatchStrategy(NonViralName.class);
35
	}
36

    
37
	/**
38
	 * <p>TeamOrPersonMatchStrategy</p>
39
	 *
40
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
41
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
42
	 */
43
	public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
44
		return PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
45
	}
46

    
47
	/**
48
	 * <p>ReferenceMatchStrategy</p>
49
	 *
50
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
51
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
52
	 */
53
	public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
54
		return getDefaultReferenceMatchStrategy();// PreferencesUtil.getMatchStrategy(ReferenceBase.class);
55
	}
56

    
57
	/**
58
	 * <p>getDefaultNonViralNameMatchStrategy</p>
59
	 *
60
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
61
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
62
	 */
63
	public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
64
		IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(TaxonName.class);
65

    
66
		strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
67
		strategy.setMatchMode("combinationAuthorship", MatchMode.IGNORE);
68
		strategy.setMatchMode("exCombinationAuthorship", MatchMode.IGNORE);
69
		strategy.setMatchMode("basionymAuthorship", MatchMode.IGNORE);
70
		strategy.setMatchMode("exBasionymAuthorship", MatchMode.IGNORE);
71

    
72
		return strategy;
73
	}
74

    
75
	/**
76
	 * <p>getDefaultTeamOrPersonMatchStrategy</p>
77
	 *
78
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
79
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
80
	 */
81
	public static IMatchStrategy getDefaultTeamOrPersonMatchStrategy() throws MatchException{
82
		IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(TeamOrPersonBase.class);
83

    
84
		return strategy;
85
	}
86

    
87

    
88
	/**
89
	 * <p>getDefaultReferenceMatchStrategy</p>
90
	 *
91
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
92
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
93
	 */
94
	public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
95
		IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(Reference.class);
96

    
97
		strategy.setMatchMode("title", MatchMode.EQUAL);
98
		strategy.setMatchMode("inReference", MatchMode.IGNORE);
99

    
100
		return strategy;
101
	}
102

    
103
	/**
104
	 * <p>setMatchStrategy</p>
105
	 *
106
	 * @param matchStrategy a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
107
	 */
108
	public static void setMatchStrategy(IMatchStrategy matchStrategy) {
109
		PreferencesUtil.setMatchStrategy(matchStrategy);
110
	}
111

    
112
}
(1-1/2)