Skip to content
Snippets Groups Projects
Commit 2e9008ed authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

#1065237 Trigger workflows with link

parent cb98a0d5
No related branches found
No related tags found
No related merge requests found
import("Util_lib");
import("system.text");
import("system.logging");
import("system.project");
......@@ -601,3 +602,56 @@ WorkflowModelerApiCall.prototype.importModel = function ()
}
function WorkflowLinkActions () {}
WorkflowLinkActions.types = {
RECEIVE_TASK: function () {return "receive";}
};
WorkflowLinkActions.types.RECEIVE_TASK.execute = function (pParameters)
{
if (!pParameters.piId || !pParameters.recId)
return;
workflow.triggerReceiveTask(pParameters.piId, pParameters.recId);
}
WorkflowLinkActions.encodeAction = function (pType, pLink, pParams)
{
var actionObj = pParams || {};
actionObj.type = pType;
actionObj.link = pLink;
var actionString = JSON.stringify(actionObj);
return encodeURIComponent(util.encodeBase64String(actionString));
}
WorkflowLinkActions.parseAction = function (pEncodedAction)
{
try
{
var decodedAction = decodeURIComponent(util.decodeBase64String(pEncodedAction))
var parsedAction = JSON.parse(decodedAction);
}
catch (err)
{
parsedAction = {};
}
return {
type: parsedAction.type || null,
redirectLink: parsedAction.link || null,
params: parsedAction,
run: function ()
{
for (let typeName in WorkflowLinkActions.types)
{
let actionType = WorkflowLinkActions.types[typeName];
if (this.type == actionType())
return actionType.execute.call(this, this.params);
}
return null;
}
};
}
\ No newline at end of file
import("Workflow_lib");
import("system.util");
import("system.logging");
function restget (pRequest)
{
var request = JSON.parse(pRequest);
var action = WorkflowLinkActions.parseAction(request.query.act);
action.run();
if (action.redirectLink)
{
request.response.httpStatusCode = 302; //found, redirect
request.response.header.Location = action.redirectLink;
}
else
{
request.response.httpStatusCode = 204; //no content
}
return JSON.stringify(request);
}
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>redirect_rest</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/redirect_rest/process.js</process>
<publishAsWebservice v="true" />
<style>REST</style>
<loginTypeId>internal.none</loginTypeId>
<variants>
<element>EXECUTABLE</element>
</variants>
</process>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment