From 1226f24c66a950cbb80435c19f459cd4c16acbae Mon Sep 17 00:00:00 2001 From: Cherian Mathew Date: Wed, 26 Aug 2015 14:45:13 +0200 Subject: [PATCH] #5143, #5144 Improve load performance for name editor --- .../taxeditor/editor/TaxonEditorInput.java | 121 +++++++----------- .../lazyloading/PropertyPathsTest.java | 52 +++++++- 2 files changed, 100 insertions(+), 73 deletions(-) diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java index a110a37b7..c59e0f2fe 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java @@ -9,8 +9,8 @@ package eu.etaxonomy.taxeditor.editor; +import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -95,28 +95,8 @@ public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorI */ private void initForTaxonNode(UUID taxonNodeUuid) { - List taxonNodePropertyPaths = Arrays.asList(new String[] { - "taxon.annotations", - "taxon.markers", - "taxon.credits", - "taxon.extensions", - "taxon.rights", - "taxon.sources", - "taxon.descriptions", - "taxon.synonymRelations.relatedFrom.name.homotypicalGroup.typifiedNames", - "taxon.relationsToThisTaxon", - "taxon.relationsFromThisTaxon", - "taxon.taxonNodes", - "taxon.name.status", - "taxon.name.homotypicalGroup.typifiedNames", - "taxon.name.taxonBases", - "taxon.name.descriptions.descriptionElements", - "taxon.name.descriptions.markers" - - }); - - TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNodeUuid, taxonNodePropertyPaths); + 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."); @@ -126,29 +106,7 @@ public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorI } private void initForTaxonBase(UUID taxonBaseUuid) { - - - List taxonBasePropertyPaths = Arrays.asList(new String[] { - "annotations", - "markers", - "credits", - "extensions", - "rights", - "sources", - "descriptions", - "relationsToThisTaxon", - "relationsFromThisTaxon", - "taxonNodes", - "name.status", - "name.nomenclaturalReference", - "synonymRelations.relatedFrom.name.status.type", - "synonymRelations.relatedFrom.name.nomenclaturalReference.inReference", - "name.taxonBases", - "name.descriptions.descriptionElements", - "name.descriptions.markers", - "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.relatedFrom.name.*" - }); - TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths); + TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, getTaxonBasePropertyPaths()); if (taxonBase != null){ if(taxonBase.isInstanceOf(Taxon.class)){ Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); @@ -498,34 +456,53 @@ public class TaxonEditorInput extends CdmEntitySessionInput implements IEditorI @Override public Map> getPropertyPathsMap() { - Map> propertyPathsMap = new HashMap>(); -// List taxonNameBasePropertyPaths = Arrays.asList(new String[] { -// "status", -// "taxonBases.taxonNodes", -// "homotypicalGroup.typifiedNames.taxonBases.synonymRelations", -// "taxonBases.relationsToThisTaxon", -// "taxonBases.relationsFromThisTaxon", -// "descriptions" -// }); -// propertyPathsMap.put(TaxonNameBase.class, taxonNameBasePropertyPaths); -// -// List taxonBasePropertyPaths = Arrays.asList(new String[] { -// "taxon.annotations", -// "taxon.markers", -// "taxon.credits", -// "taxon.extensions", -// "taxon.rights", -// "taxon.sources", -// "taxon.descriptions" -// }); -// propertyPathsMap.put(TaxonNode.class, taxonBasePropertyPaths); -// List homotypicalGroupPropertyPaths = Arrays.asList(new String[] { -// "typifiedNames.taxonBases.synonymRelations.relatedFrom.name", -// "typifiedNames.taxonBases.synonymRelations.relatedFrom.name.status" -// }); -// propertyPathsMap.put(HomotypicalGroup.class, homotypicalGroupPropertyPaths); -// return propertyPathsMap; return null; } + private List getTaxonNodePropertyPaths() { + List taxonNodePropertyPaths = new ArrayList(); + for(String propertyPath : getTaxonBasePropertyPaths()) { + taxonNodePropertyPaths.add("taxon." + propertyPath); + } + return taxonNodePropertyPaths; + } + + private List getTaxonBasePropertyPaths() { + List 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; + } + } diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java index a496521f7..6cdb5c326 100644 --- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java +++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java @@ -9,20 +9,70 @@ */ package eu.etaxonomy.taxeditor.lazyloading; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import org.junit.Ignore; import org.junit.Test; +import eu.etaxonomy.cdm.api.service.ITaxonService; +import eu.etaxonomy.cdm.model.common.CdmBase; +import eu.etaxonomy.cdm.model.name.TaxonNameBase; +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonBase; import eu.etaxonomy.taxeditor.httpinvoker.BaseRemotingTest; +import eu.etaxonomy.taxeditor.store.CdmStore; /** + * This test class is primarily for performance testing. + * It should be used to make read-only calls to the target cdm-server. + * * @author cmathew * @date 26 Aug 2015 * */ +//FIXME:Remoting ignoring until we can target integration servers +@Ignore public class PropertyPathsTest extends BaseRemotingTest { @Test public void taxonLoadTest() { - + // load taxon Crepis from cichorieae + UUID taxonBaseUuid = UUID.fromString("d0ae2121-1c32-4737-8c49-f871d429fd90"); + List taxonBasePropertyPaths = Arrays.asList(new String[] { + "synonymRelations.synonym.name.status.type", + "name.homotypicalGroup.typifiedNames.taxonBases.synonymRelations.relatedFrom.name.status" + }); + TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).load(taxonBaseUuid, taxonBasePropertyPaths); + Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class); + Set synonymRelations = taxon.getSynonymRelations(); + for(SynonymRelationship rel : synonymRelations) { + rel.getSynonym().getName().getStatus().size(); + } + Set typifiedNames = taxon.getName().getHomotypicalGroup().getTypifiedNames(); + for(TaxonNameBase name : typifiedNames) { + Set taxonBases = name.getTaxonBases(); + for(TaxonBase tb : taxonBases) { + if(tb instanceof Synonym) { + Synonym syn = CdmBase.deproxy(tb, Synonym.class); + Set rels = syn.getSynonymRelations(); + for(SynonymRelationship rel : rels) { + rel.getSynonym().getName().getStatus().size(); + } + } + if(tb instanceof Taxon) { + Taxon syn = CdmBase.deproxy(tb, Taxon.class); + Set rels = syn.getSynonymRelations(); + for(SynonymRelationship rel : rels) { + rel.getSynonym().getName().getStatus().size(); + } + } + } + } } } -- 2.34.1