Завершить задачу Alfreso Rest API - PullRequest
0 голосов
/ 28 апреля 2018

Я занимаюсь разработкой веб-приложения для управления рабочими процессами под открытым небом с помощью Rest api, в моем процессе у меня есть эксклюзивный шлюз с условием потока22, как показано на этом рисунке: enter image description here (если переменная решения равна «одобрить», процесс переходит к задаче 3)

Для первой и второй задачи все работает нормально, за исключением того, что я получаю эту ошибку при завершении задачи 2 с помощью команды Rest, зная, что я уже установил свою переменную для утверждения. enter image description here это мой бит / мин

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="pres" name="prestation" isExecutable="true">
    <startEvent id="startevent1" name="Start" activiti:initiator="${initiator.properties.userName}" activiti:formKey="pfewf:submitHelloWorldTask"></startEvent>
    <userTask id="usertask1" name="Remplir formulaire demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:demandepres">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemA',task.getVariableLocal('pfewf_nomprenomDem'));
execution.setVariable('pfewf_ipDemA',task.getVariableLocal('pfewf_ipDem'));
execution.setVariable('pfewf_organismeDemA',task.getVariableLocal('pfewf_organismeDem'));
execution.setVariable('pfewf_refDemA',task.getVariableLocal('pfewf_refDem'));
execution.setVariable('pfewf_appDemA',task.getVariableLocal('pfewf_appDem'));
execution.setVariable('pfewf_dateDemA',task.getVariable('pfewf_dateDem'));
execution.setVariable('pfewf_typeDemA',task.getVariableLocal('pfewf_typeDem'));
execution.setVariable('pfewf_userDetailsA',task.getVariableLocal('pfewf_userDetails'));
execution.setVariable('pfewf_respTech',task.getVariableLocal('pfewf_respTech'));
execution.setVariable('pfewf_respTechR',task.getVariableLocal('pfewf_respTech'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[var date = new Date();
var timeInMillisecs = date.getTime(); 
var ISODate = utils.toISO8601(timeInMillisecs);
var origDate = utils.fromISO8601(ISODate);
execution.setVariable('pfewf_dateDem',origDate);]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_userDetails',task.getVariable('pfewf_userDetails'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask2" name="Responsable technique" activiti:assignee="${pfewf_respTech.properties.userName}" activiti:formKey="pfewf:avisTech">
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemR',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemR',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemR',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemR',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemR',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemR',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemR',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsR',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_userDetailsA',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testR',task.getVariable('pfewf_testA'));
execution.setVariable('pfewf_avisRespTech',task.getVariableLocal('pfewf_avisRespTech'));
execution.setVariable('pfewf_respTechR',task.getVariable('pfewf_respTech'));
execution.setVariable('pfewf_remarquesR',task.getVariableLocal('pfewf_remarquesA'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <userTask id="usertask3" name="Revision demande" activiti:assignee="${initiator.properties.userName}" activiti:formKey="pfewf:revisionDem"></userTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow8" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow9" name="a reviser" sourceRef="exclusivegateway1" targetRef="usertask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'A Rectifier'}]]></conditionExpression>
    </sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow10" sourceRef="usertask3" targetRef="exclusivegateway2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow11" name="annuler" sourceRef="exclusivegateway2" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
                   == 'Annuler'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow12" name="renvoyer" sourceRef="exclusivegateway2" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_decisionR
                   == 'Renvoyer'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow13" name="refuser" sourceRef="exclusivegateway1" targetRef="endevent2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'Refuser'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask4" name="Avis DHE" activiti:candidateGroups="GROUP_DHE" activiti:formKey="pfewf:dhe">
      <extensionElements>
        <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string><![CDATA[execution.setVariable('pfewf_nomprenomDemD',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemD',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemD',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemD',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemD',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemD',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemD',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsD',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testD',task.getVariable('pfewf_testA'));


execution.setVariable('pfewf_nomprenomDemDr',task.getVariable('pfewf_nomprenomDemA'));
execution.setVariable('pfewf_ipDemDr',task.getVariable('pfewf_ipDemA'));
execution.setVariable('pfewf_organismeDemDr',task.getVariable('pfewf_organismeDemA'));
execution.setVariable('pfewf_refDemDr',task.getVariable('pfewf_refDemA'));
execution.setVariable('pfewf_appDemDr',task.getVariable('pfewf_appDemA'));
execution.setVariable('pfewf_dateDemDr',task.getVariable('pfewf_dateDemA'));
execution.setVariable('pfewf_typeDemDr',task.getVariable('pfewf_typeDemA'));
execution.setVariable('pfewf_userDetailsDr',task.getVariable('pfewf_userDetails'));
execution.setVariable('pfewf_testDr',task.getVariable('pfewf_testA'));]]></activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow14" name="valider" sourceRef="exclusivegateway1" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${pfewf_avisRespTech
                   == 'Valider'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask5" name="Avis DRSM" activiti:candidateGroups="GROUP_DRSM" activiti:formKey="pfewf:drsm"></userTask>
    <sequenceFlow id="flow15" sourceRef="usertask4" targetRef="usertask5"></sequenceFlow>
    <endEvent id="endevent3" name="End"></endEvent>
    <sequenceFlow id="flow16" sourceRef="usertask5" targetRef="endevent3"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_pres">
    <bpmndi:BPMNPlane bpmnElement="pres" id="BPMNPlane_pres">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="310.0" y="323.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="71.0" width="112.0" x="400.0" y="305.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="65.0" width="105.0" x="558.0" y="308.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="688.0" y="461.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="720.0" y="321.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="590.0" y="468.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="480.0" y="471.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="723.0" y="220.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="805.0" y="314.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
        <omgdc:Bounds height="55.0" width="105.0" x="955.0" y="314.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="1105.0" y="324.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="345.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="512.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="558.0" y="340.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="663.0" y="340.0"></omgdi:waypoint>
        <omgdi:waypoint x="720.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="740.0" y="361.0"></omgdi:waypoint>
        <omgdi:waypoint x="740.0" y="461.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="48.0" x="752.0" y="390.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="688.0" y="488.0"></omgdi:waypoint>
        <omgdi:waypoint x="630.0" y="488.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="590.0" y="488.0"></omgdi:waypoint>
        <omgdi:waypoint x="515.0" y="488.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="42.0" x="532.0" y="500.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="610.0" y="468.0"></omgdi:waypoint>
        <omgdi:waypoint x="610.0" y="373.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="48.0" x="615.0" y="431.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="740.0" y="321.0"></omgdi:waypoint>
        <omgdi:waypoint x="740.0" y="255.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="39.0" x="752.0" y="296.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="760.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="805.0" y="341.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="16.0" width="100.0" x="760.0" y="341.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="910.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="955.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="1060.0" y="341.0"></omgdi:waypoint>
        <omgdi:waypoint x="1105.0" y="341.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Как я могу иметь дело с эксклюзивными воротами через Rest api? Заранее спасибо.

Ответы [ 2 ]

0 голосов
/ 13 мая 2018

Есть много решений:

  1. Вы можете использовать это условие в своем потоке14 "$ {pfewf_avisRespTech! = 'Refuser' && pfewf_avisRespTech! = 'Выпрямитель'}".
  2. В вашей модели установите значение по умолчанию для pfewf_avisRespTech в качестве «Valider», например
  3. Прежде чем просить движок рабочего процесса выполнить вашу задачу, попросите его обновить значение вашего pfewf_avisRespTech
  4. В полном прослушивателе task2 проверьте значение "pfewf_avisRespTech", если оно равно "", или null дает ему какое-то значение.
0 голосов
/ 28 апреля 2018

Я сильно сомневаюсь, что переменная solution уже установлена, после завершения task2 вы можете проверить значение переменной, вызвав эту конечную точку:

GET /tasks/{taskId}/variables

Чтобы установить переменные перед выполнением задачи, вы должны сделать это следующим образом

URL:

PUT /tasks/{taskId}?select=state,variables

Тело запроса:

{
  "state": "completed",
  "variables": [
      {
          "name": "decision",
          "type": "d_text",
          "value": "approve",
          "scope": "global"
      }
  ]
}
...