Project

General

Profile

Revision de9aa4e6

IDde9aa4e6a4c1d00d40f40407390d302b5ea09bfc
Parent d6de6988
Child 5c05e409

Added by Katja Luther over 2 years ago

add createsynonym method to service

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITaxonService.java
949 949
    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
950 950
            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
951 951

  
952
    /**
953
     * @param acceptedTaxonUuid
954
     * @param newName
955
     * @param type
956
     * @return
957
     */
958
    UpdateResult createSynonym(UUID acceptedTaxonUuid, Synonym synonym);
959

  
960

  
961

  
952 962

  
953 963

  
954 964
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonNodeServiceImpl.java
47 47
import eu.etaxonomy.cdm.model.common.TreeIndex;
48 48
import eu.etaxonomy.cdm.model.description.TaxonDescription;
49 49
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
50
import eu.etaxonomy.cdm.model.name.HybridRelationship;
50 51
import eu.etaxonomy.cdm.model.name.TaxonName;
51 52
import eu.etaxonomy.cdm.model.reference.Reference;
52 53
import eu.etaxonomy.cdm.model.taxon.Classification;
......
747 748
        if (newTaxon.getName().getId() != 0){
748 749
            TaxonName name = nameService.load(newTaxon.getName().getUuid());
749 750
            newTaxon.setName(name);
751
        }else{
752
            for (HybridRelationship rel : newTaxon.getName().getHybridChildRelations()){
753
                if (!rel.getHybridName().isPersited()) {
754
                    nameService.save(rel.getHybridName());
755
                }
756
                if (!rel.getParentName().isPersited()) {
757
                    nameService.save(rel.getParentName());
758
                }
759
            }
750 760
        }
751 761
        UUID taxonUUID = taxonService.saveOrUpdate(newTaxon);
752 762
        newTaxon = (Taxon) taxonService.load(taxonUUID);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
96 96
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
97 97
import eu.etaxonomy.cdm.model.media.MediaUtils;
98 98
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
99
import eu.etaxonomy.cdm.model.name.HybridRelationship;
99 100
import eu.etaxonomy.cdm.model.name.IZoologicalName;
100 101
import eu.etaxonomy.cdm.model.name.Rank;
101 102
import eu.etaxonomy.cdm.model.name.TaxonName;
......
294 295

  
295 296
    @Override
296 297
    @Transactional(readOnly = false)
298
    public UpdateResult createSynonym(UUID acceptedTaxonUuid,
299
            Synonym newSynonym)  {
300
        UpdateResult result = new UpdateResult();
301
        for (HybridRelationship rel : newSynonym.getName().getHybridChildRelations()){
302
            if (!rel.getHybridName().isPersited()) {
303
                nameService.save(rel.getHybridName());
304
            }
305
            if (!rel.getParentName().isPersited()) {
306
                nameService.save(rel.getParentName());
307
            }
308
        }
309
        Taxon acceptedTaxon = (Taxon)load(acceptedTaxonUuid);
310
        acceptedTaxon.addSynonym(newSynonym, newSynonym.getType());
311
        result.addUpdatedObject(acceptedTaxon);
312
        return result;
313

  
314
    }
315

  
316

  
317

  
318

  
319
    @Override
320
    @Transactional(readOnly = false)
297 321
    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid,
298 322
            UUID toTaxonUuid,
299 323
            TaxonRelationshipType taxonRelationshipType,

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)