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.group.authority;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.Collection;
|
13
|
import java.util.UUID;
|
14
|
|
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.permission.Group;
|
20
|
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
21
|
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
/**
|
25
|
* Editor input for the {@link CdmAuthorityEditor}.
|
26
|
*
|
27
|
* @author cmathew
|
28
|
* @created Mar 28, 2013
|
29
|
*/
|
30
|
public class CdmAuthorityEditorInput
|
31
|
extends CdmEntitySessionInput<Group>
|
32
|
implements IConversationEnabled {
|
33
|
|
34
|
private ConversationHolder conversation;
|
35
|
private Group group;
|
36
|
|
37
|
protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
|
38
|
super(true);
|
39
|
this.conversation = conversation;
|
40
|
this.group = CdmApplicationState.getCurrentAppConfig().getGroupService().load(group.getUuid());
|
41
|
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Creates a new instance of the input for a given group.
|
46
|
*
|
47
|
* @param groupUuid
|
48
|
* @return
|
49
|
* @throws Exception
|
50
|
*/
|
51
|
public static CdmAuthorityEditorInput NewInstance(UUID groupUuid) throws Exception{
|
52
|
ConversationHolder conversation = CdmStore.createConversation();
|
53
|
Group group = CdmStore.getService(IGroupService.class).load(groupUuid, null);
|
54
|
return new CdmAuthorityEditorInput(conversation, group);
|
55
|
}
|
56
|
|
57
|
public Object getAdapter(Class adapter) {
|
58
|
if (adapter == Group.class) {
|
59
|
return this.group;
|
60
|
}
|
61
|
|
62
|
return null;
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public void update(CdmDataChangeMap changeEvents) {
|
67
|
// TODO Auto-generated method stub
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public ConversationHolder getConversationHolder() {
|
72
|
return this.conversation;
|
73
|
}
|
74
|
|
75
|
public String getName() {
|
76
|
return group.getName();
|
77
|
}
|
78
|
|
79
|
@Override
|
80
|
public boolean equals(Object object) {
|
81
|
if (object instanceof CdmAuthorityEditorInput
|
82
|
&& getGroup() != null
|
83
|
&& getGroup().equals(((CdmAuthorityEditorInput) object).getGroup())
|
84
|
){
|
85
|
return true;
|
86
|
}
|
87
|
return super.equals(object);
|
88
|
}
|
89
|
|
90
|
public Group getGroup() {
|
91
|
return this.group;
|
92
|
}
|
93
|
|
94
|
@Override
|
95
|
public Collection<Group> getRootEntities() {
|
96
|
return Arrays.asList(group);
|
97
|
}
|
98
|
|
99
|
@Override
|
100
|
public void merge() {
|
101
|
group = CdmStore.getService(IGroupService.class).merge(group, true).getMergedEntity();
|
102
|
}
|
103
|
}
|