Project

General

Profile

Download (3.08 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.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.entitycreator.UserCreator;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

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

    
31
	public static final String ID = "bulkeditor.input.user";
32
	
33
	private static UserEditorInput instance;
34
	
35
	/**
36
	 * @return the instance
37
	 */
38
	public static UserEditorInput getInstance() {
39
		if(instance == null){
40
			instance = new UserEditorInput();
41
		}
42
		return instance;
43
	}
44
	
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.ui.IEditorInput#getName()
47
	 */
48
	@Override
49
	public String getName() {
50
		return BulkEditorInputType.USER.label;
51
	}
52

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

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

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

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

    
86
	
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#loadEntity(java.util.UUID)
89
	 */
90
	@Override
91
	protected User loadEntity(UUID entityUuid) {
92
		List<String> propertyPaths = Arrays.asList(new String[]{}); 
93
		return CdmStore.getService(IUserService.class).load(entityUuid, propertyPaths);
94
	}
95

    
96
	/* (non-Javadoc)
97
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator()
98
	 */
99
	@Override
100
	protected IEntityCreator<User> createEntityCreator() {
101
		return new UserCreator();
102
	}
103
	
104
	/* (non-Javadoc)
105
	 * @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getText(eu.etaxonomy.cdm.model.common.ICdmBase)
106
	 */
107
	@Override
108
	public String getText(User entity) {
109
		return String.format("%s, %s", entity.getUsername(), entity.getPerson());
110
	}
111

    
112

    
113
}
(9-9/9)