Project

General

Profile

Download (3.15 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2016 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.ui.section.classification;
10

    
11
import java.util.Collection;
12
import java.util.Collections;
13
import java.util.List;
14
import java.util.Map;
15

    
16
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
19
import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
20
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
21
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author k.luther
26
 * @date 23.03.2016
27
 *
28
 */
29
public class EditTaxonNodeWizard extends AbstractEditWizard<TaxonNode> implements ICdmEntitySessionEnabled{
30

    
31
    private TaxonNodeWizardPage taxonNodePage;
32
    private IWizardPageListener wizardPageListener;
33
    private ICdmEntitySession cdmEntitySession;
34

    
35

    
36
    /* (non-Javadoc)
37
     * @see eu.etaxonomy.taxeditor.ui.section.classification.AbstractEditWizard#getEntityName()
38
     */
39
    @Override
40
    protected String getEntityName() {
41
        return "taxon node";
42
    }
43

    
44
    /* (non-Javadoc)
45
     * @see eu.etaxonomy.taxeditor.ui.section.classification.AbstractEditWizard#saveEntity()
46
     */
47
    @Override
48
    protected void saveEntity() {
49
        getConversationHolder().bind();
50
        TaxonNode node = getEntity();
51

    
52
        MergeResult result = CdmStore.getService(ITaxonNodeService.class).merge(node, true);
53

    
54
    }
55
    @Override
56
    public void addPages() {
57
        taxonNodePage = new TaxonNodeWizardPage(formFactory, getConversationHolder(), getEntity(), wizardPageListener, false);
58

    
59
        addPage(taxonNodePage);
60
    }
61

    
62
    public void addWizardPageListener(IWizardPageListener wizardPageListener){
63
        this.wizardPageListener = wizardPageListener;
64
    }
65

    
66
    /* (non-Javadoc)
67
     * @see eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard#setEntity(java.lang.Object)
68
     */
69
    @Override
70
    public void setEntity(TaxonNode entity) {
71
        setWindowTitle(String.format("Edit %s", getEntityName()));
72
        if (CdmStore.isActive() && cdmEntitySession == null) {
73

    
74
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
75
            cdmEntitySession.bind();
76
        }
77
        entity = CdmStore.getService(ITaxonNodeService.class).load(entity.getUuid());
78
        super.setEntity(entity);
79
    }
80

    
81
    /**
82
     * {@inheritDoc}
83
     */
84
    @Override
85
    public ICdmEntitySession getCdmEntitySession() {
86

    
87
        return cdmEntitySession;
88
    }
89

    
90
    /**
91
     * {@inheritDoc}
92
     */
93
    @Override
94
    public Collection<TaxonNode> getRootEntities() {
95
        return Collections.singleton(this.getEntity());
96
    }
97

    
98
    /**
99
     * {@inheritDoc}
100
     */
101
    @Override
102
    public Map<Object, List<String>> getPropertyPathsMap() {
103
        // TODO Auto-generated method stub
104
        return null;
105
    }
106

    
107
    @Override
108
    public void dispose() {
109
        cdmEntitySession.dispose();
110
        super.dispose();
111
    }
112

    
113

    
114

    
115
}
(7-7/12)