diff --git a/entity/Document_entity/Document_entity.aod b/entity/Document_entity/Document_entity.aod index 9538910600d82021526465d4a5f860db211b964b..53179f421d3345b085069915dd237dded13bd70a 100644 --- a/entity/Document_entity/Document_entity.aod +++ b/entity/Document_entity/Document_entity.aod @@ -27,6 +27,7 @@ <name>NAME</name> <title>Dateiname</title> <fieldName>FILENAME</fieldName> + <mandatory v="true" /> <state>AUTO</state> </entityField> <entityField> @@ -44,6 +45,7 @@ <title>Datum</title> <fieldName>EDIT_DATE</fieldName> <contentType>DATE</contentType> + <outputFormat>yyyy-MM-dd HH:mm:ss</outputFormat> <state>READONLY</state> </entityField> <entityField> @@ -69,7 +71,7 @@ <name>BINDATA_UPLOAD</name> <title>Datei</title> <contentType>FILE</contentType> - <defaultAction>%aditoprj%/entity/Document_entity/entityfields/bindata_upload/defaultAction.js</defaultAction> + <onValueChange>%aditoprj%/entity/Document_entity/entityfields/bindata_upload/onValueChange.js</onValueChange> </entityField> <entityActionGroup> <name>Document_actions</name> diff --git a/entity/Document_entity/entityfields/bindata_upload/defaultAction.js b/entity/Document_entity/entityfields/bindata_upload/defaultAction.js deleted file mode 100644 index 2822624e944f56efe058139e54e0b97775d664d4..0000000000000000000000000000000000000000 --- a/entity/Document_entity/entityfields/bindata_upload/defaultAction.js +++ /dev/null @@ -1,2 +0,0 @@ -import("system.logging"); -logging.log("document default action"); \ No newline at end of file diff --git a/entity/Document_entity/entityfields/bindata_upload/onValueChange.js b/entity/Document_entity/entityfields/bindata_upload/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..71f1f3c4dbb0367012d066a6d47e37146a6b1f34 --- /dev/null +++ b/entity/Document_entity/entityfields/bindata_upload/onValueChange.js @@ -0,0 +1,8 @@ +import("system.logging"); +import("system.vars"); +import("system.neon"); +import("Util_lib"); +import("Document_lib"); + +var uploadValue = ProcessHandlingUtil.getOnValidationValue(vars.get("$field.BINDATA_UPLOAD")); +neon.setFieldValue("$field.NAME", DocumentUtil.getFilenameFromUpload(uploadValue)); diff --git a/entity/Document_entity/onInsert.js b/entity/Document_entity/onInsert.js index 9373df97d6b978c37603e8f7cf3d4b176c506e67..5bb825c7b8412a332957bbd3d90b01cca81e79fa 100644 --- a/entity/Document_entity/onInsert.js +++ b/entity/Document_entity/onInsert.js @@ -1,11 +1,12 @@ import("system.logging"); import("system.db"); import("system.vars"); +import("Document_lib"); var assignmentTable = vars.get("$param.AssignmentTable_param"); var assignmentName = vars.get("$param.AssignmentName_param"); var assignmentRowId = vars.get("$param.AssignmentRowId_param"); -var bindata = vars.get("$field.BINDATA_UPLOAD"); +var bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.BINDATA_UPLOAD")); var filename = vars.get("$field.NAME"); var description = vars.get("$field.DESCRIPTION"); var alias = db.getCurrentAlias(); diff --git a/entity/Document_entity/onUpdate.js b/entity/Document_entity/onUpdate.js index acd28548e79c49b8a9500768e1b77884307877ae..b43e4f3eaebf22042cbcdefaa67a199a2e849a01 100644 --- a/entity/Document_entity/onUpdate.js +++ b/entity/Document_entity/onUpdate.js @@ -1,6 +1,7 @@ import("system.vars"); import("system.db"); import("system.logging"); +import("Document_lib"); var id = vars.get("$field.ID"); var parentId = ""; @@ -8,10 +9,15 @@ var fileName = vars.get("$field.NAME"); var description = vars.get("$field.DESCRIPTION"); var keyword = ""; var alias = db.getCurrentAlias(); -var base64data = vars.get("$field.BINDATA_UPLOAD"); + +var bindata = DocumentUtil.getBindataFromUpload(vars.get("$field.BINDATA_UPLOAD")); + +if (bindata == ''){ + bindata = vars.get("$field.BINDATA_UPLOAD") +} // Check if bindata is present and execute the corresponding update method -if(base64data != '') - db.updateBinary(id, parentId, base64data, fileName, description, keyword, alias); +if(bindata != '') + db.updateBinary(id, parentId, bindata, fileName, description, keyword, alias); else db.updateBinaryMetadata(id, parentId, fileName, description, keyword, alias); \ No newline at end of file diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod index b9ad55a7ef331c6febd3f03705b16f3566f6ef80..7d6620665e9b89be3cf68bf59eebe6e1c26cb415 100644 --- a/entity/Pers_entity/Pers_entity.aod +++ b/entity/Pers_entity/Pers_entity.aod @@ -10,6 +10,25 @@ <alias>Data_alias</alias> <fromClauseProcess>%aditoprj%/entity/Pers_entity/fromClauseProcess.js</fromClauseProcess> <conditionProcess>%aditoprj%/entity/Pers_entity/conditionProcess.js</conditionProcess> + <linkInformation> + <linkInformation> + <name>9ce0dfd2-192d-4446-8b2d-a4c053abc44a</name> + <tableName>PERS</tableName> + <primaryKey>PERSID</primaryKey> + </linkInformation> + <linkInformation> + <name>348312a8-6392-4adb-af69-75cbcfc5b65b</name> + <tableName>RELATION</tableName> + <primaryKey>RELATIONID</primaryKey> + <isUIDTable v="true" /> + </linkInformation> + <linkInformation> + <name>edf5e4f3-993d-4097-b59d-a100d5222cad</name> + <tableName>ORG</tableName> + <primaryKey>ORGID</primaryKey> + <readonly v="true" /> + </linkInformation> + </linkInformation> <entityFields> <entityField> <name>DATEOFBIRTH</name> @@ -449,23 +468,4 @@ <description>PARAMETER</description> </entityParameter> </entityFields> - <linkInformation> - <linkInformation> - <name>9ce0dfd2-192d-4446-8b2d-a4c053abc44a</name> - <tableName>PERS</tableName> - <primaryKey>PERSID</primaryKey> - </linkInformation> - <linkInformation> - <name>348312a8-6392-4adb-af69-75cbcfc5b65b</name> - <tableName>RELATION</tableName> - <primaryKey>RELATIONID</primaryKey> - <isUIDTable v="true" /> - </linkInformation> - <linkInformation> - <name>edf5e4f3-993d-4097-b59d-a100d5222cad</name> - <tableName>ORG</tableName> - <primaryKey>ORGID</primaryKey> - <readonly v="true" /> - </linkInformation> - </linkInformation> </entity> diff --git a/process/Document_lib/process.js b/process/Document_lib/process.js index 4b811e6a60aad40a4d1975ee6df7c17a93e60f35..11f51c0ffff52cc6ae45da4e53a5538b92b949f6 100644 --- a/process/Document_lib/process.js +++ b/process/Document_lib/process.js @@ -53,3 +53,35 @@ DocumentUtil.deleteCurrentDocument = function() { db.deleteBinary(uid, alias); } } + +/** + * Utility function to retrieve the filename from an uploadcomponent value. + * The value of an uploadcomponent contains filename + filedata separated by + * a semicolon e.g. "file1.jpg;base64data" + * + * @param {String} pUploadValue the value of the uploadcomponent (filename + filedata) + * @return {String} the filename or empty String + */ +DocumentUtil.getFilenameFromUpload = function(pUploadValue) { + var result = pUploadValue.split(";"); + if(result.length > 0) + return result[0]; + else + return ''; +} + +/** + * Utility function to retrieve the filedata from an uploadcomponent value. + * The value of an uploadcomponent contains filename + filedata separated by + * a semicolon e.g. "file1.jpg;base64data" + * + * @param {String} pUploadValue the value of the uploadcomponent (filename + filedata) + * @return {String} the filedata or empty String + */ +DocumentUtil.getBindataFromUpload = function(pUploadValue) { + var result = pUploadValue.split(";"); + if(result.length > 1) + return result[1]; + else + return ''; +} \ No newline at end of file