Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Activiti/Activiti
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Jun 17, 2013
2 parents 5e0bf81 + ba0b0e4 commit fa95598
Show file tree
Hide file tree
Showing 23 changed files with 413 additions and 215 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.restlet.security.ChallengeAuthenticator;
import org.restlet.security.SecretVerifier;
import org.restlet.security.Verifier;
import org.restlet.service.StatusService;
/**
* @author Tijs Rademakers
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ create table ACT_HI_IDENTITYLINK (
primary key (ID_)
);


create index ACT_IDX_HI_PROCVAR_NAME_TYPE on ACT_HI_VARINST(NAME_, VAR_TYPE_);
create index ACT_IDX_HI_ACT_INST_PROCINST on ACT_HI_ACTINST(PROC_INST_ID_, ACT_ID_);
create index ACT_IDX_HI_ACT_INST_EXEC on ACT_HI_ACTINST(EXECUTION_ID_, ACT_ID_);
create index ACT_IDX_HI_IDENT_LNK_USER on ACT_HI_IDENTITYLINK(USER_ID_);
create index ACT_IDX_HI_IDENT_LNK_TASK on ACT_HI_IDENTITYLINK(TASK_ID_);
create index ACT_IDX_HI_IDENT_LNK_PROCINST on ACT_HI_IDENTITYLINK(PROC_INST_ID_);
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Map;

import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.task.Task;

Expand Down Expand Up @@ -66,33 +67,35 @@ protected void tearDown() throws Exception {
}

public void testQuery() {
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables()
.variableValueEquals("anothertest", 123).singleResult();
Map<String, Object> variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));

List<HistoricProcessInstance> instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().list();
assertEquals(5, instanceList.size());

instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
assertEquals(4, instanceList.size());
processInstance = instanceList.get(0);
variableMap = processInstance.getProcessVariables();
assertEquals(2, variableMap.size());
assertEquals("test", variableMap.get("test"));
assertEquals("test2", variableMap.get("test2"));

processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables()
.processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));

processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().finished().singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(2, variableMap.size());
assertEquals("test", variableMap.get("test"));
assertEquals("test2", variableMap.get("test2"));
if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables()
.variableValueEquals("anothertest", 123).singleResult();
Map<String, Object> variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));

List<HistoricProcessInstance> instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().list();
assertEquals(5, instanceList.size());

instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
assertEquals(4, instanceList.size());
processInstance = instanceList.get(0);
variableMap = processInstance.getProcessVariables();
assertEquals(2, variableMap.size());
assertEquals("test", variableMap.get("test"));
assertEquals("test2", variableMap.get("test2"));

processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables()
.processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(1, variableMap.size());
assertEquals(123, variableMap.get("anothertest"));

processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().finished().singleResult();
variableMap = processInstance.getProcessVariables();
assertEquals(2, variableMap.size());
assertEquals("test", variableMap.get("test"));
assertEquals("test2", variableMap.get("test2"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;

import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.impl.util.ClockUtil;
import org.activiti.engine.task.Task;
Expand Down Expand Up @@ -58,84 +59,86 @@ public void tearDown() throws Exception {

@Deployment
public void testQuery() {
HistoricTaskInstance task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("gonzo").singleResult();
Map<String, Object> variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals(0, task.getProcessVariables().size());
assertNotNull(variableMap.get("testVar"));
assertEquals("someVariable", variableMap.get("testVar"));
assertNotNull(variableMap.get("testVar2"));
assertEquals(123, variableMap.get("testVar2"));

List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(3, tasks.size());

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("gonzo").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());

Map<String, Object> startMap = new HashMap<String, Object>();
startMap.put("processVar", true);
runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(1, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertTrue((Boolean) task.getProcessVariables().get("processVar"));

taskService.setVariable(task.getId(), "anotherProcessVar", 123);
taskService.setVariableLocal(task.getId(), "localVar", "test");

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

tasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskInvolvedUser("kermit").list();
assertEquals(3, tasks.size());
assertEquals(1, tasks.get(0).getTaskLocalVariables().size());
assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
assertEquals(0, tasks.get(0).getProcessVariables().size());

tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskInvolvedUser("kermit").list();
assertEquals(3, tasks.size());
assertEquals(0, tasks.get(0).getProcessVariables().size());
assertEquals(0, tasks.get(0).getTaskLocalVariables().size());

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").singleResult();
taskService.complete(task.getId());
task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().finished().singleResult();
variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals(0, task.getProcessVariables().size());
assertNotNull(variableMap.get("testVar"));
assertEquals("someVariable", variableMap.get("testVar"));
assertNotNull(variableMap.get("testVar2"));
assertEquals(123, variableMap.get("testVar2"));
if(processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricTaskInstance task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("gonzo").singleResult();
Map<String, Object> variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals(0, task.getProcessVariables().size());
assertNotNull(variableMap.get("testVar"));
assertEquals("someVariable", variableMap.get("testVar"));
assertNotNull(variableMap.get("testVar2"));
assertEquals(123, variableMap.get("testVar2"));

List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().list();
assertEquals(3, tasks.size());

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("gonzo").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());

Map<String, Object> startMap = new HashMap<String, Object>();
startMap.put("processVar", true);
runtimeService.startProcessInstanceByKey("oneTaskProcess", startMap);

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(1, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertTrue((Boolean) task.getProcessVariables().get("processVar"));

taskService.setVariable(task.getId(), "anotherProcessVar", 123);
taskService.setVariableLocal(task.getId(), "localVar", "test");

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

tasks = historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskInvolvedUser("kermit").list();
assertEquals(3, tasks.size());
assertEquals(1, tasks.get(0).getTaskLocalVariables().size());
assertEquals("test", tasks.get(0).getTaskLocalVariables().get("test"));
assertEquals(0, tasks.get(0).getProcessVariables().size());

tasks = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskInvolvedUser("kermit").list();
assertEquals(3, tasks.size());
assertEquals(0, tasks.get(0).getProcessVariables().size());
assertEquals(0, tasks.get(0).getTaskLocalVariables().size());

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
assertEquals(0, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeProcessVariables().taskAssignee("kermit").taskVariableValueEquals("localVar", "test").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(0, task.getTaskLocalVariables().size());
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().includeProcessVariables().taskAssignee("kermit").singleResult();
assertEquals(2, task.getProcessVariables().size());
assertEquals(1, task.getTaskLocalVariables().size());
assertEquals("test", task.getTaskLocalVariables().get("localVar"));
assertEquals(true, task.getProcessVariables().get("processVar"));
assertEquals(123, task.getProcessVariables().get("anotherProcessVar"));

task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().taskAssignee("gonzo").singleResult();
taskService.complete(task.getId());
task = (HistoricTaskInstance) historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables().finished().singleResult();
variableMap = task.getTaskLocalVariables();
assertEquals(2, variableMap.size());
assertEquals(0, task.getProcessVariables().size());
assertNotNull(variableMap.get("testVar"));
assertEquals("someVariable", variableMap.get("testVar"));
assertNotNull(variableMap.get("testVar2"));
assertEquals(123, variableMap.get("testVar2"));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ public DeploymentResourceResponse createDeploymentResourceResponse(SecuredResour
String mediaTypeString = (mediaType != null) ? mediaType.toString() : null;

// Determine type
// TODO: do based on the returned resource-POJO from the API once ready instead of doing it here
DeploymentResourceType type = DeploymentResourceType.RESOURCE;
for(String suffix : BpmnDeployer.BPMN_RESOURCE_SUFFIXES) {
if(resourceId.endsWith(suffix)) {
Expand All @@ -186,7 +185,7 @@ public ProcessDefinitionResponse createProcessDefinitionResponse(SecuredResource
response.setStartFormDefined(processDefinition.hasStartFormKey());

// Check if graphical notation defined
// TODO: this method does an additional check to see if the process-definition exists which causes an additional query on top
// This method does an additional check to see if the process-definition exists which causes an additional query on top
// of the one we already did to retrieve the processdefinition in the first place.
ProcessDefinition deployedDefinition = ActivitiUtil.getRepositoryService().getProcessDefinition(processDefinition.getId());
response.setGraphicalNotationDefined(((ProcessDefinitionEntity) deployedDefinition).isGraphicalNotationDefined());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public final class RestUrls {
public static final String SEGMENT_MODEL_RESOURCE = "models";
public static final String SEGMENT_SOURCE = "source";
public static final String SEGMENT_SOURCE_EXTRA = "source-extra";
public static final String SEGMENT_DIAGRAM = "diagram";

/**
* URL template for the deployment collection: <i>repository/deployments</i>
Expand Down Expand Up @@ -277,6 +278,11 @@ public final class RestUrls {
*/
public static final String[] URL_PROCESS_INSTANCE = {SEGMENT_RUNTIME_RESOURCES, SEGMENT_PROCESS_INSTANCE_RESOURCE, "{0}"};

/**
* URL template for the diagram for a single process instance: <i>runtime/process-instances/{0:processInstanceId}/diagram</i>
*/
public static final String[] URL_PROCESS_INSTANCE_DIAGRAM = {SEGMENT_RUNTIME_RESOURCES, SEGMENT_PROCESS_INSTANCE_RESOURCE, "{0}", SEGMENT_DIAGRAM};

/**
* URL template for process instance variable collection: <i>runtime/process-instances/{0:processInstanceId}/variables</i>
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.activiti.rest.api.runtime.process;
package org.activiti.rest.api.legacy.process;

import java.io.InputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/

package org.activiti.rest.api.runtime.process;
package org.activiti.rest.api.legacy.process;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
Expand Down
Loading

0 comments on commit fa95598

Please sign in to comment.