提交 fd006abe 编写于 作者: T tombaeyens

ACT-258 added form properties to history

上级 229ff01e
......@@ -15,7 +15,7 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.db.DbSqlSessionFactory;
import org.activiti.engine.impl.db.IbatisVariableTypeHandler;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
......@@ -48,7 +48,7 @@ public class CycleDbSqlSessionFactory extends DbSqlSessionFactory {
XMLConfigBuilder parser = new XMLConfigBuilder(reader);
Configuration configuration = parser.getConfiguration();
configuration.setEnvironment(environment);
configuration.getTypeHandlerRegistry().register(Type.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
configuration = parser.parse();
return new DefaultSqlSessionFactory(configuration);
......
......@@ -18,8 +18,8 @@ import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.history.HistoricVariableUpdateQuery;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.history.HistoricDetailQuery;
/**
* Service exposing information about ongoing and past process instances. This is different
......@@ -40,6 +40,6 @@ public interface HistoryService {
/** Creates a new programmatic query to search for {@link HistoricActivityInstance}s. */
HistoricActivityInstanceQuery createHistoricActivityInstanceQuery();
/** Creates a new programmatic query to search for {@link HistoricVariableUpdate}s. */
HistoricVariableUpdateQuery createHistoricVariableUpdateQuery();
/** Creates a new programmatic query to search for {@link HistoricDetail}s. */
HistoricDetailQuery createHistoricDetailQuery();
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.history;
import java.util.Date;
/**
* @author Tom Baeyens
*/
public interface HistoricDetail {
String getId();
String getProcessInstanceId();
String getActivityInstanceId();
String getExecutionId();
Date getTime();
}
......@@ -19,14 +19,17 @@ import org.activiti.engine.query.Query;
/**
* @author Tom Baeyens
*/
public interface HistoricVariableUpdateQuery extends Query<HistoricVariableUpdateQuery, HistoricVariableUpdate> {
public interface HistoricDetailQuery extends Query<HistoricDetailQuery, HistoricDetail> {
/** Only select historic variable updates with the given process instance.
* {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. */
HistoricVariableUpdateQuery processInstanceId(String processInstanceId);
HistoricDetailQuery processInstanceId(String processInstanceId);
/** Only select historic variable updates with the given variableName. */
HistoricVariableUpdateQuery variableName(String variableName);
/** Only select {@link HistoricFormProperty}s. */
HistoricDetailQuery onlyFormProperties();
/** Only select {@link HistoricVariableUpdate}s. */
HistoricDetailQuery onlyVariableUpdates();
}
......@@ -22,19 +22,19 @@ import org.activiti.engine.query.QueryProperty;
/**
* @author Tom Baeyens
*/
public class HistoricVariableUpdateQueryProperty implements QueryProperty {
public class HistoricDetailQueryProperty implements QueryProperty {
private static final Map<String, HistoricVariableUpdateQueryProperty> properties = new HashMap<String, HistoricVariableUpdateQueryProperty>();
private static final Map<String, HistoricDetailQueryProperty> properties = new HashMap<String, HistoricDetailQueryProperty>();
public static final HistoricVariableUpdateQueryProperty PROCESS_INSTANCE_ID_ = new HistoricVariableUpdateQueryProperty("PROC_INST_ID_");
public static final HistoricVariableUpdateQueryProperty VARIABLE_NAME = new HistoricVariableUpdateQueryProperty("NAME_");
public static final HistoricVariableUpdateQueryProperty VARIABLE_TYPE = new HistoricVariableUpdateQueryProperty("TYPE_");
public static final HistoricVariableUpdateQueryProperty INDEX = new HistoricVariableUpdateQueryProperty("INDEX_");
public static final HistoricVariableUpdateQueryProperty TIME = new HistoricVariableUpdateQueryProperty("TIME_");
public static final HistoricDetailQueryProperty PROCESS_INSTANCE_ID_ = new HistoricDetailQueryProperty("PROC_INST_ID_");
public static final HistoricDetailQueryProperty VARIABLE_NAME = new HistoricDetailQueryProperty("NAME_");
public static final HistoricDetailQueryProperty VARIABLE_TYPE = new HistoricDetailQueryProperty("TYPE_");
public static final HistoricDetailQueryProperty REVISION = new HistoricDetailQueryProperty("REV_");
public static final HistoricDetailQueryProperty TIME = new HistoricDetailQueryProperty("TIME_");
private String name;
public HistoricVariableUpdateQueryProperty(String name) {
public HistoricDetailQueryProperty(String name) {
this.name = name;
properties.put(name, this);
}
......@@ -43,7 +43,7 @@ public class HistoricVariableUpdateQueryProperty implements QueryProperty {
return name;
}
public static HistoricVariableUpdateQueryProperty findByName(String propertyName) {
public static HistoricDetailQueryProperty findByName(String propertyName) {
return properties.get(propertyName);
}
}
......@@ -11,13 +11,16 @@
* limitations under the License.
*/
package org.activiti.engine.impl.history;
package org.activiti.engine.history;
/**
* @author Tom Baeyens
*/
public class HistoricDetailVariableUpdateEntity extends HistoricDetailEntity {
public interface HistoricFormProperty extends HistoricDetail {
String getPropertyId();
String getPropertyValue();
}
......@@ -24,8 +24,6 @@ public interface HistoricProcessInstance {
String getId();
String getProcessInstanceId();
String getBusinessKey();
String getProcessDefinitionId();
......
......@@ -13,18 +13,16 @@
package org.activiti.engine.history;
import org.activiti.engine.impl.variable.VariableType;
/**
* @author Tom Baeyens
*/
public interface HistoricVariableUpdate {
public interface HistoricVariableUpdate extends HistoricDetail {
String getHistoricFormInstanceId();
String getProcessInstanceId();
String getExecutionId();
String getVariableName();
String getVariableType();
VariableType getVariableType();
Object getValue();
int getRevision();
}
......@@ -16,9 +16,9 @@ package org.activiti.engine.impl;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.history.HistoricVariableUpdateQuery;
import org.activiti.engine.history.HistoricVariableUpdateQueryProperty;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.history.HistoricDetailQuery;
import org.activiti.engine.history.HistoricDetailQueryProperty;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.query.QueryProperty;
......@@ -27,34 +27,39 @@ import org.activiti.engine.query.QueryProperty;
/**
* @author Tom Baeyens
*/
public class HistoricVariableUpdateQueryImpl extends AbstractQuery<HistoricVariableUpdateQuery, HistoricVariableUpdate> implements HistoricVariableUpdateQuery {
public class HistoricDetailQueryImpl extends AbstractQuery<HistoricDetailQuery, HistoricDetail> implements HistoricDetailQuery {
protected String processInstanceId;
protected String variableName;
protected HistoricVariableUpdateQueryProperty orderProperty;
protected String type;
protected HistoricDetailQueryProperty orderProperty;
public HistoricVariableUpdateQueryImpl() {
public HistoricDetailQueryImpl() {
}
public HistoricVariableUpdateQueryImpl(CommandExecutor commandExecutor) {
public HistoricDetailQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
public HistoricVariableUpdateQueryImpl processInstanceId(String processInstanceId) {
public HistoricDetailQueryImpl processInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
return this;
}
public HistoricVariableUpdateQueryImpl variableName(String variableName) {
this.variableName = variableName;
public HistoricDetailQuery onlyFormProperties() {
this.type = "FormProperty";
return this;
}
public HistoricVariableUpdateQueryImpl asc() {
public HistoricDetailQuery onlyVariableUpdates() {
this.type = "VariableUpdate";
return this;
}
public HistoricDetailQueryImpl asc() {
return direction(Direction.ASCENDING);
}
public HistoricVariableUpdateQueryImpl desc() {
public HistoricDetailQueryImpl desc() {
return direction(Direction.DESCENDING);
}
......@@ -62,14 +67,14 @@ public class HistoricVariableUpdateQueryImpl extends AbstractQuery<HistoricVaria
checkQueryOk();
return commandContext
.getHistorySession()
.findHistoricVariableUpdateCountByQueryCriteria(this);
.findHistoricDetailCountByQueryCriteria(this);
}
public List<HistoricVariableUpdate> executeList(CommandContext commandContext, Page page) {
public List<HistoricDetail> executeList(CommandContext commandContext, Page page) {
checkQueryOk();
return commandContext
.getHistorySession()
.findHistoricVariableUpdatesByQueryCriteria(this, page);
.findHistoricDetailsByQueryCriteria(this, page);
}
protected void checkQueryOk() {
......@@ -78,7 +83,7 @@ public class HistoricVariableUpdateQueryImpl extends AbstractQuery<HistoricVaria
}
}
public HistoricVariableUpdateQueryImpl direction(Direction direction) {
public HistoricDetailQueryImpl direction(Direction direction) {
if (orderProperty==null) {
throw new ActivitiException("you should call any of the orderBy methods first before specifying a direction");
}
......@@ -87,11 +92,11 @@ public class HistoricVariableUpdateQueryImpl extends AbstractQuery<HistoricVaria
return this;
}
public HistoricVariableUpdateQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof HistoricVariableUpdateQueryProperty)) {
public HistoricDetailQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof HistoricDetailQueryProperty)) {
throw new ActivitiException("Only HistoricVariableUpdateQueryProperty can be used with orderBy");
}
this.orderProperty = (HistoricVariableUpdateQueryProperty) property;
this.orderProperty = (HistoricDetailQueryProperty) property;
return this;
}
......@@ -100,7 +105,4 @@ public class HistoricVariableUpdateQueryImpl extends AbstractQuery<HistoricVaria
public String getProcessInstanceId() {
return processInstanceId;
}
public String getVariableName() {
return variableName;
}
}
......@@ -17,7 +17,7 @@ package org.activiti.engine.impl;
import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricActivityInstanceQuery;
import org.activiti.engine.history.HistoricProcessInstanceQuery;
import org.activiti.engine.history.HistoricVariableUpdateQuery;
import org.activiti.engine.history.HistoricDetailQuery;
/**
* @author Tom Baeyens
......@@ -33,7 +33,7 @@ public class HistoryServiceImpl extends ServiceImpl implements HistoryService {
return new HistoricActivityInstanceQueryImpl(commandExecutor);
}
public HistoricVariableUpdateQuery createHistoricVariableUpdateQuery() {
return new HistoricVariableUpdateQueryImpl(commandExecutor);
public HistoricDetailQuery createHistoricDetailQuery() {
return new HistoricDetailQueryImpl(commandExecutor);
}
}
......@@ -17,7 +17,7 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
import org.activiti.engine.impl.variable.ByteArrayType;
import org.activiti.engine.impl.variable.JPAEntityVariableType;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.engine.impl.variable.VariableTypes;
......@@ -41,7 +41,7 @@ public class QueryVariableValue {
public void initialize(VariableTypes types) {
if(variableInstanceEntity == null) {
Type type = types.findVariableType(value);
VariableType type = types.findVariableType(value);
if(type instanceof ByteArrayType) {
throw new ActivitiException("Variables of type ByteArray cannot be used to query");
} else if(type instanceof JPAEntityVariableType && operator != QueryOperator.EQUALS) {
......
......@@ -17,10 +17,10 @@ import java.util.List;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.impl.HistoricActivityInstanceQueryImpl;
import org.activiti.engine.impl.HistoricProcessInstanceQueryImpl;
import org.activiti.engine.impl.HistoricVariableUpdateQueryImpl;
import org.activiti.engine.impl.HistoricDetailQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
......@@ -44,6 +44,6 @@ public interface HistorySession {
long findHistoricActivityInstanceCountByQueryCriteria(HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl);
List<HistoricActivityInstance> findHistoricActivityInstancesByQueryCriteria(HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl, Page page);
long findHistoricVariableUpdateCountByQueryCriteria(HistoricVariableUpdateQueryImpl historicVariableUpdateQueryImpl);
List<HistoricVariableUpdate> findHistoricVariableUpdatesByQueryCriteria(HistoricVariableUpdateQueryImpl historicVariableUpdateQueryImpl, Page page);
long findHistoricDetailCountByQueryCriteria(HistoricDetailQueryImpl historicDetailQueryImpl);
List<HistoricDetail> findHistoricDetailsByQueryCriteria(HistoricDetailQueryImpl historicDetailQueryImpl, Page page);
}
......@@ -80,7 +80,7 @@ import org.activiti.engine.impl.variable.EntityManagerSession;
import org.activiti.engine.impl.variable.EntityManagerSessionFactory;
import org.activiti.engine.impl.variable.JPAEntityVariableType;
import org.activiti.engine.impl.variable.SerializableType;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.engine.impl.variable.VariableTypes;
/**
......@@ -373,7 +373,7 @@ public class ProcessEngineConfiguration {
}
if(!sessionFactories.containsKey(EntityManagerSession.class)) {
sessionFactories.put(EntityManagerSession.class, new EntityManagerSessionFactory(entityManagerFactory, true, true));
Type jpaType = variableTypes.getVariableType(JPAEntityVariableType.TYPE_NAME);
VariableType jpaType = variableTypes.getVariableType(JPAEntityVariableType.TYPE_NAME);
// Add JPA-type
if(jpaType == null) {
// We try adding the variable right before SerializableType, if available
......
......@@ -47,12 +47,7 @@ public class SetVariablesCmd implements Command<Object> {
throw new ActivitiException("execution "+executionId+" doesn't exist");
}
try {
VariableMap.setExternalUpdate(Boolean.TRUE);
execution.setVariables(variables);
} finally {
VariableMap.setExternalUpdate(null);
}
execution.setVariables(variables);
return null;
}
......
......@@ -15,7 +15,10 @@ package org.activiti.engine.impl.cmd;
import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
......@@ -59,14 +62,9 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance> {
}
ExecutionEntity processInstance = processDefinition.createProcessInstance();
if (variables!=null) {
try {
VariableMap.setExternalUpdate(Boolean.TRUE);
processInstance.setVariables(variables);
} finally {
VariableMap.setExternalUpdate(null);
}
processInstance.setVariables(variables);
}
if (businessKey != null) {
......
......@@ -16,13 +16,17 @@ package org.activiti.engine.impl.cmd;
import java.util.Map;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.cfg.RepositorySession;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.history.HistoricFormPropertyEntity;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.runtime.VariableMap;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -47,15 +51,28 @@ public class SubmitStartFormCmd implements Command<ProcessInstance> {
}
ExecutionEntity processInstance = null;
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
try {
VariableMap.setExternalUpdate(Boolean.TRUE);
processInstance = processDefinition.createProcessInstance();
processInstance = startFormHandler.submitStartFormData(processDefinition, properties);
int historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
if (historyLevel>=ProcessEngineConfiguration.HISTORYLEVEL_ACTIVITY) {
DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);
} finally {
VariableMap.setExternalUpdate(null);
if (historyLevel>=ProcessEngineConfiguration.HISTORYLEVEL_AUDIT) {
String authenticatedUserId = Authentication.getAuthenticatedUserId();
HistoricProcessInstanceEntity historicProcessInstance = dbSqlSession.selectById(HistoricProcessInstanceEntity.class, processInstance.getId());
historicProcessInstance.setFormUserId(authenticatedUserId);
historicProcessInstance.setFormActivityId(processInstance.getActivityId());
for (String propertyId: properties.keySet()) {
String propertyValue = properties.get(propertyId);
HistoricFormPropertyEntity historicFormProperty = new HistoricFormPropertyEntity(processInstance, propertyId, propertyValue);
dbSqlSession.insert(historicFormProperty);
}
}
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
startFormHandler.submitFormProperties(properties, processInstance);
processInstance.start();
......
......@@ -20,7 +20,6 @@ import org.activiti.engine.impl.cfg.TaskSession;
import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.VariableMap;
import org.activiti.engine.impl.task.TaskEntity;
......@@ -51,14 +50,7 @@ public class SubmitTaskFormCmd implements Command<Object> {
}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
try {
VariableMap.setExternalUpdate(Boolean.TRUE);
taskFormHandler.submitTaskFormData(task, properties);
} finally {
VariableMap.setExternalUpdate(null);
}
taskFormHandler.submitFormProperties(properties, task.getExecution());
task.complete();
......
......@@ -18,14 +18,15 @@ import java.util.List;
import java.util.Map;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.impl.HistoricActivityInstanceQueryImpl;
import org.activiti.engine.impl.HistoricDetailQueryImpl;
import org.activiti.engine.impl.HistoricProcessInstanceQueryImpl;
import org.activiti.engine.impl.HistoricVariableUpdateQueryImpl;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.cfg.HistorySession;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.history.HistoricDetailEntity;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.history.HistoricVariableUpdateEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
......@@ -44,10 +45,10 @@ public class DbHistorySession extends AbstractDbSession implements HistorySessio
@SuppressWarnings("unchecked")
public void deleteHistoricProcessInstance(String historicProcessInstanceId) {
List<HistoricVariableUpdateEntity> historicVariableUpdates = (List) new HistoricVariableUpdateQueryImpl()
List<HistoricDetailEntity> historicDetails = (List) new HistoricDetailQueryImpl()
.processInstanceId(historicProcessInstanceId)
.executeList(CommandContext.getCurrent(), null);
for (HistoricVariableUpdateEntity historicVariableUpdate: historicVariableUpdates) {
for (HistoricDetailEntity historicVariableUpdate: historicDetails) {
historicVariableUpdate.delete();
}
......@@ -93,13 +94,13 @@ public class DbHistorySession extends AbstractDbSession implements HistorySessio
return dbSqlSession.selectList("selectHistoricActivityInstancesByQueryCriteria", historicActivityInstanceQuery, page);
}
public long findHistoricVariableUpdateCountByQueryCriteria(HistoricVariableUpdateQueryImpl historicVariableUpdateQuery) {
return (Long) dbSqlSession.selectOne("selectHistoricVariableUpdateCountByQueryCriteria", historicVariableUpdateQuery);
public long findHistoricDetailCountByQueryCriteria(HistoricDetailQueryImpl historicVariableUpdateQuery) {
return (Long) dbSqlSession.selectOne("selectHistoricDetailCountByQueryCriteria", historicVariableUpdateQuery);
}
@SuppressWarnings("unchecked")
public List<HistoricVariableUpdate> findHistoricVariableUpdatesByQueryCriteria(HistoricVariableUpdateQueryImpl historicVariableUpdateQuery, Page page) {
return dbSqlSession.selectList("selectHistoricVariableUpdatesByQueryCriteria", historicVariableUpdateQuery, page);
public List<HistoricDetail> findHistoricDetailsByQueryCriteria(HistoricDetailQueryImpl historicVariableUpdateQuery, Page page) {
return dbSqlSession.selectList("selectHistoricDetailsByQueryCriteria", historicVariableUpdateQuery, page);
}
public void close() {
......
......@@ -176,6 +176,9 @@ public class DbSqlSession implements Session {
String selectStatement = dbSqlSessionFactory.getSelectStatement(entityClass);
selectStatement = dbSqlSessionFactory.mapStatement(selectStatement);
persistentObject = (T) sqlSession.selectOne(selectStatement, id);
if (persistentObject==null) {
return null;
}
cachePut(persistentObject, true);
return persistentObject;
}
......
......@@ -37,7 +37,7 @@ import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.engine.impl.util.ReflectUtil;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.pvm.impl.util.ClassNameUtil;
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
......@@ -142,7 +142,7 @@ public class DbSqlSessionFactory implements SessionFactory, ProcessEngineConfigu
XMLConfigBuilder parser = new XMLConfigBuilder(reader);
Configuration configuration = parser.getConfiguration();
configuration.setEnvironment(environment);
configuration.getTypeHandlerRegistry().register(Type.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler());
configuration = parser.parse();
return new DefaultSqlSessionFactory(configuration);
......
......@@ -20,7 +20,7 @@ import java.sql.SQLException;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.engine.impl.variable.VariableTypes;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
......@@ -35,7 +35,7 @@ public class IbatisVariableTypeHandler implements TypeHandler {
public Object getResult(ResultSet rs, String columnName) throws SQLException {
String typeName = rs.getString(columnName);
Type type = getVariableTypes().getVariableType(typeName);
VariableType type = getVariableTypes().getVariableType(typeName);
if (type == null) {
throw new ActivitiException("unknown variable type name " + typeName);
}
......@@ -44,7 +44,7 @@ public class IbatisVariableTypeHandler implements TypeHandler {
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
String typeName = cs.getString(columnIndex);
Type type = getVariableTypes().getVariableType(typeName);
VariableType type = getVariableTypes().getVariableType(typeName);
if (type == null) {
throw new ActivitiException("unknown variable type name " + typeName);
}
......@@ -52,7 +52,7 @@ public class IbatisVariableTypeHandler implements TypeHandler {
}
public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
String typeName = ((Type) parameter).getTypeName();
String typeName = ((VariableType) parameter).getTypeName();
ps.setString(i, typeName);
}
......
......@@ -32,8 +32,8 @@ import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public class DefaultFormHandler {
public class DefaultFormHandler implements FormHandler {
protected String formKey;
protected String deploymentId;
protected List<FormPropertyHandler> formPropertyHandlers = new ArrayList<FormPropertyHandler>();
......@@ -118,7 +118,7 @@ public class DefaultFormHandler {
formData.setFormProperties(formProperties);
}
protected void submitFormProperties(Map<String, String> properties, ExecutionEntity execution) {
public void submitFormProperties(Map<String, String> properties, ExecutionEntity execution) {
Map<String, String> propertiesCopy = new HashMap<String, String>(properties);
for (FormPropertyHandler formPropertyHandler: formPropertyHandlers) {
// submitFormProperty will remove all the keys which it takes care of
......
......@@ -34,8 +34,7 @@ public class DefaultStartFormHandler extends DefaultFormHandler implements Start
return startFormData;
}
public ExecutionEntity submitStartFormData(ProcessDefinitionEntity processDefinition, Map<String, String> properties) {
ExecutionEntity processInstance = processDefinition.createProcessInstance();
public ExecutionEntity submitStartFormData(ExecutionEntity processInstance, Map<String, String> properties) {
submitFormProperties(properties, processInstance);
return processInstance;
}
......
......@@ -33,8 +33,4 @@ public class DefaultTaskFormHandler extends DefaultFormHandler implements TaskFo
initializeFormProperties(taskFormData, task.getExecution());
return taskFormData;
}
public void submitTaskFormData(TaskEntity task, Map<String, String> properties) {
submitFormProperties(properties, task.getExecution());
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.form;
import java.util.Map;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public interface FormHandler {
ThreadLocal<FormHandler> current = new ThreadLocal<FormHandler>();
void parseConfiguration(Element activityElement, DeploymentEntity deployment, BpmnParse bpmnParse);
void submitFormProperties(Map<String, String> properties, ExecutionEntity execution);
}
......@@ -14,7 +14,6 @@
package org.activiti.engine.impl.form;
import org.activiti.engine.form.StartFormData;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.repository.ProcessDefinition;
......
......@@ -13,22 +13,14 @@
package org.activiti.engine.impl.form;
import java.util.Map;
import org.activiti.engine.form.StartFormData;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public interface StartFormHandler {
public interface StartFormHandler extends FormHandler {
StartFormData createStartFormData(ProcessDefinitionEntity processDefinition);
ExecutionEntity submitStartFormData(ProcessDefinitionEntity processDefinition, Map<String, String> properties);
void parseConfiguration(Element startEventElement, DeploymentEntity deployment, BpmnParse bpmnParse);
}
......@@ -16,19 +16,13 @@ package org.activiti.engine.impl.form;
import java.util.Map;
import org.activiti.engine.form.TaskFormData;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.repository.DeploymentEntity;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.impl.util.xml.Element;
/**
* @author Tom Baeyens
*/
public interface TaskFormHandler {
public interface TaskFormHandler extends FormHandler {
TaskFormData createTaskForm(TaskEntity task);
void submitTaskFormData(TaskEntity task, Map<String, String> properties);
void parseConfiguration(Element userTaskElement, DeploymentEntity deployment, BpmnParse bpmnParse);
}
......@@ -15,23 +15,36 @@ package org.activiti.engine.impl.history;
import java.util.Date;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.ByteArrayEntity;
import org.activiti.engine.impl.runtime.JobEntity;
/**
* @author Tom Baeyens
*/
public class HistoricDetailEntity implements PersistentObject {
public class HistoricDetailEntity implements HistoricDetail, PersistentObject {
protected String id;
protected String type;
protected String processInstanceId;
protected String activityInstanceId;
protected String taskInstanceId;
protected String executionId;
protected Date time;
public Object getPersistentState() {
return null;
// details are not updatable so we always provide the same object as the state
return HistoricDetailEntity.class;
}
public void delete() {
DbSqlSession dbSqlSession = CommandContext
.getCurrent()
.getDbSqlSession();
dbSqlSession.delete(HistoricDetailEntity.class, id);
}
// getters and setters //////////////////////////////////////////////////////
......@@ -42,4 +55,42 @@ public class HistoricDetailEntity implements PersistentObject {
public void setId(String id) {
this.id = id;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getExecutionId() {
return executionId;
}
public void setExecutionId(String executionId) {
this.executionId = executionId;
}
public String getActivityInstanceId() {
return activityInstanceId;
}
public void setActivityInstanceId(String activityInstanceId) {
this.activityInstanceId = activityInstanceId;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.history;
import org.activiti.engine.history.HistoricFormProperty;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
*/
public class HistoricFormPropertyEntity extends HistoricDetailEntity implements HistoricFormProperty {
protected String propertyId;
protected String propertyValue;
public HistoricFormPropertyEntity() {
}
public HistoricFormPropertyEntity(ExecutionEntity processInstance, String propertyId, String propertyValue) {
this.processInstanceId = processInstance.getId();
this.executionId = processInstance.getId();
this.propertyId = propertyId;
this.propertyValue = propertyValue;
this.time = ClockUtil.getCurrentTime();
}
public String getPropertyId() {
return propertyId;
}
public void setPropertyId(String propertyId) {
this.propertyId = propertyId;
}
public String getPropertyValue() {
return propertyValue;
}
public void setPropertyValue(String propertyValue) {
this.propertyValue = propertyValue;
}
}
......@@ -17,14 +17,30 @@ package org.activiti.engine.impl.history;
import java.util.Map;
import org.activiti.engine.history.HistoricProcessInstance;
import org.activiti.engine.impl.runtime.ExecutionEntity;
import org.activiti.engine.impl.util.ClockUtil;
/**
* @author Tom Baeyens
* @author Christian Stettler
*/
public class HistoricProcessInstanceEntity extends HistoricScopeInstanceEntity implements HistoricProcessInstance {
protected String endActivityId;
protected String businessKey;
protected String formUserId;
protected String formActivityId;
public HistoricProcessInstanceEntity() {
}
public HistoricProcessInstanceEntity(ExecutionEntity processInstance) {
id = processInstance.getId();
processInstanceId = processInstance.getId();
businessKey = processInstance.getBusinessKey();
processDefinitionId = processInstance.getProcessDefinitionId();
startTime = ClockUtil.getCurrentTime();
}
@SuppressWarnings("unchecked")
@Override
......@@ -49,4 +65,16 @@ public class HistoricProcessInstanceEntity extends HistoricScopeInstanceEntity i
public void setEndActivityId(String endActivityId) {
this.endActivityId = endActivityId;
}
public String getFormUserId() {
return formUserId;
}
public void setFormUserId(String formUserId) {
this.formUserId = formUserId;
}
public String getFormActivityId() {
return formActivityId;
}
public void setFormActivityId(String formActivityId) {
this.formActivityId = formActivityId;
}
}
......@@ -23,18 +23,31 @@ import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.ByteArrayEntity;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
import org.activiti.engine.impl.util.ClockUtil;
import org.activiti.engine.impl.variable.ValueFields;
import org.activiti.engine.impl.variable.VariableType;
/**
* @author Tom Baeyens
*/
public class HistoricVariableUpdateEntity extends VariableInstanceEntity implements HistoricVariableUpdate, PersistentObject {
public class HistoricVariableUpdateEntity extends HistoricDetailEntity implements ValueFields, HistoricVariableUpdate, PersistentObject {
private static final long serialVersionUID = 1L;
protected String historicFormInstanceId;
protected Date time;
protected String name;
protected int revision;
protected VariableType variableType;
protected Long longValue;
protected Double doubleValue;
protected String textValue;
protected String textValue2;
protected ByteArrayEntity byteArrayValue;
protected String byteArrayValueId;
protected Object cachedValue;
public HistoricVariableUpdateEntity() {
}
......@@ -49,7 +62,7 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
}
this.revision = variableInstance.getRevision();
this.name = variableInstance.getName();
this.type = variableInstance.getType();
this.variableType = variableInstance.getType();
this.time = ClockUtil.getCurrentTime();
if (variableInstance.getByteArrayValueId()!=null) {
// TODO test and review. name ok here?
......@@ -63,19 +76,24 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
this.longValue = variableInstance.getLongValue();
}
public void delete() {
DbSqlSession dbSqlSession = CommandContext
.getCurrent()
.getDbSqlSession();
public Object getValue() {
if (!variableType.isCachable() || cachedValue==null) {
cachedValue = variableType.getValue(this);
}
return cachedValue;
}
dbSqlSession.delete(HistoricVariableUpdateEntity.class, id);
public void delete() {
super.delete();
if (byteArrayValueId != null) {
// the next apparently useless line is probably to ensure consistency in the DbSqlSession
// cache, but should be checked and docced here (or removed if it turns out to be unnecessary)
// @see also HistoricVariableInstanceEntity
getByteArrayValue();
dbSqlSession.delete(ByteArrayEntity.class, byteArrayValueId);
CommandContext
.getCurrentSession(DbSqlSession.class)
.delete(ByteArrayEntity.class, byteArrayValueId);
}
}
......@@ -97,15 +115,100 @@ public class HistoricVariableUpdateEntity extends VariableInstanceEntity impleme
return name;
}
public String getVariableType() {
return type.getTypeName();
public VariableType getVariableType() {
return variableType;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
public String getHistoricFormInstanceId() {
return historicFormInstanceId;
public String getName() {
return name;
}
public void setHistoricFormInstanceId(String historicFormInstanceId) {
this.historicFormInstanceId = historicFormInstanceId;
public void setName(String name) {
this.name = name;
}
public Long getLongValue() {
return longValue;
}
public void setLongValue(Long longValue) {
this.longValue = longValue;
}
public Double getDoubleValue() {
return doubleValue;
}
public void setDoubleValue(Double doubleValue) {
this.doubleValue = doubleValue;
}
public String getTextValue() {
return textValue;
}
public void setTextValue(String textValue) {
this.textValue = textValue;
}
public String getTextValue2() {
return textValue2;
}
public void setTextValue2(String textValue2) {
this.textValue2 = textValue2;
}
public ByteArrayEntity getByteArrayValue() {
return byteArrayValue;
}
public void setByteArrayValue(ByteArrayEntity byteArrayValue) {
this.byteArrayValue = byteArrayValue;
}
public String getByteArrayValueId() {
return byteArrayValueId;
}
public void setByteArrayValueId(String byteArrayValueId) {
this.byteArrayValueId = byteArrayValueId;
}
public Object getCachedValue() {
return cachedValue;
}
public void setCachedValue(Object cachedValue) {
this.cachedValue = cachedValue;
}
public void setVariableType(VariableType variableType) {
this.variableType = variableType;
}
}
......@@ -27,21 +27,21 @@ import org.activiti.pvm.event.EventListenerExecution;
public class ProcessInstanceStartHandler implements EventListener {
public void notify(EventListenerExecution execution) {
ExecutionEntity executionEntity = (ExecutionEntity) execution;
String processInstanceId = executionEntity.getId();
String processDefinitionId = executionEntity.getProcessDefinitionId();
String businessKey = executionEntity.getBusinessKey();
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity();
historicProcessInstance.setId(processInstanceId);
historicProcessInstance.setProcessInstanceId(processInstanceId);
historicProcessInstance.setBusinessKey(businessKey);
historicProcessInstance.setProcessDefinitionId(processDefinitionId);
historicProcessInstance.setStartTime(ClockUtil.getCurrentTime());
CommandContext
.getCurrent()
.getDbSqlSession()
.insert(historicProcessInstance);
// ExecutionEntity executionEntity = (ExecutionEntity) execution;
// String processInstanceId = executionEntity.getId();
// String processDefinitionId = executionEntity.getProcessDefinitionId();
// String businessKey = executionEntity.getBusinessKey();
//
// HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity();
// historicProcessInstance.setId(processInstanceId);
// historicProcessInstance.setProcessInstanceId(processInstanceId);
// historicProcessInstance.setBusinessKey(businessKey);
// historicProcessInstance.setProcessDefinitionId(processDefinitionId);
// historicProcessInstance.setStartTime(ClockUtil.getCurrentTime());
//
// CommandContext
// .getCurrent()
// .getDbSqlSession()
// .insert(historicProcessInstance);
}
}
......@@ -15,8 +15,11 @@ package org.activiti.engine.impl.repository;
import java.util.ArrayList;
import java.util.Map;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.ExecutionEntity;
......@@ -49,6 +52,13 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
public ExecutionEntity createProcessInstance() {
ExecutionEntity processInstance = (ExecutionEntity) super.createProcessInstance();
CommandContext commandContext = CommandContext.getCurrent();
commandContext
.getDbSqlSession()
.insert(processInstance);
processInstance.setExecutions(new ArrayList<ExecutionImpl>());
processInstance.setProcessDefinition(processDefinition);
// Do not initialize variable map (let it happen lazily)
......@@ -64,20 +74,20 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
VariableMap variableMap = VariableMap.createNewInitialized(processInstance.getId(), processInstance.getId());
processInstance.setVariables(variableMap);
int historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
if (historyLevel>=ProcessEngineConfiguration.HISTORYLEVEL_ACTIVITY) {
DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
dbSqlSession.insert(historicProcessInstance);
}
return processInstance;
}
@Override
protected ExecutionImpl newProcessInstance() {
ExecutionEntity processInstance = new ExecutionEntity();
CommandContext
.getCurrent()
.getDbSqlSession()
.insert(processInstance);
return processInstance;
return new ExecutionEntity();
}
public String toString() {
......
......@@ -26,12 +26,13 @@ import org.activiti.engine.impl.TaskQueryImpl;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.calendar.BusinessCalendar;
import org.activiti.engine.impl.calendar.DurationBusinessCalendar;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.history.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.history.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.repository.ProcessDefinitionEntity;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.impl.variable.VariableDeclaration;
import org.activiti.engine.runtime.Execution;
......@@ -42,6 +43,8 @@ import org.activiti.pvm.impl.process.ActivityImpl;
import org.activiti.pvm.impl.process.ProcessDefinitionImpl;
import org.activiti.pvm.impl.process.ScopeImpl;
import org.activiti.pvm.impl.runtime.ExecutionImpl;
import org.activiti.pvm.process.PvmProcessDefinition;
import org.activiti.pvm.runtime.PvmProcessInstance;
/**
......@@ -109,6 +112,21 @@ public class ExecutionEntity extends ExecutionImpl implements PersistentObject,
public ExecutionEntity() {
}
@Override
public PvmProcessInstance createSubProcessInstance(PvmProcessDefinition processDefinition) {
PvmProcessInstance subProcessInstance = super.createSubProcessInstance(processDefinition);
CommandContext commandContext = CommandContext.getCurrent();
int historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
if (historyLevel>=ProcessEngineConfiguration.HISTORYLEVEL_ACTIVITY) {
DbSqlSession dbSqlSession = commandContext.getSession(DbSqlSession.class);
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity((ExecutionEntity) subProcessInstance);
dbSqlSession.insert(historicProcessInstance);
}
return subProcessInstance;
}
@Override
protected ExecutionImpl newExecution() {
......
......@@ -82,8 +82,8 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject {
public void delete() {
DbSqlSession dbSqlSession = CommandContext
.getCurrent()
.getDbSqlSession();
.getCurrent()
.getDbSqlSession();
dbSqlSession.delete(JobEntity.class, id);
......
......@@ -20,12 +20,13 @@ import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.task.TaskEntity;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.ValueFields;
import org.activiti.engine.impl.variable.VariableType;
/**
* @author Tom Baeyens
*/
public class VariableInstanceEntity implements Serializable, PersistentObject {
public class VariableInstanceEntity implements ValueFields, PersistentObject, Serializable {
private static final long serialVersionUID = 1L;
......@@ -48,13 +49,13 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
protected Object cachedValue;
protected Type type;
protected VariableType type;
// Default constructor for SQL mapping
protected VariableInstanceEntity() {
}
public static VariableInstanceEntity createAndInsert(String name, Type type, Object value) {
public static VariableInstanceEntity createAndInsert(String name, VariableType type, Object value) {
VariableInstanceEntity variableInstance = create(name, type, value);
CommandContext
......@@ -65,7 +66,7 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
return variableInstance;
}
public static VariableInstanceEntity create(String name, Type type, Object value) {
public static VariableInstanceEntity create(String name, VariableType type, Object value) {
VariableInstanceEntity variableInstance = new VariableInstanceEntity();
variableInstance.name = name;
variableInstance.type = type;
......@@ -222,10 +223,10 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
public void setRevision(int revision) {
this.revision = revision;
}
public void setType(Type type) {
public void setType(VariableType type) {
this.type = type;
}
public Type getType() {
public VariableType getType() {
return type;
}
public Object getCachedValue() {
......
......@@ -25,7 +25,7 @@ import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.history.HistoricVariableUpdateEntity;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.variable.Type;
import org.activiti.engine.impl.variable.VariableType;
import org.activiti.engine.impl.variable.VariableTypes;
......@@ -40,17 +40,12 @@ public class VariableMap implements Map<String, Object> , Serializable {
protected String executionId;
protected String processInstanceId;
protected Map<String, VariableInstanceEntity> variableInstances = null;
protected static ThreadLocal<Boolean> isExternalUpdateThreadLocal = new ThreadLocal<Boolean>();
public VariableMap(String executionId, String processInstanceId) {
this.executionId = executionId;
this.processInstanceId = processInstanceId;
}
public static void setExternalUpdate(Boolean isExternalUpdate) {
isExternalUpdateThreadLocal.set(isExternalUpdate);
}
/** returns an initialized empty variable map */
public static VariableMap createNewInitialized(String executionId, String processInstanceId) {
VariableMap variableMap = new VariableMap(executionId, processInstanceId);
......@@ -111,7 +106,7 @@ public class VariableMap implements Map<String, Object> , Serializable {
.getProcessEngineConfiguration()
.getVariableTypes();
Type type = variableTypes.findVariableType(value);
VariableType type = variableTypes.findVariableType(value);
variableInstance = VariableInstanceEntity.createAndInsert(key, type, value);
variableInstance.setExecutionId(executionId);
......@@ -121,9 +116,7 @@ public class VariableMap implements Map<String, Object> , Serializable {
variableInstance.setValue(value);
int historyLevel = commandContext.getProcessEngineConfiguration().getHistoryLevel();
if ( (historyLevel>=ProcessEngineConfiguration.HISTORYLEVEL_AUDIT)
&& (Boolean.TRUE.equals(isExternalUpdateThreadLocal.get()))
) {
if (historyLevel==ProcessEngineConfiguration.HISTORYLEVEL_FULL) {
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
HistoricVariableUpdateEntity historicVariableUpdate = new HistoricVariableUpdateEntity(variableInstance, dbSqlSession);
dbSqlSession.insert(historicVariableUpdate);
......
......@@ -221,12 +221,7 @@ public class TaskEntity implements Task, Serializable, PersistentObject {
public void setExecutionVariables(Map<String, Object> parameters) {
if (getExecution()!=null) {
try {
VariableMap.setExternalUpdate(Boolean.TRUE);
execution.setVariables(parameters);
} finally {
VariableMap.setExternalUpdate(null);
}
execution.setVariables(parameters);
}
}
......
......@@ -14,12 +14,11 @@ package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.runtime.ByteArrayEntity;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class ByteArrayType implements Type {
public class ByteArrayType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -31,15 +30,15 @@ public class ByteArrayType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
if (variableInstanceEntity.getByteArrayValueId()==null) {
public Object getValue(ValueFields valueFields) {
if (valueFields.getByteArrayValueId()==null) {
return null;
}
return variableInstanceEntity.getByteArrayValue().getBytes();
return valueFields.getByteArrayValue().getBytes();
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
ByteArrayEntity byteArray = variableInstanceEntity.getByteArrayValue();
public void setValue(Object value, ValueFields valueFields) {
ByteArrayEntity byteArray = valueFields.getByteArrayValue();
byte[] bytes = (byte[]) value;
if (byteArray==null) {
byteArray = new ByteArrayEntity(bytes);
......@@ -47,7 +46,7 @@ public class ByteArrayType implements Type {
.getCurrent()
.getDbSqlSession()
.insert(byteArray);
variableInstanceEntity.setByteArrayValue(byteArray);
valueFields.setByteArrayValue(byteArray);
} else {
byteArray.setBytes(bytes);
}
......
......@@ -20,7 +20,7 @@ import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class DateType implements Type {
public class DateType implements VariableType {
public String getTypeName() {
return "date";
......@@ -37,19 +37,19 @@ public class DateType implements Type {
return Date.class.isAssignableFrom(value.getClass());
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
Long longValue = variableInstanceEntity.getLongValue();
public Object getValue(ValueFields valueFields) {
Long longValue = valueFields.getLongValue();
if (longValue!=null) {
return new Date(longValue);
}
return null;
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
public void setValue(Object value, ValueFields valueFields) {
if (value!=null) {
variableInstanceEntity.setLongValue(((Date)value).getTime());
valueFields.setLongValue(((Date)value).getTime());
} else {
variableInstanceEntity.setLongValue(null);
valueFields.setLongValue(null);
}
}
}
......@@ -27,8 +27,8 @@ public class DefaultVariableTypes implements Serializable, VariableTypes {
private static final long serialVersionUID = 1L;
private final List<Type> typesList = new ArrayList<Type>();
private final Map<String, Type> typesMap = new HashMap<String, Type>();
private final List<VariableType> typesList = new ArrayList<VariableType>();
private final Map<String, VariableType> typesMap = new HashMap<String, VariableType>();
public DefaultVariableTypes() {
addType(new NullType());
......@@ -42,31 +42,31 @@ public class DefaultVariableTypes implements Serializable, VariableTypes {
addType(new SerializableType());
}
public DefaultVariableTypes addType(Type type) {
public DefaultVariableTypes addType(VariableType type) {
return addType(type, typesList.size());
}
public DefaultVariableTypes addType(Type type, int index) {
public DefaultVariableTypes addType(VariableType type, int index) {
typesList.add(index, type);
typesMap.put(type.getTypeName(), type);
return this;
}
public void setTypesList(List<Type> typesList) {
public void setTypesList(List<VariableType> typesList) {
this.typesList.clear();
this.typesList.addAll(typesList);
this.typesMap.clear();
for (Type type : typesList) {
for (VariableType type : typesList) {
typesMap.put(type.getTypeName(), type);
}
}
public Type getVariableType(String typeName) {
public VariableType getVariableType(String typeName) {
return typesMap.get(typeName);
}
public Type findVariableType(Object value) {
for (Type type : typesList) {
public VariableType findVariableType(Object value) {
for (VariableType type : typesList) {
if (type.isAbleToStore(value)) {
return type;
}
......@@ -74,12 +74,12 @@ public class DefaultVariableTypes implements Serializable, VariableTypes {
throw new ActivitiException("couldn't find type for " + value);
}
public int getTypeIndex(Type type) {
public int getTypeIndex(VariableType type) {
return typesList.indexOf(type);
}
public int getTypeIndex(String typeName) {
Type type = typesMap.get(typeName);
VariableType type = typesMap.get(typeName);
if(type != null) {
return getTypeIndex(type);
} else {
......@@ -87,7 +87,7 @@ public class DefaultVariableTypes implements Serializable, VariableTypes {
}
}
public VariableTypes removeType(Type type) {
public VariableTypes removeType(VariableType type) {
typesList.remove(type);
typesMap.remove(type.getTypeName());
return this;
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class DoubleType implements Type {
public class DoubleType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,12 +29,12 @@ public class DoubleType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
return variableInstanceEntity.getDoubleValue();
public Object getValue(ValueFields valueFields) {
return valueFields.getDoubleValue();
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
variableInstanceEntity.setDoubleValue( (Double) value );
public void setValue(Object value, ValueFields valueFields) {
valueFields.setDoubleValue( (Double) value );
}
public boolean isAbleToStore(Object value) {
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Joram Barrez
*/
public class IntegerType implements Type {
public class IntegerType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,20 +29,20 @@ public class IntegerType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
if(variableInstanceEntity.getLongValue() != null) {
return new Integer(variableInstanceEntity.getLongValue().intValue());
public Object getValue(ValueFields valueFields) {
if(valueFields.getLongValue() != null) {
return new Integer(valueFields.getLongValue().intValue());
}
return null;
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
public void setValue(Object value, ValueFields valueFields) {
if (value!=null) {
variableInstanceEntity.setLongValue(((Integer) value).longValue());
variableInstanceEntity.setTextValue(value.toString());
valueFields.setLongValue(((Integer) value).longValue());
valueFields.setTextValue(value.toString());
} else {
variableInstanceEntity.setLongValue(null);
variableInstanceEntity.setTextValue(null);
valueFields.setLongValue(null);
valueFields.setTextValue(null);
}
}
......
......@@ -13,7 +13,6 @@
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* Variable type capable of storing reference to JPA-entities. Only JPA-Entities which
......@@ -21,7 +20,7 @@ import org.activiti.engine.impl.runtime.VariableInstanceEntity;
*
* @author Frederik Heremans
*/
public class JPAEntityVariableType implements Type {
public class JPAEntityVariableType implements VariableType {
public static final String TYPE_NAME = "jpa-entity";
......@@ -46,21 +45,21 @@ public class JPAEntityVariableType implements Type {
return mappings.isJPAEntity(value);
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
public void setValue(Object value, ValueFields valueFields) {
if(value != null) {
String className = mappings.getJPAClassString(value);
String idString = mappings.getJPAIdString(value);
variableInstanceEntity.setTextValue(className);
variableInstanceEntity.setTextValue2(idString);
valueFields.setTextValue(className);
valueFields.setTextValue2(idString);
} else {
variableInstanceEntity.setTextValue(null);
variableInstanceEntity.setTextValue2(null);
valueFields.setTextValue(null);
valueFields.setTextValue2(null);
}
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
if(variableInstanceEntity.getTextValue() != null && variableInstanceEntity.getTextValue2() != null) {
return mappings.getJPAEntity(variableInstanceEntity.getTextValue(), variableInstanceEntity.getTextValue2());
public Object getValue(ValueFields valueFields) {
if(valueFields.getTextValue() != null && valueFields.getTextValue2() != null) {
return mappings.getJPAEntity(valueFields.getTextValue(), valueFields.getTextValue2());
}
return null;
}
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class LongType implements Type {
public class LongType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,16 +29,16 @@ public class LongType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
return variableInstanceEntity.getLongValue();
public Object getValue(ValueFields valueFields) {
return valueFields.getLongValue();
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
variableInstanceEntity.setLongValue((Long) value);
public void setValue(Object value, ValueFields valueFields) {
valueFields.setLongValue((Long) value);
if (value!=null) {
variableInstanceEntity.setTextValue(value.toString());
valueFields.setTextValue(value.toString());
} else {
variableInstanceEntity.setTextValue(null);
valueFields.setTextValue(null);
}
}
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class NullType implements Type {
public class NullType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,7 +29,7 @@ public class NullType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
public Object getValue(ValueFields valueFields) {
return null;
}
......@@ -38,7 +37,6 @@ public class NullType implements Type {
return (value==null);
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
public void setValue(Object value, ValueFields valueFields) {
}
}
......@@ -35,37 +35,39 @@ public class SerializableType extends ByteArrayType {
return TYPE_NAME;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
Object cachedObject = variableInstanceEntity.getCachedValue();
public Object getValue(ValueFields valueFields) {
Object cachedObject = valueFields.getCachedValue();
if (cachedObject!=null) {
return cachedObject;
}
byte[] bytes = (byte[]) super.getValue(variableInstanceEntity);
byte[] bytes = (byte[]) super.getValue(valueFields);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
Object deserializedObject;
try {
ObjectInputStream ois = new ObjectInputStream(bais);
deserializedObject = ois.readObject();
variableInstanceEntity.setCachedValue(deserializedObject);
valueFields.setCachedValue(deserializedObject);
CommandContext
.getCurrent()
.getDbSqlSession()
.addDeserializedObject(deserializedObject, bytes, variableInstanceEntity);
if (valueFields instanceof VariableInstanceEntity) {
CommandContext
.getCurrent()
.getDbSqlSession()
.addDeserializedObject(deserializedObject, bytes, (VariableInstanceEntity) valueFields);
}
} catch (Exception e) {
throw new ActivitiException("coudn't deserialize object in variable '"+variableInstanceEntity.getName()+"'", e);
throw new ActivitiException("coudn't deserialize object in variable '"+valueFields.getName()+"'", e);
}
return deserializedObject;
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
byte[] byteArray = serialize(value, variableInstanceEntity);
variableInstanceEntity.setCachedValue(value);
super.setValue(byteArray, variableInstanceEntity);
public void setValue(Object value, ValueFields valueFields) {
byte[] byteArray = serialize(value, valueFields);
valueFields.setCachedValue(value);
super.setValue(byteArray, valueFields);
}
public static byte[] serialize(Object value, VariableInstanceEntity variableInstanceEntity) {
public static byte[] serialize(Object value, ValueFields valueFields) {
if(value == null) {
return null;
}
......@@ -74,7 +76,7 @@ public class SerializableType extends ByteArrayType {
ObjectOutputStream ois = new ObjectOutputStream(baos);
ois.writeObject(value);
} catch (Exception e) {
throw new ActivitiException("coudn't deserialize value '"+value+"' in variable '"+variableInstanceEntity.getName()+"'", e);
throw new ActivitiException("coudn't deserialize value '"+value+"' in variable '"+valueFields.getName()+"'", e);
}
return baos.toByteArray();
}
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Joram Barrez
*/
public class ShortType implements Type {
public class ShortType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,20 +29,20 @@ public class ShortType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
if(variableInstanceEntity.getLongValue() != null) {
return new Short(variableInstanceEntity.getLongValue().shortValue());
public Object getValue(ValueFields valueFields) {
if(valueFields.getLongValue() != null) {
return new Short(valueFields.getLongValue().shortValue());
}
return null;
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
public void setValue(Object value, ValueFields valueFields) {
if (value!=null) {
variableInstanceEntity.setLongValue(((Short) value).longValue());
variableInstanceEntity.setTextValue(value.toString());
valueFields.setLongValue(((Short) value).longValue());
valueFields.setTextValue(value.toString());
} else {
variableInstanceEntity.setLongValue(null);
variableInstanceEntity.setTextValue(null);
valueFields.setLongValue(null);
valueFields.setTextValue(null);
}
}
......
......@@ -12,13 +12,12 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public class StringType implements Type {
public class StringType implements VariableType {
private static final long serialVersionUID = 1L;
......@@ -30,12 +29,12 @@ public class StringType implements Type {
return true;
}
public Object getValue(VariableInstanceEntity variableInstanceEntity) {
return variableInstanceEntity.getTextValue();
public Object getValue(ValueFields valueFields) {
return valueFields.getTextValue();
}
public void setValue(Object value, VariableInstanceEntity variableInstanceEntity) {
variableInstanceEntity.setTextValue((String) value);
public void setValue(Object value, ValueFields valueFields) {
valueFields.setTextValue((String) value);
}
public boolean isAbleToStore(Object value) {
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.ByteArrayEntity;
/**
* @author Tom Baeyens
*/
public interface ValueFields {
String getName();
String getTextValue();
void setTextValue(String textValue);
String getTextValue2();
void setTextValue2(String textValue2);
Long getLongValue();
void setLongValue(Long longValue);
Double getDoubleValue();
void setDoubleValue(Double doubleValue);
String getByteArrayValueId();
void setByteArrayValue(ByteArrayEntity byteArrayValue);
ByteArrayEntity getByteArrayValue();
Object getCachedValue();
void setCachedValue(Object deserializedObject);
}
......@@ -12,18 +12,17 @@
*/
package org.activiti.engine.impl.variable;
import org.activiti.engine.impl.runtime.VariableInstanceEntity;
/**
* @author Tom Baeyens
*/
public interface Type {
public interface VariableType {
String getTypeName();
boolean isCachable();
boolean isAbleToStore(Object value);
void setValue(Object value, VariableInstanceEntity variableInstanceEntity);
Object getValue(VariableInstanceEntity variableInstanceEntity);
void setValue(Object value, ValueFields valueFields);
Object getValue(ValueFields valueFields);
}
......@@ -14,7 +14,7 @@
package org.activiti.engine.impl.variable;
/**
* Interface describing a container for all available {@link Type}s of variables.
* Interface describing a container for all available {@link VariableType}s of variables.
* @author dsyer
* @author Frederik Heremans
*/
......@@ -24,26 +24,26 @@ public interface VariableTypes {
* @return the type for the given type name.
* Returns null if no type was found with the name.
*/
public Type getVariableType(String typeName);
public VariableType getVariableType(String typeName);
/**
* @return the variable type to be used to store the given value as a variable.
* @throws ActivitiException When no available type is capable of storing the value.
*/
public Type findVariableType(Object value);
public VariableType findVariableType(Object value);
public VariableTypes addType(Type type);
public VariableTypes addType(VariableType type);
/**
* Add type at the given index. The index is used when finding a type for an object. When
* different types can store a specific object value, the one with the smallest
* index will be used.
*/
public VariableTypes addType(Type type, int index);
public VariableTypes addType(VariableType type, int index);
public int getTypeIndex(Type type);
public int getTypeIndex(VariableType type);
public int getTypeIndex(String typeName);
public VariableTypes removeType(Type type);
public VariableTypes removeType(VariableType type);
}
\ No newline at end of file
......@@ -165,14 +165,15 @@ create table ACT_HI_ACT_INST (
primary key (ID_)
);
create table ACT_HI_VAR_UPDATE (
create table ACT_HI_DETAIL (
ID_ varchar(64) not null,
TYPE_ varchar(255) not null,
PROC_INST_ID_ varchar(64) not null,
EXECUTION_ID_ varchar(64) not null,
TASK_ID_ varchar(64),
TYPE_ varchar(255) not null,
ACT_INST_ID_ varchar(64),
NAME_ varchar(255) not null,
INDEX_ integer,
VAR_TYPE_ varchar(255),
REV_ integer,
TIME_ timestamp not null,
BYTEARRAY_ID_ varchar(64),
DATE_ timestamp,
......@@ -191,8 +192,10 @@ create index ACT_IDX_HI_PRO_INST_END on ACT_HI_PROC_INST(END_TIME_);
create index ACT_IDX_HI_PRO_I_BUSKEY on ACT_HI_PROC_INST(BUSINESS_KEY_);
create index ACT_IDX_HI_ACT_INST_START on ACT_HI_ACT_INST(START_TIME_);
create index ACT_IDX_HI_ACT_INST_END on ACT_HI_ACT_INST(END_TIME_);
create index ACT_IDX_HI_VAR_UPD_TIME on ACT_HI_VAR_UPDATE(TIME_);
create index ACT_IDX_HI_VAR_UPD_NAME on ACT_HI_VAR_UPDATE(NAME_);
create index ACT_IDX_HI_DETAIL_PROC_INST on ACT_HI_DETAIL(PROC_INST_ID_);
create index ACT_IDX_HI_DETAIL_ACT_INST on ACT_HI_DETAIL(ACT_INST_ID_);
create index ACT_IDX_HI_DETAIL_TIME on ACT_HI_DETAIL(TIME_);
create index ACT_IDX_HI_DETAIL_NAME on ACT_HI_DETAIL(NAME_);
alter table ACT_GE_BYTEARRAY
add constraint FK_BYTEARR_DEPL
......
......@@ -6,8 +6,10 @@ drop index ACT_IDX_HI_PRO_INST_END;
drop index ACT_IDX_HI_PRO_I_BUSKEY;
drop index ACT_IDX_HI_ACT_INST_START;
drop index ACT_IDX_HI_ACT_INST_END;
drop index ACT_IDX_HI_VAR_UPD_TIME;
drop index ACT_IDX_HI_VAR_UPD_NAME;
drop index ACT_IDX_HI_DETAIL_PROC_INST;
drop index ACT_IDX_HI_DETAIL_ACT_INST;
drop index ACT_IDX_HI_DETAIL_TIME;
drop index ACT_IDX_HI_DETAIL_NAME;
alter table ACT_GE_BYTEARRAY
drop constraint FK_BYTEARR_DEPL;
......@@ -74,4 +76,4 @@ drop table ACT_RU_IDENTITY_LINK if exists;
drop table ACT_RU_VARIABLE if exists;
drop table ACT_HI_PROC_INST if exists;
drop table ACT_HI_ACT_INST if exists;
drop table ACT_HI_VAR_UPDATE if exists;
drop table ACT_HI_DETAIL if exists;
......@@ -46,9 +46,6 @@
<update id="updateHistoricProcessInstance" parameterType="org.activiti.engine.impl.history.HistoricProcessInstanceEntity">
update ACT_HI_PROC_INST set
PROC_INST_ID_ = #{processInstanceId, jdbcType=VARCHAR},
BUSINESS_KEY_ = #{businessKey, jdbcType=VARCHAR},
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
START_TIME_ = #{startTime, jdbcType=TIMESTAMP},
END_TIME_ = #{endTime, jdbcType=TIMESTAMP},
DURATION_ = #{durationInMillis ,jdbcType=BIGINT},
......@@ -224,15 +221,29 @@
</where>
</sql>
<!-- HISTORIC VARIABLE UPDATE INSERT -->
<!-- HISTORIC DETAILS INSERT -->
<insert id="insertHistoricFormProperty" parameterType="org.activiti.engine.impl.history.HistoricFormPropertyEntity">
insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, ACT_INST_ID_, EXECUTION_ID_, TIME_, NAME_, TEXT1_)
values (
#{id, jdbcType=VARCHAR},
'FormProperty',
#{processInstanceId, jdbcType=VARCHAR},
#{activityInstanceId, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{time, jdbcType=TIMESTAMP},
#{propertyId, jdbcType=VARCHAR},
#{propertyValue, jdbcType=VARCHAR}
)
</insert>
<insert id="insertHistoricVariableUpdate" parameterType="org.activiti.engine.impl.history.HistoricVariableUpdateEntity">
insert into ACT_HI_VAR_UPDATE (ID_, PROC_INST_ID_, EXECUTION_ID_, TASK_ID_, NAME_, TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT1_, TEXT2_)
insert into ACT_HI_DETAIL (ID_, TYPE_, PROC_INST_ID_, EXECUTION_ID_, NAME_, VAR_TYPE_, TIME_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT1_, TEXT2_)
values (
#{id, jdbcType=VARCHAR},
'VariableUpdate',
#{processInstanceId, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{taskId, jdbcType=VARCHAR},
#{variableName, jdbcType=VARCHAR},
#{variableType, jdbcType=VARCHAR },
#{time, jdbcType=TIMESTAMP },
......@@ -244,54 +255,66 @@
)
</insert>
<!-- HISTORIC VARIABLE UPDATE DELETE -->
<!-- HISTORIC DETAILS DELETE -->
<delete id="deleteHistoricVariableUpdate">
delete from ACT_HI_VAR_UPDATE where ID_ = #{historicVariableUpdateId}
<delete id="deleteHistoricDetail">
delete from ACT_HI_DETAIL where ID_ = #{historicDetailId}
</delete>
<!-- HISTORIC VARIABLE UPDATE RESULTMAP -->
<resultMap id="historicVariableUpdateResultMap" type="org.activiti.engine.impl.history.HistoricVariableUpdateEntity">
<!-- HISTORIC DETAILS RESULTMAP -->
<resultMap id="historicDetailResultMap" type="org.activiti.engine.impl.history.HistoricDetailEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="activityInstanceId" column="ACT_INST_ID_" jdbcType="VARCHAR" />
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="taskId" column="TASK_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="type" column="TYPE_" javaType="org.activiti.engine.impl.variable.Type" jdbcType="VARCHAR"/>
<result property="activityId" column="ACTIVITY_ID_" jdbcType="VARCHAR" />
<result property="time" column="TIME_" jdbcType="TIMESTAMP" />
<discriminator javaType="string" column="TYPE_">
<case value="VariableUpdate" resultMap="historicVariableUpdateResultMap"/>
<case value="FormProperty" resultMap="historicFormPropertyResultMap"/>
</discriminator>
</resultMap>
<resultMap id="historicVariableUpdateResultMap" extends="historicDetailResultMap" type="org.activiti.engine.impl.history.HistoricVariableUpdateEntity">
<result property="name" column="NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<result property="variableType" column="VAR_TYPE_" javaType="org.activiti.engine.impl.variable.VariableType" jdbcType="VARCHAR"/>
<result property="activityId" column="ACTIVITY_ID_" jdbcType="VARCHAR" />
<result property="byteArrayValueId" column="BYTEARRAY_ID_" />
<result property="doubleValue" column="DOUBLE_" />
<result property="textValue" column="TEXT1_" />
<result property="textValue2" column="TEXT2_" />
<result property="longValue" column="LONG_" />
<result property="byteArrayValueId" column="BYTEARRAY_ID_" jdbcType="VARCHAR" />
<result property="doubleValue" column="DOUBLE_" jdbcType="DOUBLE" />
<result property="textValue" column="TEXT1_" jdbcType="VARCHAR" />
<result property="textValue2" column="TEXT2_" jdbcType="VARCHAR" />
<result property="longValue" column="LONG_" jdbcType="BIGINT" />
</resultMap>
<resultMap id="historicFormPropertyResultMap" extends="historicDetailResultMap" type="org.activiti.engine.impl.history.HistoricFormPropertyEntity">
<result property="propertyId" column="NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="propertyValue" column="TEXT1_" javaType="String" jdbcType="VARCHAR"/>
</resultMap>
<!-- HISTORIC VARIABLE UPDATE SELECT -->
<select id="selectHistoricVariableUpdatesByQueryCriteria" parameterType="org.activiti.engine.impl.HistoricVariableUpdateQueryImpl" resultMap="historicVariableUpdateResultMap">
<select id="selectHistoricDetailsByQueryCriteria" parameterType="org.activiti.engine.impl.HistoricDetailQueryImpl" resultMap="historicDetailResultMap">
select *
<include refid="selectHistoricVariableUpdatesByQueryCriteriaSql"/>
<include refid="selectHistoricDetailsByQueryCriteriaSql"/>
<if test="orderBy != null">
order by ${orderBy}
</if>
</select>
<select id="selectHistoricVariableUpdateCountByQueryCriteria" parameterType="org.activiti.engine.impl.HistoricVariableUpdateQueryImpl" resultType="long">
<select id="selectHistoricDetailCountByQueryCriteria" parameterType="org.activiti.engine.impl.HistoricDetailQueryImpl" resultType="long">
select count(*)
<include refid="selectHistoricVariableUpdatesByQueryCriteriaSql"/>
<include refid="selectHistoricDetailsByQueryCriteriaSql"/>
</select>
<sql id="selectHistoricVariableUpdatesByQueryCriteriaSql">
from ACT_HI_VAR_UPDATE HVU
<sql id="selectHistoricDetailsByQueryCriteriaSql">
from ACT_HI_DETAIL HD
<where>
<if test="processInstanceId != null">
HVU.PROC_INST_ID_ = #{processInstanceId}
HD.PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="variableName != null">
and HVU.NAME_ = #{variableName}
<if test="type != null">
and HD.TYPE_ = #{type}
</if>
</where>
</sql>
......
......@@ -50,18 +50,18 @@
<resultMap id="variableInstanceResultMap" type="org.activiti.engine.impl.runtime.VariableInstanceEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER"/>
<result property="type" column="TYPE_" javaType="org.activiti.engine.impl.variable.Type" jdbcType="VARCHAR"/>
<result property="type" column="TYPE_" javaType="org.activiti.engine.impl.variable.VariableType" jdbcType="VARCHAR"/>
<result property="name" column="NAME_" javaType="String" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="activityId" column="ACTIVITY_ID_" jdbcType="VARCHAR" />
<result property="isActive" column="IS_ACTIVE_" jdbcType="BOOLEAN" />
<result property="isConcurrencyScope" column="IS_CONCURRENCY_SCOPE_" jdbcType="BOOLEAN" />
<result property="byteArrayValueId" column="BYTEARRAY_ID_" />
<result property="doubleValue" column="DOUBLE_" />
<result property="textValue" column="TEXT1_" />
<result property="textValue2" column="TEXT2_" />
<result property="longValue" column="LONG_" />
<result property="byteArrayValueId" column="BYTEARRAY_ID_" jdbcType="VARCHAR" />
<result property="doubleValue" column="DOUBLE_" jdbcType="DOUBLE" />
<result property="textValue" column="TEXT1_" jdbcType="VARCHAR"/>
<result property="textValue2" column="TEXT2_" jdbcType="VARCHAR"/>
<result property="longValue" column="LONG_" jdbcType="BIGINT"/>
</resultMap>
<!-- VARIABLE INSTANCE SELECT -->
......
......@@ -52,7 +52,7 @@ public class HistoricProcessInstanceTest extends ActivitiInternalTestCase {
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance.getId(), historicProcessInstance.getProcessInstanceId());
assertEquals(processInstance.getId(), historicProcessInstance.getId());
assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId());
assertEquals(noon, historicProcessInstance.getStartTime());
assertNull(historicProcessInstance.getEndTime());
......@@ -71,7 +71,7 @@ public class HistoricProcessInstanceTest extends ActivitiInternalTestCase {
historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(historicProcessInstance);
assertEquals(processInstance.getId(), historicProcessInstance.getProcessInstanceId());
assertEquals(processInstance.getId(), historicProcessInstance.getId());
assertEquals(processInstance.getProcessDefinitionId(), historicProcessInstance.getProcessDefinitionId());
assertEquals(noon, historicProcessInstance.getStartTime());
assertEquals(twentyFiveSecsAfterNoon, historicProcessInstance.getEndTime());
......
......@@ -17,8 +17,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.history.HistoricVariableUpdate;
import org.activiti.engine.history.HistoricVariableUpdateQueryProperty;
import org.activiti.engine.history.HistoricDetail;
import org.activiti.engine.history.HistoricDetailQueryProperty;
import org.activiti.engine.history.HistoricFormProperty;
import org.activiti.engine.impl.test.ActivitiInternalTestCase;
import org.activiti.engine.test.Deployment;
......@@ -30,26 +31,31 @@ public class HistoricVariableUpdateTest extends ActivitiInternalTestCase {
@Deployment
public void testHistoricVariableUpdates() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("startFormParamA", "one");
variables.put("startFormParamB", new Long(234));
variables.put("startFormParamC", new SerializableVariable("contents"));
runtimeService.startProcessInstanceByKey("HistoricVariableUpdateProcess", variables);
Map<String, String> properties = new HashMap<String, String>();
properties.put("startFormParamA", "one");
properties.put("startFormParamB", "234");
List<HistoricVariableUpdate> historicVariableUpdates = historyService
.createHistoricVariableUpdateQuery()
.orderBy(HistoricVariableUpdateQueryProperty.INDEX).asc()
String processInstanceId = formService.submitStartFormData("HistoricVariableUpdateProcess:1", properties).getId();
List<HistoricDetail> historicDetails = historyService
.createHistoricDetailQuery()
.orderBy(HistoricDetailQueryProperty.VARIABLE_NAME).asc()
.list();
// HistoricVariableUpdate historicVariableUpdate = historicVariableUpdates.get(0);
// assertEquals(expected, historicVariableUpdate.getProcessInstanceId());
// assertEquals(expected, historicVariableUpdate.getExecutionId());
// assertEquals(expected, historicVariableUpdate.getIndex());
// assertEquals(expected, historicVariableUpdate.getTime());
// assertEquals(expected, historicVariableUpdate.getVariableName());
// assertEquals(expected, historicVariableUpdate.getVariableType());
// assertEquals(expected, historicVariableUpdate.getValue());
System.out.println(historicVariableUpdates);
System.out.println(historicDetails);
HistoricFormProperty historicFormProperty = (HistoricFormProperty) historicDetails.get(0);
assertEquals(processInstanceId, historicFormProperty.getProcessInstanceId());
assertEquals(processInstanceId, historicFormProperty.getExecutionId());
assertNotNull(historicFormProperty.getTime());
assertEquals("startFormParamA", historicFormProperty.getPropertyId());
assertEquals("one", historicFormProperty.getPropertyValue());
historicFormProperty = (HistoricFormProperty) historicDetails.get(1);
assertEquals(processInstanceId, historicFormProperty.getProcessInstanceId());
assertEquals(processInstanceId, historicFormProperty.getExecutionId());
assertNotNull(historicFormProperty.getTime());
assertEquals("startFormParamB", historicFormProperty.getPropertyId());
assertEquals("234", historicFormProperty.getPropertyValue());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册