From 8437dda72eff112e5a259b33dcbaf815441b22e4 Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Tue, 11 Aug 2020 08:57:49 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201057177][Schl=C3=BCsselwort-Eigenschaft,=20die=20in=20Verwen?=
 =?UTF-8?q?dung=20ist,=20darf=20nicht=20gel=C3=B6scht=20werden=20k=C3=B6nn?=
 =?UTF-8?q?en]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../KeywordAttribute_entity.aod                |  1 +
 .../grantDeleteProcess.js                      | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 entity/KeywordAttribute_entity/grantDeleteProcess.js

diff --git a/entity/KeywordAttribute_entity/KeywordAttribute_entity.aod b/entity/KeywordAttribute_entity/KeywordAttribute_entity.aod
index 3c1336f58b..ac1185cf4b 100644
--- a/entity/KeywordAttribute_entity/KeywordAttribute_entity.aod
+++ b/entity/KeywordAttribute_entity/KeywordAttribute_entity.aod
@@ -4,6 +4,7 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/KeywordAttribute_entity/documentation.adoc</documentation>
   <title>Keyword Attribute</title>
+  <grantDeleteProcess>%aditoprj%/entity/KeywordAttribute_entity/grantDeleteProcess.js</grantDeleteProcess>
   <contentTitleProcess>%aditoprj%/entity/KeywordAttribute_entity/contentTitleProcess.js</contentTitleProcess>
   <iconId>VAADIN:KEY_O</iconId>
   <iconIdProcess>%aditoprj%/entity/KeywordAttribute_entity/iconIdProcess.js</iconIdProcess>
diff --git a/entity/KeywordAttribute_entity/grantDeleteProcess.js b/entity/KeywordAttribute_entity/grantDeleteProcess.js
new file mode 100644
index 0000000000..d7194ae0db
--- /dev/null
+++ b/entity/KeywordAttribute_entity/grantDeleteProcess.js
@@ -0,0 +1,18 @@
+import("system.result");
+import("Attribute_lib");
+import("system.vars");
+import("Sql_lib");
+import("Entity_lib");
+
+var id = vars.get("$field.AB_KEYWORD_ATTRIBUTEID");
+
+var countSql = newSelect("count(*)")
+                            .from("AB_KEYWORD_ATTRIBUTERELATION")
+                            .where("AB_KEYWORD_ATTRIBUTERELATION.AB_KEYWORD_ATTRIBUTE_ID", id)
+
+var canDelete = new HasLinkedObjectTester()
+    .andSqlYieldsZero(countSql)
+    .andNoEntityRows("KeywordAttributeRelation_entity", "AttributesForKeywordEntry", {KeywordEntryId_param: id})
+    .validate();
+    
+result.string(canDelete);
-- 
GitLab