Skip to content

Commit

Permalink
introduced new field and getter/setter method, added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jun 6, 2018
1 parent 2c6b9a0 commit e087a30
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1057,10 +1057,49 @@ public String getType() {
}

/**
* This method is deprecated. Use instead getTaskID()
*
* @return current $processID
*/
@Deprecated
public int getProcessID() {
return getItemValueInteger(WorkflowKernel.PROCESSID);
int result= getItemValueInteger(WorkflowKernel.PROCESSID);
if (result == 0 && hasItem("$taskid")) {
result = getTaskID();
}
return result;
}

/**
* @return current $TaskID
*/
public int getTaskID() {
int result = getItemValueInteger(WorkflowKernel.TASKID);
// test for deprecated version
if (result == 0 && hasItem("$processid") && getItemValueInteger("$processid") != 0) {
// see issue #384
/*
* logger.
* warning("The field $processid is deprecated. Please use $taskid instead. "
* +
* "Processing a workitem with an deprecated $processid is still supported.");
*/
result = getItemValueInteger("$processid");
// update eventID
replaceItemValue(WorkflowKernel.TASKID, result);
}
return result;
}

/**
* set $taskID
*
* @param taskID
*/
public void setTaskID(int taskID) {
replaceItemValue(WorkflowKernel.TASKID, taskID);
// if deprectaed processID must still be supported. See issue #382
replaceItemValue("$processid", taskID);
}

/**
Expand Down Expand Up @@ -1091,7 +1130,7 @@ public void setActivityID(int activityID) {
public int getEventID() {
// test for deprecated version
int result = getItemValueInteger(WorkflowKernel.EVENTID);
if (result == 0 && hasItem("$activityid") && getItemValueInteger("$activityid") != 0) {
if (result == 0 && hasItem("$activityid") && getItemValueInteger("$activityid") != 0) {
logger.warning("The field $activityid is deprecated. Please use $eventid instead. "
+ "Processing a workitem with an deprecated $activityid is still supported.");
result = getItemValueInteger("$activityid");
Expand All @@ -1108,9 +1147,9 @@ public int getEventID() {
*/
public void setEventID(int eventID) {
replaceItemValue(WorkflowKernel.EVENTID, eventID);

// if deprectaed ActivityID exists we must still support it
if (hasItem("$activityid")) {
if (hasItem("$activityid")) {
replaceItemValue("$activityid", eventID);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public void testBasicAttributes() {

Assert.assertEquals("1.0.0", itemCollection1.getModelVersion());
Assert.assertEquals(10, itemCollection1.getEventID());
Assert.assertEquals(100, itemCollection1.getProcessID());
Assert.assertEquals(100, itemCollection1.getTaskID());
Assert.assertEquals("workitem_test", itemCollection1.getType());
Assert.assertEquals("ABC-123", itemCollection1.getUniqueID());

Expand Down Expand Up @@ -733,4 +733,38 @@ public void testFileData() {
Assert.assertArrayEquals(empty, file1Data1);

}

/**
* Test issue #383, #384
*/
@Test
@Category(org.imixs.workflow.ItemCollection.class)
public void testDeprecatedFieldProcessID() {

Assert.assertEquals("$processid", WorkflowKernel.PROCESSID);
Assert.assertEquals("$taskid", WorkflowKernel.TASKID);

ItemCollection itemColSource = new ItemCollection();

itemColSource.replaceItemValue("$processid", 42);
Assert.assertEquals(42, itemColSource.getTaskID());
Assert.assertEquals(42, itemColSource.getProcessID());
Assert.assertEquals(42, itemColSource.getItemValueInteger("$processid"));

// test setter
itemColSource = new ItemCollection();
itemColSource.setTaskID(43);
Assert.assertEquals(43, itemColSource.getTaskID());
Assert.assertEquals(43, itemColSource.getProcessID());
Assert.assertEquals(43, itemColSource.getItemValueInteger("$processid"));

// test direct setting
itemColSource = new ItemCollection();
itemColSource.replaceItemValue("$taskid",44);
Assert.assertEquals(44, itemColSource.getTaskID());
Assert.assertEquals(44, itemColSource.getProcessID());
// !!!
Assert.assertEquals(0, itemColSource.getItemValueInteger("$processid"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public List<ItemCollection> search(String sSearchTerm, int pageSize, int pageInd
Operator defaultOperator) throws QueryException {

long ltime = System.currentTimeMillis();

// see issue #382
/*
* if (sSearchTerm.toLowerCase().contains("$processid")) { logger.
* warning("The field $processid is deprecated. Please use $taskid instead. " +
* "searching a workitem with an deprecated $processid is still supported."); }
*/

if (pageSize <= 0) {
pageSize = DEFAULT_PAGE_SIZE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class LuceneUpdateService {

// default field lists
private static List<String> DEFAULT_SEARCH_FIELD_LIST = Arrays.asList("$workflowsummary", "$workflowabstract");
private static List<String> DEFAULT_NOANALYSE_FIELD_LIST = Arrays.asList("$modelversion", "$processid",
private static List<String> DEFAULT_NOANALYSE_FIELD_LIST = Arrays.asList("$modelversion", "$taskid", "$processid",
"$workitemid", "$uniqueidref", "type", "$writeaccess", "$modified", "$created", "namcreator", "$creator",
"$editor", "$lasteditor", "$workflowgroup", "$workflowstatus", "txtworkflowgroup", "txtname", "namowner",
"txtworkitemref","$uniqueidsource","$uniqueidversions","$lasttask","$lastevent","$lasteventdate");
Expand Down

0 comments on commit e087a30

Please sign in to comment.