Project

General

Profile

Download (2.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 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.key.polytomous;
10

    
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.HashMap;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.UUID;
17

    
18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
19
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
20
import eu.etaxonomy.cdm.model.description.PolytomousKey;
21
import eu.etaxonomy.taxeditor.editor.key.AbstractIdentificationEditorInput;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author n.hoffmann
26
 */
27
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> {
28

    
29
    private PolytomousKey key;
30

    
31

    
32
    protected PolytomousKeyEditorInput(UUID polytomousKeyUuid) {
33
        super();
34
        List<String> propertyPath = new ArrayList<>();
35
        propertyPath.add("root");
36
        propertyPath.add("root.*");
37
        this.key = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, propertyPath);
38
    }
39

    
40
    public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
41
        try{
42
        	return new PolytomousKeyEditorInput( polytomousKeyUuid);
43
        }catch(Exception e){
44
            throw e;
45
        }
46
    }
47

    
48
    @Override
49
    public PolytomousKey getKey() {
50
        return key;
51
    }
52

    
53
    @Override
54
    public boolean equals(Object object) {
55
        if (object instanceof PolytomousKeyEditorInput
56
                && getKey() != null
57
                && getKey().equals(((PolytomousKeyEditorInput) object).getKey())
58
                ){
59
            return true;
60
        }
61
        return super.equals(object);
62
    }
63

    
64
    @Override
65
    public  List<PolytomousKey> getRootEntities() {
66
        return Arrays.asList(key);
67
    }
68

    
69
    @Override
70
    public void merge() {
71
       key = CdmStore.getService(IPolytomousKeyService.class).merge(key,true).getMergedEntity();
72
    }
73

    
74
    @Override
75
    public Map<Object, List<String>> getPropertyPathsMap() {
76
        Map<Object,List<String>> propertyPathsMap = new HashMap<>();
77

    
78
        List<String> polytomousKeyNodePropertyPaths = Arrays.asList(new String[] {
79
                "statement" //$NON-NLS-1$
80
        });
81
         propertyPathsMap.put("children", polytomousKeyNodePropertyPaths); //$NON-NLS-1$
82
         return propertyPathsMap;
83
    }
84
}
(2-2/8)