3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
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
;
27 * @created Mar 9, 2011
30 public class UserEditorInput
extends AbstractBulkEditorInput
<User
> {
32 public static final String ID
= "bulkeditor.input.user";
34 private static UserEditorInput instance
;
37 * @return the instance
39 public static UserEditorInput
getInstance() {
41 instance
= new UserEditorInput();
47 * @see org.eclipse.ui.IEditorInput#getName()
50 public String
getName() {
51 return BulkEditorInputType
.USER
.label
;
55 * @see org.eclipse.ui.IEditorInput#getToolTipText()
58 public String
getToolTipText() {
63 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
66 public boolean save(User entity
) {
67 return CdmStore
.getService(IUserService
.class).saveOrUpdate(entity
) != null;
71 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
74 public boolean delete(User entity
) throws ReferencedObjectUndeletableException
{
75 return CdmStore
.getService(IUserService
.class).delete(entity
) != null;
79 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
82 protected List
<User
> listEntities(
83 IIdentifiableEntityServiceConfigurator configurator
) {
84 return CdmStore
.getSearchManager().findUsers(configurator
);
89 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
92 protected User loadEntity(UUID entityUuid) {
93 List<String> propertyPaths = Arrays.asList(new String[]{});
94 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
98 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
101 protected IEntityCreator
<User
> createEntityCreator() {
102 return new UserCreator();
106 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
109 public String
getText(User entity
) {
110 return String
.format("%s, %s", entity
.getUsername(), entity
.getPerson());