Project

General

Profile

Revision b084af2b

IDb084af2b8e9b43b6e3caef96db150e8bd635f34e
Parent 25cf7939
Child bca0ecd6

Added by Katja Luther about 2 years ago

ref #7393: fix regression for deleting cascading from relations

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
66 66
    private TaxonNode taxonNode;
67 67

  
68 68
    private Map<TaxonBase, TaxonBaseDeletionConfigurator> toDelete = new HashMap<>();
69
    private Set<TaxonBase> toSaveNew = new HashSet<>();
69 70

  
70 71
    private Set<AbstractPostTaxonOperation> operations = new HashSet<>();
71 72

  
......
298 299
        this.operations.add(operation);
299 300
    }
300 301

  
302
    public void addToSaveNew(TaxonBase toSaveNew) {
303
        this.toSaveNew.add(toSaveNew);
304
    }
305

  
301 306
    @Override
302 307
    public List<TaxonNode> getRootEntities() {
303 308
        return Arrays.asList(taxonNode);
......
317 322
        }
318 323
        operations.clear();
319 324

  
325
        CdmStore.getService(ITaxonService.class).save(toSaveNew);
326

  
320 327
        CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
321 328

  
322 329
    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateNewTaxonBaseOperation.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.editor.name.operation;
10

  
11
import java.util.UUID;
12

  
13
import org.eclipse.core.commands.operations.IUndoContext;
14

  
15
import eu.etaxonomy.cdm.model.taxon.Taxon;
16
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
17
import eu.etaxonomy.taxeditor.editor.EditorUtil;
18
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
19
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
20
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
21

  
22
/**
23
 * @author k.luther
24
 * @since 02.05.2018
25
 *
26
 */
