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
|
@Override
|
49
|
public String getName() {
|
50
|
return BulkEditorInputType.GROUP.label;
|
51
|
}
|
52
|
|
53
|
/* (non-Javadoc)
|
54
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
|
55
|
*/
|
56
|
@Override
|
57
|
public Group save(Group entity) {
|
58
|
return CdmStore.getService(IGroupService.class).merge(entity, true).getMergedEntity();
|
59
|
|
60
|
}
|
61
|
|
62
|
/* (non-Javadoc)
|
63
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
|
64
|
*/
|
65
|
@Override
|
66
|
public boolean delete(Group entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
|
67
|
return CdmStore.getService(IGroupService.class).delete(entity.getUuid()) != null;
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
72
|
//TODO there is no count method for groups
|
73
|
return CdmStore.getService(IGroupService.class).count(Group.class);
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
|
78
|
*/
|
79
|
@Override
|
80
|
protected List<Group> listEntities(
|
81
|
IIdentifiableEntityServiceConfigurator configurator) {
|
82
|
return CdmStore.getSearchManager().findGroups(configurator);
|
83
|
}
|
84
|
|
85
|
/* (non-Javadoc)
|
86
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
|
87
|
|
88
|
@Override
|
89
|
protected Group loadEntity(UUID entityUuid) {
|
90
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
91
|
return CdmStore.getService(IGroupService.class).load(entityUuid, propertyPaths);
|
92
|
}
|
93
|
*/
|
94
|
/* (non-Javadoc)
|
95
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
|
96
|
*/
|
97
|
@Override
|
98
|
protected IEntityCreator<Group> createEntityCreator() {
|
99
|
return new GroupCreator();
|
100
|
}
|
101
|
|
102
|
/* (non-Javadoc)
|
103
|
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
|
104
|
*/
|
105
|
@Override
|
106
|
public String getText(Group entity) {
|
107
|
return entity.getName();
|
108
|
}
|
109
|
|
110
|
/* (non-Javadoc)
|
111
|
* @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
|
112
|
*/
|
113
|
@Override
|
114
|
public void merge() {
|
115
|
|
116
|
}
|
117
|
|
118
|
@Override
|
119
|
protected Group loadEntity(UUID entityUuid) {
|
120
|
List<String> propertyPaths = Arrays.asList(new String[]{});
|
121
|
return HibernateProxyHelper.deproxy(CdmStore.getService(IAgentService.class).load(entityUuid, propertyPaths), Group.class);
|
122
|
}
|
123
|
|
124
|
|
125
|
|
126
|
}
|