Project

General

Profile

Download (3.32 KB) Statistics
| Branch: | Tag: | Revision:
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.List;
14

    
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;
22

    
23
/**
24
 * @author n.hoffmann
25
 * @created Mar 9, 2011
26
 * @version 1.0
27
 */
28
public class UserEditorInput extends AbstractBulkEditorInput<User> {
29

    
30
	public static final String ID = "bulkeditor.input.user";
31

    
32
	private static UserEditorInput instance;
33

    
34
	/**
35
	 * @return the instance
36
	 */
37
	public static UserEditorInput getInstance() {
38
		if(instance == null){
39
			instance = new UserEditorInput();
40
		}
41
		return instance;
42
	}
43

    
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.ui.IEditorInput#getName()
46
	 */
47
	@Override
48
	public String getName() {
49
		return BulkEditorInputType.USER.label;
50
	}
51

    
52
	/* (non-Javadoc)
53
	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
54
	 */
55
	@Override
56
	public String getToolTipText() {
57
		return getName();
58
	}
59

    
60
	/* (non-Javadoc)
61
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#save(java.lang.Object)
62
	 */
63
	@Override
64
	public boolean save(User entity) {
65
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
66
	        return CdmStore.getService(IUserService.class).merge(entity) != null;
67
	    } else {
68
	        return CdmStore.getService(IUserService.class).saveOrUpdate(entity) != null;
69
	    }
70

    
71
	}
72

    
73
	/* (non-Javadoc)
74
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
75
	 */
76
	@Override
77
	public boolean delete(User entity) throws ReferencedObjectUndeletableException {
78
		return CdmStore.getService(IUserService.class).delete(entity) != null;
79
	}
80

    
81
	/* (non-Javadoc)
82
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator)
83
	 */
84
	@Override
85
	protected List<User> listEntities(
86
			IIdentifiableEntityServiceConfigurator configurator) {
87
		return CdmStore.getSearchManager().findUsers(configurator);
88
	}
89

    
90

    
91
	/* (non-Javadoc)
92
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
93

    
94
	@Override
95
	protected User loadEntity(UUID entityUuid) {
96
		List<String> propertyPaths = Arrays.asList(new String[]{});
97
		return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
98
	}
99
 */
100
	/* (non-Javadoc)
101
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
102
	 */
103
	@Override
104
	protected IEntityCreator<User> createEntityCreator() {
105
		return new UserCreator();
106
	}
107

    
108
	/* (non-Javadoc)
109
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
110
	 */
111
	@Override
112
	public String getText(User entity) {
113
		return String.format("%s, %s", entity.getUsername(), entity.getPerson());
114
	}
115

    
116

    
117
}
(11-11/11)