Revision 9122a3ce
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/entitycreator/GroupCreator.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator; |
11 | 11 |
|
12 | 12 |
import java.util.HashMap; |
13 |
import java.util.List; |
|
13 | 14 |
import java.util.Map; |
15 |
import java.util.UUID; |
|
14 | 16 |
|
17 |
import eu.etaxonomy.cdm.api.service.IGroupService; |
|
15 | 18 |
import eu.etaxonomy.cdm.model.common.Group; |
19 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
|
16 | 20 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
21 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
22 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
17 | 24 |
|
18 | 25 |
/** |
19 | 26 |
* @author n.hoffmann |
... | ... | |
29 | 36 |
*/ |
30 | 37 |
@Override |
31 | 38 |
public Group createEntity(String text) { |
32 |
return createEntity(null, text); |
|
39 |
Group group = createEntity(null, text); |
|
40 |
return group; |
|
33 | 41 |
} |
34 | 42 |
|
35 | 43 |
/* (non-Javadoc) |
... | ... | |
37 | 45 |
*/ |
38 | 46 |
@Override |
39 | 47 |
public Group createEntity(Object key, String text) { |
40 |
return Group.NewInstance(text); |
|
48 |
List<Group> groupList =CdmStore.getService(IGroupService.class).listByName(text, MatchMode.EXACT, null, 100, 0, null, null); |
|
49 |
|
|
50 |
if (groupList.isEmpty()){ |
|
51 |
Group group = Group.NewInstance(text); |
|
52 |
UUID groupUuid = CdmStore.getService(IGroupService.class).saveGroup(group); |
|
53 |
group = CdmStore.getService(IGroupService.class).loadWithUpdate(groupUuid); |
|
54 |
return group; |
|
55 |
} else{ |
|
56 |
MessagingUtils.messageDialog(Messages.GROUP_CREATOR_group_exists_title, text, Messages.GROUP_CREATOR_group_exists); |
|
57 |
return null; |
|
58 |
} |
|
59 |
|
|
60 |
|
|
41 | 61 |
} |
42 | 62 |
|
43 | 63 |
/* (non-Javadoc) |
Also available in: Unified diff
ref #4573: handle duplicate user and group name in editor