-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout d'un cheduler pour anonymiser les tables de demandes
- Loading branch information
1 parent
1a0235e
commit 529c2ca
Showing
4 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
cadastrapp/src/main/java/org/georchestra/cadastrapp/scheduler/AnonymizationScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.georchestra.cadastrapp.scheduler; | ||
|
||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
import org.georchestra.cadastrapp.model.request.InformationRequest; | ||
import org.georchestra.cadastrapp.model.request.ObjectRequest; | ||
import org.georchestra.cadastrapp.repository.ObjectRequestRepository; | ||
import org.georchestra.cadastrapp.repository.RequestRepository; | ||
import org.georchestra.cadastrapp.repository.UserRequestRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component("anonymizationSchedulerBean") | ||
public class AnonymizationScheduler { | ||
@Autowired | ||
RequestRepository requestRepository; | ||
|
||
@Autowired | ||
ObjectRequestRepository objectRequestRepository; | ||
|
||
@Autowired | ||
UserRequestRepository userRequestRepository; | ||
|
||
public void anonymize() { | ||
Calendar cal = Calendar.getInstance(); | ||
cal.add(Calendar.MONTH, -1); | ||
List<InformationRequest> ls = requestRepository.findAllByRequestDateBefore(cal.getTime()); | ||
for (InformationRequest informationRequest : ls) { | ||
for (ObjectRequest objectRequest : informationRequest.getObjectsRequest()) { | ||
objectRequestRepository.delete(objectRequest); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
userRequestRepository.delete(informationRequest.getUser()); | ||
This comment has been minimized.
Sorry, something went wrong.
pierrejego
Member
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
En fait on anonymise pas mais on purge.