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
|
|
10
|
package eu.etaxonomy.taxeditor.bulkeditor.input;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.IAgentService;
|
17
|
import eu.etaxonomy.cdm.api.service.IGroupService;
|
18
|
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
|
19
|
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
|
20
|
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
|
21
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
22
|
import eu.etaxonomy.cdm.model.common.Group;
|
23
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
24
|
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* @author n.hoffmann
|
29
|
* @created Mar 9, 2011
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
|
33
|
|
34
|
public static final String ID = "bulkeditor.input.group";
|
35
|
|
36
|
private static GroupEditorInput instance;
|
37
|
|
38
|
/**
|
39
|
* @return the instance
|
40
|
*/
|
41
|
public static GroupEditorInput getInstance() {
|
42
|
if(instance == null){
|
43
|
instance = new GroupEditorInput();
|
44
|
}
|
45
|
return instance;
|
46
|
}
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see org.eclipse.ui.IEditorInput#getName()
|
50
|
*/
|
51
|
@Override
|
52
|
public String getName() {
|
53
|
return BulkEditorInputType.GROUP.label;
|
54
|
}
|
55
|
|
56
|
/* (non-Javadoc)
|
57
|
* @see org.eclipse.ui.IEditorInput#getToolTipText()
|
58
|
*/
|
59
|
@Override
|
60
|
public String getToolTipText() {
|
61
|
return getName();
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
|
66
|
*/
|
67
|
@Override
|
68
|
public Group save(Group entity) {
|
69
|
return CdmStore.getService(IGroupService.class).merge(entity, true).getMergedEntity();
|
70
|
|
71
|
}
|
72
|
|
73
|
/* (non-Javadoc)
|
74
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
|
75
|
*/
|
76
|
@Override
|
77
|
public boolean delete(Group entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
|
78
|
return CdmStore.getService(IGroupService.class).delete(entity.getUuid()) != null;
|
79
|
}
|
80
|
|
81
|
/* (non-Javadoc)
|
82
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
|
83
|
*/
|
84
|
@Override
|
85
|
protected List<Group> listEntities(
|
86
|
IIdentifiableEntityServiceConfigurator configurator) {
|
87
|
return CdmStore.getSearchManager().findGroups(configurator);
|
88
|
}
|
89
|
|
90
|
/* (non-Javadoc)
|
91
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
|
92
|
|
93
|
@Override
|
94
|
protected Group loadEntity(UUID entityUuid) {
|
95
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
96
|
return CdmStore.getService(IGroupService.class).load(entityUuid, propertyPaths);
|
97
|
}
|
98
|
*/
|
99
|
/* (non-Javadoc)
|
100
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
|
101
|
*/
|
102
|
@Override
|
103
|
protected IEntityCreator<Group> createEntityCreator() {
|
104
|
return new GroupCreator();
|
105
|
}
|
106
|
|
107
|
/* (non-Javadoc)
|
108
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
|
109
|
*/
|
110
|
@Override
|
111
|
public String getText(Group entity) {
|
112
|
return entity.getName();
|
113
|
}
|
114
|
|
115
|
/* (non-Javadoc)
|
116
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
117
|
*/
|
118
|
@Override
|
119
|
public void merge() {
|
120
|
|
121
|
}
|
122
|
|
123
|
@Override
|
124
|
protected Group loadEntity(UUID entityUuid) {
|
125
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
126
|
return HibernateProxyHelper.deproxy(CdmStore.getService(IAgentService.class).load(entityUuid, propertyPaths), Group.class);
|
127
|
}
|
128
|
|
129
|
|
130
|
|
131
|
}
|