Project

General

Profile

Actions

feature request #7648

open

Create taxonrelation to genus or species when subordinate names are created

Added by Andreas Kohlbecker over 4 years ago. Updated 9 months ago.

Status:
Resolved
Priority:
Priority14
Category:
cdm-vaadin
Target version:
Start date:
Due date:
% Done:

70%

Estimated time:
Severity:
normal
Tags:

Description

When creating a species a new Taxon needs to be created for this species and the new taxon needs to be related to the genus via INCLUDED_IN.

Q1:

According to #6173 6) [N1T] 2. there should always only be one taxon per name for the higher classification.

Does this also account for genera? In the same ticket we wrote:

The search process primarily aims in finding genera, all species and subspecies which fall under each genus found are to be displayed independently of the higher classification information associated with the individual names. Practically this will be solved by creating for each TaxonName an includenIn relation to the Taxon for the name used in the uninomialOrGenus and in the specificEpithet field.
Ranks like e.g. variety and subgenus can not be associated automatically, so their relation to the genus or species respectively must be created manually if this information is available or if it is required in a specific case. It also should be considered to associate e.g. species to the according subgenera.


The relation needs to be updated or deleted when

  • a higher ranked name part is changed

Related issues

Related to PhycoBank - task #6173: Concept for a useful algae registry taxon classification ClosedAndreas Kohlbecker

Actions
Related to EDIT - bug #7858: names used in the TaxonGraph can not be deleted if the user has no DELETE permission on TaxonNewAndreas Müller

Actions
Related to EDIT - task #7862: Improve documentation on TaxonGraphHibernateListener and related classesClosedAndreas Kohlbecker

Actions
Related to EDIT - bug #8064: NPE in AbstractHibernateTaxonGraphProcessor.assureSingleTaxon() on saving new name for new registration with new genusClosedAndreas Kohlbecker

Actions
Related to EDIT - bug #9912: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String in TaxonGraphBeforeTransactionCompleteProcess L229NewAndreas Müller

Actions
Related to EDIT - bug #9223: make changes of nomenclatural references detectable again in TaxonGraphBeforeTransactionCompleteProcessResolvedAndreas Müller

Actions
Related to EDIT - task #10067: Update to hibernate 5.4 (or higher) and hibernate search 5.11 and lucene 5.5ClosedAndreas Müller05/23/202206/01/2022

Actions
Copied to EDIT - feature request #7861: TaxonGraphHibernateListener: inject the ITaxonGraphDao into TaxonGraphBeforeTransactionCompleteProcessIn ProgressAndreas Müller

Actions
Actions #1

Updated by Andreas Kohlbecker over 4 years ago

  • Description updated (diff)
Actions #2

Updated by Andreas Kohlbecker over 4 years ago

  • Related to task #6173: Concept for a useful algae registry taxon classification added
Actions #3

Updated by Andreas Müller over 4 years ago

Andreas Kohlbecker wrote:

When creating a species a new Taxon needs to be created for this species and the new taxon needs to be related to the genus via INCLUDED_IN.

Q1:

According to #6173 6) [N1T] 2. there should always only be one taxon per name for the higher classification.

The final decision on N1T was to create multiple taxa for higher rank taxon names, 1 taxon per classification. This will also hold for taxa of rank genus. Therefore we need to create multiple INCLUDED_IN relationships depending on the number of taxa we have.

Actions #4

Updated by Andreas Müller over 4 years ago

Also after import of new higher classifications we need to attache subgeneric taxa to their according taxa in bulk.

So maybe we should implement an algorithm that creates these relationships for all relevant data additionally to the algorithm which attaches a single new taxon to its parents.

Actions #5

Updated by Andreas Kohlbecker over 4 years ago

  • Target version changed from Release 5.3 to Release 5.4
Actions #6

Updated by Andreas Kohlbecker over 4 years ago

Andreas Müller wrote:

Andreas Kohlbecker wrote:

When creating a species a new Taxon needs to be created for this species and the new taxon needs to be related to the genus via INCLUDED_IN.

Q1:

According to #6173 6) [N1T] 2. there should always only be one taxon per name for the higher classification.

The final decision on N1T was to create multiple taxa for higher rank taxon names, 1 taxon per classification. This will also hold for taxa of rank genus. Therefore we need to create multiple INCLUDED_IN relationships depending on the number of taxa we have.

