Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Activiti/Activiti
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarrez committed Jun 11, 2013
2 parents 292ee44 + 97c956f commit 77bc8ad
Show file tree
Hide file tree
Showing 50 changed files with 2,397 additions and 411 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
public interface HistoricVariableInstanceQuery extends Query<HistoricVariableInstanceQuery, HistoricVariableInstance> {

/** Only select a historic variable with the given id. */
HistoricVariableInstanceQuery id(String id);

/** Only select historic process variables with the given process instance. */
HistoricVariableInstanceQuery processInstanceId(String processInstanceId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.util.List;

import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.history.HistoricVariableInstance;
import org.activiti.engine.history.HistoricVariableInstanceQuery;
Expand All @@ -32,6 +31,7 @@ public class HistoricVariableInstanceQueryImpl extends AbstractQuery<HistoricVar
HistoricVariableInstanceQuery {

private static final long serialVersionUID = 1L;
protected String id;
protected String taskId;
protected String processInstanceId;
protected String activityInstanceId;
Expand All @@ -50,8 +50,13 @@ public HistoricVariableInstanceQueryImpl(CommandContext commandContext) {
public HistoricVariableInstanceQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}

public HistoricVariableInstanceQuery id(String id) {
this.id = id;
return this;
}

public HistoricVariableInstanceQueryImpl processInstanceId(String processInstanceId) {
public HistoricVariableInstanceQuery processInstanceId(String processInstanceId) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public void setProcessDef(ProcessDefinitionEntity processDef) {
this.processDef = processDef;
this.processDefId = processDef.getId();
}

@Override
public String getProcessDefinitionId() {
return this.processDefId;
}

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,15 @@ public interface IdentityLink {
* The id of the task associated with this identity link.
*/
String getTaskId();

/**
* The process definition id associated with this identity link.
*/
String getProcessDefinitionId();

/**
* The process instance id associated with this identity link.
*/
String getProcessInstanceId();

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
<sql id="selectHistoricVariableInstanceByQueryCriteriaSql">
from ${prefix}ACT_HI_VARINST RES
<where>
<if test="id != null">
RES.ID_ = #{id}
</if>
<if test="processInstanceId != null">
RES.PROC_INST_ID_ = #{processInstanceId}
</if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<result property="groupId" column="GROUP_ID_" jdbcType="VARCHAR" />
<result property="taskId" column="TASK_ID_" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="processDefId" column="PROCESS_DEF_ID_" jdbcType="VARCHAR" />
<result property="processDefId" column="PROC_DEF_ID_" jdbcType="VARCHAR" />
</resultMap>

<!-- IDENTITY LINK SELECT -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ConcurrentEngineUsageTest extends PluggableActivitiTestCase {
@Deployment
public void testConcurrentUsage() throws Exception {

if(!processEngineConfiguration.getDatabaseType().equals("h2")) {
if(!processEngineConfiguration.getDatabaseType().equals("h2") && !processEngineConfiguration.getDatabaseType().equals("db2")) {
int numberOfThreads = 5;
int numberOfProcessesPerThread = 5;
int totalNumberOfTasks = 2 * numberOfThreads * numberOfProcessesPerThread;
Expand All @@ -55,7 +55,12 @@ public void testConcurrentUsage() throws Exception {

// Wait for termination or timeout and check if all tasks are complete
executor.shutdown();
executor.awaitTermination(20000, TimeUnit.MILLISECONDS);
boolean isEnded = executor.awaitTermination(20000, TimeUnit.MILLISECONDS);
if(!isEnded) {
log.error("Executor was not shut down after timeout, not al tasks have been executed");
executor.shutdownNow();

}
assertEquals(0, executor.getActiveCount());

// Check there are no processes active anymore
Expand Down
31 changes: 0 additions & 31 deletions modules/activiti-engine/src/test/resources/chinese.bpmn

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.activiti.rest.api.engine.AttachmentResponse;
import org.activiti.rest.api.engine.CommentResponse;
import org.activiti.rest.api.engine.EventResponse;
import org.activiti.rest.api.engine.RestIdentityLink;
import org.activiti.rest.api.engine.variable.BooleanRestVariableConverter;
import org.activiti.rest.api.engine.variable.DateRestVariableConverter;
import org.activiti.rest.api.engine.variable.DoubleRestVariableConverter;
Expand All @@ -63,7 +64,6 @@
import org.activiti.rest.api.identity.MembershipResponse;
import org.activiti.rest.api.identity.UserInfoResponse;
import org.activiti.rest.api.identity.UserResponse;
import org.activiti.rest.api.legacy.identity.LegacyRestIdentityLink;
import org.activiti.rest.api.management.JobResponse;
import org.activiti.rest.api.management.TableResponse;
import org.activiti.rest.api.repository.DeploymentResourceResponse;
Expand All @@ -84,6 +84,14 @@
*/
public class RestResponseFactory {

public static final int VARIABLE_TASK = 1;
public static final int VARIABLE_EXECUTION = 2;
public static final int VARIABLE_PROCESS = 3;
public static final int VARIABLE_HISTORY_TASK = 4;
public static final int VARIABLE_HISTORY_PROCESS = 5;
public static final int VARIABLE_HISTORY_VARINSTANCE = 6;
public static final int VARIABLE_HISTORY_DETAIL = 7;

public static final String BYTE_ARRAY_VARIABLE_TYPE = "binary";
public static final String SERIALIZABLE_VARIABLE_TYPE = "serializable";

Expand Down Expand Up @@ -167,33 +175,34 @@ public ProcessDefinitionResponse createProcessDefinitionResponse(SecuredResource
return response;
}

public List<RestVariable> createRestVariables(SecuredResource securedResource, Map<String, Object> variables, String taskId, String executionId, String processInstanceId, RestVariableScope scope) {
public List<RestVariable> createRestVariables(SecuredResource securedResource, Map<String, Object> variables, String id, int variableType, RestVariableScope scope) {
List<RestVariable> result = new ArrayList<RestVariable>();

for(Entry<String, Object> pair : variables.entrySet()) {
result.add(createRestVariable(securedResource, pair.getKey(), pair.getValue(), scope, taskId, executionId, processInstanceId, null, false));
result.add(createRestVariable(securedResource, pair.getKey(), pair.getValue(), scope, id, variableType, false));
}

return result;
}

public RestVariable createRestVariable(SecuredResource securedResource, String name, Object value, RestVariableScope scope, String taskId,
String executionId, String processInstanceId, String historicDetailId, boolean includeBinaryValue) {
public RestVariable createRestVariable(SecuredResource securedResource, String name, Object value, RestVariableScope scope,
String id, int variableType, boolean includeBinaryValue) {

RestVariableConverter converter = null;
RestVariable restVar = new RestVariable();
restVar.setVariableScope(scope);
restVar.setName(name);

if(value != null) {
if (value != null) {
// Try converting the value
for(RestVariableConverter c : variableConverters) {
if(value.getClass().isAssignableFrom(c.getVariableType())) {
for (RestVariableConverter c : variableConverters) {
if (value.getClass().isAssignableFrom(c.getVariableType())) {
converter = c;
break;
}
}

if(converter != null) {
if (converter != null) {
converter.convertVariableValue(value, restVar);
restVar.setType(converter.getRestTypeName());
} else {
Expand All @@ -204,24 +213,24 @@ public RestVariable createRestVariable(SecuredResource securedResource, String n
restVar.setType(SERIALIZABLE_VARIABLE_TYPE);
}

if(includeBinaryValue) {
if (includeBinaryValue) {
restVar.setValue(value);
}

if(taskId != null) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_TASK_VARIABLE_DATA, taskId, name));
}

if(executionId != null) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_EXECUTION_VARIABLE_DATA, executionId, name));
}

if(processInstanceId != null) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_DATA, processInstanceId, name));
}

if(historicDetailId != null) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_DETAIL_VARIABLE_DATA, historicDetailId));
if (variableType == VARIABLE_TASK) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_TASK_VARIABLE_DATA, id, name));
} else if (variableType == VARIABLE_EXECUTION) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_EXECUTION_VARIABLE_DATA, id, name));
} else if (variableType == VARIABLE_PROCESS) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_PROCESS_INSTANCE_VARIABLE_DATA, id, name));
} else if (variableType == VARIABLE_HISTORY_TASK) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE_VARIABLE_DATA, id, name));
} else if (variableType == VARIABLE_HISTORY_PROCESS) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_VARIABLE_DATA, id, name));
} else if (variableType == VARIABLE_HISTORY_VARINSTANCE) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_VARIABLE_INSTANCE_DATA, id));
} else if (variableType == VARIABLE_HISTORY_DETAIL) {
restVar.setValueUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_DETAIL_VARIABLE_DATA, id));
}
}
}
Expand Down Expand Up @@ -300,12 +309,12 @@ public Object getVariableValue(QueryVariable restVariable) {
return value;
}

