Project

General

Profile

« Previous | Next » 

Revision 92749440

Added by Katja Luther almost 3 years ago

fix #8111: fix saving problem for members in group

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
36 36
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
37 37
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
38 38
import eu.etaxonomy.cdm.model.common.CdmBase;
39
import eu.etaxonomy.cdm.model.common.Group;
40
import eu.etaxonomy.cdm.model.common.User;
39 41
import eu.etaxonomy.cdm.model.description.DescriptionBase;
40 42
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
41 43
import eu.etaxonomy.cdm.model.description.TaxonDescription;
......
47 49
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
48 50
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
49 51
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
52
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
50 53
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
51 54
import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
52 55
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
......
252 255
                    getEditorInput().addSaveCandidate(changedTaxon);
253 256
                    input.replaceInModel(changedTaxon);
254 257
                }
258
            }else if(element instanceof Group){
259
                 Group oldGroup = ((GroupEditorInput)input).getEntityFromModel((Group)element);
260
                 ((GroupEditorInput)input).getSaveUserCandidates().addAll(oldGroup.getMembers());
261
                 getEditorInput().addSaveCandidate((Group)element);
262
                 input.replaceInModel((CdmBase) element);
255 263
            }else{
256 264
                getEditorInput().addSaveCandidate((CdmBase)element);
257 265
                input.replaceInModel((CdmBase) element);
......
324 332
        }
325 333
    }
326 334

  
335
    @Inject
336
    @Optional
337
    private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.REMOVE_USER) User user) {
338
        if (input instanceof GroupEditorInput){
339
            ((GroupEditorInput)input).getSaveUserCandidates().add(user);
340
        }
341
    }
342

  
327 343
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
32 32
import eu.etaxonomy.cdm.model.common.CdmBase;
33 33
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
34 34
import eu.etaxonomy.cdm.model.common.MarkerType;
35
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
35 36
import eu.etaxonomy.cdm.strategy.merge.IMergable;
36 37
import eu.etaxonomy.cdm.strategy.merge.MergeException;
37 38
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
......
357 358
            }
358 359
	    }
359 360
	    if (!saveCandidates.isEmpty()){
360
	        CdmStore.getService(saveCandidates.iterator().next()).merge(new ArrayList<>(saveCandidates), true);
361
	        List<MergeResult<T>> results = CdmStore.getService(saveCandidates.iterator().next()).merge(new ArrayList<>(saveCandidates), true);
362
	        for (MergeResult<T> result: results){
363
	            if (result.getMergedEntity() != null){
364
	                T entitiy = result.getMergedEntity();
365
	            }
366

  
367
	        }
361 368
        }
362 369
	    if(resetMerge){
363 370
	        //merge entities
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
12 12
import java.util.ArrayList;
13 13
import java.util.Arrays;
14 14
import java.util.Comparator;
15
import java.util.HashSet;
15 16
import java.util.List;
17
import java.util.Set;
16 18
import java.util.UUID;
17 19

  
18 20
import eu.etaxonomy.cdm.api.service.IGroupService;
21
import eu.etaxonomy.cdm.api.service.IUserService;
19 22
import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
20 23
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
21 24
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
22 25
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
23 26
import eu.etaxonomy.cdm.model.common.Group;
27
import eu.etaxonomy.cdm.model.common.User;
24 28
import eu.etaxonomy.cdm.persistence.query.OrderHint;
25 29
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
26 30
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
......
38 42
	public static final String ID = "bulkeditor.input.group";
39 43

  
40 44
	private static GroupEditorInput instance;
45
	private Set<User> saveUserCandidates = new HashSet<>();
46

  
41 47

  
42 48
	public static GroupEditorInput getInstance() {
43 49
		if(instance == null){
......
107 113
        return new GroupNameComparator();
108 114
    }
109 115

  
116
	@Override
117
    public void saveModel(boolean resetMerge){
118
        super.saveModel(resetMerge);
119
        if (!saveUserCandidates.isEmpty()){
120
            CdmStore.getService(IUserService.class).merge(new ArrayList<>(saveUserCandidates), true);
121
        }
122
        saveUserCandidates.clear();
123
    }
124

  
125
	public Group getEntityFromModel(Group group){
126
	    return this.getModel().get(this.getModel().indexOf(group));
127
	}
128

  
129
    public Set<User> getSaveUserCandidates() {
130
        return saveUserCandidates;
131
    }
132

  
133
    public void setSaveUserCandidates(Set<User> saveUserCandidates) {
134
        this.saveUserCandidates = saveUserCandidates;
135
    }
136

  
137

  
110 138
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
39 39

  
40 40
    public static final String REFRESH_DETAILS = "REFRESH/DETAILS/DISTRIBUTION";
41 41

  
42
    public static final String REMOVE_USER = "UPDATE/GROUP/REMOVEUSER";
43

  
42 44
}

Also available in: Unified diff