27
public abstract class CreateNewTaxonBaseOperation extends AbstractPostTaxonOperation {
28

  
29
    /**
30
     * @param label
31
     * @param undoContext
32
     * @param taxonUuid
33
     */
34
    public CreateNewTaxonBaseOperation(String label, IUndoContext undoContext, UUID taxonUuid) {
35
        super(label, undoContext, taxonUuid);
36

  
37
    }
38

  
39
    /**
40
     * @param label
41
     * @param undoContext
42
     * @param taxon
43
     * @param postOperationEnabled
44
     */
45
    public CreateNewTaxonBaseOperation(String label, IUndoContext undoContext, Taxon taxon,
46
            IPostOperationEnabled postOperationEnabled) {
47
        super(label, undoContext, taxon, postOperationEnabled);
48
    }
49

  
50
    /**
51
     * @param newTaxonBase
52
     */
53
    protected void addToSaveList(TaxonBase newTaxonBase) {
54
        TaxonNameEditorE4 editor = null;
55
        Object activePart = EditorUtil.getActivePart();
56
        if (activePart instanceof TaxonNameEditorE4){
57
           editor = (TaxonNameEditorE4) activePart;
58

  
59
        }
60
        editor.getEditorInput().addToSaveNew(newTaxonBase);
61
        editor.setDirty();
62

  
63
    }
64

  
65
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java
16 16
import org.eclipse.core.runtime.IStatus;
17 17

  
18 18
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
19
import eu.etaxonomy.cdm.model.name.INonViralName;
20 19
import eu.etaxonomy.cdm.model.name.TaxonName;
21 20
import eu.etaxonomy.cdm.model.taxon.Synonym;
22 21
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
24 22
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25 23

  
26 24
/**
......
30 28
 * @created 02.02.2009
31 29
 */
32 30
public class CreateSynonymInExistingHomotypicalGroupOperation extends
33
		AbstractPostTaxonOperation {
31
		CreateNewTaxonBaseOperation {
34 32

  
35 33
	private final HomotypicalGroup group;
36 34
	private final TaxonName newSynonymName;
......
48 46
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 47
	 */
50 48
	public CreateSynonymInExistingHomotypicalGroupOperation(String label,
51
			IUndoContext undoContext, Taxon taxon, HomotypicalGroup group, 
49
			IUndoContext undoContext, Taxon taxon, HomotypicalGroup group,
52 50
			TaxonName newSynonymName, IPostOperationEnabled postOperationEnabled) {
53 51
		super(label, undoContext, taxon, postOperationEnabled);
54 52
		this.group = group;
......
71 69
		}else{
72 70
			synonym = element.addHeterotypicSynonymName(newSynonymName);
73 71
		}
72

  
73
//		addToSaveList(synonym);
74 74
		monitor.worked(40);
75 75

  
76 76
//		Synonym affectedSynonym = null;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java
20 20
import eu.etaxonomy.cdm.model.name.TaxonName;
21 21
import eu.etaxonomy.cdm.model.taxon.Synonym;
22 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
24 23
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25 24

  
26 25
/**
......
34 33
 * @author n.hoffmann
35 34
 * @created 16.01.2009
36 35
 */
37
public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation {
36
public class CreateSynonymInNewGroupOperation extends CreateNewTaxonBaseOperation {
38 37

  
39 38
	private final TaxonName newSynonymName;
40 39
	private Synonym newSynonym;
......
64 63
		HomotypicalGroup.NewInstance().addTypifiedName(newSynonymName);
65 64
		monitor.worked(20);
66 65
		HibernateProxyHelper.deproxy(element);
67
		// Create a new synonym for the taxon
68 66
		newSynonym = element.addHeterotypicSynonymName(newSynonymName);
69 67
		monitor.worked(40);
70
		
68

  
71 69
		return postExecute(newSynonym);
72 70
	}
73 71

  
74
	/** {@inheritDoc} */
72

  
73

  
74
    /** {@inheritDoc} */
75 75
	@Override
76 76
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
77 77
			throws ExecutionException {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java
17 17

  
18 18
import eu.etaxonomy.cdm.model.taxon.Taxon;
19 19
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
20
import eu.etaxonomy.taxeditor.editor.name.operation.CreateNewTaxonBaseOperation;
20 21
import eu.etaxonomy.taxeditor.model.TaxonRelationshipTypeInverseContainer;
21
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
22 22
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
23 23

  
24 24
/**
......
29 29
 * @created 26.01.2009
30 30
 * @version 1.0
31 31
 */
32
public class CreateConceptRelationOperation extends AbstractPostTaxonOperation {
32
public class CreateConceptRelationOperation extends CreateNewTaxonBaseOperation {
33 33

  
34 34
	private final Taxon concept;
35 35
	private final TaxonRelationshipTypeInverseContainer taxonRelationshipTypeInverseContainer;
......
67 67
			throws ExecutionException {
68 68

  
69 69
		monitor.worked(20);
70
		addToSaveList(concept);
70 71
		// add concept to taxon
71 72
		if(taxonRelationshipTypeInverseContainer.isInverse()){
72 73
			element.addTaxonRelation(concept, taxonRelationshipTypeInverseContainer.getType(), null, null);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
13 13
import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
14 14
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
15 15
import eu.etaxonomy.cdm.api.service.IClassificationService;
16
import eu.etaxonomy.cdm.api.service.INameService;
16 17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17 18
import eu.etaxonomy.cdm.api.service.ITaxonService;
18 19
import eu.etaxonomy.cdm.api.service.UpdateResult;
19 20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.cdm.model.name.HybridRelationship;
22
import eu.etaxonomy.cdm.model.name.TaxonName;
20 23
import eu.etaxonomy.cdm.model.reference.Reference;
21 24
import eu.etaxonomy.cdm.model.taxon.Classification;
22 25
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
......
69 72
            	    parentNodeUuid = parent.getUuid();
70 73
            	}
71 74
            	UpdateResult result;
75
            	if (!taxon.getName().getHybridChildRelations().isEmpty() || !taxon.getName().getHybridParentRelations().isEmpty()){
76
                    Set<TaxonName> namesToSave = new HashSet<>();
77
                    for (HybridRelationship hybridRelationship: taxon.getName().getHybridChildRelations()){
78
                        if (hybridRelationship.getParentName() != taxon.getName()){
79
                            if (!hybridRelationship.getParentName().isPersited()){
80
                                namesToSave.add(hybridRelationship.getParentName());
81
                            }
82
                       }else if (hybridRelationship.getHybridName() != taxon.getName()){
83
                           if (!hybridRelationship.getHybridName().isPersited()){
84
                               namesToSave.add(hybridRelationship.getHybridName());
85
                           }
86
                        }
87

  
88
                    }
89

  
90
                    for (HybridRelationship hybridRelationship: taxon.getName().getHybridParentRelations()){
91
                        if (hybridRelationship.getParentName() != taxon.getName()){
92
                            if (!hybridRelationship.getParentName().isPersited()){
93
                                namesToSave.add(hybridRelationship.getParentName());
94
                            }
95
                       }else if (hybridRelationship.getHybridName() != taxon.getName()){
96
                           if (!hybridRelationship.getHybridName().isPersited()){
97
                               namesToSave.add(hybridRelationship.getHybridName());
98
                           }
99
                        }
100

  
101
                    }
102
                    CdmStore.getService(INameService.class).save(namesToSave);
103
                }
72 104

  
73 105
            	if (taxon.getId() == 0){
74 106
            		result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parentNodeUuid, taxon, parent.getReference(), parent.getMicroReference());
......
81 113
	             	taxonNode.getTaxon().setSec(sec);
82 114
	             	taxonNode.setExcluded(((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isExcluded());
83 115
	             	taxonNode.setUnplaced(((TaxonNodeDetailElement)taxonNodePage.getDetailElement()).isUnplaced());
116

  
117

  
84 118
	             	MergeResult resultMerge =  CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
85 119
	                 Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
86 120
	                 if (result.getUpdatedObjects().iterator().hasNext()){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonWizard.java
40 40
	/** {@inheritDoc} */
41 41
	@Override
42 42
	protected void saveEntity() {
43

  
43 44
	    CdmStore.getService(ITaxonService.class).save(getEntity());
44 45
	}
45 46

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/classification/TaxonNodeWizardPage.java
16 16

  
17 17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18 18
import eu.etaxonomy.cdm.common.CdmUtils;
19
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19 20
import eu.etaxonomy.cdm.model.name.INonViralName;
20 21
import eu.etaxonomy.cdm.model.reference.Reference;
21 22
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
22 23
import eu.etaxonomy.cdm.model.taxon.Taxon;
23 24
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
25
import eu.etaxonomy.taxeditor.l10n.Messages;
24 26
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
25 27
import eu.etaxonomy.taxeditor.parser.ParseHandler;
28
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
26 29
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage;
27 30
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
28 31
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
138 141
			String taxonName = ((TaxonNodeDetailElement) getDetailElement()).getTaxonName();
139 142
			Reference reference = ((TaxonNodeDetailElement) getDetailElement()).getReference();
140 143
			INonViralName parseReferencedName = ParseHandler.parseReferencedName(taxonName, null);
141
			return Taxon.NewInstance(parseReferencedName, reference);
144
			Taxon taxon = Taxon.NewInstance(parseReferencedName, reference);
145
			if (PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag).getValue().equals(Messages.PublishFlagPreference_set)){
146
			    taxon.setPublish(true);
147
			} else if (PreferencesUtil.getPreferenceFromDB(PreferencePredicate.DefaultBehaviourForPublishFlag).getValue().equals(Messages.PublishFlagPreference_do_not_set)){
148
			    taxon.setPublish(false);
149
			}else{
150
			    taxon.setPublish(((TaxonNode)this.getParentTreeNode()).getTaxon().isPublish());
151
			}
152
			return taxon;
142 153
		} else{
143 154
			return ((TaxonNodeDetailElement) getDetailElement()).getTaxon();
144 155
		}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)