public LegacyRestIdentityLink createRestIdentityLink(SecuredResource securedResource, IdentityLink link) {
return createRestIdentityLink(securedResource, link.getType(), link.getUserId(), link.getGroupId(), link.getTaskId());
public RestIdentityLink createRestIdentityLink(SecuredResource securedResource, IdentityLink link) {
return createRestIdentityLink(securedResource, link.getType(), link.getUserId(), link.getGroupId(), link.getTaskId(), link.getProcessDefinitionId(), link.getProcessInstanceId());
}

public LegacyRestIdentityLink createRestIdentityLink(SecuredResource securedResource, String type, String userId, String groupId, String taskId) {
LegacyRestIdentityLink result = new LegacyRestIdentityLink();
public RestIdentityLink createRestIdentityLink(SecuredResource securedResource, String type, String userId, String groupId, String taskId, String processDefinitionId, String processInstanceId) {
RestIdentityLink result = new RestIdentityLink();
result.setUser(userId);
result.setGroup(groupId);
result.setType(type);
Expand All @@ -316,7 +325,13 @@ public LegacyRestIdentityLink createRestIdentityLink(SecuredResource securedReso
} else {
family = RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS;
}
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_TASK_IDENTITYLINK, taskId, family, (userId != null ? userId : groupId), type));
if(processDefinitionId != null) {
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinitionId, family, (userId != null ? userId : groupId)));
} else if(taskId != null){
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_TASK_IDENTITYLINK, taskId, family, (userId != null ? userId : groupId), type));
} else {
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstanceId, (userId != null ? userId : groupId), type));
}
return result;
}

