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