package eu.etaxonomy.taxeditor.editor.view.derivate;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateContentProvider;
import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
public class DerivateView extends EditorPart implements IPartContentHasFactualData, IDirtyMarkable,
IConversationEnabled, IPartContentHasDetails, IPartContentHasSupplementalData, IPartContentHasMedia,
- ISelectionChangedListener, IPostOperationEnabled/*, ICdmEntitySessionEnabled*/{
+ ISelectionChangedListener, IPostOperationEnabled, ICdmEntitySessionEnabled{
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView"; //$NON-NLS-1$
public static final String YOU_NEED_TO_SAVE_BEFORE_PERFORMING_THIS_ACTION = Messages.DerivateView_YOU_NEED_TO_SAVE;
*/
private Set<SpecimenOrObservationBase<?>> rootElements;
+ private ICdmEntitySession cdmEntitySession;
+
/**
* Default constructor
*/
public DerivateView() {
- conversation = CdmStore.createConversation();
}
@Override
// commit the conversation and start a new transaction immediately
conversation.commit(true);
-// TODO: what does this do? merge();
+
+ if(CdmStore.getCurrentSessionManager().isRemoting()) {
+ CdmStore.getService(IOccurrenceService.class).merge(new ArrayList(getRootEntities()), true);
+ }
monitor.worked(1);
this.setDirty(false);
setInput(input);
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
+
+ if (CdmStore.isActive() && conversation == null) {
+ conversation = CdmStore.createConversation();
+ }
+ if (CdmStore.isActive()) {
+ cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+ }
}
@Override
if(!conversation.isBound()){
conversation.bind();
}
+ if(cdmEntitySession != null) {
+ cdmEntitySession.bind();
+ }
}
@Override
changed(null);
}
-// @Override
-// public Set<SpecimenOrObservationBase<?>> getRootEntities() {
-// return rootElements;
-// }
-//
-// @Override
-// public void merge() {
-// if(CdmStore.getCurrentSessionManager().isRemoting()) {
-// CdmApplicationState.getCurrentAppConfig().getOccurrenceService().merge(new ArrayList(getRootEntities()), true);
-// }
-// }
-//
-// @Override
-// public Map<Object, List<String>> getPropertyPathsMap() {
-// List<String> specimenPropertyPaths = Arrays.asList(new String[] {
-// "descriptions",
-// "derivationEvents.derivates",
-// "annotations",
-// "markers",
-// "credits",
-// "extensions",
-// "rights",
-// "sources"
-// });
-// Map<Object, List<String>> specimenPropertyPathMap =
-// new HashMap<Object, List<String>>();
-// specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
-// return specimenPropertyPathMap;
-// }
+ @Override
+ public Set<SpecimenOrObservationBase<?>> getRootEntities() {
+ return rootElements;
+ }
+
+ @Override
+ public Map<Object, List<String>> getPropertyPathsMap() {
+ List<String> specimenPropertyPaths = Arrays.asList(new String[] {
+ "descriptions",
+ "derivationEvents.derivates",
+ "annotations",
+ "markers",
+ "credits",
+ "extensions",
+ "rights",
+ "sources"
+ });
+ Map<Object, List<String>> specimenPropertyPathMap =
+ new HashMap<Object, List<String>>();
+ specimenPropertyPathMap.put(SpecimenOrObservationBase.class,specimenPropertyPaths);
+ return specimenPropertyPathMap;
+ }
/**
* Refreshes the derivate hierarchy tree and expands the tree
derivateToRootEntityMap.put(fieldUnit, fieldUnit);
}
-// @Override
-// public ICdmEntitySession getCdmEntitySession() {
-// return conversation;
-// }
+ @Override
+ public ICdmEntitySession getCdmEntitySession() {
+ return cdmEntitySession;
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if(conversation!=null){
+ conversation.close();
+ }
+ if(cdmEntitySession != null) {
+ cdmEntitySession.dispose();
+ }
+ }
}