Merge branch 'release/5.3.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / parser / MatchStrategyConfigurator.java
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.taxeditor.parser;
11
12 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
13 import eu.etaxonomy.cdm.model.name.TaxonName;
14 import eu.etaxonomy.cdm.model.reference.Reference;
15 import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
16 import eu.etaxonomy.cdm.strategy.match.MatchException;
17 import eu.etaxonomy.cdm.strategy.match.MatchMode;
18 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19
20 /**
21 * This class defines the MatchStrategies that will be used by the ParseHandler.
22 *
23 * @author n.hoffmann
24 * @created Jan 22, 2010
25 * @version 1.0
26 */
27 public class MatchStrategyConfigurator {
28
29 /**
30 * <p>NonViralNameMatchStrategy</p>
31 *
32 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
33 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
34 */
35 public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
36 return getDefaultNonViralNameMatchStrategy();// PreferencesUtil.getMatchStrategy(NonViralName.class);
37 }
38
39 /**
40 * <p>TeamOrPersonMatchStrategy</p>
41 *
42 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
43 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
44 */
45 public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
46 return PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
47 }
48
49 /**
50 * <p>ReferenceMatchStrategy</p>
51 *
52 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
53 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
54 */
55 public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
56 return getDefaultReferenceMatchStrategy();// PreferencesUtil.getMatchStrategy(ReferenceBase.class);
57 }
58
59 /**
60 * <p>getDefaultNonViralNameMatchStrategy</p>
61 *
62 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
63 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
64 */
65 public static IMatchStrategy getDefaultNonViralNameMatchStrategy() throws MatchException{
66 IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(TaxonName.class);
67
68 strategy.setMatchMode("nomenclaturalReference", MatchMode.IGNORE);
69 strategy.setMatchMode("combinationAuthorship", MatchMode.IGNORE);
70 strategy.setMatchMode("exCombinationAuthorship", MatchMode.IGNORE);
71 strategy.setMatchMode("basionymAuthorship", MatchMode.IGNORE);
72 strategy.setMatchMode("exBasionymAuthorship", MatchMode.IGNORE);
73
74 return strategy;
75 }
76
77 /**
78 * <p>getDefaultTeamOrPersonMatchStrategy</p>
79 *
80 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
81 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
82 */
83 public static IMatchStrategy getDefaultTeamOrPersonMatchStrategy() throws MatchException{
84 IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(TeamOrPersonBase.class);
85
86 return strategy;
87 }
88
89
90 /**
91 * <p>getDefaultReferenceMatchStrategy</p>
92 *
93 * @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
94 * @throws eu.etaxonomy.cdm.strategy.match.MatchException if any.
95 */
96 public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
97 IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(Reference.class);
98
99 strategy.setMatchMode("title", MatchMode.EQUAL);
100 strategy.setMatchMode("inReference", MatchMode.IGNORE);
101
102 return strategy;
103 }
104
105 /**
106 * <p>setMatchStrategy</p>
107 *
108 * @param matchStrategy a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
109 */
110 public static void setMatchStrategy(IMatchStrategy matchStrategy) {
111 PreferencesUtil.setMatchStrategy(matchStrategy);
112 }
113
114 }