Project

General

Profile

« Previous | Next » 

Revision cedc4ff1

Added by Katja Luther about 6 years ago

ref #2380: implement usage of Dto for taxon navigator

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingDeleteTaxonNodeOperation.java
17 17

  
18 18
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
19 19
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
20
import eu.etaxonomy.cdm.api.service.DeleteResult;
20 21
import eu.etaxonomy.cdm.api.service.UpdateResult;
21 22
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
22 23
import eu.etaxonomy.cdm.model.taxon.Classification;
23
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
24
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
24
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
25 25
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
26 26
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
27 27

  
......
34 34

  
35 35
    private final static String LABEL = Messages.RemotingDeleteTaxonNodeOperation_DELETE_OP;
36 36

  
37
    private final Set<ITaxonTreeNode> treeNodes;
37
    private final Set<TaxonNodeDto> treeNodes;
38
    private final Set<TaxonNodeDto> classifications;
38 39
    private final TaxonDeletionConfigurator config;
39 40

  
40 41
    /**
......
45 46
     */
46 47
    public RemotingDeleteTaxonNodeOperation(Object source,
47 48
            boolean async,
48
            Set<ITaxonTreeNode> treeNodes,
49
            Set<TaxonNodeDto> treeNodes,
50
            Set<TaxonNodeDto> classifications,
49 51
            TaxonDeletionConfigurator config) {
50 52
        super(LABEL, Action.Delete, source, async);
51 53
        this.treeNodes = treeNodes;
54
        this.classifications = classifications;
52 55
        this.config = config;
53 56
    }
54 57

  
......
61 64

  
62 65
        if(treeNodes.size() == 1) {
63 66
            // when single node this is either a taxon or a classification
64
            ITaxonTreeNode node = treeNodes.iterator().next();
65
            if(node instanceof TaxonNode) {
66
                return CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNode(((TaxonNode)node).getUuid(), config);
67
            } else if(node instanceof Classification) {
68
                entityType = Classification.class;
69
                return CdmApplicationState.getCurrentAppConfig().getClassificationService().delete(((Classification)node).getUuid());
67
            TaxonNodeDto node = treeNodes.iterator().next();
68
            if(node.getType() != null && node.getType().equals(Classification.class)) {
69
                return CdmApplicationState.getCurrentAppConfig().getClassificationService().delete(node.getUuid());
70 70
            }
71
            return CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNode((node).getUuid(), config);
72
//            } else if(node.getType().equals( Classification.class)) {
73
//                entityType = Classification.class;
74
//                return CdmApplicationState.getCurrentAppConfig().getClassificationService().delete(node.getUuid());
75
//            }
71 76
        } else {
72 77
            // when list we assume all are taxon nodes
73 78
            Set<UUID> treeNodeUuids = new HashSet<UUID>();
74
            ITaxonTreeNode entity = null;
75
            for(ITaxonTreeNode treeNode : treeNodes) {
76
                if(entity == null) {
77
                    entity = treeNode;
79
            Set<UUID> classificationsUuids = new HashSet<UUID>();
80
            if (treeNodes != null){
81
                for(TaxonNodeDto treeNode : treeNodes) {
82
                    treeNodeUuids.add(treeNode.getUuid());
83
                }
84
            }
85
            if (classifications != null){
86
                for(TaxonNodeDto treeNode : classifications) {
87
                    classificationsUuids.add(treeNode.getClassificationUUID());
88
                }
89
            }
90
            DeleteResult result = new DeleteResult();
91
            if (!treeNodeUuids.isEmpty()){
92
                result.includeResult(CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNodes(treeNodeUuids, new TaxonDeletionConfigurator()));
93
            }
94
            if (!classificationsUuids.isEmpty()){
95
                for (UUID classificationUuid: classificationsUuids){
96
                    result.includeResult(CdmApplicationState.getCurrentAppConfig().getClassificationService().delete(classificationUuid, config));
78 97
                }
79
                treeNodeUuids.add(treeNode.getUuid());
80 98
            }
81 99

  
82
            return CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNodes(treeNodeUuids, new TaxonDeletionConfigurator());
100
            return result;
83 101
        }
84
        return null;
102

  
85 103
    }
86 104

  
87 105
}

Also available in: Unified diff