Merged 5.1.N (5.1.1) to HEAD (5.1)

118424 cturlica: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)
      118394 amukha: Merged 5.0.1 (5.0.1.14) to 5.0.N (5.0.4)
         117907 abalmus: MNT-14631 : REST Processes and Tasks API for parameters/variables allowed MATCHES operator, operator is not case-insensitive
            - Fix on Alfresco side, test and updated pom.xml to use new Activiti jar


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123593 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 17:30:06 +00:00
parent 0e0e903b61
commit 021911fad0
2 changed files with 40 additions and 1 deletions

View File

@@ -377,8 +377,16 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
{ {
throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName()); throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName());
} }
if (((String) queryVariableHolder.getPropertyValue()).startsWith("(?i)"))
{
query.variableValueLikeIgnoreCase(queryVariableHolder.getPropertyName(), ((String) queryVariableHolder.getPropertyValue()).substring("(?i)".length()).toLowerCase());
}
else
{
query.variableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue()); query.variableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
} }
}
else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION) else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION)
{ {
query.variableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue()); query.variableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());

View File

@@ -80,6 +80,8 @@ public class ProcessesImplTest extends TestCase
private static final String QUERY_STATUS_ACTIVE = "(status=active)"; private static final String QUERY_STATUS_ACTIVE = "(status=active)";
private static final String QUERY_WORKFLOWDESCRIPTION_MATCHES = "(variables/bpm_workflowDescription MATCHES ('%s'))";
private ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS); private ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
@@ -122,6 +124,7 @@ public class ProcessesImplTest extends TestCase
{ {
Map<QName, Serializable> parameters = new HashMap<QName, Serializable>(); Map<QName, Serializable> parameters = new HashMap<QName, Serializable>();
parameters.put(WorkflowModel.ASSOC_ASSIGNEE, (Serializable) Collections.singletonList(assignee)); parameters.put(WorkflowModel.ASSOC_ASSIGNEE, (Serializable) Collections.singletonList(assignee));
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Test workflow api calls review and approve"); // MNT-14631
//parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null)); //parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowService.createPackage(null));
workflowService.startWorkflow(neededDefinition.getId(), parameters); workflowService.startWorkflow(neededDefinition.getId(), parameters);
@@ -182,6 +185,34 @@ public class ProcessesImplTest extends TestCase
assertFalse(actualProcesses.hasMoreItems()); assertFalse(actualProcesses.hasMoreItems());
} }
@Test
public void testGetProcessesMatchesIgnoreCase()
{
CollectionWithPagingInfo<ProcessInfo> result = queryMatchesProcesses("(?i)test workflow api calls review and approve");
assertNotNull(result);
assertNotNull(result.getCollection());
assertTrue(result.getTotalItems() > 0 );
}
@Test
public void testGetProcessesMatchesIgnoreCaseNoResults()
{
CollectionWithPagingInfo<ProcessInfo> result = queryMatchesProcesses("test workflow api calls review and approve");
assertNotNull(result);
assertNotNull(result.getCollection());
assertTrue(result.getTotalItems() == 0 );
}
private CollectionWithPagingInfo<ProcessInfo> queryMatchesProcesses(String matchesString)
{
Query query = ResourceWebScriptHelper.getWhereClause(String.format(QUERY_WORKFLOWDESCRIPTION_MATCHES, matchesString));
Parameters parameters = Params.valueOf(new RecognizedParams(null, Paging.valueOf(0, ACTIVE_WORKFLOWS_INITIAL_AMOUNT), null, null, null, query, null), null, null);
return processes.getProcesses(parameters);
}
private CollectionWithPagingInfo<ProcessInfo> queryActiveProcessesAndAssertResult(int skipCount, int maxItems) private CollectionWithPagingInfo<ProcessInfo> queryActiveProcessesAndAssertResult(int skipCount, int maxItems)
{ {
Query query = ResourceWebScriptHelper.getWhereClause(QUERY_STATUS_ACTIVE); Query query = ResourceWebScriptHelper.getWhereClause(QUERY_STATUS_ACTIVE);