Project

General

Profile

« Previous | Next » 

Revision 68a31601

Added by Katja Luther over 5 years ago

improve termdeletion, show only a warning when term can not be deleted

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
22 22
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
23 23
import eu.etaxonomy.cdm.model.common.TermBase;
24 24
import eu.etaxonomy.cdm.model.common.TermVocabulary;
25
import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermEditorE4;
26 25
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
27 26
import eu.etaxonomy.taxeditor.model.MessagingUtils;
28 27
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
......
69 68
			definedEditorInput.getVocabularies().remove(termBase);
70 69

  
71 70
			DeleteResult result =	CdmStore.getService(IVocabularyService.class).delete(termBase.getUuid());
72
			if (result.isError()){
71
			if (!result.isOk()){
73 72
				StringBuffer errorString = new StringBuffer();
74 73
				for (Exception e:result.getExceptions()){
75
					errorString.append(e.getMessage() + "\\n");
74
					errorString.append(e.getMessage() + System.lineSeparator());
76 75
				}
77
				MessageDialog.openError(null, "Delete failed", errorString.toString());
76
				MessageDialog.openWarning(null, "Delete failed", errorString.toString());
78 77
			}
79 78

  
80 79
		} else if (termBase instanceof DefinedTermBase) {
......
93 92
				return status;
94 93
			}
95 94

  
96

  
97
			DefinedTermBase partOf = definedTermBase.getPartOf();
98
			if(partOf != null){
99
				partOf.removeIncludes(definedTermBase);
100
			}
101

  
102
			DefinedTermBase kindOf = definedTermBase.getKindOf();
103
			if(kindOf != null){
104
				definedTermBase.removeGeneralization(kindOf);
105
			}
106

  
107
			TermVocabulary vocabulary = definedTermBase.getVocabulary();
108
			if(vocabulary != null){
109
				vocabulary.removeTerm(definedTermBase);
110
			}
111

  
112 95
			DeleteResult result =	CdmStore.getService(ITermService.class).delete(termBase.getUuid());
113 96

  
114
			if (result.isError()){
115
				StringBuffer errorString = new StringBuffer();
116
				for (Exception e:result.getExceptions()){
117
					errorString.append(e.getMessage() + "\\n");
118
				}
119
				MessageDialog.openError(null, "Delete failed", errorString.toString());
120
			}
97
			if (!result.isOk()){
98
                StringBuffer errorString = new StringBuffer();
99
                for (Exception e:result.getExceptions()){
100
                    errorString.append(e.getMessage() + System.lineSeparator());
101
                }
102
                MessageDialog.openWarning(null, "Delete failed", errorString.toString());
103
            }
121 104
		}
122 105

  
123 106
		return postExecute(termBase);

Also available in: Unified diff