cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Fri, 8 Jul 2022 13:59:36 +0000 (15:59 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Mon, 11 Jul 2022 11:02:42 +0000 (13:02 +0200)
cdmlib-cache/pom.xml
cdmlib-cache/src/main/java/eu/etaxonomy/cdm/cache/CdmModelCacher.java
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/cdmLight/out/CdmLightExportTest.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/RelationshipTermBase.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmMetaData.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v532_53x/VocabularyTreeCreator.java [moved from cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v529_53x/VocabularyTreeCreator.java with 100% similarity]

index 422f4e8292ff6e09a15201aa87c361bdecfe1c21..ca369df228435ce27f249e148a5bdd095b230ee9 100644 (file)
@@ -22,7 +22,7 @@
                 <execution>
                     <phase>compile</phase> 
                     <goals>
-                        <!-- goal 'java'  has problems with closing threads, therefore se exec -->
+                        <!-- goal 'java'  has problems with closing threads, therefore use exec -->
                         <goal>exec</goal>
                     </goals>
                 </execution>
                     <classpath/>
                     <argument>eu.etaxonomy.cdm.cache.CdmModelCacher</argument>
                 </arguments>
-                <!-- configuration if using goal 'java' -->
-     <!--       <mainClass>eu.etaxonomy.cdm.cache.CdmModelCacher</mainClass>
-                <cleanupDaemonThreads>true</cleanupDaemonThreads>
-                <stopUnresponsiveDaemonThreads>false</stopUnresponsiveDaemonThreads>  -->
             </configuration>
         </plugin>
     </plugins>
index b3541a5bea76a75650d1e6d122f716c45d58e791..81371b56feb3fc5439c75ded134f3f5d001f5de2 100644 (file)
@@ -139,9 +139,8 @@ public class CdmModelCacher {
 
         // To create the serialised cdm map run
         // mvn exec:exec -Dexec.mainClass="eu.etaxonomy.cdm.cache.CdmModelCacher"
-        // in the cdmlib-cache project root directory
+        // in the cdmlib-cache project root directory.
        // See also https://dev.e-taxonomy.eu/redmine/projects/edit/wiki/TaxonomicEditorDevelopersGuide#Model-Change-Actions
-       //Note AM: does not fully work for me, but running the main from the IDE works.
 
         System.out.println("Start CdmModelCacher main.");
         CdmModelCacher cdmModelCacher = new CdmModelCacher();
index ab791c28b29a0ff3a4f2552cf0adf6d8d40e3412..f19606a0a05b0813ef84a870da696f385e4a347e 100755 (executable)
@@ -256,7 +256,6 @@ public class CdmLightClassificationExport
                     state.getNodeChildrenMap().put(root.getUuid(), childNodes);
 
                     // add root to node map
-
                 }
                 TaxonNodeDto rootDto = new TaxonNodeDto(root);
                 UUID parentUuid = root.getParent() != null ? root.getParent().getUuid()
@@ -268,11 +267,9 @@ public class CdmLightClassificationExport
                     List<TaxonNodeDto> rootList = new ArrayList<>();
                     rootList.add(rootDto);
                     state.getNodeChildrenMap().put(parentUuid, rootList);
-
                 }
                 if (root.hasTaxon()) {
                     handleTaxon(state, root);
-
                 }
             } catch (Exception e) {
                 state.getResult().addException(e, "An unexpected error occurred when handling taxonNode "
@@ -297,8 +294,11 @@ public class CdmLightClassificationExport
                 Taxon taxon = CdmBase.deproxy(taxonNode.getTaxon());
 
                 try {
+                    //accepted name
                     TaxonName name = taxon.getName();
                     handleName(state, name, taxon, true);
+
+                    //homotypic group / synonyms
                     HomotypicalGroup homotypicGroup = taxon.getHomotypicGroup();
                     int index = 0;
                     int homotypicGroupIndex = 0;
@@ -318,18 +318,20 @@ public class CdmLightClassificationExport
                         homotypicGroupIndex++;
                     }
 
+                    //pro parte synonyms
                     index = 0;
                     for (Taxon tax : taxon.getAllProParteSynonyms()) {
                         handleProPartePartialMisapplied(state, tax, taxon, true, false, index);
                         index++;
                     }
 
-
+                    //misapplications
                     for (Taxon tax : taxon.getAllMisappliedNames()) {
                         handleProPartePartialMisapplied(state, tax, taxon, false, true, index);
                         index++;
                     }
 
+                    //taxon table
                     CdmLightExportTable table = CdmLightExportTable.TAXON;
                     String[] csvLine = new String[table.getSize()];
 
@@ -357,9 +359,12 @@ public class CdmLightClassificationExport
                             taxonNode.getClassification());
                     csvLine[table.getIndex(CdmLightExportTable.CLASSIFICATION_TITLE)] = taxonNode.getClassification()
                             .getTitleCache();
-
                     csvLine[table.getIndex(CdmLightExportTable.PUBLISHED)] = taxon.isPublish() ? "1" : "0";
+
+                    //taxon node
                     csvLine[table.getIndex(CdmLightExportTable.EXCLUDED)] = taxonNode.isExcluded() ? "1" : "0";
+                    csvLine[table.getIndex(CdmLightExportTable.UNPLACED)] = taxonNode.isUnplaced() ? "1" : "0";
+                    csvLine[table.getIndex(CdmLightExportTable.DOUBTFUL)] = taxonNode.isDoubtful() ? "1" : "0";
                     Map<Language, LanguageString> notesMap = taxonNode.getStatusNote();
                     String statusNotes = "";
                     if (!notesMap.isEmpty() && notesMap.size() == 1) {
@@ -373,9 +378,10 @@ public class CdmLightClassificationExport
                     }
                     csvLine[table.getIndex(CdmLightExportTable.STATUS_NOTES)] = statusNotes;
 
-                    csvLine[table.getIndex(CdmLightExportTable.UNPLACED)] = taxonNode.isUnplaced() ? "1" : "0";
-                    csvLine[table.getIndex(CdmLightExportTable.DOUBTFUL)] = taxonNode.isDoubtful() ? "1" : "0";
+                    //process taxon line
                     state.getProcessor().put(table, taxon, csvLine);
+
+                    //descriptions
                     handleDescriptions(state, taxon);
                 } catch (Exception e) {
                     state.getResult().addException(e,
@@ -383,7 +389,6 @@ public class CdmLightClassificationExport
                     state.getResult().setState(ExportResultState.INCOMPLETE_WITH_ERROR);
                 }
             }
