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
.group
.authority
;
11 import java
.util
.Arrays
;
12 import java
.util
.Collection
;
13 import java
.util
.UUID
;
15 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IGroupService
;
19 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
20 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.CdmDataChangeMap
;
21 import eu
.etaxonomy
.taxeditor
.editor
.CdmEntitySessionInput
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
25 * Editor input for the {@link CdmAuthorityEditor}.
28 * @created Mar 28, 2013
32 public class CdmAuthorityEditorInput
extends CdmEntitySessionInput
implements IConversationEnabled
{
33 private ConversationHolder conversation
;
36 protected CdmAuthorityEditorInput(ConversationHolder conversation
, Group group
) {
38 this.conversation
= conversation
;
39 this.group
= CdmApplicationState
.getCurrentAppConfig().getGroupService().load(group
.getUuid());
44 * Creates a new instance of the input for a given group.
50 public static CdmAuthorityEditorInput
NewInstance(UUID groupUuid
) throws Exception
{
51 ConversationHolder conversation
= CdmStore
.createConversation();
52 Group group
= CdmStore
.getService(IGroupService
.class).load(groupUuid
, null);
53 return new CdmAuthorityEditorInput(conversation
, group
);
56 public Object
getAdapter(Class adapter
) {
57 if (adapter
== Group
.class) {
64 * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
67 public void update(CdmDataChangeMap changeEvents
) {
68 // TODO Auto-generated method stub
72 * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
75 public ConversationHolder
getConversationHolder() {
76 return this.conversation
;
78 public String
getName() {
79 return group
.getName();
83 * @see java.lang.Object#equals(java.lang.Object)
86 public boolean equals(Object object
) {
87 if (object
instanceof CdmAuthorityEditorInput
89 && getGroup().equals(((CdmAuthorityEditorInput
) object
).getGroup())
93 return super.equals(object
);
97 * Getter method for group member.
101 public Group
getGroup() {
106 * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
109 public Collection
<Group
> getRootEntities() {
110 return Arrays
.asList(group
);
114 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
117 public void merge() {
118 group
= CdmStore
.getService(IGroupService
.class).merge(group
, true).getMergedEntity();