Project

General

Profile

Download (2.69 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 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.navigation.operation;
10

    
11
import org.eclipse.core.commands.ExecutionException;
12
import org.eclipse.core.commands.operations.IUndoContext;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16

    
17
import eu.etaxonomy.cdm.api.service.config.SubtreeCloneConfigurator;
18
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
19
import eu.etaxonomy.cdm.api.service.UpdateResult;
20
import eu.etaxonomy.cdm.model.reference.Reference;
21
import eu.etaxonomy.cdm.model.taxon.Classification;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * @author pplitzner
29
 */
30
public class CloneClassificationOperation extends AbstractPersistentPostOperation {
31

    
32
    private final Classification classification;
33

    
34
    private final ITaxonNodeService service;
35

    
36
    private String classificationName;
37

    
38
    private Reference sec;
39

    
40
    private TaxonRelationshipType relationType;
41

    
42
    public CloneClassificationOperation(String label, IUndoContext undoContext, Classification classification,
43
            String classificationName, Reference sec, TaxonRelationshipType relationType,
44
            IPostOperationEnabled postOperationEnabled) {
45
        super(label, undoContext, postOperationEnabled);
46

    
47
        this.classification = classification;
48
        this.classificationName = classificationName;
49
        this.sec = sec;
50
        this.relationType = relationType;
51
        this.service = CdmStore.getService(ITaxonNodeService.class);
52
    }
53

    
54
    @Override
55
    public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
56
    	
57
    	SubtreeCloneConfigurator cloneConfig = SubtreeCloneConfigurator.NewBaseInstance(
58
    			classification.getRootNode().getUuid(), classificationName);
59
        cloneConfig.setTaxonSecundum(sec);
60
        cloneConfig.setRelationTypeToOldTaxon(relationType);
61
        
62
        UpdateResult result = service.cloneSubtree(cloneConfig);
63
        return postExecute(result.getCdmEntity());
64
    }
65

    
66
    @Override
67
    public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
68
        return null;
69
    }
70

    
71
    @Override
72
    public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
73
        return null;
74
    }
75

    
76
}
(1-1/5)