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
.List
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
16 import eu
.etaxonomy
.cdm
.api
.service
.config
.IIdentifiableEntityServiceConfigurator
;
17 import eu
.etaxonomy
.cdm
.api
.service
.exception
.ReferencedObjectUndeletableException
;
18 import eu
.etaxonomy
.cdm
.model
.common
.User
;
19 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
20 import eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
.UserCreator
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
25 * @created Mar 9, 2011
28 public class UserEditorInput
extends AbstractBulkEditorInput
<User
> {
30 public static final String ID
= "bulkeditor.input.user";
32 private static UserEditorInput instance
;
35 * @return the instance
37 public static UserEditorInput
getInstance() {
39 instance
= new UserEditorInput();
45 * @see org.eclipse.ui.IEditorInput#getName()
48 public String
getName() {
49 return BulkEditorInputType
.USER
.label
;
53 * @see org.eclipse.ui.IEditorInput#getToolTipText()
56 public String
getToolTipText() {
61 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
64 public User
save(User entity
) {
65 if(CdmStore
.getCurrentSessionManager().isRemoting()) {
66 return CdmStore
.getService(IUserService
.class).merge(entity
, true).getMergedEntity();
68 CdmStore
.getService(IUserService
.class).saveOrUpdate(entity
);
75 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
78 public boolean delete(User entity
) throws ReferencedObjectUndeletableException
{
79 return CdmStore
.getService(IUserService
.class).delete(entity
) != null;
83 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
86 protected List
<User
> listEntities(
87 IIdentifiableEntityServiceConfigurator configurator
) {
88 return CdmStore
.getSearchManager().findUsers(configurator
);
93 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
96 protected User loadEntity(UUID entityUuid) {
97 List<String> propertyPaths = Arrays.asList(new String[]{});
98 return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
102 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
105 protected IEntityCreator
<User
> createEntityCreator() {
106 return new UserCreator();
110 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
113 public String
getText(User entity
) {
114 return String
.format("%s, %s", entity
.getUsername(), entity
.getPerson());
118 * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
121 public void merge() {