Project

General

Profile

Download (1.94 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14

    
15
import org.springframework.security.access.AccessDeniedException;
16

    
17
import eu.etaxonomy.cdm.api.service.IUserService;
18
import eu.etaxonomy.cdm.model.common.User;
19
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
20
import eu.etaxonomy.taxeditor.model.MessagingUtils;
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 UserCreator  implements IEntityCreator<User>{
29

    
30
	/* (non-Javadoc)
31
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.String)
32
	 */
33
	@Override
34
	public User createEntity(String text) {
35
		return createEntity(null, text);
36
	}
37

    
38
	/* (non-Javadoc)
39
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Object, java.lang.String)
40
	 */
41
	@Override
42
	public User createEntity(Object key, String text) {
43
		try{
44
			User user = User.NewInstance(text, text);
45
			CdmStore.getService(IUserService.class).createUser(user);
46
			user = CdmStore.getService(IUserService.class).loadWithUpdate(user.getUuid());
47
			return user;
48
		} catch (AccessDeniedException e){
49
			MessagingUtils.messageDialog("Access denied", getClass(), e.getMessage(), e);
50
			return null;
51
		}
52
	}
53

    
54
	/* (non-Javadoc)
55
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getKeyLabelPairs()
56
	 */
57
	@Override
58
	public Map<Object, String> getKeyLabelPairs() {
59
		Map<Object, String> result = new HashMap<Object, String>();
60
		result.put(User.class, "User");
61
		return result;
62
	}
63

    
64
	@Override
65
	public boolean savesEntity() {
66
		// TODO Auto-generated method stub
67
		return false;
68
	}
69

    
70
}
(8-8/8)