Project

General

Profile

« Previous | Next » 

Revision 9122a3ce

Added by Katja Luther over 5 years ago

ref #4573: handle duplicate user and group name in editor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/e4/handler/NewObjectHandlerE4.java
75 75
            if (dialog.open() != Window.CANCEL) {
76 76
                IEntityCreator entityCreator = bulkEditor.getEditorInput().getEntityCreator();
77 77
                Object createdEntity = entityCreator.createEntity(key, dialog.getValue());
78
                if (createdEntity == null){
79
                    return;
80
                }
78 81
                bulkEditor.getEditorInput().getModel().add(createdEntity);
79 82
                if (createdEntity instanceof CdmBase){
80 83
                    bulkEditor.getEditorInput().addSaveCandidate((CdmBase)createdEntity);
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)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
10 10
    public static String AbstractBulkEditorInput_MERGE_ERROR_TITLE;
11 11
    public static String USER_CREATOR_user_exists_title;
12 12
    public static String USER_CREATOR_user_exists;
13
    public static String GROUP_CREATOR_group_exists_title;
14
    public static String GROUP_CREATOR_group_exists;
13 15
    public static String BulkEditorE4_CANCEL;
14 16
    public static String BulkEditorE4_DONT_SAVE;
15 17
    public static String BulkEditorE4_SAVE_AND_SEARCH;
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
25 25

  
26 26
USER_CREATOR_user_exists_title=The user already exists
27 27
USER_CREATOR_user_exists=The user already exists in database
28
GROUP_CREATOR_group_exists_title=The group already exists
29
GROUP_CREATOR_group_exists=The group already exists in database.
28 30
ReferencingObjectsLabelProvider_No_description_available=No description available
29 31
ConvertPerson2TeamHandler_warning=While reloading the data an exception occurred
30 32
ConvertPerson2TeamHandler_lable=Convert Person to Team
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
25 25

  
26 26
USER_CREATOR_user_exists_title=Der Benutzer existiert bereits
27 27
USER_CREATOR_user_exists=Der Benutzer existiert bereits in der Datenbank.
28
GROUP_CREATOR_group_exists_title=Die Gruppe existiert bereits
29
GROUP_CREATOR_group_exists=Die Gruppe existiert bereits in der Datenbank.
30

  
28 31
ReferencingObjectsLabelProvider_No_description_available=Keine Beschreibung verf?gbar
29 32
ConvertPerson2TeamHandler_warning=Beim Neuladen der Daten ist ein Fehler aufgetreten
30 33
ConvertPerson2TeamHandler_lable=Wandle Person in Team um

Also available in: Unified diff