Project

General

Profile

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

    
11
package eu.etaxonomy.taxeditor.parser;
12

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

    
21
/**
22
 * This class defines the MatchStrategies that will be used by the ParseHandler.
23
 *
24
 * @author n.hoffmann
25
 * @created Jan 22, 2010
26
 * @version 1.0
27
 */
28
public class MatchStrategyConfigurator {
29
	
30
	/**
31
	 * <p>NonViralNameMatchStrategy</p>
32
	 *
33
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
34
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
35
	 */
36
	public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
37
		return getDefaultNonViralNameMatchStrategy();// PreferencesUtil.getMatchStrategy(NonViralName.class);
38
	}
39
	
40
	/**
41
	 * <p>TeamOrPersonMatchStrategy</p>
42
	 *
43
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
44
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
45
	 */
46
	public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
47
		return PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
48
	} 
49
	
50
	/**
51
	 * <p>ReferenceMatchStrategy</p>
52
	 *
53
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
54
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
55
	 */
56
	public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
57
		return getDefaultReferenceMatchStrategy();// PreferencesUtil.getMatchStrategy(ReferenceBase.class);
58
	}
59

    
60
	/**
61
	 * <p>getDefaultNonViralNameMatchStrategy</p>
62
	 *
63
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
64
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
65
	 */
66
	public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
67
		IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(NonViralName.class);
68
		
69
		strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
70
		strategy.setMatchMode("combinationAuthorship", MatchMode.IGNORE);
71
		strategy.setMatchMode("exCombinationAuthorship", MatchMode.IGNORE);
72
		strategy.setMatchMode("basionymAuthorship", MatchMode.IGNORE);
73
		strategy.setMatchMode("exBasionymAuthorship", MatchMode.IGNORE);
74
		
75
		return strategy;
76
	}
77

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

    
91
	/**
92
	 * <p>getDefaultReferenceMatchStrategy</p>
93
	 *
94
	 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
95
	 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
96
	 */
97
	public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
98
		IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(Reference.class);
99
		
100
		strategy.setMatchMode("title", MatchMode.EQUAL);
101
		strategy.setMatchMode("inReference", MatchMode.IGNORE);
102
		
103
		return strategy;
104
	}
105

    
106
	/**
107
	 * <p>setMatchStrategy</p>
108
	 *
109
	 * @param matchStrategy a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
110
	 */
111
	public static void setMatchStrategy(IMatchStrategy matchStrategy) {
112
		PreferencesUtil.setMatchStrategy(matchStrategy);
113
	}
114
	
115
}
(1-1/2)