2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Arrays
;
13 import java
.util
.HashMap
;
14 import java
.util
.List
;
16 import java
.util
.UUID
;
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
;
27 public class PolytomousKeyEditorInput
extends AbstractIdentificationEditorInput
<PolytomousKey
> {
29 private final String name
;
30 private PolytomousKey key
;
33 protected PolytomousKeyEditorInput(ConversationHolder conversation
,
34 UUID polytomousKeyUuid
) {
36 List
<String
> propertyPath
= new ArrayList
<>();
37 propertyPath
.add("root");
38 propertyPath
.add("root.*");
39 this.key
= CdmStore
.getService(IPolytomousKeyService
.class).load(polytomousKeyUuid
, propertyPath
);
40 this.name
= key
.getTitleCache();
43 // public PolytomousKeyEditorInput(UUID polytomousKeyUuid, String name) {
44 // super(CdmStore.createConversation());
45 // this.keyUuid = polytomousKeyUuid;
49 public static PolytomousKeyEditorInput
NewInstance(UUID polytomousKeyUuid
) throws Exception
{
51 ConversationHolder conversation
= CdmStore
.createConversation();
52 return new PolytomousKeyEditorInput(conversation
, polytomousKeyUuid
);
59 public PolytomousKey
getKey() {
64 public boolean equals(Object object
) {
65 if (object
instanceof PolytomousKeyEditorInput
67 && getKey().equals(((PolytomousKeyEditorInput
) object
).getKey())
71 return super.equals(object
);
75 public List
<PolytomousKey
> getRootEntities() {
76 return Arrays
.asList(key
);
81 key
= CdmStore
.getService(IPolytomousKeyService
.class).merge(key
,true).getMergedEntity();
85 public Map
<Object
, List
<String
>> getPropertyPathsMap() {
86 Map
<Object
,List
<String
>> propertyPathsMap
= new HashMap
<Object
,List
<String
>>();
88 List
<String
> polytomousKeyNodePropertyPaths
= Arrays
.asList(new String
[] {
89 "statement" //$NON-NLS-1$
91 propertyPathsMap
.put("children", polytomousKeyNodePropertyPaths
); //$NON-NLS-1$
92 return propertyPathsMap
;