Project

General

Profile

Revision 72c9224a

ID72c9224a508dfe86cb784042c7af33c1220f5ca5
Parent bd864794
Child ba5dcea5

Added by Andreas Müller about 1 year ago

ref #7334 add convenience methods for pro parte and partial synonym to Taxon and TaxonRelationshipType

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java
992 992
        return taxa;
993 993
    }
994 994

  
995
//***************************** Synonyms ******************************************************/
996

  
995 997
    /*
996 998
     * PRO PARTE SYNONYMS
997 999
     */
......
1019 1021

  
1020 1022

  
1021 1023

  
1022
    /*
1023
     * DEALING WITH SYNONYMS
1024
    /**
1025
     * Returns the set of pro parte or partial synonym relationships in which this taxon
1026
     * plays the role of the "correctly" accepted taxon (target).
1027
     *
1028
     * @see #getProParteAndPartialSynonyms()
1029
     * @see #getMisappliedNameRelations()
1024 1030
     */
1031
    @Transient
1032
    public Set<TaxonRelationship> getProParteAndPartialSynonymRelations(){
1033
        Set<TaxonRelationship> result = new HashSet<>();
1034
        Set<TaxonRelationship> rels = this.getRelationsToThisTaxon();
1035
        for (TaxonRelationship rel: rels){
1036
            TaxonRelationshipType relType = rel.getType();
1037
            if (relType.isAnySynonym()){
1038
                result.add(rel);
1039
            }
1040
        }
1041
        return result;
1042
    }
1043

  
1025 1044
    /**
1026
     * Returns the set of all {@link Synonym synonyms} of <i>this</i> ("accepted/valid") taxon
1027
     * sorted by the different {@link SynonymType categories}.
1028
      *
1029
     * @see    #getSynonyms()
1030
     * @see    #getSynonymNames()
1031
     * @see    #addSynonym(Synonym, SynonymType)
1032
     * @see    #addSynonym(Synonym, SynonymType, Reference, String)
1033
     * @see    #removeSynonym(Synonym)
1034
     * @deprecated not yet implemented
1045
     * Returns the set of pro parte or partial synonyms in which this taxon
1046
     * plays the role of the "correctly" accepted taxon (target).
1047
     *
1048
     * @see #getProParteAndPartialSynonymRelations()
1049
     * @see #getMisappliedNames(boolean)
1035 1050
     */
1036 1051
    @Transient
1037
    @Deprecated
1038
    public Set<Synonym> getSynonymsSortedByType(){
1039
        // FIXME: need to sort synonyms according to type!!!
1040
        logger.warn("getSynonymsSortedByType() not yet implemented");
1041
        return getSynonyms();
1052
    public Set<Taxon> getProParteAndPartialSynonyms(){
1053
        Set<Taxon> synonyms = new HashSet<>();
1054
        Set<TaxonRelationship> rels = this.getProParteAndPartialSynonymRelations();
1055
        for (TaxonRelationship rel: rels){
1056
            synonyms.add(rel.getFromTaxon());
1057
        }
1058
        return synonyms;
1042 1059
    }
1060

  
1043 1061
    /**
1044 1062
     * Returns the set of all {@link TaxonName taxon names} used as {@link Synonym synonyms}
1045 1063
     * of <i>this</i> ("accepted/valid") taxon.
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonRelationshipType.java
188 188
        return (allMisappliedNameTypes().contains(this));
189 189
    }
190 190

  
191

  
192
    /**
193
     * <code>true</code> if this relationship type is any
194
     * of the pro parte or partial synonym relationship types
195
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PARTIAL_SYNONYM_FOR()}
196
     *
197
     * @see #isAnyMisappliedName()
198
     */
199
    public boolean isAnySynonym(){
200
        return (allSynonymTypes().contains(this));
201
    }
202

  
203
    /**
204
     * <code>true</code> if this relationship type is either
205
     * a pro parte synonym or a pro parte misapplied name relationship type
206
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PRO_PARTE_MISAPPLIED_NAME_FOR}
207
     */
208
    public boolean isProParte(){
209
        return (allProParteTypes().contains(this));
210
    }
211

  
212
    /**
213
     * <code>true</code> if this relationship type is either
214
     * a partial synonym or a partial misapplied name relationship type
215
     * {@link #PARTIAL_SYNONYM_FOR()} or {@link #PARTIAL_MISAPPLIED_NAME_FOR}
216
     *
217
     * @see #isProParte()
218
     */
219
    public boolean isPartial(){
220
        return (allPartialTypes().contains(this));
221
    }
222

  
191 223
    /**
192 224
     * Returns a list of all misapplied name relationship
193 225
     * types such as "misapplied name for" and
......
200 232
        Set<TaxonRelationshipType> result = new HashSet<>();
201 233
        result.add(MISAPPLIED_NAME_FOR());
202 234
        result.add(PRO_PARTE_MISAPPLIED_NAME_FOR());
235
        result.add(PARTIAL_MISAPPLIED_NAME_FOR());
236
        return result;
237
    }
238

  
239
    public static Set<TaxonRelationshipType> allSynonymTypes(){
240
        Set<TaxonRelationshipType> result = new HashSet<>();
241
        result.add(PRO_PARTE_SYNONYM_FOR());
242
        result.add(PARTIAL_SYNONYM_FOR());
243
        return result;
244
    }
245

  
246
    public static Set<TaxonRelationshipType> allProParteTypes(){
247
        Set<TaxonRelationshipType> result = new HashSet<>();
248
        result.add(PRO_PARTE_SYNONYM_FOR());
249
        result.add(PRO_PARTE_MISAPPLIED_NAME_FOR());
203 250
        return result;
204 251
    }
205 252

  
253
    public static Set<TaxonRelationshipType> allPartialTypes(){
254
        Set<TaxonRelationshipType> result = new HashSet<>();
255
        result.add(PARTIAL_SYNONYM_FOR());
256
        result.add(PARTIAL_MISAPPLIED_NAME_FOR());
257
        return result;
258
    }
206 259

  
207 260

  
208 261
	/**

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)