#5143, #5144 Improve load performance for name editor
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 26 Aug 2015 12:45:13 +0000 (14:45 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 26 Aug 2015 12:55:03 +0000 (14:55 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/lazyloading/PropertyPathsTest.java

index a110a37b75848bd650037356b8958254cc18bc51..c59e0f2fe7628eb14567c9bdc2f1182a2e63e5fc 100644 (file)
@@ -9,8 +9,8 @@
 
 package eu.etaxonomy.taxeditor.editor;
 
 
 package eu.etaxonomy.taxeditor.editor;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 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) {
 
      */
     private void initForTaxonNode(UUID taxonNodeUuid) {
 
-        List<String> 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.");
 
         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) {
     }
 
     private void initForTaxonBase(UUID taxonBaseUuid) {
-
-
-        List<String> 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);
         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<Object, List<String>> getPropertyPathsMap() {
 
     @Override
     public Map<Object, List<String>> getPropertyPathsMap() {
-        Map<Object, List<String>> propertyPathsMap = new HashMap<Object, List<String>>();
-//        List<String> taxonNameBasePropertyPaths = Arrays.asList(new String[] {
-//                "status",
-//                "taxonBases.taxonNodes",
-//                "homotypicalGroup.typifiedNames.taxonBases.synonymRelations",
-//                "taxonBases.relationsToThisTaxon",
-//                "taxonBases.relationsFromThisTaxon",
-//                "descriptions"
-//        });
-//         propertyPathsMap.put(TaxonNameBase.class, taxonNameBasePropertyPaths);
-//
-//         List<String> 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<String> 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;
     }
 
         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;
+    }
+
 }
 }
index a496521f72eb75ae9638197c47122da63ad5210b..6cdb5c326c03f23c4eb9cad4a6cce65dd91b3792 100644 (file)
@@ -9,20 +9,70 @@
 */
 package eu.etaxonomy.taxeditor.lazyloading;
 
 */
 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 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.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
  *
  */
  * @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() {
 public class PropertyPathsTest extends BaseRemotingTest {
 
     @Test
     public void taxonLoadTest() {
-
+        // load taxon Crepis from cichorieae
+        UUID taxonBaseUuid = UUID.fromString("d0ae2121-1c32-4737-8c49-f871d429fd90");
+        List<String> 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<SynonymRelationship> synonymRelations = taxon.getSynonymRelations();
+        for(SynonymRelationship rel : synonymRelations) {
+            rel.getSynonym().getName().getStatus().size();
+        }
+        Set<TaxonNameBase> typifiedNames = taxon.getName().getHomotypicalGroup().getTypifiedNames();
+        for(TaxonNameBase name : typifiedNames) {
+            Set<TaxonBase> taxonBases = name.getTaxonBases();
+            for(TaxonBase tb : taxonBases) {
+                if(tb instanceof Synonym) {
+                    Synonym syn = CdmBase.deproxy(tb, Synonym.class);
+                    Set<SynonymRelationship> rels = syn.getSynonymRelations();
+                    for(SynonymRelationship rel : rels) {
+                        rel.getSynonym().getName().getStatus().size();
+                    }
+                }
+                if(tb instanceof Taxon) {
+                    Taxon syn = CdmBase.deproxy(tb, Taxon.class);
+                    Set<SynonymRelationship> rels = syn.getSynonymRelations();
+                    for(SynonymRelationship rel : rels) {
+                        rel.getSynonym().getName().getStatus().size();
+                    }
+                }
+            }
+        }
     }
 
 }
     }
 
 }