Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permanent deletion for Case [5] #7942

Closed
22 tasks done
Tracked by #7736
MartinWahnschaffe opened this issue Feb 10, 2022 · 3 comments · Fixed by #8442
Closed
22 tasks done
Tracked by #7736

Permanent deletion for Case [5] #7942

MartinWahnschaffe opened this issue Feb 10, 2022 · 3 comments · Fixed by #8442
Assignees
Labels
backend Affects the web backend cases data-protection feature A new feature to be developed (ticket type)

Comments

@MartinWahnschaffe
Copy link
Contributor

MartinWahnschaffe commented Feb 10, 2022

Situation Description

Big picture is permanent deletion of core entities as listed in epic #7736.

Feature Description

Important: Currently deleting a case also deletes all of the related contacts. This should no longer be done. Instead:

  • Remove the logic that deletes contacts from the CaseService.delete method
  • When manually deleting a case ask the user whether all related contacts should also be deleted. Add a deleteWithContacts method to the CaseFacade.

The logic for most of what is needed here is currently executed in CaseService.delete and needs to be moved. The only thing remaining in CaseService.delete should be the soft deletion of related samples.

Related entities to be deleted in deletePermanent method:

  • delete tasks (move from the CaseService delete method)
  • delete surveillance reports (move from the CaseService delete method)
  • delete clinical visits (move from the CaseService delete method)
  • delete treatments (move from the CaseService delete method)
  • delete prescriptions (move from the CaseService delete method)
  • delete sample's reference and the sample itself if it's not referenced (duplicate the logic from delete method - when a case is permanently deleted all related samples are also permanently deleted)
  • call markAsDeleted for all documents related to the case

Entites where the Case reference needs to be removed:

  • remove the Case from any SormasToSormasShareInfo that is referencing it and delete it if no longer referenced by another entity
  • Don't cascade the deletion of the SormasToSormasOriginInfo - it can have other entities as-well
  • remove the Case from any ExternalShareInfo that is referencing it
  • Case.duplicateOf

Same for the following references, but these also need to be removed on soft-delete -> ideally move this unlinking to a separate method called from both soft- and permanent delete.

  • Contact.resultingCase
  • Contact.sourceCase
  • EventParticipant.resultingCase
  • TravelEntry.resultingCase
  • Immunization.relatedCase

Finally:

  • CoreEntityDeletionService: Call executePermanentDeletion for the CaseService

Since we are not deleting clinical visits etc. anymore when the case is soft-deleted we need to do the following:

  • Check DELETED flag of related case in ClinicalVisitService.getAllActiveClinicalVisitsAfter and getAllActiveUuids (already done vor ARCHIVED)
  • Check DELETED flag of related case in PrescriptionService.getAllActivePrescriptionsAfter and getAllActiveUuids (already done vor ARCHIVED)
  • Check DELETED flag of related case in TreatmentService.getAllActiveTreatmentsAfter and getAllActiveUuids (already done vor ARCHIVED)

Possible Alternatives

Additional Information

@MartinWahnschaffe MartinWahnschaffe added backend Affects the web backend feature A new feature to be developed (ticket type) data-protection labels Feb 10, 2022
@markusmann-vg markusmann-vg changed the title Permanent deletion for Case Permanent deletion for Case [5] Mar 3, 2022
@MateStrysewske MateStrysewske self-assigned this Mar 17, 2022
@MateStrysewske MateStrysewske added vaadin-app Affects the Vaadin application android-app Affects the Android app and removed android-app Affects the Android app vaadin-app Affects the Vaadin application labels Mar 17, 2022
MateStrysewske added a commit that referenced this issue Mar 21, 2022
@StefanKock StefanKock added this to the Sprint 113 - 1.70.0 milestone Mar 22, 2022
MateStrysewske added a commit that referenced this issue Mar 24, 2022
MateStrysewske added a commit that referenced this issue Mar 24, 2022
MateStrysewske added a commit that referenced this issue Mar 25, 2022
* #7942 - Add permanent deletion for cases

* #7942 - Added choice to delete contacts

* #7942 - Code review suggestions

* #7942 - Removed unnecessary calls

* #7942 - Test fixes

* #7942 - Fixed unit test
@richardbartha richardbartha self-assigned this Mar 25, 2022
@richardbartha
Copy link
Contributor

Ticket checked on local environment with version 1.70.0-snapshot(3309a9f)
Permanent deletion of case does not happen in the db due to some authorization issue!

Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: javax.ejb.EJBAccessException: Client not authorized for this invocation
	at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:615)
	at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:485)
	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4601)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2134)
	... 174 more
Caused by: javax.ejb.EJBAccessException: Client not authorized for this invocation
	at com.sun.ejb.containers.BaseContainer.mapLocal3xException(BaseContainer.java:2397)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2183)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2104)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:90)
	at com.sun.proxy.$Proxy534.deleteCaseInExternalSurveillanceTool(Unknown Source)
	at de.symeda.sormas.backend.caze.__EJB31_Generated__CaseFacadeEjb$CaseFacadeEjbLocal__Intf____Bean__.deleteCaseInExternalSurveillanceTool(Unknown Source)
	at de.symeda.sormas.backend.caze.CaseService.deletePermanent(CaseService.java:951)
	at de.symeda.sormas.backend.caze.CaseService.deletePermanent(CaseService.java:162)
	at de.symeda.sormas.backend.common.BaseAdoService.lambda$deletePermanent$1(BaseAdoService.java:320)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at de.symeda.sormas.backend.common.BaseAdoService.deletePermanent(BaseAdoService.java:320)
	at de.symeda.sormas.backend.common.AbstractDeletableAdoService.lambda$executePermanentDeletion$1(AbstractDeletableAdoService.java:29)
	at de.symeda.sormas.backend.util.IterableHelper.executeBatched(IterableHelper.java:36)
	at de.symeda.sormas.backend.common.AbstractDeletableAdoService.executePermanentDeletion(AbstractDeletableAdoService.java:26)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:588)
	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:408)
	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4835)
	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:665)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:834)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
	at de.symeda.sormas.backend.util.ValidationConstraintViolationInterceptor.handleValidationConstraintViolation(ValidationConstraintViolationInterceptor.java:34)
	at jdk.internal.reflect.GeneratedMethodAccessor222.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
	at de.symeda.sormas.backend.util.PerformanceLoggingInterceptor.logInvokeDuration(PerformanceLoggingInterceptor.java:37)
	at jdk.internal.reflect.GeneratedMethodAccessor221.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
	at de.symeda.sormas.backend.audit.AuditLoggerInterceptor.logAudit(AuditLoggerInterceptor.java:85)
	at jdk.internal.reflect.GeneratedMethodAccessor220.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
	at jdk.internal.reflect.GeneratedMethodAccessor219.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833)
	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615)
	at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72)
	at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
	at jdk.internal.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888)
	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833)
	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4807)
	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4795)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
	... 172 more

@richardbartha richardbartha reopened this Mar 28, 2022
@StefanKock
Copy link
Contributor

@richardbartha Version 1.70.0 was released. Please document a bug as follow-up ticket and close this one again.

@richardbartha
Copy link
Contributor

Opened ticket nr #8592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Affects the web backend cases data-protection feature A new feature to be developed (ticket type)
Projects
None yet
4 participants