Revision caaaa636
Added by Niels Hoffmann over 12 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermStore.java | ||
---|---|---|
42 | 42 |
*/ |
43 | 43 |
public class TermStore { |
44 | 44 |
|
45 |
/** |
|
46 |
* Returns an alphabetically sorted list of terms (anything that extends {@link DefinedTermBase}) of the given type currently available in the system. |
|
47 |
* |
|
48 |
* @param clazz a class that inherits from {@link DefinedTermBase} |
|
49 |
* @return an alphabetically sorted list of terms |
|
50 |
*/ |
|
45 | 51 |
public static <TERM extends DefinedTermBase> List<TERM> getTerms(Class<TERM> clazz){ |
46 | 52 |
return getTerms(clazz, null, true); |
47 | 53 |
} |
... | ... | |
51 | 57 |
* If <code>filtered</code> is set to <code>true</code>, all terms for certain types will be |
52 | 58 |
* gathered from edge cases. |
53 | 59 |
* |
54 |
* @param clazz |
|
55 |
* @param comparator |
|
56 |
* @param filtered Will filter out some results
|
|
57 |
* @return |
|
60 |
* @param clazz a class that inherits from {@link DefinedTermBase}
|
|
61 |
* @param comparator a {@link Comparator} that defines the sorting algorithm. If set to null, {@link DefaultTermComparator} will be used
|
|
62 |
* @param filtered if set to true, some terms are filtered from the result (according to definition in {@link ITermStoreEdgeCase}s)
|
|
63 |
* @return a sorted list of terms
|
|
58 | 64 |
*/ |
59 | 65 |
public static <TERM extends DefinedTermBase> List<TERM> getTerms(Class<TERM> clazz, Comparator<TERM> comparator, boolean filtered){ |
60 | 66 |
List<TERM> terms = new ArrayList<TERM>(); |
... | ... | |
70 | 76 |
|
71 | 77 |
} |
72 | 78 |
|
79 |
/** |
|
80 |
* |
|
81 |
* @param termClass |
|
82 |
* @param comparator |
|
83 |
* @return |
|
84 |
*/ |
|
73 | 85 |
private static <T extends DefinedTermBase> List<T> getTermsFromService(Class<T> termClass, Comparator<T> comparator){ |
74 | 86 |
if (comparator == null){ |
75 | 87 |
comparator = new DefaultTermComparator<T>(); |
... | ... | |
80 | 92 |
return terms; |
81 | 93 |
} |
82 | 94 |
|
83 |
// /** |
|
84 |
// * <p>getFeatures</p> |
|
85 |
// * |
|
86 |
// * @return a {@link java.util.List} object. |
|
87 |
// */ |
|
88 |
// public static List<Feature> getFeatures() { |
|
89 |
// List<Feature> features = getTerms(Feature.class); |
|
90 |
// features.remove(Feature.IMAGE()); |
|
91 |
// return features; |
|
92 |
// |
|
93 |
// } |
|
94 |
// |
|
95 |
// |
|
96 |
// /** |
|
97 |
// * <p>getNonTechnicalMarkerTypes</p> |
|
98 |
// * |
|
99 |
// * @return a {@link java.util.List} object. |
|
100 |
// */ |
|
101 |
// public static List<MarkerType> getNonTechnicalMarkerTypes() { |
|
102 |
// List<MarkerType> nonTechnicalMarkerTypes = new ArrayList<MarkerType>(); |
|
103 |
// List<MarkerType> markerTypes = getTerms(MarkerType.class); |
|
104 |
// |
|
105 |
// for (Object type : markerTypes) { |
|
106 |
// if (((MarkerType) type).isTechnical() == false) { |
|
107 |
// nonTechnicalMarkerTypes.add((MarkerType) type); |
|
108 |
// } |
|
109 |
// } |
|
110 |
// |
|
111 |
// return nonTechnicalMarkerTypes; |
|
112 |
// } |
|
113 |
// |
|
114 |
// /** |
|
115 |
// * Retrieve all ranks from data store. |
|
116 |
// * |
|
117 |
// * @return a {@link java.util.List} object. |
|
118 |
// */ |
|
119 |
// public static List<Rank> getRanks(){ |
|
120 |
// if(PreferencesUtil.getSortRanksHierarchichally()){ |
|
121 |
// return getTerms(Rank.class, new Comparator<Rank>(){ |
|
122 |
// |
|
123 |
// @Override |
|
124 |
// public int compare(Rank o1, Rank o2) { |
|
125 |
// return o1.compareTo(o2); |
|
126 |
// } |
|
127 |
// |
|
128 |
// }); |
|
129 |
// }else{ |
|
130 |
// return getTerms(Rank.class); |
|
131 |
// } |
|
132 |
// } |
|
133 |
// |
|
134 |
// |
|
135 |
// /** |
|
136 |
// * Retrieve all presence and absence terms from data store. |
|
137 |
// * |
|
138 |
// * @return a {@link java.util.List} object. |
|
139 |
// */ |
|
140 |
// public static List<PresenceAbsenceTermBase> getPresenceAbsenceTerms() { |
|
141 |
// List presenceAbsenceTerms = getTerms(PresenceTerm.class); |
|
142 |
// presenceAbsenceTerms.addAll(getTerms(AbsenceTerm.class)); |
|
143 |
// |
|
144 |
// return presenceAbsenceTerms; |
|
145 |
// } |
|
146 |
|
|
147 | 95 |
/** |
148 | 96 |
* @param term a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase} object. |
149 | 97 |
*/ |
... | ... | |
168 | 116 |
public static void updateVocabulary(DefinedTermBase term) { |
169 | 117 |
CdmStore.getService(ITermService.class).saveOrUpdate(term); |
170 | 118 |
} |
119 |
|
|
120 |
/** |
|
121 |
* Handingling of special cases |
|
122 |
*/ |
|
171 | 123 |
|
172 | 124 |
private static Set<ITermStoreEdgeCase<? extends DefinedTermBase>> termStoreEdgeCases = new HashSet<ITermStoreEdgeCase<? extends DefinedTermBase>>(); |
173 | 125 |
|
Also available in: Unified diff
Added documentation