import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
-import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @created 30.04.2014
* @version 1.0
*/
-public class ChecklistEditor extends EditorPart implements ISelectionListener, IPartContentHasFactualData,
- IConversationEnabled, IContextListener, IPartContentHasDetails, IDirtyMarkable, ICdmEntitySessionEnabled {
+public class ChecklistEditor extends EditorPart implements ISelectionListener, IPartContentHasFactualData, IConversationEnabled,
+ IContextListener, IPartContentHasDetails, IDirtyMarkable{//, ICdmEntitySessionEnabled {
private static final Logger logger = Logger.getLogger(ChecklistEditor.class);
/**
private Label statusLabel;
- private final ICdmEntitySession cdmEntitySession;
+ // private final ICdmEntitySession cdmEntitySession;
private ChecklistLabelProvider labelProvider;
* </p>
*/
public ChecklistEditor() {
- cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
+ //cdmEntitySession = CdmStore.getCurrentSessionManager().newSession(this, true);
}
/** {@inheritDoc} */
@Override
public void dispose() {
- cdmEntitySession.dispose();
+ this.checklistEditorInput.dispose();
+
+ conversation.unregisterForDataStoreChanges(this);
+ conversation.close();
super.dispose();
}
/** {@inheritDoc} */
@Override
public void setFocus() {
- cdmEntitySession.bind();
+
viewer.getControl().setFocus();
}
public void doSave(IProgressMonitor monitor) {
try {
monitor.beginTask("Saving Editor", 1);
- getConversationHolder().bind();
- getConversationHolder().commit(true);
+ if (!conversation.isBound()) {
+ conversation.bind();
+ }
+ CdmStore.getService(ITaxonNodeService.class).merge(selectedTaxonNodes, true);
+ //this.checklistEditorInput.merge();
+ conversation.commit(true);
setDirty(false);
monitor.worked(1);
} finally {
if (input instanceof ChecklistEditorInput) {
checklistEditorInput = (ChecklistEditorInput) input;
setPartName(getPartName() + ": " + checklistEditorInput.getName());
- conversation = ((ChecklistEditorInput) input).getConversationHolder();
+ conversation = checklistEditorInput.getConversation();
+ conversation.registerForDataStoreChanges(this);
}
simpleSelectionProvider = new SimpleSelectionProvider();
getSite().setSelectionProvider(simpleSelectionProvider);
+
}
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
}
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update
- * (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
- */
- @Override
- public void update(CdmDataChangeMap changeEvents) {
- }
- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder
- * ()
- */
- @Override
- public ConversationHolder getConversationHolder() {
- return conversation;
- }
+
/*
* (non-Javadoc)
private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[] { "descriptions",
"descriptions.*", "description.state", "feature", "feature.*", "childNodes", "childNodes.taxon",
"childNodes.taxon.name", "taxonNodes", "taxonNodes.*", "taxonNodes.taxon.*", "taxon.*",
- "taxon.descriptions", "taxon.sec", "taxon.name.*", "taxon.synonymRelations", "terms", "name.*",
- "name.rank.representations", "name.status.type.representations", "sources.$", "stateData.$" });
+ "taxon.descriptions", "taxon.sec", "taxon.name.*", "terms", "name.*",
+ "name.rank.representations", "name.status.type.representations", "stateData.$" });
/*
* (non-Javadoc)
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getCdmEntitySession()
*/
- @Override
- public ICdmEntitySession getCdmEntitySession() {
- // TODO Auto-generated method stub
- return null;
+
+
+// /* (non-Javadoc)
+// * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+// */
+// @Override
+// public <T extends CdmBase> Collection<T> getRootEntities() {
+// // TODO Auto-generated method stub
+// return null;
+// }
+//
+// /* (non-Javadoc)
+// * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+// */
+// @Override
+// public Map<Object, List<String>> getPropertyPathsMap() {
+// // TODO Auto-generated method stub
+// return null;
+// }
+
+ /**
+ * @return the labelProvider
+ */
+ public ChecklistLabelProvider getLabelProvider() {
+ return labelProvider;
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+ * @see eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update(eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap)
*/
@Override
- public <T extends CdmBase> Collection<T> getRootEntities() {
+ public void update(CdmDataChangeMap arg0) {
// TODO Auto-generated method stub
- return null;
+
}
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+ * @see eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder()
*/
@Override
- public Map<Object, List<String>> getPropertyPathsMap() {
- // TODO Auto-generated method stub
- return null;
- }
+ public ConversationHolder getConversationHolder() {
- /**
- * @return the labelProvider
- */
- public ChecklistLabelProvider getLabelProvider() {
- return labelProvider;
+ return conversation;
}
}
*/
package eu.etaxonomy.taxeditor.editor.view.checklist;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.UUID;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IPersistableElement;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @date 25.04.2014
*
*/
-public class ChecklistEditorInput implements IEditorInput, IPersistable {
+public class ChecklistEditorInput extends CdmEntitySessionInput implements IEditorInput, IPersistable {
/**
* The selected classification
*/
private TaxonNode taxonNode = null;
+ private final List<TaxonBase> taxa = new ArrayList<TaxonBase>();
+
private Classification classification = null;
- private final ConversationHolder conversationHolder;
+ private final ConversationHolder conversation;
/**
* @param taxonNode
*/
public ChecklistEditorInput(TaxonNode taxonNode){
- super();
- this.conversationHolder = CdmStore.createConversation();
+ super(true);
+ this.conversation = CdmStore.createConversation();
this.taxonNode = CdmStore.getCurrentApplicationConfiguration().getTaxonNodeService().load(taxonNode.getUuid());
+ // getChildTaxa(taxonNode);
classification = taxonNode.getClassification();
}
+ /**
+ * @param taxonNode2
+ */
+ private void getChildTaxa(TaxonNode taxonNode2) {
+ taxonNode2.removeNullValueFromChildren();
+ if (taxonNode2.hasChildNodes()){
+ for (TaxonNode node: taxonNode2.getChildNodes()){
+ taxa.add(node.getTaxon());
+ getChildTaxa(node);
+ }
+ }
+
+
+ }
+
/**
* Creates an editor input for the {@link ChecklistView} with the currently selected classification.
* @param classificationUuid
*/
public ChecklistEditorInput(Classification classification) {
- super();
- this.conversationHolder = CdmStore.createConversation();
+ super(true);
+ this.conversation = CdmStore.createConversation();
this.classification = CdmStore.getCurrentApplicationConfiguration().getClassificationService().load(classification.getUuid());
}
return classification;
}
- /**
- * @return the conversationHolder
- */
- public ConversationHolder getConversationHolder() {
- return conversationHolder;
- }
+// /**
+// * @return the conversationHolder
+// */
+// public ConversationHolder getConversationHolder() {
+// return conversationHolder;
+// }
UUID uuid = classification.getUuid();
}
+ @Override
+ public void merge() {
+ for (TaxonBase taxon:taxa){
+ CdmStore.getService(ITaxonService.class).merge(taxon, true);
+ }
+
+ // CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
+ */
+ @Override
+ public List<TaxonNode> getRootEntities() {
+ return Arrays.asList(taxonNode);
+ }
+
+ /**
+ * @return the conversation
+ */
+ public ConversationHolder getConversation() {
+ return conversation;
+ }
+
}