diff --git a/entity/History_entity/History_entity.aod b/entity/History_entity/History_entity.aod index ee8acf62800ccc5794a7c77dc87f838bf9450d7f..858f19eb53b930ad7c103eca4807026512a23395 100644 --- a/entity/History_entity/History_entity.aod +++ b/entity/History_entity/History_entity.aod @@ -11,6 +11,14 @@ <conditionProcess>%aditoprj%/entity/History_entity/conditionProcess.js</conditionProcess> <onDBInsert>%aditoprj%/entity/History_entity/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/History_entity/onDBDelete.js</onDBDelete> + <linkInformation> + <linkInformation> + <name>0f5254de-80c0-4861-9526-dab5144c73e1</name> + <tableName>HISTORY</tableName> + <primaryKey>HISTORYID</primaryKey> + <isUIDTable v="true" /> + </linkInformation> + </linkInformation> <entityFields> <entityField> <name>DIRECTION</name> @@ -150,12 +158,57 @@ </dependencies> </entityIncomingField> </entityFields> - <linkInformation> - <linkInformation> - <name>0f5254de-80c0-4861-9526-dab5144c73e1</name> - <tableName>HISTORY</tableName> - <primaryKey>HISTORYID</primaryKey> - <isUIDTable v="true" /> - </linkInformation> - </linkInformation> + <recordContainers> + <dbRecordContainer> + <name>db</name> + <alias>Data_alias</alias> + <fromClauseProcess>%aditoprj%/entity/History_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess> + <conditionProcess>%aditoprj%/entity/History_entity/recordcontainers/db/conditionProcess.js</conditionProcess> + <onDBInsert>%aditoprj%/entity/History_entity/recordcontainers/db/onDBInsert.js</onDBInsert> + <onDBDelete>%aditoprj%/entity/History_entity/recordcontainers/db/onDBDelete.js</onDBDelete> + <linkInformation> + <linkInformation> + <name>3d146593-d7a8-463c-9805-0d607c9053e9</name> + <tableName>HISTORY</tableName> + <primaryKey>HISTORYID</primaryKey> + <isUIDTable v="true" /> + <readonly v="false" /> + </linkInformation> + </linkInformation> + <recordFieldMappings> + <dbRecordFieldMapping> + <name>DATE_NEW.value</name> + <value>HISTORY.DATE_NEW</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>HISTORYID.value</name> + <value>HISTORY.HISTORYID</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>DIRECTION.value</name> + <value>HISTORY.DIRECTION</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>INFO.value</name> + <value>HISTORY.INFO</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>MEDIUM.value</name> + <value>HISTORY.MEDIUM</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>SUBJECT.value</name> + <value>HISTORY.SUBJECT</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>ENTRYDATE.value</name> + <value>HISTORY.ENTRYDATE</value> + </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>USER_NEW.value</name> + <value>HISTORY.USER_NEW</value> + </dbRecordFieldMapping> + </recordFieldMappings> + </dbRecordContainer> + </recordContainers> </entity> diff --git a/entity/History_entity/recordcontainers/db/conditionProcess.js b/entity/History_entity/recordcontainers/db/conditionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f98df46a0822d6518665993eae104760207a4d12 --- /dev/null +++ b/entity/History_entity/recordcontainers/db/conditionProcess.js @@ -0,0 +1,9 @@ +import("system.db"); +import("system.result"); +import("Sql_lib"); + +var cond = new SqlCondition(); +cond.andPrepareVars("HISTORYLINK.ROW_ID", "$param.RowId_param"); + +//TODO: use a preparedCondition when available +result.string(db.translateCondition(cond.build("1 = 1"))); \ No newline at end of file diff --git a/entity/History_entity/recordcontainers/db/fromClauseProcess.js b/entity/History_entity/recordcontainers/db/fromClauseProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..4086d379af381c81a5532a920eec8e778aa041aa --- /dev/null +++ b/entity/History_entity/recordcontainers/db/fromClauseProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("HISTORY join HISTORYLINK on (HISTORY.HISTORYID = HISTORYLINK.HISTORY_ID)"); \ No newline at end of file diff --git a/entity/History_entity/recordcontainers/db/onDBDelete.js b/entity/History_entity/recordcontainers/db/onDBDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..c054511acc1b09e43342928834e640c67a375d3f --- /dev/null +++ b/entity/History_entity/recordcontainers/db/onDBDelete.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.db"); + +db.deleteData("HISTORYLINK", "HISTORYLINK.HISTORY_ID = '" + vars.getString("$field.HISTORYID") + "'"); + diff --git a/entity/History_entity/recordcontainers/db/onDBInsert.js b/entity/History_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..10db22cf0452e0bc6ba7f737923d798aac94dcb9 --- /dev/null +++ b/entity/History_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,12 @@ +import("system.util"); +import("system.db"); +import("system.neon"); +import("system.vars"); + +if (vars.exists("$param.RowId_param") && vars.get("$param.RowId_param") != null ) +{ + var cols = ["HISTORYLINKID", "OBJECT_ID", "ROW_ID", "HISTORY_ID", "USER_NEW", "DATE_NEW"]; + var vals = [util.getNewUUID(), 1, vars.get("$param.RowId_param"), vars.getString("$field.HISTORYID"), vars.getString("$sys.user"), vars.getString("$sys.date")]; // use new OBJECT_ID for context + var colTypes = db.getColumnTypes("HISTORYLINK", cols); + db.insertData("HISTORYLINK", cols, colTypes, vals); +} \ No newline at end of file