Expand Down Expand Up @@ -425,6 +440,13 @@ public HistoricProcessInstanceResponse createHistoricProcessInstanceResponse(Sec
result.setStartUserId(processInstance.getStartUserId());
result.setSuperProcessInstanceId(processInstance.getSuperProcessInstanceId());
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId()));
if (processInstance.getProcessVariables() != null) {
Map<String, Object> variableMap = processInstance.getProcessVariables();
for (String name : variableMap.keySet()) {
result.addVariable(createRestVariable(securedResource, name, variableMap.get(name),
RestVariableScope.GLOBAL, processInstance.getId(), VARIABLE_HISTORY_PROCESS, false));
}
}
return result;
}

Expand Down Expand Up @@ -452,6 +474,20 @@ public HistoricTaskInstanceResponse createHistoricTaskInstanceResponse(SecuredRe
result.setTaskDefinitionKey(taskInstance.getTaskDefinitionKey());
result.setWorkTimeInMillis(taskInstance.getWorkTimeInMillis());
result.setUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_TASK_INSTANCE, taskInstance.getId()));
if (taskInstance.getProcessVariables() != null) {
Map<String, Object> variableMap = taskInstance.getProcessVariables();
for (String name : variableMap.keySet()) {
result.addVariable(createRestVariable(securedResource, name, variableMap.get(name),
RestVariableScope.GLOBAL, taskInstance.getId(), VARIABLE_HISTORY_TASK, false));
}
}
if (taskInstance.getTaskLocalVariables() != null) {
Map<String, Object> variableMap = taskInstance.getTaskLocalVariables();
for (String name : variableMap.keySet()) {
result.addVariable(createRestVariable(securedResource, name, variableMap.get(name),
RestVariableScope.LOCAL, taskInstance.getId(), VARIABLE_HISTORY_TASK, false));
}
}
return result;
}

Expand Down Expand Up @@ -481,9 +517,8 @@ public HistoricVariableInstanceResponse createHistoricVariableInstanceResponse(S
result.setProcessInstanceId(variableInstance.getProcessInstanceId());
result.setProcessInstanceUrl(securedResource.createFullResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, variableInstance.getProcessInstanceId()));
result.setTaskId(variableInstance.getTaskId());
result.setValue(variableInstance.getValue());
result.setVariableName(variableInstance.getVariableName());
result.setVariableTypeName(variableInstance.getVariableTypeName());
result.setVariable(createRestVariable(securedResource, variableInstance.getVariableName(), variableInstance.getValue(),
null, variableInstance.getId(), VARIABLE_HISTORY_VARINSTANCE, false));
return result;
}

Expand Down Expand Up @@ -511,7 +546,7 @@ public HistoricDetailResponse createHistoricDetailResponse(SecuredResource secur
result.setDetailType(HistoricDetailResponse.VARIABLE_UPDATE);
result.setRevision(variableUpdate.getRevision());
result.setVariable(createRestVariable(securedResource, variableUpdate.getVariableName(), variableUpdate.getValue(),
null, null, null, null, detail.getId(), false));
null, detail.getId(), VARIABLE_HISTORY_DETAIL, false));
}
return result;
}
Expand Down
Loading

0 comments on commit 77bc8ad

Please sign in to comment.