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.service.IPolytomousKeyService;
|
19
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
20
|
import eu.etaxonomy.taxeditor.editor.key.AbstractIdentificationEditorInput;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
*/
|
26
|
public class PolytomousKeyEditorInput extends AbstractIdentificationEditorInput<PolytomousKey> {
|
27
|
|
28
|
private PolytomousKey key;
|
29
|
|
30
|
|
31
|
protected PolytomousKeyEditorInput(UUID polytomousKeyUuid) {
|
32
|
super();
|
33
|
List<String> propertyPath = new ArrayList<>();
|
34
|
propertyPath.add("root");
|
35
|
propertyPath.add("root.*");
|
36
|
this.key = CdmStore.getService(IPolytomousKeyService.class).load(polytomousKeyUuid, propertyPath);
|
37
|
}
|
38
|
|
39
|
public static PolytomousKeyEditorInput NewInstance(UUID polytomousKeyUuid) throws Exception{
|
40
|
try{
|
41
|
return new PolytomousKeyEditorInput( polytomousKeyUuid);
|
42
|
}catch(Exception e){
|
43
|
throw e;
|
44
|
}
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public PolytomousKey getKey() {
|
49
|
return key;
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
public boolean equals(Object object) {
|
54
|
if (object instanceof PolytomousKeyEditorInput
|
55
|
&& getKey() != null
|
56
|
&& getKey().equals(((PolytomousKeyEditorInput) object).getKey())
|
57
|
){
|
58
|
return true;
|
59
|
}
|
60
|
return super.equals(object);
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public List<PolytomousKey> getRootEntities() {
|
65
|
return Arrays.asList(key);
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public void merge() {
|
70
|
key = CdmStore.getService(IPolytomousKeyService.class).merge(key,true).getMergedEntity();
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public Map<Object, List<String>> getPropertyPathsMap() {
|
75
|
Map<Object,List<String>> propertyPathsMap = new HashMap<>();
|
76
|
|
77
|
List<String> polytomousKeyNodePropertyPaths = Arrays.asList(new String[] {
|
78
|
"statement" //$NON-NLS-1$
|
79
|
});
|
80
|
propertyPathsMap.put("children", polytomousKeyNodePropertyPaths); //$NON-NLS-1$
|
81
|
return propertyPathsMap;
|
82
|
}
|
83
|
}
|