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.common.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
|
*/
|
31
|
|
32
|
public class CdmAuthorityEditorInput extends CdmEntitySessionInput implements IConversationEnabled {
|
33
|
private ConversationHolder conversation;
|
34
|
private Group group;
|
35
|
|
36
|
protected CdmAuthorityEditorInput(ConversationHolder conversation, Group group) {
|
37
|
super(true);
|
38
|
this.conversation = conversation;
|
39
|
this.group = CdmApplicationState.getCurrentAppConfig().getGroupService().load(group.getUuid());
|
40
|
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Creates a new instance of the input for a given group.
|
45
|
*
|
46
|
* @param groupUuid
|
47
|
* @return
|
48
|
* @throws Exception
|
49
|
*/
|
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);
|
54
|
}
|
55
|
|
56
|
public Object getAdapter(Class adapter) {
|
57
|
if (adapter == Group.class) {
|
58
|
return this.group;
|
59
|
}
|
60
|
|
61
|
return null;
|
62
|
}
|
63
|
/* (non-Javadoc)
|
64
|
* @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
|
65
|
*/
|
66
|
@Override
|
67
|
public void update(CdmDataChangeMap changeEvents) {
|
68
|
// TODO Auto-generated method stub
|
69
|
|
70
|
}
|
71
|
/* (non-Javadoc)
|
72
|
* @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
|
73
|
*/
|
74
|
@Override
|
75
|
public ConversationHolder getConversationHolder() {
|
76
|
return this.conversation;
|
77
|
}
|
78
|
public String getName() {
|
79
|
return group.getName();
|
80
|
}
|
81
|
|
82
|
/* (non-Javadoc)
|
83
|
* @see java.lang.Object#equals(java.lang.Object)
|
84
|
*/
|
85
|
@Override
|
86
|
public boolean equals(Object object) {
|
87
|
if (object instanceof CdmAuthorityEditorInput
|
88
|
&& getGroup() != null
|
89
|
&& getGroup().equals(((CdmAuthorityEditorInput) object).getGroup())
|
90
|
){
|
91
|
return true;
|
92
|
}
|
93
|
return super.equals(object);
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* Getter method for group member.
|
98
|
*
|
99
|
* @return
|
100
|
*/
|
101
|
public Group getGroup() {
|
102
|
return this.group;
|
103
|
}
|
104
|
|
105
|
/* (non-Javadoc)
|
106
|
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
|
107
|
*/
|
108
|
@Override
|
109
|
public Collection<Group> getRootEntities() {
|
110
|
return Arrays.asList(group);
|
111
|
}
|
112
|
|
113
|
/* (non-Javadoc)
|
114
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
115
|
*/
|
116
|
@Override
|
117
|
public void merge() {
|
118
|
group = CdmStore.getService(IGroupService.class).merge(group, true).getMergedEntity();
|
119
|
|
120
|
}
|
121
|
}
|