Revision 892efc69
Added by Andreas Kohlbecker almost 14 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java | ||
---|---|---|
14 | 14 |
import java.util.Collections; |
15 | 15 |
import java.util.Comparator; |
16 | 16 |
import java.util.HashSet; |
17 |
import java.util.Iterator; |
|
17 | 18 |
import java.util.List; |
18 | 19 |
import java.util.Set; |
19 | 20 |
import java.util.UUID; |
... | ... | |
32 | 33 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
33 | 34 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
34 | 35 |
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache; |
35 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
|
36 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
|
36 |
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction; |
|
37 | 37 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
38 | 38 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
39 | 39 |
import eu.etaxonomy.cdm.model.media.Media; |
40 | 40 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
41 |
import eu.etaxonomy.cdm.model.media.MediaUtils; |
|
41 | 42 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
42 | 43 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
43 | 44 |
import eu.etaxonomy.cdm.model.name.Rank; |
... | ... | |
250 | 251 |
for(TaxonDescription oldDescription : oldTaxon.getDescriptions()){ |
251 | 252 |
|
252 | 253 |
TaxonDescription newDescription = TaxonDescription.NewInstance(newAcceptedTaxon); |
253 |
newDescription.setTitleCache("Description copied from " + oldTaxon + ". Old title: " + oldDescription.getTitleCache()); |
|
254 |
newDescription.setTitleCache("Description copied from " + oldTaxon + ". Old title: " + oldDescription.getTitleCache(), true);
|
|
254 | 255 |
|
255 | 256 |
for(DescriptionElementBase element : oldDescription.getElements()){ |
256 | 257 |
newDescription.addElement(element); |
... | ... | |
275 | 276 |
// store the synonyms name |
276 | 277 |
TaxonNameBase newAcceptedTaxonName = synonym.getName(); |
277 | 278 |
|
279 |
Set<SynonymRelationship> synrels = acceptedTaxon.getSynonymRelations(); |
|
280 |
Iterator<SynonymRelationship> synRelIterator = synrels.iterator(); |
|
281 |
SynonymRelationshipType type = null; |
|
282 |
while (synRelIterator.hasNext()){ |
|
283 |
SynonymRelationship synRel = synRelIterator.next(); |
|
284 |
if (synRel.getSynonym().equals(synonym)){ |
|
285 |
type = synRel.getType(); |
|
286 |
break; |
|
287 |
} |
|
288 |
} |
|
289 |
|
|
278 | 290 |
// remove synonym from oldAcceptedTaxon |
279 | 291 |
acceptedTaxon.removeSynonym(synonym); |
280 | 292 |
|
281 | 293 |
// make synonym name the accepted taxons name |
282 | 294 |
acceptedTaxon.setName(newAcceptedTaxonName); |
295 |
synonym.setName(oldAcceptedTaxonName); |
|
283 | 296 |
|
284 | 297 |
// add the new synonym to the acceptedTaxon |
285 | 298 |
if(synonymRelationshipType == null){ |
286 |
synonymRelationshipType = SynonymRelationshipType.SYNONYM_OF(); |
|
299 |
//synonymRelationshipType = SynonymRelationshipType.SYNONYM_OF(); |
|
300 |
synonymRelationshipType = type; |
|
301 |
} |
|
302 |
if (type.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())){ |
|
303 |
acceptedTaxon.addHomotypicSynonym(synonym, null, null); |
|
304 |
}else{ |
|
305 |
acceptedTaxon.addSynonymName(oldAcceptedTaxonName, synonymRelationshipType); |
|
287 | 306 |
} |
288 |
|
|
289 |
acceptedTaxon.addSynonymName(oldAcceptedTaxonName, synonymRelationshipType); |
|
290 | 307 |
} |
308 |
|
|
291 | 309 |
|
292 | 310 |
/* |
293 | 311 |
* (non-Javadoc) |
... | ... | |
438 | 456 |
long numberTaxaResults = 0L; |
439 | 457 |
|
440 | 458 |
Class<? extends TaxonBase> clazz = null; |
459 |
List<String> propertyPath = new ArrayList<String>(); |
|
460 |
propertyPath.addAll(configurator.getTaxonPropertyPath()); |
|
441 | 461 |
if ((configurator.isDoTaxa() && configurator.isDoSynonyms())) { |
442 | 462 |
clazz = TaxonBase.class; |
463 |
//propertyPath.addAll(configurator.getTaxonPropertyPath()); |
|
464 |
//propertyPath.addAll(configurator.getSynonymPropertyPath()); |
|
443 | 465 |
} else if(configurator.isDoTaxa()) { |
444 | 466 |
clazz = Taxon.class; |
467 |
//propertyPath = configurator.getTaxonPropertyPath(); |
|
445 | 468 |
} else if (configurator.isDoSynonyms()) { |
446 | 469 |
clazz = Synonym.class; |
470 |
//propertyPath = configurator.getSynonymPropertyPath(); |
|
447 | 471 |
} |
448 | 472 |
|
449 | 473 |
if(clazz != null){ |
... | ... | |
455 | 479 |
taxa = dao.getTaxaByName(clazz, |
456 | 480 |
configurator.getSearchString(), configurator.getTaxonomicTree(), configurator.getMatchMode(), |
457 | 481 |
configurator.getNamedAreas(), configurator.getPageSize(), |
458 |
configurator.getPageNumber(), configurator.getTaxonPropertyPath());
|
|
482 |
configurator.getPageNumber(), propertyPath);
|
|
459 | 483 |
} |
460 | 484 |
} |
461 | 485 |
|
... | ... | |
503 | 527 |
|
504 | 528 |
} |
505 | 529 |
|
506 |
|
|
507 |
//FIXME does not work any more after model change |
|
508 |
logger.warn("Sort does currently not work on identifiable entities due to model changes (duplicated implementation of the Comparable interface)."); |
|
509 |
//Collections.sort(results); |
|
510 |
return new DefaultPagerImpl<IdentifiableEntity> |
|
530 |
return new DefaultPagerImpl<IdentifiableEntity> |
|
511 | 531 |
(configurator.getPageNumber(), numberOfResults, configurator.getPageSize(), results); |
512 | 532 |
} |
513 | 533 |
|
... | ... | |
525 | 545 |
for(Media media : descElem.getMedia()){ |
526 | 546 |
|
527 | 547 |
//find the best matching representation |
528 |
medRep.add(media.findBestMatchingRepresentation(size, height, widthOrDuration, mimeTypes));
|
|
548 |
medRep.add(MediaUtils.findBestMatchingRepresentation(media, size, height, widthOrDuration, mimeTypes));
|
|
529 | 549 |
|
530 | 550 |
} |
531 | 551 |
} |
... | ... | |
557 | 577 |
return this.dao.findIdenticalTaxonNames(propertyPath); |
558 | 578 |
} |
559 | 579 |
|
580 |
public List<TaxonNameBase> findIdenticalTaxonNameIds(List<String> propertyPath) { |
|
581 |
|
|
582 |
return this.dao.findIdenticalNamesNew(propertyPath); |
|
583 |
} |
|
584 |
|
|
560 | 585 |
public String getPhylumName(TaxonNameBase name){ |
561 | 586 |
return this.dao.getPhylumName(name); |
562 | 587 |
} |
... | ... | |
570 | 595 |
} |
571 | 596 |
|
572 | 597 |
} |
598 |
|
|
599 |
public long deleteSynonymRelationships(Synonym syn) { |
|
600 |
|
|
601 |
return dao.deleteSynonymRelationships(syn); |
|
602 |
} |
|
603 |
|
|
604 |
|
|
605 |
public List<SynonymRelationship> listSynonymRelationships( |
|
606 |
TaxonBase taxonBase, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, |
|
607 |
List<OrderHint> orderHints, List<String> propertyPaths, Direction direction) { |
|
608 |
Integer numberOfResults = dao.countSynonymRelationships(taxonBase, type, direction); |
|
609 |
|
|
610 |
List<SynonymRelationship> results = new ArrayList<SynonymRelationship>(); |
|
611 |
if(numberOfResults > 0) { // no point checking again |
|
612 |
results = dao.getSynonymRelationships(taxonBase, type, pageSize, pageNumber, orderHints, propertyPaths, direction); |
|
613 |
} |
|
614 |
return results; |
|
615 |
} |
|
573 | 616 |
} |
Also available in: Unified diff
merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk