mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
105791: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud) 105689: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.3) 105571: Merged DEV to V4.2-BUG-FIX (4.2.5) 103740: MNT-13855: Completing a a workflow on Mobile results in "Approve" being reported as "Rejected" in Alfresco 4.2.3 and 5.0, and no result in 4.2.1 - Updated sequence of actions to complete a task. 104919: MNT-13855: Completing a a workflow on Mobile results in "Approve" being reported as "Rejected" in Alfresco 4.2.3 and 5.0, and no result in 4.2.1 - Implemented unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@105946 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -869,11 +869,13 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
setOutcome(localVariables, taskId);
|
|
||||||
if (localVariables.size() > 0)
|
if (localVariables.size() > 0)
|
||||||
{
|
{
|
||||||
activitiProcessEngine.getTaskService().setVariablesLocal(taskId, localVariables);
|
activitiProcessEngine.getTaskService().setVariablesLocal(taskId, localVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setOutcome(taskId);
|
||||||
|
|
||||||
if (globalVariables.size() > 0)
|
if (globalVariables.size() > 0)
|
||||||
{
|
{
|
||||||
activitiProcessEngine.getTaskService().complete(taskId, globalVariables);
|
activitiProcessEngine.getTaskService().complete(taskId, globalVariables);
|
||||||
@@ -900,11 +902,13 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RESOLVED:
|
case RESOLVED:
|
||||||
setOutcome(localVariables, taskId);
|
|
||||||
if (localVariables.size() > 0)
|
if (localVariables.size() > 0)
|
||||||
{
|
{
|
||||||
activitiProcessEngine.getTaskService().setVariablesLocal(taskId, localVariables);
|
activitiProcessEngine.getTaskService().setVariablesLocal(taskId, localVariables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setOutcome(taskId);
|
||||||
|
|
||||||
if (globalVariables.size() > 0)
|
if (globalVariables.size() > 0)
|
||||||
{
|
{
|
||||||
activitiProcessEngine.getTaskService().resolveTask(taskId, globalVariables);
|
activitiProcessEngine.getTaskService().resolveTask(taskId, globalVariables);
|
||||||
@@ -1728,11 +1732,11 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
|
|||||||
* @param localVariables The variable, that will be set to the task
|
* @param localVariables The variable, that will be set to the task
|
||||||
* @param taskId The id of the task
|
* @param taskId The id of the task
|
||||||
*/
|
*/
|
||||||
private void setOutcome(Map<String, Object> localVariables, String taskId)
|
private void setOutcome(String taskId)
|
||||||
{
|
{
|
||||||
WorkflowQNameConverter qNameConverter = getQNameConverter();
|
|
||||||
org.activiti.engine.task.Task task = activitiProcessEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
|
org.activiti.engine.task.Task task = activitiProcessEngine.getTaskService().createTaskQuery().taskId(taskId).singleResult();
|
||||||
String outcomeValue = ActivitiConstants.DEFAULT_TRANSITION_NAME;
|
String outcomeValue = ActivitiConstants.DEFAULT_TRANSITION_NAME;
|
||||||
|
HashMap<QName, Serializable> updates = new HashMap<QName, Serializable>();
|
||||||
Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task);
|
Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task);
|
||||||
QName outcomePropName = (QName) properties.get(WorkflowModel.PROP_OUTCOME_PROPERTY_NAME);
|
QName outcomePropName = (QName) properties.get(WorkflowModel.PROP_OUTCOME_PROPERTY_NAME);
|
||||||
if (outcomePropName != null)
|
if (outcomePropName != null)
|
||||||
@@ -1743,6 +1747,7 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
|
|||||||
outcomeValue = DefaultTypeConverter.INSTANCE.convert(String.class, rawOutcome);
|
outcomeValue = DefaultTypeConverter.INSTANCE.convert(String.class, rawOutcome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localVariables.put(qNameConverter.mapQNameToName(WorkflowModel.PROP_OUTCOME), outcomeValue);
|
updates.put(WorkflowModel.PROP_OUTCOME, outcomeValue);
|
||||||
|
propertyConverter.updateTask(task, updates, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -55,6 +55,7 @@ import org.alfresco.rest.api.tests.PersonInfo;
|
|||||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
import org.alfresco.rest.api.tests.RepoService.TestPerson;
|
||||||
import org.alfresco.rest.api.tests.RepoService.TestSite;
|
import org.alfresco.rest.api.tests.RepoService.TestSite;
|
||||||
|
import org.alfresco.rest.api.tests.client.HttpResponse;
|
||||||
import org.alfresco.rest.api.tests.client.PublicApiException;
|
import org.alfresco.rest.api.tests.client.PublicApiException;
|
||||||
import org.alfresco.rest.api.tests.client.RequestContext;
|
import org.alfresco.rest.api.tests.client.RequestContext;
|
||||||
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
import org.alfresco.rest.api.tests.client.data.MemberOfSite;
|
||||||
@@ -1055,6 +1056,29 @@ public class TaskWorkflowApiTest extends EnterpriseWorkflowTestApi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void testSetOutcome() throws Exception
|
||||||
|
{
|
||||||
|
RequestContext requestContext = initApiClientWithTestUser();
|
||||||
|
ProcessInfo processInf = startReviewPooledProcess(requestContext);
|
||||||
|
Task task = activitiProcessEngine.getTaskService().createTaskQuery().processInstanceId(processInf.getId()).singleResult();
|
||||||
|
TasksClient tasksClient = publicApiClient.tasksClient();
|
||||||
|
activitiProcessEngine.getTaskService().saveTask(task);
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("select", "state,variables");
|
||||||
|
HttpResponse response = tasksClient.update("tasks",
|
||||||
|
task.getId(),
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
"{\"state\":\"completed\",\"variables\":[{\"name\":\"wf_reviewOutcome\",\"value\":\"Approve\",\"scope\":\"local\"},{\"name\":\"bpm_comment\",\"value\":\"approved by me\",\"scope\":\"local\"}]}",
|
||||||
|
"Failed to update task", params);
|
||||||
|
assertEquals(200, response.getStatusCode());
|
||||||
|
HistoricTaskInstance historyTask = activitiProcessEngine.getHistoryService().createHistoricTaskInstanceQuery().taskId(task.getId()).includeProcessVariables().includeTaskLocalVariables().singleResult();
|
||||||
|
String outcome = (String) historyTask.getTaskLocalVariables().get("bpm_outcome");
|
||||||
|
assertEquals("Approve", outcome);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testResolveTask() throws Exception
|
public void testResolveTask() throws Exception
|
||||||
|
Reference in New Issue
Block a user