Project

General

Profile

« Previous | Next » 

Revision 346352ad

Added by Patrick Plitzner over 8 years ago

Enable remote session support

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
1 1
package eu.etaxonomy.taxeditor.editor.view.derivate;
2 2

  
3
import java.util.ArrayList;
3 4
import java.util.Arrays;
4 5
import java.util.Collection;
5 6
import java.util.HashMap;
......
55 56
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
56 57
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
57 58
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
59
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
60
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
58 61
import eu.etaxonomy.taxeditor.store.CdmStore;
59 62
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
60 63
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
......
66 69
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
67 70
        IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
68 71

  
69
        ISelectionChangedListener, IPostOperationEnabled/*, ICdmEntitySessionEnabled*/{
72
        ISelectionChangedListener, IPostOperationEnabled, ICdmEntitySessionEnabled{
70 73
    public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
71 74

  
72 75
    public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
......
118 121
     */
119 122
    private Set<SpecimenOrObservationBase<?>> rootElements;
120 123

  
124
    private ICdmEntitySession cdmEntitySession;
125

  
121 126
    /**
122 127
     * Default constructor
123 128
     */
124 129
    public DerivateView() {
125
        conversation = CdmStore.createConversation();
126 130
    }
127 131

  
128 132
    @Override
......
229 233

  
230 234
        // commit the conversation and start a new transaction immediately
231 235
        conversation.commit(true);
232
//      TODO: what does this do?  merge();
236

  
237
        if(CdmStore.getCurrentSessionManager().isRemoting()) {
238
            CdmStore.getService(IOccurrenceService.class).merge(new ArrayList(getRootEntities()), true);
239
        }
233 240
        monitor.worked(1);
234 241

  
235 242
        this.setDirty(false);
......
262 269
        setInput(input);
263 270
        this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
264 271
        this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
272

  
273
        if (CdmStore.isActive() && conversation == null) {
274
            conversation = CdmStore.createConversation();
275
        }
276
        if (CdmStore.isActive()) {
277
            cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
278
        }
265 279
    }
266 280

  
267 281
    @Override
......
288 302
        if(!conversation.isBound()){
289 303
            conversation.bind();
290 304
        }
305
        if(cdmEntitySession != null) {
306
            cdmEntitySession.bind();
307
        }
291 308
    }
292 309

  
293 310
    @Override
......
318 335
        changed(null);
319 336
    }
320 337

  
321
//    @Override
322
//    public Set<SpecimenOrObservationBase<?>> getRootEntities() {
323
//        return rootElements;
324
//    }
325
//
326
//    @Override
327
//    public void merge() {
328
//        if(CdmStore.getCurrentSessionManager().isRemoting()) {
329
//            CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true);
330
//        }
331
//    }
332
//
333
//    @Override
334
//    public Map<Object, List<String>> getPropertyPathsMap() {
335
//        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
336
//                "descriptions",
337
//                "derivationEvents.derivates",
338
//                "annotations",
339
//                "markers",
340
//                "credits",
341
//                "extensions",
342
//                "rights",
343
//                "sources"
344
//        });
345
//        Map<Object, List<String>> specimenPropertyPathMap =
346
//                new HashMap<Object, List<String>>();
347
//        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
348
//        return specimenPropertyPathMap;
349
//    }
338
    @Override
339
    public Set<SpecimenOrObservationBase<?>> getRootEntities() {
340
        return rootElements;
341
    }
342

  
343
    @Override
344
    public Map<Object, List<String>> getPropertyPathsMap() {
345
        List<String> specimenPropertyPaths = Arrays.asList(new String[] {
346
                "descriptions",
347
                "derivationEvents.derivates",
348
                "annotations",
349
                "markers",
350
                "credits",
351
                "extensions",
352
                "rights",
353
                "sources"
354
        });
355
        Map<Object, List<String>> specimenPropertyPathMap =
356
                new HashMap<Object, List<String>>();
357
        specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
358
        return specimenPropertyPathMap;
359
    }
350 360

  
351 361
    /**
352 362
     * Refreshes the derivate hierarchy tree and expands the tree
......
437 447
        derivateToRootEntityMap.put(fieldUnit, fieldUnit);
438 448
    }
439 449

  
440
//    @Override
441
//    public ICdmEntitySession getCdmEntitySession() {
442
//        return conversation;
443
//    }
450
    @Override
451
    public ICdmEntitySession getCdmEntitySession() {
452
        return cdmEntitySession;
453
    }
454

  
455
    @Override
456
    public void dispose() {
457
        super.dispose();
458
        if(conversation!=null){
459
            conversation.close();
460
        }
461
        if(cdmEntitySession != null) {
462
            cdmEntitySession.dispose();
463
        }
464
    }
444 465
}

Also available in: Unified diff