Merge branch 'release/4.4.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / UserEditorInput.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.bulkeditor.input;
12
13 import java.util.Arrays;
14 import java.util.List;
15 import java.util.UUID;
16
17 import eu.etaxonomy.cdm.api.service.IUserService;
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.model.common.User;
22 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
23 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.UserCreator;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26 /**
27 * @author n.hoffmann
28 * @created Mar 9, 2011
29 * @version 1.0
30 */
31 public class UserEditorInput extends AbstractBulkEditorInput<User> {
32
33 public static final String ID = "bulkeditor.input.user";
34
35 private static UserEditorInput instance;
36
37 /**
38 * @return the instance
39 */
40 public static UserEditorInput getInstance() {
41 if(instance == null){
42 instance = new UserEditorInput();
43 }
44 return instance;
45 }
46
47 /* (non-Javadoc)
48 * @see org.eclipse.ui.IEditorInput#getName()
49 */
50 @Override
51 public String getName() {
52 return BulkEditorInputType.USER.label;
53 }
54
55 /* (non-Javadoc)
56 * @see org.eclipse.ui.IEditorInput#getToolTipText()
57 */
58 @Override
59 public String getToolTipText() {
60 return getName();
61 }
62
63 /* (non-Javadoc)
64 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
65 */
66 @Override
67 public User save(User entity) {
68 return CdmStore.getService(IUserService.class).merge(entity, true).getMergedEntity();
69 }
70
71 /* (non-Javadoc)
72 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
73 */
74 @Override
75 public boolean delete(User entity, DeleteConfiguratorBase config) throws ReferencedObjectUndeletableException {
76 return CdmStore.getService(IUserService.class).delete(entity) != null;
77 }
78
79 /* (non-Javadoc)
80 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
81 */
82 @Override
83 protected List<User> listEntities(
84 IIdentifiableEntityServiceConfigurator configurator) {
85 return CdmStore.getSearchManager().findUsers(configurator);
86 }
87
88
89 /* (non-Javadoc)
90 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
91
92 @Override
93 protected User loadEntity(UUID entityUuid) {
94 List<String> propertyPaths = Arrays.asList(new String[]{});
95 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
96 }
97 */
98 /* (non-Javadoc)
99 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
100 */
101 @Override
102 protected IEntityCreator<User> createEntityCreator() {
103 return new UserCreator();
104 }
105
106 /* (non-Javadoc)
107 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
108 */
109 @Override
110 public String getText(User entity) {
111 return String.format("%s, %s", entity.getUsername(), entity.getPerson());
112 }
113
114 /* (non-Javadoc)
115 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
116 */
117 @Override
118 public void merge() {
119
120 }
121
122
123 @Override
124 protected User loadEntity(UUID entityUuid) {
125 List<String> propertyPaths = Arrays.asList(new String[]{});
126 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
127 }
128
129
130
131 }