-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/ae 2283 public UI changes
- Loading branch information
Showing
16 changed files
with
574 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
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
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
50 changes: 50 additions & 0 deletions
50
etp-core/etp-backend/src/main/clj/solita/etp/service/energiatodistus_destruction.clj
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,50 @@ | ||
(ns solita.etp.service.energiatodistus-destruction | ||
"Contains functions for anonymizing the energiatodistus and removing | ||
data linked to it." | ||
(:require [clojure.java.jdbc :as jdbc] | ||
[clojure.tools.logging :as log] | ||
[solita.etp.db :as db] | ||
[solita.etp.service.complete-energiatodistus :as complete-energiatodistus-service] | ||
[solita.etp.service.energiatodistus :as energiatodistus-service] | ||
[solita.etp.service.file :as file]) | ||
(:import (clojure.lang ExceptionInfo) | ||
(org.postgresql.util PSQLException))) | ||
|
||
(db/require-queries 'energiatodistus-destruction) | ||
|
||
(defn- get-currently-expired-todistus-ids [db] | ||
(->> (energiatodistus-destruction-db/select-expired-energiatodistus-ids db) | ||
(map :id))) | ||
|
||
(defn- anonymize-energiatodistus! [db id] | ||
(energiatodistus-destruction-db/anonymize-energiatodistus! db {:id id})) | ||
|
||
(defn- destroy-energiatodistus-audit-data! [db id] | ||
(energiatodistus-destruction-db/destroy-energiatodistus-audit-information! db {:id id})) | ||
|
||
(defn- delete-energiatodistus-pdf! [aws-s3-client id language] | ||
(let [file-key (energiatodistus-service/file-key id language)] | ||
(file/delete-file aws-s3-client file-key) | ||
(log/info (str "Deleted " file-key " from S3")))) | ||
|
||
(defn- delete-energiatodistus-pdfs! [db aws-s3-client id] | ||
(let [language-codes (-> (complete-energiatodistus-service/find-complete-energiatodistus db id) | ||
:perustiedot | ||
:kieli | ||
energiatodistus-service/language-id->codes)] | ||
(doseq [language-code language-codes] | ||
(delete-energiatodistus-pdf! aws-s3-client id language-code)))) | ||
|
||
(defn- destroy-expired-energiatodistus! [db aws-s3-client id] | ||
(jdbc/with-db-transaction [db db] | ||
(anonymize-energiatodistus! db id) | ||
(destroy-energiatodistus-audit-data! db id)) | ||
(delete-energiatodistus-pdfs! db aws-s3-client id) | ||
(log/info (str "Destroyed energiatodistus (id: " id ")"))) | ||
|
||
(defn destroy-expired-energiatodistukset! [db aws-s3-client] | ||
(log/info (str "Destruction of expired energiatodistukset initiated.")) | ||
(let [expired-todistukset (get-currently-expired-todistus-ids db)] | ||
(map #(destroy-expired-energiatodistus! db aws-s3-client %) expired-todistukset) | ||
nil)) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,4 +95,5 @@ | |
{:communication -3 | ||
:laskutus -2 | ||
:presigned -4 | ||
:aineisto -5}) | ||
:aineisto -5 | ||
:expiration -6}) |
Oops, something went wrong.