-
         } catch (Exception e) {
             state.getResult().addException(e, "An unexpected error occurred when handling the taxon node of "
                     + cdmBaseStr(taxonNode.getTaxon()) + ", titleCache:"+ taxonNode.getTaxon().getTitleCache()+": " + e.getMessage());
index 200abe57941d738d84d9b504f33e50ad7a553027..9210102d0667e733f29c3230cca7ca66d649e80d 100755 (executable)
@@ -19,7 +19,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -83,19 +84,6 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
 
         @Before
         public void setUp()  {
-//            DefinedTerm ipniIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("IPNI Identifier", "IPNI Identifier", "IPNI Identifier");
-//            ipniIdentifierTerm.setUuid(DefinedTerm.uuidIpniNameIdentifier);
-//
-//            DefinedTerm tropicosIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("Tropicos Identifier", "Tropicos Identifier", "Tropicos Identifier");
-//            tropicosIdentifierTerm.setUuid(DefinedTerm.uuidTropicosNameIdentifier);
-//
-//            DefinedTerm wfoIdentifierTerm = DefinedTerm.NewIdentifierTypeInstance("WFO Identifier", "WFO Identifier", "WFO Identifier");
-//            wfoIdentifierTerm.setUuid(DefinedTerm.uuidWfoNameIdentifier);
-//            List<DefinedTermBase> terms = new ArrayList();
-//            terms.add(wfoIdentifierTerm);
-//            terms.add(tropicosIdentifierTerm);
-//            terms.add(ipniIdentifierTerm);
-//            termService.saveOrUpdate(terms);
             createFullTestDataSet();
         }
 
@@ -107,7 +95,6 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
         public void testSubTree(){
 
             CdmLightExportConfigurator config = CdmLightExportConfigurator.NewInstance();
-//            config.setCreateCondensedDistributionString(false);
             config.setTaxonNodeFilter(TaxonNodeFilter.NewSubtreeInstance(UUID.fromString("f8c9933a-fe3a-42ce-8a92-000e27bfdfac")));
 
             config.setTarget(TARGET.EXPORT_DATA);
@@ -118,9 +105,9 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
             @SuppressWarnings("unchecked")
             Map<String, byte[]> data = (Map<String, byte[]>) exportData.getExportData();
 
-            byte[] taxon = data.get(CdmLightExportTable.TAXON.getTableName());
-            Assert.assertNotNull("Taxon table must not be null", taxon);
-            String taxonStr = new String(taxon);
+            byte[] taxonByte = data.get(CdmLightExportTable.TAXON.getTableName());
+            Assert.assertNotNull("Taxon table must not be null", taxonByte);
+            String taxonStr = new String(taxonByte);
             String notExpected =  "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
             Assert.assertFalse("Result must not contain root taxon", taxonStr.startsWith(notExpected));
             String expected = "\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"4096df99-7274-421e-8843-211b603d832e\",\"CdmLightExportTest Classification\",\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"4b6acca1-959b-4790-b76e-e474a0882990\",\"My sec ref\"";
@@ -187,35 +174,35 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
 
             ByteArrayInputStream stream = new ByteArrayInputStream( data.get(CdmLightExportTable.TAXON.getTableName()));
             BufferedReader reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
-            String line;
+
             int count = 0;
             try {
-                while ((line = reader.readLine()) != null) {
+                while (reader.readLine() != null) {
                     count ++;
                 }
-                Assert.assertTrue("There should be 5 taxa", count == 6);// 6 because of the header line
+                Assert.assertTrue("There should be 5 taxa", count == 5+1);// 1 header line
 
                 stream = new ByteArrayInputStream(data.get(CdmLightExportTable.REFERENCE.getTableName()));
                 reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
                 count = 0;
-                while ((line = reader.readLine()) != null) {
+                while (reader.readLine() != null) {
                     count ++;
                 }
-                Assert.assertTrue("There should be 7 references (6 nomenclatural references and 1 sec reference)", count == 8);
+                Assert.assertTrue("There should be 7 references (6 nomenclatural references and 1 sec reference)", count == 7+1);  //1 header line
                 stream = new ByteArrayInputStream(data.get(CdmLightExportTable.SYNONYM.getTableName()));
                 reader = new BufferedReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
                 count = 0;
-                while ((line = reader.readLine()) != null) {
+                while (reader.readLine() != null) {
                     count ++;
                 }
-                Assert.assertTrue("There should be 1 synonym", count == 2);
+                Assert.assertTrue("There should be 1 synonym", count == 1+1);  // 1 header line
             } catch (IOException e) {
                 e.printStackTrace();
                 Assert.fail("IO Exception thrown during test.");
             }
-            byte[] taxon = data.get(CdmLightExportTable.TAXON.getTableName());
-            Assert.assertNotNull("Taxon table must not be null", taxon);
-            String taxonStr = new String(taxon);
+            byte[] taxonByte = data.get(CdmLightExportTable.TAXON.getTableName());
+            Assert.assertNotNull("Taxon table must not be null", taxonByte);
+            String taxonStr = new String(taxonByte);
             String notExpected =  "\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\"";
             Assert.assertFalse("Result must not contain root taxon", taxonStr.startsWith(notExpected));
             String expected = "\"b2c86698-500e-4efb-b9ae-6bb6e701d4bc\",\"4096df99-7274-421e-8843-211b603d832e\",\"CdmLightExportTest Classification\",\"3483cc5e-4c77-4c80-8cb0-73d43df31ee3\",\"9182e136-f2e2-4f9a-9010-3f35908fb5e0\",\"4b6acca1-959b-4790-b76e-e474a0882990\",\"My sec ref\"";
@@ -340,6 +327,7 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
         }
 
         public void createFullTestDataSet() {
+
             Set<TaxonNode> nodesToSave = new HashSet<>();
 
             Reference sec1 = ReferenceFactory.newGeneric();
@@ -428,13 +416,5 @@ public class CdmLightExportTest extends CdmTransactionalIntegrationTest{
         }
 
         @Override
-        public void createTestDataSet() throws FileNotFoundException {
-            //      try {
-            //      writeDbUnitDataSetFile(new String[] {
-            //              "Classification",
-            //      }, "testAttachDnaSampleToDerivedUnit");
-            //  } catch (FileNotFoundException e) {
-            //      e.printStackTrace();
-            //  }
-        }
+        public void createTestDataSet() throws FileNotFoundException {}
 }
\ No newline at end of file
index 38fd96303dd0a9e2f43c8fa5c1aa0a7595a88226..8f87d2828301bc230026d6841e62e1e0a9c0b348 100644 (file)
@@ -104,7 +104,6 @@ public abstract class RelationshipTermBase<T extends RelationshipTermBase<T>>
 //******************** CONSTRUCTOR ************************/
 
     //for hibernate use only, *packet* private required by bytebuddy
-    @SuppressWarnings("unused")
     @Deprecated
     RelationshipTermBase(){}
 
index 62d2080b942cff2e2fb0e53d7a8aeee7a65899ef..2776800de12549bf3e685a7a22c0d09625dbdabb 100644 (file)
@@ -6,7 +6,6 @@
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
-
 package eu.etaxonomy.cdm.model.metadata;
 
 import java.util.ArrayList;
@@ -19,7 +18,8 @@ import javax.persistence.Entity;
 import javax.validation.constraints.NotNull;
 import javax.xml.bind.annotation.XmlAttribute;
 
-import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.hibernate.annotations.Type;
 import org.joda.time.DateTime;
 
index fc9d745efb1abfc9495144279978d31a3cc8d83e..f108ec60f0ee421b12622eff520c76dec12e9745 100644 (file)
@@ -6,7 +6,6 @@
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
-
 package eu.etaxonomy.cdm.model.taxon;
 
 import java.util.ArrayList;
@@ -90,8 +89,6 @@ import eu.etaxonomy.cdm.validation.annotation.ChildTaxaMustNotSkipRanks;
 })
 @XmlRootElement(name = "TaxonNode")
 @Entity
-//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
-//@Indexed(index = "eu.etaxonomy.cdm.model.taxon.TaxonNode")
 @Audited
 @Table(name="TaxonNode", indexes = { @javax.persistence.Index(name = "taxonNodeTreeIndex", columnList = "treeIndex") })
 @ChildTaxaMustBeLowerRankThanParent(groups = Level3.class)