Project

General

Profile

« Previous | Next » 

Revision 5b03e061

Added by Katja Luther about 8 years ago

use new createTaxonNode method instead of do it on the editor side

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java
14 14
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
15 15
import eu.etaxonomy.cdm.api.service.IClassificationService;
16 16
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
17
import eu.etaxonomy.cdm.api.service.UpdateResult;
17 18
import eu.etaxonomy.cdm.model.common.CdmBase;
18 19
import eu.etaxonomy.cdm.model.taxon.Classification;
19 20
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
......
52 53
            ITaxonTreeNode parent = getParentTreeNode();
53 54
            Taxon taxon = taxonNodePage.getTaxon();
54 55
            try{
55
                TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
56
            	UpdateResult result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, parent.getReference(), parent.getMicroReference());
57
            		
58
                //TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
56 59

  
57
                if(CdmStore.getCurrentSessionManager().isRemoting()) {
60
              /*  if(CdmStore.getCurrentSessionManager().isRemoting()) {
58 61
                    taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
59 62
                } else {
60 63
                    taxonNode = CdmStore.getService(ITaxonNodeService.class).save(taxonNode);
61
                }
62
                generatedTaxonNodeUuid = taxonNode.getUuid();
64
                }*/
65
            	generatedTaxonNodeUuid = result.getCdmEntity().getUuid();
66
            	TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(generatedTaxonNodeUuid);
63 67

  
64 68
                Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
65

  
66
                TaxonNode parentNode = taxonNode.getParent();
67
                if(parentNode.getParent() == null) {
68
                    affectedObjects.add(taxonNode.getClassification());
69
                if (result.getUpdatedObjects().iterator().hasNext()){
70
                	TaxonNode parentNode = (TaxonNode)result.getUpdatedObjects().iterator().next();
71
                	if(parentNode.getParent() == null) {
72
                        affectedObjects.add(taxonNode.getClassification());
73
                    }
74
                	if(parentNode instanceof TaxonNode) {
75
                        affectedObjects.add(parentNode);
76
                    }
69 77
                }
78
                
70 79

  
71
                if(parentNode instanceof TaxonNode) {
72
                    affectedObjects.add(parentNode);
73
                }
80
                
74 81

  
75 82
                if(CdmStore.getCurrentSessionManager().isRemoting()) {
76 83
                    CdmApplicationState.getCurrentDataChangeService()

Also available in: Unified diff