this is a misinterpretation of the N1T schema!

Actions #7

Updated by Andreas Kohlbecker over 4 years ago

  • Description updated (diff)
  • Priority changed from New to Highest
Actions #8

Updated by Andreas Kohlbecker over 4 years ago

  • Status changed from New to Resolved
  • Assignee changed from Andreas Kohlbecker to Andreas Müller
  • % Done changed from 0 to 50

please review 335d7c23

especially

  • PreferencePredicate.TaxonGraphSecRefUuid predicate ok?
  • CdmPreferenceLookup where to move this to?
Actions #9

Updated by Andreas Kohlbecker over 4 years ago

There is a problem when running the test in the maven test suite. The TaxonGraphHibernateListenerTest fails when it is run after specific combinations of other tests:

AnnotationDaoTest,CdmEntityDaoBaseTest,TaxonGraphHibernateListenerTest ==> FAILS
CdmEntityDaoBaseTest,AnnotationDaoTest,TaxonGraphHibernateListenerTest ==> FAILS
AnnotationDaoTest,TaxonGraphHibernateListenerTest ==> OK
CdmEntityDaoBaseTest,TaxonGraphHibernateListenerTest ==> OK

The problem caused by the test combination is:

org.hibernate.SessionException: Session is closed!
        at org.hibernate.internal.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:132)
        at org.hibernate.internal.SessionImpl.clear(SessionImpl.java:384)
        at org.springframework.orm.hibernate5.SpringSessionSynchronization.afterCompletion(SpringSessionSynchronization.java:143)
        at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:168)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:1001)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:976)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:880)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830)
        at eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest.endTransaction(CdmTransactionalIntegrationTest.java:306)
        at eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest.onTearDown(CdmTransactionalIntegrationTest.java:232)
Actions #10

Updated by Andreas Kohlbecker over 4 years ago

"Session is closed!"-problem is solved now.

Actions #11

Updated by Andreas Kohlbecker over 4 years ago

  • % Done changed from 50 to 70

implementation complete!

Actions #12

Updated by Andreas Kohlbecker over 4 years ago

  • Status changed from Resolved to In Progress

The taxon graph management processes are currently run in with the current authentication, this causes problems if a user has no grants to create or modify taxa as demonstrated by the below stacktrace snippet:

Caused by: eu.etaxonomy.cdm.database.PermissionDeniedException: [CREATE] not permitted for 'andreas' on Taxon[uuid:2abdadac-6725-493b-9ccc-70b071f773ce', toString:'Achnanthes kohlii Koh, AK & Pakla, MP sec. PhycoBank']
    at eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor.checkPermissions(CdmSecurityHibernateInterceptor.java:207)
    at eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor.onSave(CdmSecurityHibernateInterceptor.java:106)
    at org.hibernate.event.internal.AbstractSaveEventListener.substituteValuesIfNecessary(AbstractSaveEventListener.java:388)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:254)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:178)
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:97)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
    at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:648)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:640)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:635)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.taxonGraph.AbstractHibernateTaxonGraphProcessor.assureSingleTaxon(AbstractHibernateTaxonGraphProcessor.java:215)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.taxonGraph.TaxonGraphBeforeTransactionCompleteProcess.onNameOrRankChange(TaxonGraphBeforeTransactionCompleteProcess.java:157)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.taxonGraph.TaxonGraphBeforeTransactionCompleteProcess.onNewTaxonName(TaxonGraphBeforeTransactionCompleteProcess.java:153)
    at eu.etaxonomy.cdm.persistence.dao.hibernate.taxonGraph.TaxonGraphBeforeTransactionCompleteProcess.doBeforeTransactionCompletion(TaxonGraphBeforeTransactionCompleteProcess.java:80)
    at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:899)
    at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:481)
    at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2340)
    at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:147)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
    at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:231)
    at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65)
    at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:581)
    ... 106 more

The operations in the TaxonGraphBeforeTransactionCompleteProcess which modify the persisted data must be run as admin, see RunAsAuthenticator

Actions #13

Updated by Andreas Kohlbecker over 4 years ago

  • Status changed from In Progress to Feedback

