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.cdm.strategy.match;
|
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
|
|
17
|
/**
|
18
|
* This class defines the MatchStrategies that will be used by the ParseHandler.
|
19
|
*
|
20
|
* @author n.hoffmann
|
21
|
* @created Jan 22, 2010
|
22
|
* @version 1.0
|
23
|
*/
|
24
|
public class MatchStrategyConfigurator {
|
25
|
|
26
|
|
27
|
public enum MatchStrategy {
|
28
|
NonViralName,
|
29
|
TeamOrPerson,
|
30
|
Reference
|
31
|
}
|
32
|
|
33
|
public static IMatchStrategy getMatchStrategy(MatchStrategy strategy) throws MatchException {
|
34
|
switch(strategy) {
|
35
|
case NonViralName :
|
36
|
return NonViralNameMatchStrategy();
|
37
|
case TeamOrPerson:
|
38
|
return TeamOrPersonMatchStrategy();
|
39
|
case Reference :
|
40
|
return ReferenceMatchStrategy();
|
41
|
default :
|
42
|
return null;
|
43
|
}
|
44
|
}
|
45
|
/**
|
46
|
* <p>NonViralNameMatchStrategy</p>
|
47
|
*
|
48
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
49
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
50
|
*/
|
51
|
public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
|
52
|
return getDefaultNonViralNameMatchStrategy();// PreferencesUtil.getMatchStrategy(NonViralName.class);
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* <p>TeamOrPersonMatchStrategy</p>
|
57
|
*
|
58
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
59
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
60
|
*/
|
61
|
public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
|
62
|
return getDefaultTeamOrPersonMatchStrategy();// PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* <p>ReferenceMatchStrategy</p>
|
67
|
*
|
68
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
69
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
70
|
*/
|
71
|
public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
|
72
|
return getDefaultReferenceMatchStrategy();// PreferencesUtil.getMatchStrategy(ReferenceBase.class);
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* <p>getDefaultNonViralNameMatchStrategy</p>
|
77
|
*
|
78
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
79
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
80
|
*/
|
81
|
public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
|
82
|
IMatchStrategy strategy = DefaultMatchStrategy.NewInstance(NonViralName.class);
|
83
|
|
84
|
strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
|
85
|
strategy.setMatchMode("combinationAuthorship", MatchMode.IGNORE);
|
86
|
strategy.setMatchMode("exCombinationAuthorship", MatchMode.IGNORE);
|
87
|
strategy.setMatchMode("basionymAuthorship", MatchMode.IGNORE);
|
88
|
strategy.setMatchMode("exBasionymAuthorship", MatchMode.IGNORE);
|
89
|
|
90
|
return strategy;
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* <p>getDefaultTeamOrPersonMatchStrategy</p>
|
95
|
*
|
96
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
97
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
98
|
*/
|
99
|
public static IMatchStrategy getDefaultTeamOrPersonMatchStrategy() throws MatchException{
|
100
|
IMatchStrategy strategy = DefaultMatchStrategy.NewInstance(TeamOrPersonBase.class);
|
101
|
|
102
|
return strategy;
|
103
|
}
|
104
|
|
105
|
|
106
|
/**
|
107
|
* <p>getDefaultReferenceMatchStrategy</p>
|
108
|
*
|
109
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
110
|
* @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
|
111
|
*/
|
112
|
public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
|
113
|
IMatchStrategy strategy = DefaultMatchStrategy.NewInstance(Reference.class);
|
114
|
|
115
|
strategy.setMatchMode("title", MatchMode.EQUAL);
|
116
|
strategy.setMatchMode("inReference", MatchMode.IGNORE);
|
117
|
|
118
|
return strategy;
|
119
|
}
|
120
|
|
121
|
|
122
|
}
|