Project

General

Profile

Download (3.47 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 User save(User entity) {
65
	    if(CdmStore.getCurrentSessionManager().isRemoting()) {
66
	        return CdmStore.getService(IUserService.class).merge(entity, true);
67
	    } else {
68
	        CdmStore.getService(IUserService.class).saveOrUpdate(entity);
69
	        return entity;
70
	    }
71

    
72
	}
73

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

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

    
91

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

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

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

    
117
    /* (non-Javadoc)
118
     * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
119
     */
120
    @Override
121
    public void merge() {
122

    
123
    }
124

    
125

    
126
}
(11-11/11)