Search in sources :

Example 6 with PayPapercutTransactionLog

use of org.esupportail.papercut.domain.PayPapercutTransactionLog in project esup-papercut by EsupPortail.

the class AdminController method archiveAll.

@Transactional
@PostMapping(value = "archiveAll")
public String archiveAll(@PathVariable String papercutContext) {
    Page<PayPapercutTransactionLog> txLogsPage = papercutDaoService.findAllPayPapercutTransactionLogs(PageRequest.of(0, 1000));
    while (true) {
        for (PayPapercutTransactionLog txLog : txLogsPage.getContent()) {
            txLog.setArchived(true);
        }
        if (txLogsPage.hasNext()) {
            Pageable pageable = txLogsPage.nextPageable();
            txLogsPage = papercutDaoService.findAllPayPapercutTransactionLogs(pageable);
        } else {
            break;
        }
    }
    return "redirect:/" + papercutContext + "/admin";
}
Also used : PayPapercutTransactionLog(org.esupportail.papercut.domain.PayPapercutTransactionLog) Pageable(org.springframework.data.domain.Pageable) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with PayPapercutTransactionLog

use of org.esupportail.papercut.domain.PayPapercutTransactionLog in project esup-papercut by EsupPortail.

the class AdminController method archive.

@Transactional
@PostMapping(value = "archive")
public String archive(@RequestParam Long id, @PathVariable String papercutContext) {
    PayPapercutTransactionLog txLog = papercutDaoService.findById(id);
    txLog.setArchived(true);
    return "redirect:/" + papercutContext + "/admin?id=" + id;
}
Also used : PayPapercutTransactionLog(org.esupportail.papercut.domain.PayPapercutTransactionLog) PostMapping(org.springframework.web.bind.annotation.PostMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with PayPapercutTransactionLog

use of org.esupportail.papercut.domain.PayPapercutTransactionLog in project esup-papercut by EsupPortail.

the class AnonymiseService method anonymiseOldTransactions.

@Scheduled(fixedDelay = 3600000)
public void anonymiseOldTransactions() {
    for (String context : config.getContexts().keySet()) {
        if (config.getContext(context).getAnonymiseEnabled()) {
            log.debug(String.format("anonymiseOldTransactions called for context %s - transactions logs older than %s days will be anonymised", context, config.getContext(context).getAnonymiseOldDays()));
            List<PayPapercutTransactionLog> transactionLogs = allContextPapercutDaoService.findOldPayPapercutTransactionLogsNotAnonymised(config.getContext(context).getAnonymiseOldDays());
            for (PayPapercutTransactionLog transactionLog : transactionLogs) {
                anonymise(transactionLog);
            }
            if (transactionLogs.size() > 0) {
                log.info(transactionLogs.size() + " old transactionLogs anonymised");
            }
        } else {
            log.debug(String.format("Anonymisation of context %s is not Enabled", context));
        }
    }
}
Also used : PayPapercutTransactionLog(org.esupportail.papercut.domain.PayPapercutTransactionLog) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 9 with PayPapercutTransactionLog

use of org.esupportail.papercut.domain.PayPapercutTransactionLog in project esup-papercut by EsupPortail.

the class AnonymizeService method anonymizeOldTransactions.

@Scheduled(fixedDelay = 3600000)
public void anonymizeOldTransactions() {
    Collection<EsupPapercutContext> availableContexts = esupPapercutConfig.getContexts().values();
    for (EsupPapercutContext availableContext : availableContexts) {
        if (availableContext.getAnonymization().isEnabled()) {
            log.debug("anonymizeOldTransactions called for context : " + availableContext);
            List<PayPapercutTransactionLog> transactionLogs = payPapercutTransactionLogRepository.findAllByTransactionDateBeforeAndUidIsNotLike(Date.from(Instant.now().minus(Duration.ofDays(availableContext.getAnonymization().getOldDaysTransactionsLogs()))), "anonymized");
            for (PayPapercutTransactionLog transactionLog : transactionLogs) {
                anonymizeOneService.anonymize(transactionLog.getId());
            }
            if (transactionLogs.size() > 0) {
                log.info(transactionLogs.size() + " old transactionLogs anonymized for context : " + availableContext);
            }
        }
    }
}
Also used : PayPapercutTransactionLog(org.esupportail.papercut.domain.PayPapercutTransactionLog) EsupPapercutContext(org.esupportail.papercut.config.EsupPapercutContext) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 10 with PayPapercutTransactionLog

use of org.esupportail.papercut.domain.PayPapercutTransactionLog in project esup-papercut by EsupPortail.

the class AnonymizeOneService method anonymize.

@Transactional
public void anonymize(long id) {
    PayPapercutTransactionLog transactionLog = payPapercutTransactionLogRepository.findById(id).get();
    transactionLog.setUid("anonymized");
    transactionLog.setReference("anonymized");
}
Also used : PayPapercutTransactionLog(org.esupportail.papercut.domain.PayPapercutTransactionLog) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PayPapercutTransactionLog (org.esupportail.papercut.domain.PayPapercutTransactionLog)11 Transactional (org.springframework.transaction.annotation.Transactional)6 Date (java.util.Date)2 EsupPapercutContext (org.esupportail.papercut.config.EsupPapercutContext)2 Pageable (org.springframework.data.domain.Pageable)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 TreeMap (java.util.TreeMap)1 IzlyPayForm (org.esupportail.papercut.domain.IzlyPayForm)1 PayBoxForm (org.esupportail.papercut.domain.PayBoxForm)1 UserPapercutInfos (org.esupportail.papercut.domain.UserPapercutInfos)1 StopWatch (org.springframework.util.StopWatch)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1