package eu.etaxonomy.taxeditor.editor;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
-import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.IClassificationService;
* @created 19.03.2009
* @version 1.0
*/
-public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorInput, IConversationEnabled, IPersistableElement {
+public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorInput, IConversationEnabled, IPersistableElement {
private final ConversationHolder conversation;
private TaxonBase initiallySelectedTaxonBase;
- private final ITaxonNodeService service;
-
private enum CdmType {
TAXON_NODE,
TAXON_BASE,
}
private TaxonEditorInput(UUID uuid, CdmType type) {
+ super(true);
this.conversation = CdmStore.createConversation();
- service = CdmStore.getService(ITaxonNodeService.class);
switch(type) {
case PARENT_TAXON_NODE:
initForParentTaxonNode(uuid);
private void initForTaxonNode(UUID taxonNodeUuid) {
- TaxonNode taxonNode = getCdmEntitySession().remoteLoad(service,taxonNodeUuid, null);
+ TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid, getTaxonNodePropertyPaths());
if(taxonNode == null){
MessagingUtils.warningDialog("Not yet implemented", TaxonEditorInput.class, "Selected element is not type TaxonBase.");
}
private void initForTaxonBase(UUID taxonBaseUuid) {
-
- TaxonBase taxonBase = getCdmEntitySession().remoteLoad(CdmStore.getService(ITaxonService.class),taxonBaseUuid);
+ TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, getTaxonBasePropertyPaths());
if (taxonBase != null){
if(taxonBase.isInstanceOf(Taxon.class)){
Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
TaxonNode newTaxonNode = parentNode.addChildTaxon(newTaxon, parentNode.getReference(), parentNode.getMicroReference());
// add the new taxon to the editors persistence context
- UUID newTaxonNodeUuid = getCdmEntitySession().remoteSave(CdmStore.getService(ITaxonNodeService.class),newTaxonNode);
+ UUID newTaxonNodeUuid = CdmStore.getService(ITaxonNodeService.class).save(newTaxonNode).getUuid();
initForTaxonNode(newTaxonNodeUuid);
}
}
-
-
/**
* <p>NewEmptyInstance</p>
*
return initiallySelectedTaxonBase;
}
- @Override
- public String toString() {
- return String.format("%s[%s]", this.getClass().getSimpleName(), getTaxon());
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#getService()
- */
- @Override
- public ITaxonNodeService getService() {
- return service;
- }
+// @Override
+// public String toString() {
+// return String.format("%s[%s]", this.getClass().getSimpleName(), getTaxon());
+// }
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#getRootEntities()
+ * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getRootEntities()
*/
@Override
- public List<TaxonNode> getRootEntities() {
+ public List<TaxonNode> getRootEntities() {
return Arrays.asList(taxonNode);
}
-
/* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#update()
+ * @see eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput#merge()
*/
@Override
- public <T extends CdmBase> void update() {
- taxonNode = getCdmEntitySession().remoteUpdate(service, taxonNode);
+ public void merge() {
+ CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.api.application.ICdmChangeListener#onChange(eu.etaxonomy.cdm.api.application.CdmChangeEvent)
- */
@Override
- public void onChange(CdmChangeEvent event) {
- // TODO Auto-generated method stub
+ public Map<Object, List<String>> getPropertyPathsMap() {
+ return null;
+ }
+
+ private List<String> getTaxonNodePropertyPaths() {
+ List<String> taxonNodePropertyPaths = new ArrayList<String>();
+ for(String propertyPath : getTaxonBasePropertyPaths()) {
+ taxonNodePropertyPaths.add("taxon." + propertyPath);
+ }
+ return taxonNodePropertyPaths;
+ }
+ private List<String> getTaxonBasePropertyPaths() {
+ List<String> taxonBasePropertyPaths = Arrays.asList(new String[] {
+ "sec",
+ "createdBy",
+ "updatedBy",
+ "annotations",
+ "markers",
+ "credits",
+ "extensions",
+ "rights",
+ "sources",
+ "descriptions",
+ "relationsToThisTaxon",
+ "relationsFromThisTaxon",
+ "taxonNodes",
+ "descriptions.descriptionElements.feature",
+ "descriptions.descriptionElements.area",
+ "descriptions.descriptionElements.status",
+ "descriptions.markers",
+ "name.descriptions",
+ "name.typeDesignations",
+ "name.status",
+ "name.nomenclaturalReference.inReference",
+ "name.taxonBases.taxonNodes",
+ "name.relationsFromThisName",
+ "name.relationsToThisName",
+ "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.synonym.name.status",
+ "name.homotypicalGroup.typifiedNames.relationsToThisName.fromName",
+ "synonymRelations.synonym.name.status.type",
+ "synonymRelations.synonym.name.relationsToThisName.fromName",
+ "synonymRelations.synonym.name.nomenclaturalReference.inReference.authorship",
+ "synonymRelations.synonym.name.nomenclaturalReference.authorship",
+ "synonymRelations.synonym.name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations"
+ });
+
+ return taxonBasePropertyPaths;
}
}