- Fix multiple saving of the same term base
*/
package eu.etaxonomy.taxeditor.editor.definedterm.e4;
*/
package eu.etaxonomy.taxeditor.editor.definedterm.e4;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashSet;
+import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.ITermService;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.common.TermBase;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.cdm.persistence.dto.TermDto;
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
@Inject
private MPart thisPart;
@Inject
private MPart thisPart;
- private List<DefinedTermBase> changedTerms = new ArrayList<>();
+ private Set<TermBase> changedTerms = new HashSet<>();
@Inject
public DefinedTermEditorE4() {
@Inject
public DefinedTermEditorE4() {
@Persist
public void save(IProgressMonitor monitor) {
getConversationHolder().commit();
@Persist
public void save(IProgressMonitor monitor) {
getConversationHolder().commit();
- changedTerms.forEach(term->CdmStore.getService(ITermService.class).merge(term));
+ for(TermBase term:changedTerms){
+ if(term.isInstanceOf(DefinedTermBase.class)){
+ CdmStore.getService(ITermService.class).merge((DefinedTermBase) term);
+ }
+ else if(term.isInstanceOf(TermVocabulary.class)){
+ CdmStore.getService(IVocabularyService.class).merge((TermVocabulary) term);
+ }
+ }
setDirty(false);
input.initialiseVocabularies();
viewer.refresh();
setDirty(false);
input.initialiseVocabularies();
viewer.refresh();
TermVocabulary vocabulary = (TermVocabulary)element;
TermVocabularyDto vocabularyDto = new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations());
viewer.update(vocabularyDto, null);
TermVocabulary vocabulary = (TermVocabulary)element;
TermVocabularyDto vocabularyDto = new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations());
viewer.update(vocabularyDto, null);
+ changedTerms.add(vocabulary);
}
setDirty(true);
viewer.update(element, null);
}
setDirty(true);
viewer.update(element, null);