The RunAsAuthenticator is in cdmlib-service and TaxonGraphBeforeTransactionCompleteProcess in cdmlib-persistence.
We need to move on of these classes into the other project. Move TaxonGraphBeforeTransactionCompleteProcess, TaxonGraphHibernateListener into cdmlib-service or rater move a authentication related class into the persistence. I think the first option is more logical.

Actions #14

Updated by Andreas Kohlbecker over 4 years ago

After moving the TaxonGraphHibernateListenerTest into cdmlib-services we are again facing problems with test being not independent.

Running

mvn  -Dtest=eu.etaxonomy.cdm.api.service.dto.TaxonRelationshipsDTOTest,eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest test

causes all tests in TaxonGraphHibernateListenerTest to fail due to polluted Session.

Tests in error: 
  testChangeSpecificEpithet_of_InfraSpecific(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testChangeNomRef(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testChangeSpecificEpithet_of_Species(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testChangeRank(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testNewTaxonName(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testChangeGenus(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType
  testNewGenusName(eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest): object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType

When running all test which precedeTaxonGraphHibernateListenerTest in the suite

mvn -Dtest=eu.etaxonomy.cdm.api.service.SecurityTest,eu.etaxonomy.cdm.api.service.StatisticsServiceImplTest,eu.etaxonomy.cdm.api.service.TaxonNodeDtoByNameComparatorTest,eu.etaxonomy.cdm.api.service.TaxonNodeServiceImplTest,eu.etaxonomy.cdm.api.service.TaxonServiceImplBusinessTest,eu.etaxonomy.cdm.api.service.TaxonServiceImplTest,eu.etaxonomy.cdm.api.service.TaxonServiceSearchTaxaAndNamesTest,eu.etaxonomy.cdm.api.service.TaxonServiceSearchTest,eu.etaxonomy.cdm.api.service.TermServiceImplTest,eu.etaxonomy.cdm.api.service.TransmissionEngineDistributionTest,eu.etaxonomy.cdm.api.service.TreeIndexComparatorTest,eu.etaxonomy.cdm.api.service.TypeDesignationSetManagerTest,eu.etaxonomy.cdm.api.service.UserAndGroupServiceImplTest,eu.etaxonomy.cdm.api.service.VocabularyServiceImplTest,eu.etaxonomy.cdm.api.service.dto.TaxonRelationshipsDTOTest,eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinterTest,eu.etaxonomy.cdm.api.service.lsid.LSIDAuthorityServiceTest,eu.etaxonomy.cdm.api.service.lsid.LSIDDataServiceTest,eu.etaxonomy.cdm.api.service.lsid.LSIDMetadataServiceTest,eu.etaxonomy.cdm.api.service.lsid.LSIDRegistryTest,eu.etaxonomy.cdm.api.service.molecular.AmplificationServiceTest,eu.etaxonomy.cdm.api.service.molecular.PrimerServiceTest,eu.etaxonomy.cdm.api.service.molecular.SequenceServiceTest,eu.etaxonomy.cdm.api.service.pager.PagerTest,eu.etaxonomy.cdm.api.service.search.LuceneIndexToolProviderTest,eu.etaxonomy.cdm.api.service.search.QueryFactoryTest,eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest test

only testNewGenusName() fails

This is just like playing lotto!

Actions #15

Updated by Andreas Kohlbecker over 4 years ago

Since this is not a problem with the TaxonGraphHibernateListenerTest I am creating a new issue: #7818

Actions #16

Updated by Andreas Kohlbecker over 4 years ago

The problem described in #7818 was not the actual cause for the test failing in the full suite, another candidate is the RegistrationIdentifierMinterTest:

mvn -Dtest=eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinterTest,eu.etaxonomy.cdm.api.service.taxonGraph.TaxonGraphHibernateListenerTest test
Actions #17

Updated by Andreas Kohlbecker over 4 years ago

now the expected functionality I implemented, but we could think about refactoring the TaxonGraphHibernateListener a bit:

Andreas Müller suggested to inject the ITaxonGraphDao into TaxonGraphBeforeTransactionCompleteProcess which could be done by passing it as cunstrucor parameter of the TaxonGraphBeforeTransactionCompleteProcess. Here some example code snippets of a spring configuration class setting up the TaxonGraphHibernateListener:

@Configuration
@CdmHibernateListener // enable the configuration which activates the TaxonGraphHibernateListener bean
public class MyConfiguration {

    @Autowired
    @Qualifier("runAsAuthenticationProvider")
    private AuthenticationProvider runAsAuthenticationProvider;

    @Autowired
    private ITaxonGraphHibernateListener taxonGraphHibernateListener;


    @Autowired
    private ITaxonGraphDao taxonGraphDao;

    @Bean
    public MyBean myBean() {
     taxonGraphHibernateListener.registerProcessClass(
        TaxonGraphBeforeTransactionCompleteProcess.class, 
        new Object[]{new RunAsAdmin(runAsAuthenticationProvider), taxonGraphDao}, 
        new Class[]{IRunAs.class, ITaxonGraphDao.class});
    }

}

The constructor of the TaxonGraphBeforeTransactionCompleteProcess would need to be adapted for this to work.
The main benefit of this excercise is that we could get rid of the AbstractHibernateTaxonGraphProcessor which currently is the common base class for the dao and the TaxonGraphBeforeTransactionCompleteProcess.

And also some documentation which goes beyond linking this ticket would be nice.

Actions #18

Updated by Andreas Müller over 4 years ago

  • Assignee changed from Andreas Müller to Andreas Kohlbecker

Can we create a new ticket for the remaining issues and close this one?

Does this ticket need further review from my side? I think functionality testing can and will be done by phycobank anyway.

Actions #19

Updated by Andreas Kohlbecker over 4 years ago

  • Related to bug #7858: names used in the TaxonGraph can not be deleted if the user has no DELETE permission on Taxon added
Actions #20

Updated by Andreas Kohlbecker over 4 years ago

  • Copied to feature request #7861: TaxonGraphHibernateListener: inject the ITaxonGraphDao into TaxonGraphBeforeTransactionCompleteProcess added
Actions #21

Updated by Andreas Kohlbecker over 4 years ago

  • Related to task #7862: Improve documentation on TaxonGraphHibernateListener and related classes added
Actions #22

Updated by Andreas Kohlbecker over 4 years ago

  • Status changed from Feedback to Resolved
  • Assignee changed from Andreas Kohlbecker to Andreas Müller

ok, all open tasks are copied to new issues: #7862, #7861

the reason why I passed this to you is written in comment 8 which is meanwhile hard to find in the long thread, here is it again:

please review 335d7c23

especially

  • PreferencePredicate.TaxonGraphSecRefUuid predicate ok?
  • CdmPreferenceLookup where to move this to? (Note by AM: this is called CdmPreferenceCache now, 2022-5)
Actions #23

Updated by Andreas Müller over 4 years ago

  • Priority changed from Highest to Priority14
Actions #24

Updated by Andreas Kohlbecker about 4 years ago

  • Related to bug #8064: NPE in AbstractHibernateTaxonGraphProcessor.assureSingleTaxon() on saving new name for new registration with new genus added
Actions #25

Updated by Andreas Müller about 1 year ago

  • Related to bug #9912: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String in TaxonGraphBeforeTransactionCompleteProcess L229 added
Actions #26

Updated by Andreas Müller about 1 year ago

  • Related to bug #9223: make changes of nomenclatural references detectable again in TaxonGraphBeforeTransactionCompleteProcess added
Actions #27

Updated by Andreas Müller 9 months ago

Andreas Kohlbecker wrote in #note-10:

"Session is closed!"-problem is solved now.

This fix was only a workaround and the problem showed up after migration to hibernate 5.2 again. I fixed it now removing pure static handling of CdmPreferenceLookup (now ...Cache) and replacing it by a Lookup per dao. The problem is that in the test suite there are multiple application contexts created (the ordinary one and the one with authentication used by CdmEntityDaoImpl) therefore a pure static approach mixes sessions between these 2 app contexts (commit 8c6b6172722d)

Actions #28

Updated by Andreas Müller 9 months ago

  • Related to task #10067: Update to hibernate 5.4 (or higher) and hibernate search 5.11 and lucene 5.5 added
Actions #29

Updated by Andreas Müller 8 months ago

  • Related to bug #10075: Fix deserialization exception for bytebuddy base hibernate SerializableProxy added
Actions #30

Updated by Andreas Müller 8 months ago

  • Related to deleted (bug #10075: Fix deserialization exception for bytebuddy base hibernate SerializableProxy)
Actions

Also available in: Atom PDF