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.entitycreator;
|
12
|
|
13
|
import java.util.HashMap;
|
14
|
import java.util.Map;
|
15
|
|
16
|
import org.springframework.security.access.AccessDeniedException;
|
17
|
|
18
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
19
|
import eu.etaxonomy.cdm.model.common.User;
|
20
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
21
|
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
|
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 UserCreator implements IEntityCreator<User>{
|
30
|
|
31
|
/* (non-Javadoc)
|
32
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.String)
|
33
|
*/
|
34
|
@Override
|
35
|
public User createEntity(String text) {
|
36
|
return createEntity(null, text);
|
37
|
}
|
38
|
|
39
|
/* (non-Javadoc)
|
40
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Object, java.lang.String)
|
41
|
*/
|
42
|
@Override
|
43
|
public User createEntity(Object key, String text) {
|
44
|
try{
|
45
|
User user = User.NewInstance(text, text);
|
46
|
CdmStore.getService(IUserService.class).createUser(user);
|
47
|
return user;
|
48
|
} catch (AccessDeniedException e){
|
49
|
BulkEditorUtil.errorDialog("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
|
}
|