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