Project

General

Profile

Revision 6bae07b0

ID6bae07b008aa0a018147009b207ab46f1e593e62
Parent 1ce2be53
Child f740afa5

Added by Patrick Plitzner almost 2 years ago

ref #7887 Adapt moving terms based on DTOs

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TermServiceImpl.java
11 11

  
12 12
import java.net.URI;
13 13
import java.util.ArrayList;
14
import java.util.Arrays;
14 15
import java.util.Collection;
15 16
import java.util.Enumeration;
16 17
import java.util.HashSet;
......
67 68
	private ILanguageStringDao languageStringDao;
68 69

  
69 70
	@Autowired
71
	private IVocabularyService vocabularyService;
72

  
73
	@Autowired
70 74
	@Qualifier("langStrBaseDao")
71 75
	private ILanguageStringBaseDao languageStringBaseDao;
72 76
	private IRepresentationDao representationDao;
......
481 485
    @Transactional(readOnly = false)
482 486
    @Override
483 487
    public void moveTerm(UUID termUuuid, UUID parentUUID, boolean isKindOf) {
484
        DefinedTermBase term = dao.load(termUuuid);
488
        DefinedTermBase term = dao.load(termUuuid, Arrays.asList("vocabulary"));
489
        TermVocabulary vocabulary = term.getVocabulary();
490
        if(vocabulary!=null){
491
            vocabulary.removeTerm(term);
492
        }
493

  
485 494
        DefinedTermBase parent = dao.load(parentUUID);
486
        if(isKindOf){
487
            parent.addGeneralizationOf(term);
495
        if(parent!=null){
496
            //new parent is a term
497
            if(isKindOf){
498
                parent.addGeneralizationOf(term);
499
            }
500
            else{
501
                parent.addIncludes(term);
502
            }
503
            parent.getVocabulary().addTerm(term);
504
            dao.saveOrUpdate(parent);
488 505
        }
489 506
        else{
490
            parent.addIncludes(term);
507
            //new parent is a vocabulary
508
            TermVocabulary parentVocabulary = vocabularyService.load(parentUUID);
509
            if(parentVocabulary!=null){
510
                parentVocabulary.removeTerm(term);
511
                term.setKindOf(null);
512
                term.setPartOf(null);
513
                parentVocabulary.addTerm(term);
514
            }
515
            vocabularyService.saveOrUpdate(parentVocabulary);
491 516
        }
492 517
    }
493 518

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)