bc1fd74e18d138d835bd3a3cfcdac16d3fb5a720
[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.IIdentifiableEntityServiceConfigurator;
19 import eu.etaxonomy.cdm.model.common.User;
20 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
21 import eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputTypeValues.BulkEditorInputType;
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 /* (non-Javadoc)
47 * @see org.eclipse.ui.IEditorInput#getName()
48 */
49 @Override
50 public String getName() {
51 return BulkEditorInputType.USER.label;
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.ui.IEditorInput#getToolTipText()
56 */
57 @Override
58 public String getToolTipText() {
59 return getName();
60 }
61
62 /* (non-Javadoc)
63 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
64 */
65 @Override
66 public boolean save(User entity) {
67 return CdmStore.getService(IUserService.class).saveOrUpdate(entity) != null;
68 }
69
70 /* (non-Javadoc)
71 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
72 */
73 @Override
74 public boolean delete(User entity) {
75 return CdmStore.getService(IUserService.class).delete(entity) != null;
76 }
77
78 /* (non-Javadoc)
79 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
80 */
81 @Override
82 protected List<User> listEntities(
83 IIdentifiableEntityServiceConfigurator configurator) {
84 return CdmStore.getSearchManager().findUsers(configurator);
85 }
86
87
88 /* (non-Javadoc)
89 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
90 */
91 @Override
92 protected User loadEntity(UUID entityUuid) {
93 List<String> propertyPaths = Arrays.asList(new String[]{});
94 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
95 }
96
97 /* (non-Javadoc)
98 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
99 */
100 @Override
101 protected IEntityCreator<User> createEntityCreator() {
102 return new UserCreator();
103 }
104
105 /* (non-Javadoc)
106 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
107 */
108 @Override
109 public String getText(User entity) {
110 return String.format("%s, %s", entity.getUsername(), entity.getPerson());
111 }
112
113
114 }