From 5bfa0ec32dd0559d00d3252129c1a23d38659d17 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 31 Jan 2019 16:41:18 +0100
Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1032647][Vertrieb -
 Produkt - Preisliste - Bei Neueintrag soll des Feld Produkt vorbelegt sein]

---
 .../recordcontainers/db/conditionProcess.js         |  8 --------
 entity/Productprice_entity/Productprice_entity.aod  | 13 +++----------
 .../product_groupcodeid/possibleItemsProcess.js     |  7 -------
 .../entityfields/product_id/displayValueProcess.js  |  8 ++++++++
 .../entityfields/product_id/valueProcess.js         | 11 +++++------
 process/Product_lib/process.js                      |  2 +-
 6 files changed, 17 insertions(+), 32 deletions(-)
 delete mode 100644 entity/Productprice_entity/entityfields/product_groupcodeid/possibleItemsProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/product_id/displayValueProcess.js

diff --git a/entity/ObjectRelation_entity/recordcontainers/db/conditionProcess.js b/entity/ObjectRelation_entity/recordcontainers/db/conditionProcess.js
index 6b012d3a31..f8c7455fe2 100644
--- a/entity/ObjectRelation_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/ObjectRelation_entity/recordcontainers/db/conditionProcess.js
@@ -4,14 +4,6 @@ import("system.result");
 import("system.db");
 import("Sql_lib");
 
-logging.log("rowid: " + vars.get("$param.Object1Rowid_param"))
-logging.log("type: " + vars.get("$param.Object1Type_param"))
-logging.log(SqlCondition.begin()
-                .andPrepareVars("AB_OBJECTRELATION.OBJECT1_TYPE", "$param.Object1Type_param")
-                .andPrepareVars("AB_OBJECTRELATION.OBJECT1_ROWID", "$param.Object1Rowid_param")
-                .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONID", "$param.ObjectRelatonId_param")
-                .build("1=2").toSource())
-
 result.string(db.translateCondition(SqlCondition.begin()
                 .andPrepareVars("AB_OBJECTRELATION.OBJECT1_TYPE", "$param.Object1Type_param")
                 .andPrepareVars("AB_OBJECTRELATION.OBJECT1_ROWID", "$param.Object1Rowid_param")
diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod
index c767d4f5e2..e15116e40b 100644
--- a/entity/Productprice_entity/Productprice_entity.aod
+++ b/entity/Productprice_entity/Productprice_entity.aod
@@ -4,7 +4,6 @@
   <title>Price list</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/Productprice_entity/documentation.adoc</documentation>
-  <onValidation>%aditoprj%/entity/Productprice_entity/onValidation.js</onValidation>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityField>
@@ -56,10 +55,11 @@
       <name>PRODUCT_ID</name>
       <title>Product</title>
       <linkedContext>Product_context</linkedContext>
-      <mandatory v="false" />
+      <mandatory v="true" />
       <outgoingField>ProductpriceProduct_dfo</outgoingField>
       <state>AUTO</state>
       <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>RELATION_ID</name>
@@ -134,11 +134,6 @@
       <mandatory v="false" />
       <description>PARAMETER</description>
     </entityParameter>
-    <entityField>
-      <name>PRODUCT_GROUPCODEID</name>
-      <title>Product group</title>
-      <possibleItemsProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_groupcodeid/possibleItemsProcess.js</possibleItemsProcess>
-    </entityField>
     <entityIncomingField>
       <name>OrgProductprice_dfi</name>
       <fieldType>DEPENDENCY_IN</fieldType>
@@ -194,13 +189,11 @@
     <dbRecordContainer>
       <name>db</name>
       <alias>Data_alias</alias>
-      <maximumDbRows v="0" />
       <conditionProcess>%aditoprj%/entity/Productprice_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
       <orderClauseProcess>%aditoprj%/entity/Productprice_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
-      <onDBInsert>%aditoprj%/entity/Productprice_entity/onDBInsert.js</onDBInsert>
       <linkInformation>
         <linkInformation>
-          <name>b65e4aab-35f4-49d0-8f05-389572f29dcb</name>
+          <name>85fd1bcf-499f-4708-ad8e-18f5a0f5337d</name>
           <tableName>PRODUCTPRICE</tableName>
           <primaryKey>PRODUCTPRICEID</primaryKey>
           <isUIDTable v="true" />
diff --git a/entity/Productprice_entity/entityfields/product_groupcodeid/possibleItemsProcess.js b/entity/Productprice_entity/entityfields/product_groupcodeid/possibleItemsProcess.js
deleted file mode 100644
index 8828ea3822..0000000000
--- a/entity/Productprice_entity/entityfields/product_groupcodeid/possibleItemsProcess.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import("system.result");
-import("Keyword_lib");
-
-var items;
-
-items = KeywordUtils.getStandardArray("GROUPCODE");
-result.object(items);
\ No newline at end of file
diff --git a/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js b/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js
new file mode 100644
index 0000000000..43c39903a2
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js
@@ -0,0 +1,8 @@
+import("system.result");
+import("system.db");
+import("Sql_lib");
+
+// TODO: Wenn es möglich ist, den anzeigenamen des Produkts über die Entity beziehung zu laden, dann umbauen...!!!
+result.string(db.cell(SqlCondition.begin()
+                                  .andPrepareVars("PRODUCT.PRODUCTID", "$field.PRODUCT_ID")
+                                  .buildSql("select PRODUCTNAME from PRODUCT", "1=2")));
\ No newline at end of file
diff --git a/entity/Productprice_entity/entityfields/product_id/valueProcess.js b/entity/Productprice_entity/entityfields/product_id/valueProcess.js
index c54ef701ce..fa4b37b7f6 100644
--- a/entity/Productprice_entity/entityfields/product_id/valueProcess.js
+++ b/entity/Productprice_entity/entityfields/product_id/valueProcess.js
@@ -1,10 +1,9 @@
+import("system.logging");
 import("system.result");
-import("system.neon");
 import("system.vars");
 
-if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param"))
 {
-    if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != null && vars.get("$param.ProductId_param") != "")
-        result.string(vars.getString("$param.ProductId_param"));    
-}
-
+    result.string(vars.getString("$param.ProductId_param"));
+    logging.log("---" + vars.get("$param.ProductId_param"))
+}
\ No newline at end of file
diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js
index ceb0f67234..f0216b63a3 100644
--- a/process/Product_lib/process.js
+++ b/process/Product_lib/process.js
@@ -48,7 +48,7 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell) {
         else
             return "";
     } else {
-        throw new Error(); // TODO: add message
+        return "";
     }
 }
 
-- 
GitLab