Merge branch 'release/5.18.0'
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / dto / TaxonRelationshipsDTO.java
index 8b899d5fc9e7ec89dbc2912be6fa183179fbfe04..a1e34ba00db20913b2af1385fd420a8ccad5e222 100644 (file)
@@ -19,10 +19,10 @@ import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.format.taxon.TaxonRelationshipFormatter;
 import eu.etaxonomy.cdm.model.common.Language;
 import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
-import eu.etaxonomy.cdm.model.common.Representation;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.cdm.model.term.Representation;
 import eu.etaxonomy.cdm.persistence.dto.TermDto;
 import eu.etaxonomy.cdm.strategy.cache.TagEnum;
 import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
@@ -63,13 +63,12 @@ public class TaxonRelationshipsDTO {
             TaxonRelationshipType relType = relation.getType();
 
             if (relType != null){
-                this.misapplication = relType.isMisappliedNameOrInvalidDesignation();
+                this.misapplication = relType.isMisappliedName();
                 this.synonym = relType.isAnySynonym();
                 this.typeUuid = relType.getUuid();
 //                TODO there must be a better DTO which also includes
                 Set<Representation> representations = direction.isDirect() ? relType.getRepresentations() : relType.getInverseRepresentations();
-                UUID vocUuid = relType.getVocabulary() != null ? relType.getVocabulary().getUuid(): null;
-                TermDto termDto = new TermDto(relType.getUuid(), representations, null, vocUuid, relType.getOrderIndex());
+                TermDto termDto = TermDto.fromTerm(relType, representations);
                 this.type = termDto;
 //                TODO localize
 //                termDto.localize(representation_L10n);
@@ -190,20 +189,12 @@ public class TaxonRelationshipsDTO {
         relations.add(relation);
     }
 
-    /**
-     * @param relation
-     * @param direction
-     */
     public TaxonRelationDTO addRelation(TaxonRelationship relation, Direction direction, List<Language> languages) {
         TaxonRelationDTO newRelation = new TaxonRelationDTO(relation, direction, languages);
         relations.add(newRelation);
         return newRelation;
     }
 
-
-    /**
-     *
-     */
     public void createMisapplicationString() {
         List<List<TaggedText>> result = new ArrayList<>();
 
@@ -273,10 +264,6 @@ public class TaxonRelationshipsDTO {
         }
     }
 
-    /**
-     * @param taggedText
-     * @return
-     */
     private boolean tagIsSensu(TaggedText tag) {
         if (tag.getType() == TagEnum.secReference ||
                 tag.getType() == TagEnum.secMicroReference ||
@@ -286,10 +273,6 @@ public class TaxonRelationshipsDTO {
         return false;
     }
 
-    /**
-     * @param tag
-     * @return
-     */
     private boolean isSensuSeparator(TaggedText tag) {
         if (SENSU_SEPARATOR.equals(tag.getText())
                 && tag.getType() == TagEnum.separator) {
@@ -298,11 +281,6 @@ public class TaxonRelationshipsDTO {
         return false;
     }
 
-    /**
-     * @param x
-     * @param y
-     * @return
-     */
     private boolean tagEqualsMisapplied(TaggedText x, TaggedText y) {
         if (CdmUtils.nullSafeEqual(x.getText(),y.getText())
                 && x.getType().equals(y.getType())
@@ -347,19 +325,10 @@ public class TaxonRelationshipsDTO {
         return result;
     }
 
-    /**
-     * @return the misapplications
-     */
     public List<List<TaggedText>> getMisapplications() {
         return misapplications;
     }
-
-    /**
-     * @param misapplications the misapplications to set
-     */
     public void setMisapplications(List<List<TaggedText>> misapplications) {
         this.misapplications = misapplications;
     }
-
-
 }