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