diff --git a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod index 48cfc7f72481597e7c987f78b3814a1a82dc9257..e890ebab03fa80f68a318fe8a09c61469387077e 100644 --- a/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod +++ b/entity/WorkflowDefinition_entity/WorkflowDefinition_entity.aod @@ -23,6 +23,7 @@ </entityProvider> <entityField> <name>UID</name> + <valueProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/uid/valueProcess.js</valueProcess> </entityField> <entityActionGroup> <name>tableActions</name> @@ -47,6 +48,7 @@ </entityField> <entityField> <name>FILEUPLOAD</name> + <title>BPMN</title> <contentType>FILE</contentType> <onValidation>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/fileupload/onValidation.js</onValidation> </entityField> @@ -68,7 +70,8 @@ <name>KEY</name> <title>Key</title> <mandatory v="true" /> - <stateProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js</stateProcess> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/WorkflowDefinition_entity/entityfields/key/valueProcess.js</valueProcess> </entityField> <entityField> <name>VERSION</name> diff --git a/entity/WorkflowDefinition_entity/entityfields/fileupload/onValidation.js b/entity/WorkflowDefinition_entity/entityfields/fileupload/onValidation.js index 3810d87555c7d2596d0b4f4d6b6eb1c34b833f95..d83d5f4fa4e4965ae833b747d26ffef49d79b9d2 100644 --- a/entity/WorkflowDefinition_entity/entityfields/fileupload/onValidation.js +++ b/entity/WorkflowDefinition_entity/entityfields/fileupload/onValidation.js @@ -4,7 +4,7 @@ import("system.vars"); import("Document_lib"); import("MimeType_lib"); -var mimetype = DocumentUtil.getMimeTypeFromUpload(vars.get("$local.value")); +var upload = new FileUpload(vars.get("$local.value")); -if (mimetype != MimeTypes.XML()) +if (upload.mimeType != MimeTypes.XML()) result.string(translate.text("The file must be a XML")); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js b/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js deleted file mode 100644 index b24d4beb6d917a46a5b9b0e4187f5b51a79a4768..0000000000000000000000000000000000000000 --- a/entity/WorkflowDefinition_entity/entityfields/key/stateProcess.js +++ /dev/null @@ -1,8 +0,0 @@ -import("system.neon"); -import("system.vars"); -import("system.result"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) - result.string(neon.COMPONENTSTATE_AUTO); -else - result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/entityfields/key/valueProcess.js b/entity/WorkflowDefinition_entity/entityfields/key/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..71edaf657ebadc755e358c9f722ecf5bbac06764 --- /dev/null +++ b/entity/WorkflowDefinition_entity/entityfields/key/valueProcess.js @@ -0,0 +1,18 @@ +import("system.neon"); +import("system.result"); +import("system.vars"); +import("Document_lib"); +import("MimeType_lib"); +import("system.workflow"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) +{ + var upload = new FileUpload(vars.get("$field.FILEUPLOAD")); + + if (upload.isFilled() && upload.mimeType == MimeTypes.XML()) + { + var ids = workflow.getProcessIds(upload.getBase64DecodedData()); + if (ids != null) + result.string(JSON.parse(ids)[0]); + } +} \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/entityfields/uid/valueProcess.js b/entity/WorkflowDefinition_entity/entityfields/uid/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..81d536056cdae682fd63f176ef2bed775eb42253 --- /dev/null +++ b/entity/WorkflowDefinition_entity/entityfields/uid/valueProcess.js @@ -0,0 +1,6 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.KEY")) + result.string(vars.get("$field.KEY")); \ No newline at end of file diff --git a/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js b/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js index 737b660804ebe1b0d11c1af78c86790974b9c453..2bd181e87346374beb8b6daffec4362244aaad50 100644 --- a/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js @@ -8,16 +8,25 @@ import("JditoFilter_lib"); var workflowKey = vars.get("$param.ProcessDefinitionKey_param"); var excludeVersion = vars.get("$param.CurrentVersion_param"); var context = vars.get("$param.Context_param"); +var idvalues = vars.get("$local.idvalues"); -var loadConfig = workflow.createConfigForLoadingProcessDefinitions(); +var workflowDefs; -if (vars.get("$local.idvalues")) - loadConfig.processDefinitionIds(vars.get("$local.idvalues")); -else if (workflowKey) - loadConfig.processDefinitionKey(workflowKey); - - -var workflowDefs = JSON.parse(workflow.getProcessDefinitions(loadConfig)); +if (idvalues) +{ + var loadConfig = workflow.createConfigForLoadingProcessDefinitions() + .processDefinitionIds(idvalues); + workflowDefs = JSON.parse(workflow.getProcessDefinitions(loadConfig)); + + //after new-mode, the given uid is not the actual id, but the key, so if + //no workflow definitions were found, try it again with the key + if (workflowDefs.length === 0) + workflowDefs = _getDefinitionsByKey(idvalues[0]); +} +else +{ + workflowDefs = _getDefinitionsByKey(workflowKey); +} //structure = {processDefinitionKey : highest_version} var newestVersions = {}; @@ -71,4 +80,12 @@ workflowDefs = workflowDefs.filter(filterFn); workflowDefs = JditoFilterUtils.filterRecords(["UID", "NAME", "CATEGORY", "KEY", "VERSION", "ISACTIVE"], workflowDefs, vars.get("$local.filter").filter); -result.object(workflowDefs); \ No newline at end of file +result.object(workflowDefs); + +function _getDefinitionsByKey (pKey) +{ + var config = workflow.createConfigForLoadingProcessDefinitions(); + if (pKey) + config.processDefinitionKey(pKey); + return JSON.parse(workflow.getProcessDefinitions(config)); +} \ No newline at end of file diff --git a/process/Document_lib/process.js b/process/Document_lib/process.js index 7d6e93c958b0a802f032adfd7af93a67df2efda1..1fc5466aa2751bc671c6fdc20da3b1e025ec807a 100644 --- a/process/Document_lib/process.js +++ b/process/Document_lib/process.js @@ -1,3 +1,4 @@ +import("system.util"); import("system.translate"); import("system.result"); import("system.db"); @@ -179,4 +180,12 @@ FileUpload.prototype.isFilled = function () //this conversion is not really nescessary (e. g. in an if it wouldn't make a difference), //but it is more logical to return a 'real' boolean here return Boolean(this.filename || this.bindata); +} + +/** + * @return {String} the bindata, base64-decoded + */ +FileUpload.prototype.getBase64DecodedData = function () +{ + return util.decodeBase64String(this.bindata); } \ No newline at end of file