4 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
;
6 import java
.util
.ArrayList
;
7 import java
.util
.Arrays
;
8 import java
.util
.HashMap
;
11 import java
.util
.UUID
;
13 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
15 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
16 import eu
.etaxonomy
.taxeditor
.editor
.key
.AbstractIdentificationEditorInput
;
17 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 public class PolytomousKeyEditorInput
extends AbstractIdentificationEditorInput
<PolytomousKey
> {
25 private final String name
;
26 private PolytomousKey key
;
29 protected PolytomousKeyEditorInput(ConversationHolder conversation
,
30 UUID polytomousKeyUuid
) {
32 List
<String
> propertyPath
= new ArrayList
<>();
33 propertyPath
.add("root");
34 propertyPath
.add("root.*");
35 this.key
= CdmStore
.getService(IPolytomousKeyService
.class).load(polytomousKeyUuid
, propertyPath
);
36 this.name
= key
.getTitleCache();
39 // public PolytomousKeyEditorInput(UUID polytomousKeyUuid, String name) {
40 // super(CdmStore.createConversation());
41 // this.keyUuid = polytomousKeyUuid;
46 public static PolytomousKeyEditorInput
NewInstance(UUID polytomousKeyUuid
) throws Exception
{
48 ConversationHolder conversation
= CdmStore
.createConversation();
49 return new PolytomousKeyEditorInput(conversation
, polytomousKeyUuid
);
57 public PolytomousKey
getKey() {
62 * @see java.lang.Object#equals(java.lang.Object)
65 public boolean equals(Object object
) {
66 if (object
instanceof PolytomousKeyEditorInput
68 && getKey().equals(((PolytomousKeyEditorInput
) object
).getKey())
72 return super.equals(object
);
76 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
79 public List
<PolytomousKey
> getRootEntities() {
80 return Arrays
.asList(key
);
84 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
88 key
= CdmStore
.getService(IPolytomousKeyService
.class).merge(key
,true).getMergedEntity();
93 public Map
<Object
, List
<String
>> getPropertyPathsMap() {
94 Map
<Object
,List
<String
>> propertyPathsMap
= new HashMap
<Object
,List
<String
>>();
96 List
<String
> polytomousKeyNodePropertyPaths
= Arrays
.asList(new String
[] {
97 "statement" //$NON-NLS-1$
99 propertyPathsMap
.put("children", polytomousKeyNodePropertyPaths
); //$NON-NLS-1$
100 return propertyPathsMap
;