ref #7505, #6321 Disable parallel loading
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / UserEditorInput.java
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 @Override
68 protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) {
69 //TODO there is no count method for users
70 return CdmStore.getService(IUserService.class).count(User.class);
71 }
72
73 /* (non-Javadoc)
74 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
75 */
76 @Override
77 protected List<User> listEntities(
78 IIdentifiableEntityServiceConfigurator configurator) {
79 return CdmStore.getSearchManager().findUsers(configurator);
80 }
81
82
83 /* (non-Javadoc)
84 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
85
86 @Override
87 protected User loadEntity(UUID entityUuid) {
88 List<String> propertyPaths = Arrays.asList(new String[]{});
89 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
90 }
91 */
92 /* (non-Javadoc)
93 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
94 */
95 @Override
96 protected IEntityCreator<User> createEntityCreator() {
97 return new UserCreator();
98 }
99
100 /* (non-Javadoc)
101 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
102 */
103 @Override
104 public String getText(User entity) {
105 return String.format("%s, %s", entity.getUsername(), entity.getPerson());
106 }
107
108 /* (non-Javadoc)
109 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
110 */
111 @Override
112 public void merge() {
113
114 }
115
116
117 @Override
118 protected User loadEntity(UUID entityUuid) {
119 List<String> propertyPaths = Arrays.asList(new String[]{});
120 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
121 }
122
123
124
125 }