Revision 933e5ac3
Added by Cherian Mathew about 9 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java | ||
---|---|---|
93 | 93 |
import eu.etaxonomy.cdm.model.media.Media; |
94 | 94 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
95 | 95 |
import eu.etaxonomy.cdm.model.media.MediaUtils; |
96 |
import eu.etaxonomy.cdm.model.molecular.Amplification; |
|
97 | 96 |
import eu.etaxonomy.cdm.model.molecular.AmplificationResult; |
98 | 97 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
99 | 98 |
import eu.etaxonomy.cdm.model.molecular.Sequence; |
... | ... | |
683 | 682 |
results = dao.getTaxaByNameForEditor(configurator.isDoTaxa(), configurator.isDoSynonyms(), configurator.isDoNamesWithoutTaxa(), configurator.isDoMisappliedNames(),configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
684 | 683 |
} |
685 | 684 |
if (configurator.isDoTaxaByCommonNames()) { |
686 |
|
|
685 |
|
|
687 | 686 |
if(configurator.getPageSize() == null ){ |
688 | 687 |
List<UuidAndTitleCache<IdentifiableEntity>> commonNameResults = dao.getTaxaByCommonNameForEditor(configurator.getTitleSearchStringSqlized(), configurator.getClassification(), configurator.getMatchMode(), configurator.getNamedAreas()); |
689 | 688 |
if(commonNameResults != null){ |
... | ... | |
991 | 990 |
*/ |
992 | 991 |
@Override |
993 | 992 |
public DeleteResult deleteTaxon(Taxon taxon, TaxonDeletionConfigurator config, Classification classification) { |
994 |
|
|
993 |
|
|
995 | 994 |
if (config == null){ |
996 | 995 |
config = new TaxonDeletionConfigurator(); |
997 | 996 |
} |
... | ... | |
1074 | 1073 |
" which also describes specimens or abservations"; |
1075 | 1074 |
//throw new ReferencedObjectUndeletableException(message); |
1076 | 1075 |
} |
1076 |
|
|
1077 | 1077 |
removeDescriptions.add(desc); |
1078 |
descriptionService.delete(desc); |
|
1078 |
|
|
1079 | 1079 |
|
1080 | 1080 |
} |
1081 | 1081 |
for (TaxonDescription desc: removeDescriptions){ |
1082 | 1082 |
taxon.removeDescription(desc); |
1083 |
descriptionService.delete(desc); |
|
1083 | 1084 |
} |
1084 | 1085 |
} |
1085 | 1086 |
|
... | ... | |
1194 | 1195 |
|
1195 | 1196 |
} |
1196 | 1197 |
|
1197 |
|
|
1198 |
|
|
1198 |
|
|
1199 |
|
|
1199 | 1200 |
if (nameResult.isError()){ |
1200 | 1201 |
//result.setError(); |
1201 | 1202 |
result.addRelatedObject(name); |
... | ... | |
1374 | 1375 |
return result; |
1375 | 1376 |
} |
1376 | 1377 |
|
1377 |
|
|
1378 |
|
|
1378 | 1379 |
} |
1379 | 1380 |
return result; |
1380 | 1381 |
// else{ |
... | ... | |
1390 | 1391 |
|
1391 | 1392 |
} |
1392 | 1393 |
|
1394 |
@Transactional(readOnly = false) |
|
1395 |
@Override |
|
1396 |
public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid, SynonymDeletionConfigurator config) { |
|
1397 |
Synonym synonym = HibernateProxyHelper.deproxy(dao.load(synonymUuid), Synonym.class); |
|
1398 |
Taxon taxon = HibernateProxyHelper.deproxy(dao.load(taxonUuid), Taxon.class); |
|
1399 |
return deleteSynonym(synonym, taxon, config); |
|
1400 |
} |
|
1393 | 1401 |
|
1394 | 1402 |
/* (non-Javadoc) |
1395 | 1403 |
* @see eu.etaxonomy.cdm.api.service.ITaxonService#findIdenticalTaxonNameIds(java.util.List) |
... | ... | |
3099 | 3107 |
if (!(ref instanceof TaxonNameBase)){ |
3100 | 3108 |
if (!config.isDeleteSynonymRelations() && (ref instanceof SynonymRelationship)){ |
3101 | 3109 |
message = "The Taxon can't be deleted as long as it has synonyms."; |
3102 |
|
|
3110 |
|
|
3103 | 3111 |
} |
3104 | 3112 |
if (!config.isDeleteDescriptions() && (ref instanceof DescriptionBase)){ |
3105 | 3113 |
message = "The Taxon can't be deleted as long as it has factual data."; |
3106 |
|
|
3114 |
|
|
3107 | 3115 |
} |
3108 | 3116 |
|
3109 | 3117 |
if (!config.isDeleteTaxonNodes() && (ref instanceof TaxonNode)){ |
3110 | 3118 |
message = "The Taxon can't be deleted as long as it belongs to a taxon node."; |
3111 |
|
|
3119 |
|
|
3112 | 3120 |
} |
3113 | 3121 |
if (!config.isDeleteTaxonRelationships() && (ref instanceof TaxonNode)){ |
3114 | 3122 |
if (!config.isDeleteMisappliedNamesAndInvalidDesignations() && (((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())|| ((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR()))){ |
3115 | 3123 |
message = "The Taxon can't be deleted as long as it has misapplied names or invalid designations."; |
3116 |
|
|
3124 |
|
|
3117 | 3125 |
} else{ |
3118 | 3126 |
message = "The Taxon can't be deleted as long as it belongs to a taxon node."; |
3119 |
|
|
3127 |
|
|
3120 | 3128 |
} |
3121 | 3129 |
} |
3122 | 3130 |
if (ref instanceof PolytomousKeyNode){ |
3123 | 3131 |
message = "The Taxon can't be deleted as long as it is referenced by a polytomous key node."; |
3124 |
|
|
3132 |
|
|
3125 | 3133 |
} |
3126 | 3134 |
|
3127 | 3135 |
if (HibernateProxyHelper.isInstanceOf(ref, IIdentificationKey.class)){ |
3128 | 3136 |
message = "Taxon can't be deleted as it is used in an identification key. Remove from identification key prior to deleting this name"; |
3129 |
|
|
3137 |
|
|
3130 | 3138 |
|
3131 | 3139 |
} |
3132 | 3140 |
|
... | ... | |
3140 | 3148 |
//TaxonInteraction |
3141 | 3149 |
if (ref.isInstanceOf(TaxonInteraction.class)){ |
3142 | 3150 |
message = "Taxon can't be deleted as it is used in taxonInteraction#taxon2"; |
3143 |
|
|
3151 |
|
|
3144 | 3152 |
} |
3145 | 3153 |
|
3146 | 3154 |
//TaxonInteraction |
3147 | 3155 |
if (ref.isInstanceOf(DeterminationEvent.class)){ |
3148 | 3156 |
message = "Taxon can't be deleted as it is used in a determination event"; |
3149 |
|
|
3157 |
|
|
3150 | 3158 |
} |
3151 | 3159 |
|
3152 | 3160 |
} |
... | ... | |
3286 | 3294 |
} |
3287 | 3295 |
return result; |
3288 | 3296 |
} |
3289 |
|
|
3297 |
|
|
3290 | 3298 |
@Override |
3291 | 3299 |
public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config){ |
3292 | 3300 |
List<TaxonBase> taxonList = dao.getTaxaByName(true, false, false, config.getTaxonNameTitle(), null, MatchMode.EXACT, null, 0, 0, config.getPropertyPath()); |
3293 | 3301 |
return taxonList; |
3294 | 3302 |
} |
3295 |
|
|
3303 |
|
|
3296 | 3304 |
@Override |
3297 | 3305 |
@Transactional(readOnly = true) |
3298 | 3306 |
public <S extends TaxonBase> Pager<FindByIdentifierDTO<S>> findByIdentifier( |
... | ... | |
3302 | 3310 |
if (subtreeFilter == null){ |
3303 | 3311 |
return findByIdentifier(clazz, identifier, identifierType, matchmode, includeEntity, pageSize, pageNumber, propertyPaths); |
3304 | 3312 |
} |
3305 |
|
|
3313 |
|
|
3306 | 3314 |
Integer numberOfResults = dao.countByIdentifier(clazz, identifier, identifierType, subtreeFilter, matchmode); |
3307 | 3315 |
List<Object[]> daoResults = new ArrayList<Object[]>(); |
3308 | 3316 |
if(numberOfResults > 0) { // no point checking again |
3309 | 3317 |
daoResults = dao.findByIdentifier(clazz, identifier, identifierType, subtreeFilter, |
3310 | 3318 |
matchmode, includeEntity, pageSize, pageNumber, propertyPaths); |
3311 | 3319 |
} |
3312 |
|
|
3320 |
|
|
3313 | 3321 |
List<FindByIdentifierDTO<S>> result = new ArrayList<FindByIdentifierDTO<S>>(); |
3314 | 3322 |
for (Object[] daoObj : daoResults){ |
3315 | 3323 |
if (includeEntity){ |
3316 | 3324 |
result.add(new FindByIdentifierDTO<S>((DefinedTerm)daoObj[0], (String)daoObj[1], (S)daoObj[2])); |
3317 | 3325 |
}else{ |
3318 |
result.add(new FindByIdentifierDTO<S>((DefinedTerm)daoObj[0], (String)daoObj[1], (UUID)daoObj[2], (String)daoObj[3]));
|
|
3326 |
result.add(new FindByIdentifierDTO<S>((DefinedTerm)daoObj[0], (String)daoObj[1], (UUID)daoObj[2], (String)daoObj[3])); |
|
3319 | 3327 |
} |
3320 | 3328 |
} |
3321 | 3329 |
return new DefaultPagerImpl<FindByIdentifierDTO<S>>(pageNumber, numberOfResults, pageSize, result); |
Also available in: Unified diff
ICdmCacher, ICdmUuidCacher, CdmCacher, CdmTermCacher : refactored and added load method
Language, NameRelationshipType, Rank : now uses cacher only if termap is null or empty and only when class matches the specific term type
MockCdmCacher: not required anymore
DefaultTermInitializer : removed acall to mock cacher
MatchStrategyConfigurator : moved from editor to cdmlib
CdmDataChangeEvent : added constructor
CommonServiceImpl, ICommonService : added call to findMatchingStrategy with enum instead of object
DescriptionServiceImpl, IDescriptionService, PolytomousKeyNodeServiceImpl, IPolytomousKeyNodeService, TaxonNodeServiceImpl, ITaxonNodeService, TaxonServiceImpl: added uuid methods