Project

General

Profile

Revision e6814896

IDe68148967690a9b21817cc2cf9341771b678fdfe
Parent 4bdeb27e
Child 81d4cb59

Added by Andreas Müller over 7 years ago

fix missing idInVocabulary for countries; implement country mapping for EditGeoService (#3452, #3651)

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITermService.java
153 153
     * @return DeleteResult which holds the status of the deletion.
154 154
     */
155 155
    public DeleteResult delete(DefinedTermBase term, TermDeletionConfigurator config);
156

  
157
	/**
158
	 * Returns the term with the given idInVocabulary for the given vocabulary.
159
	 * @param id idInVocabulary
160
	 * @param vocabularyUuid uuid of vocabulary
161
	 * @param clazz term clazz
162
	 * @param pageSize page size
163
	 * @param pageNumber page number
164
	 * @return the term
165
	 */
166
	public <TERM extends DefinedTermBase> TERM getDefinedTermByIdInVocabulary(String id, UUID vocabularyUuid,
167
			Class<TERM> clazz, Integer pageSize, Integer pageNumber);
156 168
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TermServiceImpl.java
79 79
	protected void setDao(IDefinedTermDao dao) {
80 80
		this.dao = dao;
81 81
	}
82
		
82

  
83
	
84
	@Override
83 85
	public <TERM extends DefinedTermBase> List<TERM> listByTermClass(Class<TERM> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
84 86
		return dao.listByTermClass(clazz, limit, start, orderHints, propertyPaths);
85 87
	}	
86 88
	
87
	/**
88
	 * @see eu.etaxonomy.cdm.api.service.ITermService#getTermByUri(java.net.URI)
89
	 */
89
	@Override
90 90
	public DefinedTermBase getByUri(URI uri) {
91 91
		return dao.findByUri(uri);
92 92
	}
93 93
	
94
	@Override
94 95
	public Language getLanguageByIso(String iso639) {
95 96
		return dao.getLanguageByIso(iso639);
96 97
	}
97 98
	
99
	@Override
98 100
	public List<Language> getLanguagesByLocale(Enumeration<Locale> locales){
99 101
		return dao.getLanguagesByLocale(locales);
100 102
	}
101 103

  
102
	/**
103
	 *  (non-Javadoc)
104
	 * @see eu.etaxonomy.cdm.api.service.ITermService#getAreaByTdwgAbbreviation(java.lang.String)
105
	 */
104
	@Override
105
	public <TERM extends DefinedTermBase> TERM getDefinedTermByIdInVocabulary(String id, UUID vocabularyUuid, Class<TERM> clazz, Integer pageSize, Integer pageNumber) {
106
		List<TERM> list = dao.getDefinedTermByIdInVocabulary(id, vocabularyUuid, clazz, pageSize, pageNumber);
107
		if (list.isEmpty()){
108
			return null;
109
		}else if (list.size() == 1){
110
			return list.get(0);
111
		}else{
112
			String message = "There is more then 1 (%d) term with the same id in vocabulary. This is forbidden. Check the state of your database.";
113
			throw new IllegalStateException(String.format(message, list.size()));
114
		}
115
	}
116
	
117

  
118
	@Override
106 119
	public NamedArea getAreaByTdwgAbbreviation(String tdwgAbbreviation) {
107 120
		if (StringUtils.isBlank(tdwgAbbreviation)){ //TDWG areas should always have a label
108 121
			return null;
......
119 132
		
120 133
	}
121 134

  
135
	@Override
122 136
	public <T extends DefinedTermBase> Pager<T> getGeneralizationOf(T definedTerm, Integer pageSize, Integer pageNumber) {
123 137
        Integer numberOfResults = dao.countGeneralizationOf(definedTerm);
124 138
		
......
130 144
		return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
131 145
	}
132 146

  
147
	@Override
133 148
	public <T extends DefinedTermBase> Pager<T> getIncludes(Set<T> definedTerms, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
134 149
        Integer numberOfResults = dao.countIncludes(definedTerms);
135 150
		
......
141 156
		return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
142 157
	}
143 158

  
159
	@Override
144 160
	public Pager<Media> getMedia(DefinedTermBase definedTerm, Integer pageSize,	Integer pageNumber) {
145 161
        Integer numberOfResults = dao.countMedia(definedTerm);
146 162
		
......
152 168
		return new DefaultPagerImpl<Media>(pageNumber, numberOfResults, pageSize, results);
153 169
	}
154 170

  
171
	@Override
155 172
	public <T extends DefinedTermBase> Pager<T> getPartOf(Set<T> definedTerms,Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
156 173
        Integer numberOfResults = dao.countPartOf(definedTerms);
157 174
		
......
163 180
		return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
164 181
	}
165 182

  
183
	@Override
166 184
	public Pager<NamedArea> list(NamedAreaLevel level, NamedAreaType type, Integer pageSize, Integer pageNumber,
167 185
			List<OrderHint> orderHints, List<String> propertyPaths) {
168 186
		Integer numberOfResults = dao.count(level, type);
......
175 193
		return new DefaultPagerImpl<NamedArea>(pageNumber, numberOfResults, pageSize, results);
176 194
	}
177 195

  
196
	@Override
178 197
	public <T extends DefinedTermBase> Pager<T> findByRepresentationText(String label, Class<T> clazz, Integer pageSize, Integer pageNumber) {
179 198
        Integer numberOfResults = dao.countDefinedTermByRepresentationText(label,clazz);
180 199
		
......
186 205
		return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
187 206
	}
188 207
	
208
	@Override
189 209
	public <T extends DefinedTermBase> Pager<T> findByRepresentationAbbreviation(String abbrev, Class<T> clazz, Integer pageSize, Integer pageNumber) {
190 210
        Integer numberOfResults = dao.countDefinedTermByRepresentationAbbrev(abbrev,clazz);
191 211
		
......
197 217
		return new DefaultPagerImpl<T>(pageNumber, numberOfResults, pageSize, results);
198 218
	}
199 219

  
220
	@Override
200 221
	public List<LanguageString> getAllLanguageStrings(int limit, int start) {
201 222
		return languageStringDao.list(limit, start);
202 223
	}
203 224

  
225
	@Override
204 226
	public List<Representation> getAllRepresentations(int limit, int start) {
205 227
		return representationDao.list(limit,start);
206 228
	}
207 229

  
230
	@Override
208 231
	public UUID saveLanguageData(LanguageStringBase languageData) {
209 232
		return languageStringBaseDao.save(languageData);
210 233
	}
......
214 237
	 */
215 238
	/** @deprecated use {@link #delete(DefinedTermBase, TermDeletionConfigurator)} instead
216 239
	 * to allow DeleteResult return type*/
240
	@Override
217 241
	@Deprecated
218 242
	public UUID delete(DefinedTermBase term){
219 243
		UUID result = term.getUuid();
......
353 377
		return result;
354 378
	}
355 379

  
356

  
357
	/* (non-Javadoc)
358
	 * @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
359
	 */
360 380
	@Override
361 381
	@Transactional(readOnly = false)
362 382
    public void updateTitleCache(Class<? extends DefinedTermBase> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<DefinedTermBase> cacheStrategy, IProgressMonitor monitor) {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)