提交 d158ca41 编写于 作者: J Joram Barrez

Refactored all entity classes: added an interface for each entity, such that...

Refactored all entity classes: added an interface for each entity, such that alternative data stores can swap out the entity objects with more fitting ones (eg with annotations like Neo4j, JPA, etc or other mechanisms. Internally, only the entity interface is used)
上级 5f9b155d
......@@ -24,6 +24,8 @@ import java.util.Set;
public interface VariableScope {
Map<String, Object> getVariables();
Map<String, Object> getVariableValues();
Map<String, Object> getVariables(Collection<String> variableNames);
......@@ -58,12 +60,20 @@ public interface VariableScope {
* A variable is set according to the following algorithm:
*
* <p>
* <li>If this scope already contains a variable by the provided name as a <strong>local</strong> variable, its value is overwritten to the provided value.</li>
* <li>If this scope does <strong>not</strong> contain a variable by the provided name as a local variable, the variable is set to this scope's parent scope, if there is one. If there is no parent
* scope (meaning this scope is the root scope of the hierarchy it belongs to), this scope is used. This applies recursively up the parent scope chain until, if no scope contains a local variable by
* the provided name, ultimately the root scope is reached and the variable value is set on that scope.</li>
* <li>If this scope already contains a variable by the provided name as a
* <strong>local</strong> variable, its value is overwritten to the provided
* value.</li>
* <li>If this scope does <strong>not</strong> contain a variable by the
* provided name as a local variable, the variable is set to this scope's
* parent scope, if there is one. If there is no parent scope (meaning this
* scope is the root scope of the hierarchy it belongs to), this scope is
* used. This applies recursively up the parent scope chain until, if no scope
* contains a local variable by the provided name, ultimately the root scope
* is reached and the variable value is set on that scope.</li>
* <p>
* In practice for most cases, this algorithm will set variables to the scope of the execution at the process instance’s root level, if there is no execution-local variable by the provided name.
* In practice for most cases, this algorithm will set variables to the scope
* of the execution at the process instance’s root level, if there is no
* execution-local variable by the provided name.
*
* @param variableName
* the name of the variable to be set
......@@ -82,9 +92,11 @@ public interface VariableScope {
* Sets the provided variables to the variable scope.
*
* <p>
* Variables are set according algorithm for {@link #setVariable(String, Object)}, applied separately to each variable.
* Variables are set according algorithm for
* {@link #setVariable(String, Object)}, applied separately to each variable.
*
* @see #setVariable(String, Object) {@link VariableScope#setVariable(String, Object)}
* @see #setVariable(String, Object)
* {@link VariableScope#setVariable(String, Object)}
*
* @param variables
* a map of keys and values for the variables to be set
......@@ -104,32 +116,38 @@ public interface VariableScope {
void createVariableLocal(String variableName, Object value);
/**
* Removes the variable and creates a new {@link HistoricVariableUpdateEntity} .
* Removes the variable and creates a new {@link HistoricVariableUpdateEntity}
* .
*/
void removeVariable(String variableName);
/**
* Removes the local variable and creates a new {@link HistoricVariableUpdateEntity}.
* Removes the local variable and creates a new
* {@link HistoricVariableUpdateEntity}.
*/
void removeVariableLocal(String variableName);
/**
* Removes the variables and creates a new {@link HistoricVariableUpdateEntity} for each of them.
* Removes the variables and creates a new
* {@link HistoricVariableUpdateEntity} for each of them.
*/
void removeVariables(Collection<String> variableNames);
/**
* Removes the local variables and creates a new {@link HistoricVariableUpdateEntity} for each of them.
* Removes the local variables and creates a new
* {@link HistoricVariableUpdateEntity} for each of them.
*/
void removeVariablesLocal(Collection<String> variableNames);
/**
* Removes the (local) variables and creates a new {@link HistoricVariableUpdateEntity} for each of them.
* Removes the (local) variables and creates a new
* {@link HistoricVariableUpdateEntity} for each of them.
*/
void removeVariables();
/**
* Removes the (local) variables and creates a new {@link HistoricVariableUpdateEntity} for each of them.
* Removes the (local) variables and creates a new
* {@link HistoricVariableUpdateEntity} for each of them.
*/
void removeVariablesLocal();
......
......@@ -46,6 +46,8 @@ import org.activiti.engine.impl.cmd.SetDeploymentCategoryCmd;
import org.activiti.engine.impl.cmd.SetProcessDefinitionCategoryCmd;
import org.activiti.engine.impl.cmd.SuspendProcessDefinitionCmd;
import org.activiti.engine.impl.cmd.ValidateBpmnModelCmd;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ModelEntity;
import org.activiti.engine.impl.repository.DeploymentBuilderImpl;
import org.activiti.engine.repository.Deployment;
......@@ -70,7 +72,12 @@ import org.activiti.validation.ValidationError;
public class RepositoryServiceImpl extends ServiceImpl implements RepositoryService {
public DeploymentBuilder createDeployment() {
return new DeploymentBuilderImpl(this);
return commandExecutor.execute(new Command<DeploymentBuilder>() {
@Override
public DeploymentBuilder execute(CommandContext commandContext) {
return new DeploymentBuilderImpl(RepositoryServiceImpl.this);
}
});
}
public Deployment deploy(DeploymentBuilderImpl deploymentBuilder) {
......
......@@ -369,12 +369,14 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
return commandExecutor.execute(new GetAttachmentCmd(attachmentId));
}
@SuppressWarnings("unchecked")
public List<Attachment> getTaskAttachments(String taskId) {
return commandExecutor.execute(new GetTaskAttachmentsCmd(taskId));
return (List<Attachment>) commandExecutor.execute(new GetTaskAttachmentsCmd(taskId));
}
@SuppressWarnings("unchecked")
public List<Attachment> getProcessInstanceAttachments(String processInstanceId) {
return commandExecutor.execute(new GetProcessInstanceAttachmentsCmd(processInstanceId));
return (List<Attachment>) commandExecutor.execute(new GetProcessInstanceAttachmentsCmd(processInstanceId));
}
public void saveAttachment(Attachment attachment) {
......
......@@ -167,7 +167,7 @@ public class ContinueProcessOperation extends AbstractOperation {
}
protected void scheduleJob(boolean exclusive) {
MessageEntity message = new MessageEntity();
MessageEntity message = commandContext.getJobEntityManager().createMessage();
message.setExecutionId(execution.getId());
message.setProcessInstanceId(execution.getProcessInstanceId());
message.setProcessDefinitionId(execution.getProcessDefinitionId());
......
......@@ -195,7 +195,7 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
if (outgoingSequenceFlow.size() > 1) {
for (int i = 1; i < outgoingSequenceFlow.size(); i++) {
ExecutionEntity outgoingExecutionEntity = new ExecutionEntity();
ExecutionEntity outgoingExecutionEntity = commandContext.getExecutionEntityManager().create();
outgoingExecutionEntity.setProcessDefinitionId(execution.getProcessDefinitionId());
outgoingExecutionEntity.setProcessInstanceId(execution.getProcessInstanceId());
outgoingExecutionEntity.setRootProcessInstanceId(execution.getRootProcessInstanceId());
......
......@@ -39,6 +39,7 @@ public class BoundaryCancelEventActivityBehavior extends BoundaryEventActivityBe
ExecutionEntityManager executionEntityManager = Context.getCommandContext().getExecutionEntityManager();
ExecutionEntity subProcessExecution = null;
// TODO: this can be optimized. A full search in the all executions shouldn't bee needed
List<ExecutionEntity> processInstanceExecutions = executionEntityManager.findChildExecutionsByProcessInstanceId(execution.getProcessInstanceId());
for (ExecutionEntity childExecution : processInstanceExecutions) {
if (childExecution.getCurrentFlowElement() != null && childExecution.getCurrentFlowElement().getId().equals(boundaryEvent.getAttachedToRefId())) {
......
......@@ -144,7 +144,7 @@ public class CallActivityBehavior extends AbstractBpmnActivityBehavior implement
protected ExecutionEntity createSubProcessInstance(ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity superExecutionEntity, FlowElement initialFlowElement) {
ExecutionEntity subProcessInstance = new ExecutionEntity();
ExecutionEntity subProcessInstance = Context.getCommandContext().getExecutionEntityManager().create();
subProcessInstance.setProcessDefinitionId(processDefinitionEntity.getId());
subProcessInstance.setSuperExecution(superExecutionEntity);
subProcessInstance.setRootProcessInstanceId(superExecutionEntity.getRootProcessInstanceId());
......
......@@ -101,7 +101,7 @@ public class CancelEndEventActivityBehavior extends FlowNodeActivityBehavior {
ScopeUtil.createCopyOfSubProcessExecutionForCompensation(parentScopeExecution, newParentScopeExecution);
if (subProcess.getLoopCharacteristics() != null) {
List<ExecutionEntity> multiInstanceExecutions = parentScopeExecution.getExecutions();
List<? extends ExecutionEntity> multiInstanceExecutions = parentScopeExecution.getExecutions();
for (ExecutionEntity multiInstanceExecution : multiInstanceExecutions) {
if (multiInstanceExecution.getId().equals(parentScopeExecution.getId()) == false) {
ScopeUtil.createCopyOfSubProcessExecutionForCompensation(multiInstanceExecution, newParentScopeExecution);
......
......@@ -32,6 +32,7 @@ import org.activiti.engine.impl.calendar.BusinessCalendar;
import org.activiti.engine.impl.calendar.DueDateBusinessCalendar;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import org.activiti.engine.impl.task.TaskDefinition;
......@@ -57,7 +58,7 @@ public class UserTaskActivityBehavior extends TaskActivityBehavior {
public void execute(DelegateExecution execution) {
TaskEntity task = Context.getCommandContext().getTaskEntityManager().createAndInsert(execution);
task.setExecution(execution);
task.setExecution((ExecutionEntity) execution);
task.setTaskDefinition(taskDefinition);
if (taskDefinition.getNameExpression() != null) {
......
......@@ -58,6 +58,7 @@ import org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntit
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager;
import org.activiti.engine.impl.persistence.entity.ResourceEntity;
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
import org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.TimerEntity;
import org.activiti.engine.impl.util.IoUtil;
......@@ -151,7 +152,7 @@ public class BpmnDeployer implements Deployer {
processEngineConfiguration.getProcessDiagramGenerator().generateDiagram(bpmnParse.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader()), null);
diagramResourceName = getProcessImageResourceName(resourceName, processDefinition.getKey(), "png");
createResource(diagramResourceName, diagramBytes, deployment);
createResource(processEngineConfiguration.getResourceEntityManager(), diagramResourceName, diagramBytes, deployment);
} catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
log.warn("Error while generating process diagram, image will not be stored in repository", t);
}
......@@ -222,10 +223,11 @@ public class BpmnDeployer implements Deployer {
addMessageEventSubscriptions(processDefinition, process, bpmnModels.get(processDefinition.getKey()));
removeObsoleteSignalEventSubScription(processDefinition, latestProcessDefinition);
addSignalEventSubscriptions(processDefinition, process, bpmnModels.get(processDefinition.getKey()));
addSignalEventSubscriptions(commandContext, processDefinition, process, bpmnModels.get(processDefinition.getKey()));
commandContext.getProcessDefinitionEntityManager().insert(processDefinition, false);
addAuthorizations(processDefinition);
addAuthorizationsFromIterator(commandContext, processDefinition.getCandidateStarterUserIdExpressions(), processDefinition, ExprType.USER);
addAuthorizationsFromIterator(commandContext, processDefinition.getCandidateStarterGroupIdExpressions(), processDefinition, ExprType.GROUP);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, processDefinition));
......@@ -368,7 +370,7 @@ public class BpmnDeployer implements Deployer {
}
}
MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
MessageEventSubscriptionEntity newSubscription = commandContext.getEventSubscriptionEntityManager().createMessageEventSubscription();
newSubscription.setEventName(messageEventDefinition.getMessageRef());
newSubscription.setActivityId(startEvent.getId());
newSubscription.setConfiguration(processDefinition.getId());
......@@ -397,7 +399,7 @@ public class BpmnDeployer implements Deployer {
}
}
protected void addSignalEventSubscriptions(ProcessDefinitionEntity processDefinition, org.activiti.bpmn.model.Process process, BpmnModel bpmnModel) {
protected void addSignalEventSubscriptions(CommandContext commandContext, ProcessDefinitionEntity processDefinition, org.activiti.bpmn.model.Process process, BpmnModel bpmnModel) {
if (CollectionUtils.isNotEmpty(process.getFlowElements())) {
for (FlowElement element : process.getFlowElements()) {
if (element instanceof StartEvent) {
......@@ -406,7 +408,7 @@ public class BpmnDeployer implements Deployer {
EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
if (eventDefinition instanceof SignalEventDefinition) {
SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition;
SignalEventSubscriptionEntity subscriptionEntity = new SignalEventSubscriptionEntity();
SignalEventSubscriptionEntity subscriptionEntity = commandContext.getEventSubscriptionEntityManager().createSignalEventSubscription();
Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef());
if (signal != null) {
subscriptionEntity.setEventName(signal.getName());
......@@ -431,12 +433,12 @@ public class BpmnDeployer implements Deployer {
USER, GROUP
}
private void addAuthorizationsFromIterator(Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
private void addAuthorizationsFromIterator(CommandContext commandContext, Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
if (exprSet != null) {
Iterator<Expression> iterator = exprSet.iterator();
while (iterator.hasNext()) {
Expression expr = (Expression) iterator.next();
IdentityLinkEntity identityLink = new IdentityLinkEntity();
IdentityLinkEntity identityLink = commandContext.getIdentityLinkEntityManager().create();
identityLink.setProcessDef(processDefinition);
if (exprType.equals(ExprType.USER)) {
identityLink.setUserId(expr.toString());
......@@ -449,11 +451,6 @@ public class BpmnDeployer implements Deployer {
}
}
protected void addAuthorizations(ProcessDefinitionEntity processDefinition) {
addAuthorizationsFromIterator(processDefinition.getCandidateStarterUserIdExpressions(), processDefinition, ExprType.USER);
addAuthorizationsFromIterator(processDefinition.getCandidateStarterGroupIdExpressions(), processDefinition, ExprType.GROUP);
}
/**
* Returns the default name of the image resource for a certain process.
*
......@@ -499,8 +496,8 @@ public class BpmnDeployer implements Deployer {
return bpmnFileResource;
}
protected void createResource(String name, byte[] bytes, DeploymentEntity deploymentEntity) {
ResourceEntity resource = new ResourceEntity();
protected void createResource(ResourceEntityManager resourceEntityManager, String name, byte[] bytes, DeploymentEntity deploymentEntity) {
ResourceEntity resource = resourceEntityManager.create();
resource.setName(name);
resource.setBytes(bytes);
resource.setDeploymentId(deploymentEntity.getId());
......@@ -508,7 +505,7 @@ public class BpmnDeployer implements Deployer {
// Mark the resource as 'generated'
resource.setGenerated(true);
Context.getCommandContext().getDbSqlSession().insert(resource);
resourceEntityManager.insert(resource, false);
}
protected boolean isBpmnResource(String resourceName) {
......
......@@ -208,7 +208,7 @@ public class ErrorPropagation {
/*if (boundaryParentExecution.isScope() == false) {
boundaryParentExecution = Context.getCommandContext().getExecutionEntityManager().findExecutionById(boundaryParentExecution.getParentId());
}*/
List<ExecutionEntity> childExecutions = parentExecution.getExecutions();
List<? extends ExecutionEntity> childExecutions = parentExecution.getExecutions();
for (ExecutionEntity childExecution : childExecutions) {
if (childExecution.getActivityId().equals(event.getId())) {
boundaryExecution = childExecution;
......
......@@ -23,6 +23,7 @@ import org.activiti.bpmn.model.Process;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.impl.bpmn.data.IOSpecification;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.task.TaskDefinition;
......@@ -51,7 +52,7 @@ public class ProcessParseHandler extends AbstractBpmnParseHandler<Process> {
}
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) {
ProcessDefinitionEntity currentProcessDefinition = new ProcessDefinitionEntity();
ProcessDefinitionEntity currentProcessDefinition = Context.getCommandContext().getProcessDefinitionEntityManager().create();
bpmnParse.setCurrentProcessDefinition(currentProcessDefinition);
/*
......
......@@ -147,7 +147,7 @@ public abstract class AbstractSetProcessDefinitionStateCmd implements Command<Vo
if (Activiti5Util.isActiviti5ProcessDefinition(commandContext, processDefinition)) continue;
TimerEntity timer = new TimerEntity();
TimerEntity timer = commandContext.getJobEntityManager().createTimer();
timer.setProcessDefinitionId(processDefinition.getId());
// Inherit tenant identifier (if applicable)
......
......@@ -93,7 +93,7 @@ public class AddCommentCmd implements Command<Comment> {
}
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
CommentEntity comment = commandContext.getCommentEntityManager().create();
comment.setUserId(userId);
comment.setType((type == null) ? CommentEntity.TYPE_COMMENT : type);
comment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
......
......@@ -18,6 +18,7 @@ import java.util.List;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.ActivitiObjectNotFoundException;
import org.activiti.engine.compatibility.Activiti5CompatibilityHandler;
import org.activiti.engine.impl.ProcessDefinitionQueryImpl;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
......@@ -70,7 +71,7 @@ public class ChangeDeploymentTenantIdCmd implements Command<Void>, Serializable
commandContext.getEventSubscriptionEntityManager().updateEventSubscriptionTenantId(oldTenantId, newTenantId);
// Doing process definitions in memory, cause we need to clear the process definition cache
List<ProcessDefinition> processDefinitions = commandContext.getDbSqlSession().createProcessDefinitionQuery().deploymentId(deploymentId).list();
List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list();
for (ProcessDefinition processDefinition : processDefinitions) {
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().remove(processDefinition.getId());
}
......
......@@ -76,12 +76,12 @@ public class CreateAttachmentCmd implements Command<Attachment> {
}
}
AttachmentEntity attachment = new AttachmentEntity();
AttachmentEntity attachment = commandContext.getAttachmentEntityManager().create();
attachment.setName(attachmentName);
attachment.setProcessInstanceId(processInstanceId);
attachment.setTaskId(taskId);
attachment.setDescription(attachmentDescription);
attachment.setType(attachmentType);
attachment.setTaskId(taskId);
attachment.setProcessInstanceId(processInstanceId);
attachment.setUrl(url);
attachment.setUserId(Authentication.getAuthenticatedUserId());
attachment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
......
......@@ -27,7 +27,7 @@ public class CreateModelCmd implements Command<Model>, Serializable {
private static final long serialVersionUID = 1L;
public Model execute(CommandContext commandContext) {
return commandContext.getModelEntityManager().createNewModel();
return commandContext.getModelEntityManager().create();
}
}
......@@ -38,7 +38,7 @@ public class DeleteAttachmentCmd implements Command<Object>, Serializable {
}
public Object execute(CommandContext commandContext) {
AttachmentEntity attachment = commandContext.getDbSqlSession().selectById(AttachmentEntity.class, attachmentId);
AttachmentEntity attachment = commandContext.getAttachmentEntityManager().findById(attachmentId);
String processInstanceId = attachment.getProcessInstanceId();
String processDefinitionId = null;
......@@ -54,7 +54,7 @@ public class DeleteAttachmentCmd implements Command<Object>, Serializable {
}
}
commandContext.getDbSqlSession().delete(attachment);
commandContext.getAttachmentEntityManager().delete(attachment, false);
if (attachment.getContentId() != null) {
commandContext.getByteArrayEntityManager().deleteByteArrayById(attachment.getContentId());
......
......@@ -17,7 +17,6 @@ import java.io.Serializable;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.AttachmentEntity;
import org.activiti.engine.task.Attachment;
/**
......@@ -33,7 +32,7 @@ public class GetAttachmentCmd implements Command<Attachment>, Serializable {
}
public Attachment execute(CommandContext commandContext) {
return commandContext.getDbSqlSession().selectById(AttachmentEntity.class, attachmentId);
return commandContext.getAttachmentEntityManager().findById(attachmentId);
}
}
......@@ -63,14 +63,14 @@ public class GetHistoricIdentityLinksForTaskCmd implements Command<List<Historic
// Similar to GetIdentityLinksForTask, return assignee and owner as
// identity link
if (task.getAssignee() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
HistoricIdentityLinkEntity identityLink = commandContext.getHistoricIdentityLinkEntityManager().create();
identityLink.setUserId(task.getAssignee());
identityLink.setTaskId(task.getId());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
HistoricIdentityLinkEntity identityLink = commandContext.getHistoricIdentityLinkEntityManager().create();
identityLink.setTaskId(task.getId());
identityLink.setUserId(task.getOwner());
identityLink.setType(IdentityLinkType.OWNER);
......
......@@ -53,14 +53,14 @@ public class GetIdentityLinksForTaskCmd implements Command<List<IdentityLink>>,
// and of course this leads to exception while trying to delete a
// non-existing identityLink
if (task.getAssignee() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
IdentityLinkEntity identityLink = commandContext.getIdentityLinkEntityManager().create();
identityLink.setUserId(task.getAssignee());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLink.setTaskId(task.getId());
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
IdentityLinkEntity identityLink = commandContext.getIdentityLinkEntityManager().create();
identityLink.setUserId(task.getOwner());
identityLink.setTaskId(task.getId());
identityLink.setType(IdentityLinkType.OWNER);
......
......@@ -23,7 +23,7 @@ import org.activiti.engine.task.Attachment;
/**
* @author Tom Baeyens
*/
public class GetProcessInstanceAttachmentsCmd implements Command<List<Attachment>>, Serializable {
public class GetProcessInstanceAttachmentsCmd implements Command<List<? extends Attachment>>, Serializable {
private static final long serialVersionUID = 1L;
protected String processInstanceId;
......@@ -32,7 +32,7 @@ public class GetProcessInstanceAttachmentsCmd implements Command<List<Attachment
this.processInstanceId = taskId;
}
public List<Attachment> execute(CommandContext commandContext) {
public List<? extends Attachment> execute(CommandContext commandContext) {
return commandContext.getAttachmentEntityManager().findAttachmentsByProcessInstanceId(processInstanceId);
}
}
......@@ -31,7 +31,7 @@ public class GetPropertiesCmd implements Command<Map<String, String>>, Serializa
@SuppressWarnings("unchecked")
public Map<String, String> execute(CommandContext commandContext) {
List<PropertyEntity> propertyEntities = commandContext.getDbSqlSession().selectList("selectProperties");
List<PropertyEntity> propertyEntities = commandContext.getPropertyEntityManager().findAll();
Map<String, String> properties = new HashMap<String, String>();
for (PropertyEntity propertyEntity : propertyEntities) {
......
......@@ -23,7 +23,7 @@ import org.activiti.engine.task.Attachment;
/**
* @author Tom Baeyens
*/
public class GetTaskAttachmentsCmd implements Command<List<Attachment>>, Serializable {
public class GetTaskAttachmentsCmd implements Command<List<? extends Attachment>>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
......@@ -32,7 +32,7 @@ public class GetTaskAttachmentsCmd implements Command<List<Attachment>>, Seriali
this.taskId = taskId;
}
public List<Attachment> execute(CommandContext commandContext) {
public List<? extends Attachment> execute(CommandContext commandContext) {
return commandContext.getAttachmentEntityManager().findAttachmentsByTaskId(taskId);
}
}
......@@ -38,7 +38,7 @@ public class SaveAttachmentCmd implements Command<Object>, Serializable {
}
public Object execute(CommandContext commandContext) {
AttachmentEntity updateAttachment = commandContext.getDbSqlSession().selectById(AttachmentEntity.class, attachment.getId());
AttachmentEntity updateAttachment = commandContext.getAttachmentEntityManager().findById(attachment.getId());
String processInstanceId = updateAttachment.getProcessInstanceId();
String processDefinitionId = null;
......
......@@ -1032,7 +1032,9 @@ public class DbSqlSession implements Session {
PropertyEntity dbHistoryProperty;
if ("5.0".equals(dbVersion)) {
dbHistoryProperty = new PropertyEntity("schema.history", "create(5.0)");
dbHistoryProperty = Context.getCommandContext().getPropertyEntityManager().create();
dbHistoryProperty.setName("schema.history");
dbHistoryProperty.setValue("create(5.0)");
insert(dbHistoryProperty);
} else {
dbHistoryProperty = selectById(PropertyEntity.class, "schema.history");
......
......@@ -282,8 +282,11 @@ public class DbSqlSessionFactory implements SessionFactory {
return statement;
}
statement = prefix + entityClass.getSimpleName();
statement = statement.substring(0, statement.length() - 6); // removing
// 'entity'
if (statement.endsWith("Impl")) {
statement = statement.substring(0, statement.length() - 10); // removing 'entityImpl'
} else {
statement = statement.substring(0, statement.length() - 6); // removing 'entity'
}
cachedStatements.put(entityClass, statement);
return statement;
}
......
......@@ -4,41 +4,41 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.activiti.engine.impl.persistence.entity.AttachmentEntity;
import org.activiti.engine.impl.persistence.entity.ByteArrayEntity;
import org.activiti.engine.impl.persistence.entity.CommentEntity;
import org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
import org.activiti.engine.impl.persistence.entity.EventLogEntryEntity;
import org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.GroupEntity;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricDetailAssignmentEntity;
import org.activiti.engine.impl.persistence.entity.HistoricDetailEntity;
import org.activiti.engine.impl.persistence.entity.HistoricDetailTransitionInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity;
import org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntity;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricScopeInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntity;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntity;
import org.activiti.engine.impl.persistence.entity.JobEntity;
import org.activiti.engine.impl.persistence.entity.MembershipEntity;
import org.activiti.engine.impl.persistence.entity.MessageEntity;
import org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.ModelEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.persistence.entity.PropertyEntity;
import org.activiti.engine.impl.persistence.entity.ResourceEntity;
import org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.TimerEntity;
import org.activiti.engine.impl.persistence.entity.UserEntity;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
import org.activiti.engine.impl.persistence.entity.AttachmentEntityImpl;
import org.activiti.engine.impl.persistence.entity.ByteArrayEntityImpl;
import org.activiti.engine.impl.persistence.entity.CommentEntityImpl;
import org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntityImpl;
import org.activiti.engine.impl.persistence.entity.DeploymentEntityImpl;
import org.activiti.engine.impl.persistence.entity.EventLogEntryEntityImpl;
import org.activiti.engine.impl.persistence.entity.EventSubscriptionEntityImpl;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.activiti.engine.impl.persistence.entity.GroupEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricDetailAssignmentEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricDetailEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricDetailTransitionInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricFormPropertyEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricIdentityLinkEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricScopeInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntityImpl;
import org.activiti.engine.impl.persistence.entity.IdentityInfoEntityImpl;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntityImpl;
import org.activiti.engine.impl.persistence.entity.JobEntityImpl;
import org.activiti.engine.impl.persistence.entity.MembershipEntityImpl;
import org.activiti.engine.impl.persistence.entity.MessageEntityImpl;
import org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntityImpl;
import org.activiti.engine.impl.persistence.entity.ModelEntityImpl;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityImpl;
import org.activiti.engine.impl.persistence.entity.PropertyEntityImpl;
import org.activiti.engine.impl.persistence.entity.ResourceEntityImpl;
import org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntityImpl;
import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.impl.persistence.entity.TimerEntityImpl;
import org.activiti.engine.impl.persistence.entity.UserEntityImpl;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityImpl;
/**
......@@ -61,39 +61,39 @@ public class EntityDependencyOrder {
*/
/* No FK */
DELETE_ORDER.add(PropertyEntity.class);
DELETE_ORDER.add(PropertyEntityImpl.class);
/* No FK */
DELETE_ORDER.add(AttachmentEntity.class);
DELETE_ORDER.add(AttachmentEntityImpl.class);
/* No FK */
DELETE_ORDER.add(CommentEntity.class);
DELETE_ORDER.add(CommentEntityImpl.class);
/* No FK */
DELETE_ORDER.add(EventLogEntryEntity.class);
DELETE_ORDER.add(EventLogEntryEntityImpl.class);
/*
* FK to Deployment
* FK to ByteArray
*/
DELETE_ORDER.add(ModelEntity.class);
DELETE_ORDER.add(ModelEntityImpl.class);
/* Subclass of JobEntity */
DELETE_ORDER.add(MessageEntity.class);
DELETE_ORDER.add(MessageEntityImpl.class);
/* Subclass of TimerEntity */
DELETE_ORDER.add(TimerEntity.class);
DELETE_ORDER.add(TimerEntityImpl.class);
/*
* FK to ByteArray
*/
DELETE_ORDER.add(JobEntity.class);
DELETE_ORDER.add(JobEntityImpl.class);
/*
* FK to ByteArray
* FK to Exeution
*/
DELETE_ORDER.add(VariableInstanceEntity.class);
DELETE_ORDER.add(VariableInstanceEntityImpl.class);
/*
* FK from ModelEntity
......@@ -102,7 +102,7 @@ public class EntityDependencyOrder {
*
* FK to DeploymentEntity
*/
DELETE_ORDER.add(ByteArrayEntity.class);
DELETE_ORDER.add(ByteArrayEntityImpl.class);
/*
* FK from ModelEntity
......@@ -111,32 +111,32 @@ public class EntityDependencyOrder {
*
* FK to DeploymentEntity
*/
DELETE_ORDER.add(ResourceEntity.class);
DELETE_ORDER.add(ResourceEntityImpl.class);
/*
* FK from ByteArray
*/
DELETE_ORDER.add(DeploymentEntity.class);
DELETE_ORDER.add(DeploymentEntityImpl.class);
/*
* FK to Execution
*/
DELETE_ORDER.add(EventSubscriptionEntity.class);
DELETE_ORDER.add(EventSubscriptionEntityImpl.class);
/*
* FK to Execution
*/
DELETE_ORDER.add(CompensateEventSubscriptionEntity.class);
DELETE_ORDER.add(CompensateEventSubscriptionEntityImpl.class);
/*
* FK to Execution
*/
DELETE_ORDER.add(MessageEventSubscriptionEntity.class);
DELETE_ORDER.add(MessageEventSubscriptionEntityImpl.class);
/*
* FK to Execution
*/
DELETE_ORDER.add(SignalEventSubscriptionEntity.class);
DELETE_ORDER.add(SignalEventSubscriptionEntityImpl.class);
/*
......@@ -144,7 +144,7 @@ public class EntityDependencyOrder {
* FK to Execution
* FK to Task
*/
DELETE_ORDER.add(IdentityLinkEntity.class);
DELETE_ORDER.add(IdentityLinkEntityImpl.class);
/*
* FK from IdentityLink
......@@ -152,7 +152,7 @@ public class EntityDependencyOrder {
* FK to Execution
* FK to process definition
*/
DELETE_ORDER.add(TaskEntity.class);
DELETE_ORDER.add(TaskEntityImpl.class);
/*
* FK from VariableInstance
......@@ -162,50 +162,50 @@ public class EntityDependencyOrder {
*
* FK to ProcessDefinition
*/
DELETE_ORDER.add(ExecutionEntity.class);
DELETE_ORDER.add(ExecutionEntityImpl.class);
/*
* FK from Task
* FK from IdentityLink
* FK from execution
*/
DELETE_ORDER.add(ProcessDefinitionEntity.class);
DELETE_ORDER.add(ProcessDefinitionEntityImpl.class);
/*
* FK to User
* FK to Group
*/
DELETE_ORDER.add(MembershipEntity.class);
DELETE_ORDER.add(MembershipEntityImpl.class);
/*
* Fk from Membership
*/
DELETE_ORDER.add(UserEntity.class);
DELETE_ORDER.add(UserEntityImpl.class);
/*
* FK from Membership
*/
DELETE_ORDER.add(GroupEntity.class);
DELETE_ORDER.add(GroupEntityImpl.class);
// History entities have no FK's
DELETE_ORDER.add(HistoricIdentityLinkEntity.class);
DELETE_ORDER.add(HistoricIdentityLinkEntityImpl.class);
DELETE_ORDER.add(IdentityInfoEntity.class);
DELETE_ORDER.add(IdentityInfoEntityImpl.class);
DELETE_ORDER.add(HistoricActivityInstanceEntity.class);
DELETE_ORDER.add(HistoricProcessInstanceEntity.class);
DELETE_ORDER.add(HistoricTaskInstanceEntity.class);
DELETE_ORDER.add(HistoricScopeInstanceEntity.class);
DELETE_ORDER.add(HistoricActivityInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricProcessInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricTaskInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricScopeInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricVariableInstanceEntity.class);
DELETE_ORDER.add(HistoricVariableInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricDetailAssignmentEntity.class);
DELETE_ORDER.add(HistoricDetailTransitionInstanceEntity.class);
DELETE_ORDER.add(HistoricDetailVariableInstanceUpdateEntity.class);
DELETE_ORDER.add(HistoricFormPropertyEntity.class);
DELETE_ORDER.add(HistoricDetailEntity.class);
DELETE_ORDER.add(HistoricDetailAssignmentEntityImpl.class);
DELETE_ORDER.add(HistoricDetailTransitionInstanceEntityImpl.class);
DELETE_ORDER.add(HistoricDetailVariableInstanceUpdateEntityImpl.class);
DELETE_ORDER.add(HistoricFormPropertyEntityImpl.class);
DELETE_ORDER.add(HistoricDetailEntityImpl.class);
INSERT_ORDER = new ArrayList<Class<? extends Entity>>(DELETE_ORDER);
Collections.reverse(INSERT_ORDER);
......
......@@ -25,6 +25,7 @@ import org.activiti.engine.delegate.VariableScope;
* variables are not available yet, expressions should be resolved anyway.
*
* @author Frederik Heremans
* @author Joram Barrez
*/
public class NoExecutionVariableScope implements VariableScope {
......@@ -41,6 +42,11 @@ public class NoExecutionVariableScope implements VariableScope {
public Map<String, Object> getVariables() {
return Collections.EMPTY_MAP;
}
@Override
public Map<String, Object> getVariableValues() {
return Collections.EMPTY_MAP;
}
@SuppressWarnings("unchecked")
public Map<String, Object> getVariablesLocal() {
......
......@@ -6,6 +6,7 @@ import java.util.Map;
import org.activiti.engine.delegate.event.ActivitiEntityEvent;
import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.persistence.entity.EventLogEntryEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
......@@ -39,7 +40,7 @@ public abstract class AbstractDatabaseEventLoggerEventHandler implements EventLo
protected EventLogEntryEntity createEventLogEntry(String type, String processDefinitionId, String processInstanceId, String executionId, String taskId, Map<String, Object> data) {
EventLogEntryEntity eventLogEntry = new EventLogEntryEntity();
EventLogEntryEntity eventLogEntry = Context.getCommandContext().getEventLogEntryEntityManager().create();
eventLogEntry.setProcessDefinitionId(processDefinitionId);
eventLogEntry.setProcessInstanceId(processInstanceId);
eventLogEntry.setExecutionId(executionId);
......
......@@ -123,7 +123,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
@Override
public void recordProcessInstanceStart(ExecutionEntity processInstance, FlowElement startElement) {
if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance);
HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().create(processInstance);
historicProcessInstance.setStartActivityId(startElement.getId());
// Insert historic process-instance
......@@ -168,7 +168,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance, FlowElement initialElement) {
if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity((ExecutionEntity) subProcessInstance);
HistoricProcessInstanceEntity historicProcessInstance = getHistoricProcessInstanceEntityManager().create(subProcessInstance);
// Fix for ACT-1728: startActivityId not initialized with subprocess instance
if (historicProcessInstance.getStartActivityId() == null) {
......@@ -325,7 +325,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
String processDefinitionId = execution.getProcessDefinitionId();
String processInstanceId = execution.getProcessInstanceId();
HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity();
HistoricActivityInstanceEntity historicActivityInstance = getHistoricActivityInstanceEntityManager().create();
historicActivityInstance.setId(idGenerator.getNextId());
historicActivityInstance.setProcessDefinitionId(processDefinitionId);
historicActivityInstance.setProcessInstanceId(processInstanceId);
......@@ -373,7 +373,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
@Override
public void recordTaskCreated(TaskEntity task, ExecutionEntity execution) {
if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
HistoricTaskInstanceEntity historicTaskInstance = new HistoricTaskInstanceEntity(task, execution);
HistoricTaskInstanceEntity historicTaskInstance = getHistoricTaskInstanceEntityManager().create(task, execution);
getHistoricTaskInstanceEntityManager().insert(historicTaskInstance, false);
}
......@@ -714,7 +714,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
public void createIdentityLinkComment(String taskId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) {
if (isHistoryEnabled()) {
String authenticatedUserId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
CommentEntity comment = getCommentEntityManager().create();
comment.setUserId(authenticatedUserId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(getClock().getCurrentTime());
......@@ -748,7 +748,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
public void createProcessInstanceIdentityLinkComment(String processInstanceId, String userId, String groupId, String type, boolean create, boolean forceNullUserId) {
if (isHistoryEnabled()) {
String authenticatedUserId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
CommentEntity comment = getCommentEntityManager().create();
comment.setUserId(authenticatedUserId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(getClock().getCurrentTime());
......@@ -781,7 +781,7 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
public void createAttachmentComment(String taskId, String processInstanceId, String attachmentName, boolean create) {
if (isHistoryEnabled()) {
String userId = Authentication.getAuthenticatedUserId();
CommentEntity comment = new CommentEntity();
CommentEntity comment = getCommentEntityManager().create();
comment.setUserId(userId);
comment.setType(CommentEntity.TYPE_EVENT);
comment.setTime(getClock().getCurrentTime());
......@@ -824,7 +824,13 @@ public class DefaultHistoryManager extends AbstractManager implements HistoryMan
// that is related
// to a process-definition only as this is never kept in history
if (isHistoryLevelAtLeast(HistoryLevel.AUDIT) && (identityLink.getProcessInstanceId() != null || identityLink.getTaskId() != null)) {
HistoricIdentityLinkEntity historicIdentityLinkEntity = new HistoricIdentityLinkEntity(identityLink);
HistoricIdentityLinkEntity historicIdentityLinkEntity = getHistoricIdentityLinkEntityManager().create();
historicIdentityLinkEntity.setId(identityLink.getId());
historicIdentityLinkEntity.setGroupId(identityLink.getGroupId());
historicIdentityLinkEntity.setProcessInstanceId(identityLink.getProcessInstanceId());
historicIdentityLinkEntity.setTaskId(identityLink.getTaskId());
historicIdentityLinkEntity.setType(identityLink.getType());
historicIdentityLinkEntity.setUserId(identityLink.getUserId());
getHistoricIdentityLinkEntityManager().insert(historicIdentityLinkEntity, false);
}
}
......
......@@ -159,7 +159,7 @@ public class TimerDeclarationImpl implements Serializable {
duedate = businessCalendar.resolveDuedate(dueDateString);
}
TimerEntity timer = new TimerEntity(this);
TimerEntity timer = Context.getCommandContext().getJobEntityManager().createTimer();
timer.setDuedate(duedate);
timer.setEndDate(endDate);
if (executionEntity != null) {
......
......@@ -84,7 +84,7 @@ public class TriggerTimerEventJobHandler implements JobHandler {
} else if (execution.getCurrentFlowElement() instanceof CallActivity) {
ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
List<ExecutionEntity> childExecutions = subProcessInstance.getExecutions();
List<? extends ExecutionEntity> childExecutions = subProcessInstance.getExecutions();
for (ExecutionEntity subExecution : childExecutions) {
if (processedElements.contains(subExecution.getCurrentActivityId()) == false) {
dispatchExecutionTimeOut(timerEntity, subExecution, processedElements, commandContext);
......
......@@ -45,12 +45,28 @@ public class EntityCacheImpl implements EntityCache {
public <T> T findInCache(Class<T> entityClass, String id) {
CachedEntity cachedObject = null;
Map<String, CachedEntity> classCache = cachedObjects.get(entityClass);
if (classCache == null) {
classCache = findClassCacheByCheckingSubclasses(entityClass);
}
if (classCache != null) {
cachedObject = classCache.get(id);
}
if (cachedObject != null) {
return (T) cachedObject.getEntity();
}
return null;
}
protected Map<String, CachedEntity> findClassCacheByCheckingSubclasses(Class<?> entityClass) {
for (Class<?> clazz : cachedObjects.keySet()) {
if (entityClass.isAssignableFrom(clazz)) {
return cachedObjects.get(clazz);
}
}
return null;
}
......@@ -76,6 +92,11 @@ public class EntityCacheImpl implements EntityCache {
@SuppressWarnings("unchecked")
public <T> List<T> findInCache(Class<T> entityClass) {
Map<String, CachedEntity> classCache = cachedObjects.get(entityClass);
if (classCache == null) {
classCache = findClassCacheByCheckingSubclasses(entityClass);
}
if (classCache != null) {
List<T> entities = new ArrayList<T>(classCache.size());
for (CachedEntity cachedObject : classCache.values()) {
......@@ -83,6 +104,7 @@ public class EntityCacheImpl implements EntityCache {
}
return entities;
}
return Collections.emptyList();
}
......
......@@ -20,6 +20,11 @@ public abstract class AbstractEntityManager<EntityImpl extends Entity> extends A
public EntityImpl findById(String entityId) {
return getDataManager().findById(entityId);
}
@Override
public EntityImpl create() {
return getDataManager().create();
}
@Override
public void insert(EntityImpl entity) {
......
......@@ -13,143 +13,37 @@
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.db.HasRevision;
import org.activiti.engine.impl.db.Entity;
import org.activiti.engine.impl.db.HasRevision;
import org.activiti.engine.task.Attachment;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class AttachmentEntity implements Attachment, Entity, HasRevision, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected String description;
protected String type;
protected String taskId;
protected String processInstanceId;
protected String url;
protected String contentId;
protected ByteArrayEntity content;
protected String userId;
protected Date time;
public AttachmentEntity() {
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("name", name);
persistentState.put("description", description);
return persistentState;
}
public int getRevisionNext() {
return revision + 1;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public ByteArrayEntity getContent() {
return content;
}
public void setContent(ByteArrayEntity content) {
this.content = content;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public interface AttachmentEntity extends Attachment, Entity, HasRevision {
void setType(String type);
void setTaskId(String taskId);
void setProcessInstanceId(String processInstanceId);
void setUrl(String url);
void setContentId(String contentId);
ByteArrayEntity getContent();
void setContent(ByteArrayEntity content);
void setUserId(String userId);
String getUserId();
Date getTime();
void setTime(Date 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.persistence.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @author Tom Baeyens
*/
public class AttachmentEntityImpl implements AttachmentEntity, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected String description;
protected String type;
protected String taskId;
protected String processInstanceId;
protected String url;
protected String contentId;
protected ByteArrayEntity content;
protected String userId;
protected Date time;
public AttachmentEntityImpl() {
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("name", name);
persistentState.put("description", description);
return persistentState;
}
public int getRevisionNext() {
return revision + 1;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getContentId() {
return contentId;
}
public void setContentId(String contentId) {
this.contentId = contentId;
}
public ByteArrayEntity getContent() {
return content;
}
public void setContent(ByteArrayEntity content) {
this.content = content;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return userId;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
}
......@@ -14,16 +14,14 @@ package org.activiti.engine.impl.persistence.entity;
import java.util.List;
import org.activiti.engine.task.Attachment;
/**
* @author Joram Barrez
*/
public interface AttachmentEntityManager extends EntityManager<AttachmentEntity> {
List<AttachmentEntity> findAttachmentsByProcessInstanceId(String processInstanceId);
List<Attachment> findAttachmentsByProcessInstanceId(String processInstanceId);
List<Attachment> findAttachmentsByTaskId(String taskId);
List<AttachmentEntity> findAttachmentsByTaskId(String taskId);
void deleteAttachmentsByTaskId(String taskId);
......
......@@ -45,13 +45,13 @@ public class AttachmentEntityManagerImpl extends AbstractEntityManager<Attachmen
}
@Override
public List<Attachment> findAttachmentsByProcessInstanceId(String processInstanceId) {
public List<AttachmentEntity> findAttachmentsByProcessInstanceId(String processInstanceId) {
checkHistoryEnabled();
return attachmentDataManager.findAttachmentsByProcessInstanceId(processInstanceId);
}
@Override
public List<Attachment> findAttachmentsByTaskId(String taskId) {
public List<AttachmentEntity> findAttachmentsByTaskId(String taskId) {
checkHistoryEnabled();
return attachmentDataManager.findAttachmentsByTaskId(taskId);
}
......@@ -59,7 +59,7 @@ public class AttachmentEntityManagerImpl extends AbstractEntityManager<Attachmen
@Override
public void deleteAttachmentsByTaskId(String taskId) {
checkHistoryEnabled();
List<Attachment> attachments = findAttachmentsByTaskId(taskId);
List<AttachmentEntity> attachments = findAttachmentsByTaskId(taskId);
boolean dispatchEvents = getEventDispatcher().isEnabled();
String processInstanceId = null;
......
......@@ -12,121 +12,26 @@
*/
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.Arrays;
import org.activiti.engine.impl.db.HasRevision;
import org.activiti.engine.impl.db.Entity;
import org.apache.commons.lang3.StringUtils;
import org.activiti.engine.impl.db.HasRevision;
/**
* @author Tom Baeyens
* @author Marcus Klimstra (CGI)
* @author Joram Barrez
*/
public class ByteArrayEntity implements Serializable, Entity, HasRevision {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected byte[] bytes;
protected String deploymentId;
// Default constructor for SQL mapping
protected ByteArrayEntity() {
}
public ByteArrayEntity(String name, byte[] bytes) {
this.name = name;
this.bytes = bytes;
}
public ByteArrayEntity(byte[] bytes) {
this.bytes = bytes;
}
public byte[] getBytes() {
return bytes;
}
public Object getPersistentState() {
return new PersistentState(name, bytes);
}
public int getRevisionNext() {
return revision + 1;
}
// getters and setters ////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDeploymentId() {
return deploymentId;
}
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
@Override
public String toString() {
return "ByteArrayEntity[id=" + id + ", name=" + name + ", size=" + (bytes != null ? bytes.length : 0) + "]";
}
// Wrapper for a byte array, needed to do byte array comparisons
// See https://activiti.atlassian.net/browse/ACT-1524
private static class PersistentState {
public interface ByteArrayEntity extends Entity, HasRevision {
private final String name;
private final byte[] bytes;
byte[] getBytes();
public PersistentState(String name, byte[] bytes) {
this.name = name;
this.bytes = bytes;
}
String getName();
public boolean equals(Object obj) {
if (obj instanceof PersistentState) {
PersistentState other = (PersistentState) obj;
return StringUtils.equals(this.name, other.name) && Arrays.equals(this.bytes, other.bytes);
}
return false;
}
void setName(String name);
@Override
public int hashCode() {
throw new UnsupportedOperationException();
}
String getDeploymentId();
void setDeploymentId(String deploymentId);
}
void setBytes(byte[] bytes);
}
/* 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.persistence.entity;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
/**
* @author Tom Baeyens
* @author Marcus Klimstra (CGI)
* @author Joram Barrez
*/
public class ByteArrayEntityImpl implements ByteArrayEntity, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected byte[] bytes;
protected String deploymentId;
public ByteArrayEntityImpl() {
}
public ByteArrayEntityImpl(String name, byte[] bytes) {
this.name = name;
this.bytes = bytes;
}
public ByteArrayEntityImpl(byte[] bytes) {
this.bytes = bytes;
}
public byte[] getBytes() {
return bytes;
}
public Object getPersistentState() {
return new PersistentState(name, bytes);
}
public int getRevisionNext() {
return revision + 1;
}
// getters and setters ////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDeploymentId() {
return deploymentId;
}
public void setDeploymentId(String deploymentId) {
this.deploymentId = deploymentId;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
@Override
public String toString() {
return "ByteArrayEntity[id=" + id + ", name=" + name + ", size=" + (bytes != null ? bytes.length : 0) + "]";
}
// Wrapper for a byte array, needed to do byte array comparisons
// See https://activiti.atlassian.net/browse/ACT-1524
private static class PersistentState {
private final String name;
private final byte[] bytes;
public PersistentState(String name, byte[] bytes) {
this.name = name;
this.bytes = bytes;
}
public boolean equals(Object obj) {
if (obj instanceof PersistentState) {
PersistentState other = (PersistentState) obj;
return StringUtils.equals(this.name, other.name) && Arrays.equals(this.bytes, other.bytes);
}
return false;
}
@Override
public int hashCode() {
throw new UnsupportedOperationException();
}
}
}
......@@ -45,7 +45,9 @@ public class ByteArrayEntityManagerImpl extends AbstractEntityManager<ByteArrayE
@Override
public ByteArrayEntity createAndInsert(String name, byte[] bytes) {
ByteArrayEntity byteArrayEntity = new ByteArrayEntity(name, bytes);
ByteArrayEntity byteArrayEntity = byteArrayDataManager.create();
byteArrayEntity.setName(name);
byteArrayEntity.setBytes(bytes);
byteArrayDataManager.insert(byteArrayEntity);
return byteArrayEntity;
}
......
......@@ -13,11 +13,7 @@
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import org.activiti.engine.impl.db.Entity;
import org.activiti.engine.task.Comment;
......@@ -25,148 +21,33 @@ import org.activiti.engine.task.Event;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class CommentEntity implements Comment, Event, Entity, Serializable {
public interface CommentEntity extends Comment, Event, Entity {
String TYPE_EVENT = "event";
String TYPE_COMMENT = "comment";
private static final long serialVersionUID = 1L;
byte[] getFullMessageBytes();
public static final String TYPE_EVENT = "event";
public static final String TYPE_COMMENT = "comment";
void setFullMessageBytes(byte[] fullMessageBytes);
protected String id;
void setMessage(String[] messageParts);
// If comments would be removable, revision needs to be added!
void setUserId(String userId);
protected String type;
protected String userId;
protected Date time;
protected String taskId;
protected String processInstanceId;
protected String action;
protected String message;
protected String fullMessage;
void setTaskId(String taskId);
public Object getPersistentState() {
return CommentEntity.class;
}
void setMessage(String message);
public byte[] getFullMessageBytes() {
return (fullMessage != null ? fullMessage.getBytes() : null);
}
void setTime(Date time);
public void setFullMessageBytes(byte[] fullMessageBytes) {
fullMessage = (fullMessageBytes != null ? new String(fullMessageBytes) : null);
}
void setProcessInstanceId(String processInstanceId);
public static String MESSAGE_PARTS_MARKER = "_|_";
public static Pattern MESSAGE_PARTS_MARKER_REGEX = Pattern.compile("_\\|_");
void setType(String type);
public void setMessage(String[] messageParts) {
StringBuilder stringBuilder = new StringBuilder();
for (String part : messageParts) {
if (part != null) {
stringBuilder.append(part.replace(MESSAGE_PARTS_MARKER, " | "));
stringBuilder.append(MESSAGE_PARTS_MARKER);
} else {
stringBuilder.append("null");
stringBuilder.append(MESSAGE_PARTS_MARKER);
}
}
for (int i = 0; i < MESSAGE_PARTS_MARKER.length(); i++) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
message = stringBuilder.toString();
}
void setFullMessage(String fullMessage);
public List<String> getMessageParts() {
if (message == null) {
return null;
}
List<String> messageParts = new ArrayList<String>();
String[] parts = MESSAGE_PARTS_MARKER_REGEX.split(message);
for (String part : parts) {
if ("null".equals(part)) {
messageParts.add(null);
} else {
messageParts.add(part);
}
}
return messageParts;
}
// getters and setters
// //////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
void setAction(String action);
}
/* 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.persistence.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
/**
* @author Tom Baeyens
*/
public class CommentEntityImpl implements CommentEntity, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
// If comments would be removable, revision needs to be added!
protected String type;
protected String userId;
protected Date time;
protected String taskId;
protected String processInstanceId;
protected String action;
protected String message;
protected String fullMessage;
public Object getPersistentState() {
return CommentEntityImpl.class;
}
public byte[] getFullMessageBytes() {
return (fullMessage != null ? fullMessage.getBytes() : null);
}
public void setFullMessageBytes(byte[] fullMessageBytes) {
fullMessage = (fullMessageBytes != null ? new String(fullMessageBytes) : null);
}
public static String MESSAGE_PARTS_MARKER = "_|_";
public static Pattern MESSAGE_PARTS_MARKER_REGEX = Pattern.compile("_\\|_");
public void setMessage(String[] messageParts) {
StringBuilder stringBuilder = new StringBuilder();
for (String part : messageParts) {
if (part != null) {
stringBuilder.append(part.replace(MESSAGE_PARTS_MARKER, " | "));
stringBuilder.append(MESSAGE_PARTS_MARKER);
} else {
stringBuilder.append("null");
stringBuilder.append(MESSAGE_PARTS_MARKER);
}
}
for (int i = 0; i < MESSAGE_PARTS_MARKER.length(); i++) {
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
}
message = stringBuilder.toString();
}
public List<String> getMessageParts() {
if (message == null) {
return null;
}
List<String> messageParts = new ArrayList<String>();
String[] parts = MESSAGE_PARTS_MARKER_REGEX.split(message);
for (String part : parts) {
if ("null".equals(part)) {
messageParts.add(null);
} else {
messageParts.add(part);
}
}
return messageParts;
}
// getters and setters
// //////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFullMessage() {
return fullMessage;
}
public void setFullMessage(String fullMessage) {
this.fullMessage = fullMessage;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
}
......@@ -18,14 +18,8 @@ package org.activiti.engine.impl.persistence.entity;
* @author Joram Barrez
* @author Tijs Rademakers
*/
public class CompensateEventSubscriptionEntity extends EventSubscriptionEntity {
private static final long serialVersionUID = 1L;
public static final String EVENT_TYPE = "compensate";
public interface CompensateEventSubscriptionEntity extends EventSubscriptionEntity {
public CompensateEventSubscriptionEntity() {
eventType = EVENT_TYPE;
}
String EVENT_TYPE = "compensate";
}
\ No newline at end of file
/* 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.persistence.entity;
/**
* @author Joram Barrez
* @author Tijs Rademakers
*/
public class CompensateEventSubscriptionEntityImpl extends EventSubscriptionEntityImpl implements CompensateEventSubscriptionEntity {
private static final long serialVersionUID = 1L;
public CompensateEventSubscriptionEntityImpl() {
eventType = EVENT_TYPE;
}
}
\ No newline at end of file
......@@ -13,15 +13,10 @@
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.Entity;
import org.activiti.engine.repository.Deployment;
......@@ -29,142 +24,32 @@ import org.activiti.engine.repository.Deployment;
* @author Tom Baeyens
* @author Joram Barrez
*/
public class DeploymentEntity implements Serializable, Deployment, Entity {
private static final long serialVersionUID = 1L;
protected String id;
protected String name;
protected String category;
protected String tenantId = ProcessEngineConfiguration.NO_TENANT_ID;
protected Map<String, ResourceEntity> resources;
protected Date deploymentTime;
protected boolean isNew;
// Backwards compatibility
protected String engineVersion;
/**
* Will only be used during actual deployment to pass deployed artifacts (eg process definitions). Will be null otherwise.
*/
protected Map<Class<?>, List<Object>> deployedArtifacts;
public void addResource(ResourceEntity resource) {
if (resources == null) {
resources = new HashMap<String, ResourceEntity>();
}
resources.put(resource.getName(), resource);
}
// lazy loading ///////////////////////////////////////////////////////////////
public Map<String, ResourceEntity> getResources() {
if (resources == null && id != null) {
List<ResourceEntity> resourcesList = Context.getCommandContext().getResourceEntityManager().findResourcesByDeploymentId(id);
resources = new HashMap<String, ResourceEntity>();
for (ResourceEntity resource : resourcesList) {
resources.put(resource.getName(), resource);
}
}
return resources;
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("category", this.category);
persistentState.put("tenantId", tenantId);
return persistentState;
}
// Deployed artifacts manipulation ////////////////////////////////////////////
public void addDeployedArtifact(Object deployedArtifact) {
if (deployedArtifacts == null) {
deployedArtifacts = new HashMap<Class<?>, List<Object>>();
}
Class<?> clazz = deployedArtifact.getClass();
List<Object> artifacts = deployedArtifacts.get(clazz);
if (artifacts == null) {
artifacts = new ArrayList<Object>();
deployedArtifacts.put(clazz, artifacts);
}
artifacts.add(deployedArtifact);
}
@SuppressWarnings("unchecked")
public <T> List<T> getDeployedArtifacts(Class<T> clazz) {
return (List<T>) deployedArtifacts.get(clazz);
}
// getters and setters ////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public void setResources(Map<String, ResourceEntity> resources) {
this.resources = resources;
}
public Date getDeploymentTime() {
return deploymentTime;
}
public void setDeploymentTime(Date deploymentTime) {
this.deploymentTime = deploymentTime;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean isNew) {
this.isNew = isNew;
}
public String getEngineVersion() {
return engineVersion;
}
public void setEngineVersion(String engineVersion) {
this.engineVersion = engineVersion;
}
// common methods //////////////////////////////////////////////////////////
@Override
public String toString() {
return "DeploymentEntity[id=" + id + ", name=" + name + "]";
}
}
public interface DeploymentEntity extends Deployment, Entity {
void addResource(ResourceEntity resource);
Map<String, ResourceEntity> getResources();
void addDeployedArtifact(Object deployedArtifact);
<T> List<T> getDeployedArtifacts(Class<T> clazz);
void setName(String name);
void setCategory(String category);
void setTenantId(String tenantId);
void setResources(Map<String, ResourceEntity> resources);
void setDeploymentTime(Date deploymentTime);
boolean isNew();
void setNew(boolean isNew);
String getEngineVersion();
void setEngineVersion(String engineVersion);
}
\ No newline at end of file
/* 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.persistence.entity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.impl.context.Context;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class DeploymentEntityImpl implements DeploymentEntity, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
protected String name;
protected String category;
protected String tenantId = ProcessEngineConfiguration.NO_TENANT_ID;
protected Map<String, ResourceEntity> resources;
protected Date deploymentTime;
protected boolean isNew;
// Backwards compatibility
protected String engineVersion;
/**
* Will only be used during actual deployment to pass deployed artifacts (eg process definitions). Will be null otherwise.
*/
protected Map<Class<?>, List<Object>> deployedArtifacts;
public void addResource(ResourceEntity resource) {
if (resources == null) {
resources = new HashMap<String, ResourceEntity>();
}
resources.put(resource.getName(), resource);
}
// lazy loading ///////////////////////////////////////////////////////////////
public Map<String, ResourceEntity> getResources() {
if (resources == null && id != null) {
List<ResourceEntity> resourcesList = Context.getCommandContext().getResourceEntityManager().findResourcesByDeploymentId(id);
resources = new HashMap<String, ResourceEntity>();
for (ResourceEntity resource : resourcesList) {
resources.put(resource.getName(), resource);
}
}
return resources;
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("category", this.category);
persistentState.put("tenantId", tenantId);
return persistentState;
}
// Deployed artifacts manipulation ////////////////////////////////////////////
public void addDeployedArtifact(Object deployedArtifact) {
if (deployedArtifacts == null) {
deployedArtifacts = new HashMap<Class<?>, List<Object>>();
}
Class<?> clazz = deployedArtifact.getClass();
List<Object> artifacts = deployedArtifacts.get(clazz);
if (artifacts == null) {
artifacts = new ArrayList<Object>();
deployedArtifacts.put(clazz, artifacts);
}
artifacts.add(deployedArtifact);
}
@SuppressWarnings("unchecked")
public <T> List<T> getDeployedArtifacts(Class<T> clazz) {
for (Class<?> deployedArtifactsClass : deployedArtifacts.keySet()) {
if (clazz.isAssignableFrom(deployedArtifactsClass)) {
return (List<T>) deployedArtifacts.get(deployedArtifactsClass);
}
}
return null;
}
// getters and setters ////////////////////////////////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public void setResources(Map<String, ResourceEntity> resources) {
this.resources = resources;
}
public Date getDeploymentTime() {
return deploymentTime;
}
public void setDeploymentTime(Date deploymentTime) {
this.deploymentTime = deploymentTime;
}
public boolean isNew() {
return isNew;
}
public void setNew(boolean isNew) {
this.isNew = isNew;
}
public String getEngineVersion() {
return engineVersion;
}
public void setEngineVersion(String engineVersion) {
this.engineVersion = engineVersion;
}
// common methods //////////////////////////////////////////////////////////
@Override
public String toString() {
return "DeploymentEntity[id=" + id + ", name=" + name + "]";
}
}
\ No newline at end of file
......@@ -19,6 +19,8 @@ import org.activiti.engine.impl.db.Entity;
*/
public interface EntityManager<EntityImpl extends Entity> {
EntityImpl create();
EntityImpl findById(String entityId);
void insert(EntityImpl entity);
......
......@@ -22,138 +22,36 @@ import org.activiti.engine.impl.db.Entity;
*
* @author Joram Barrez
*/
public class EventLogEntryEntity implements Entity, EventLogEntry {
protected long logNumber; // cant use id here, it would clash with entity
protected String type;
protected String processDefinitionId;
protected String processInstanceId;
protected String executionId;
protected String taskId;
protected Date timeStamp;
protected String userId;
protected byte[] data;
protected String lockOwner;
protected String lockTime;
protected int isProcessed;
public EventLogEntryEntity() {
}
@Override
public String getId() {
return "event-log-" + logNumber; // To avoid clashed, prefixing it (it shouldn't be used)
}
@Override
public void setId(String id) {
// Set id doesn't do anything: auto incremented column
}
@Override
public Object getPersistentState() {
return null; // Not updateable
}
public long getLogNumber() {
return logNumber;
}
public void setLogNumber(long logNumber) {
this.logNumber = logNumber;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
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 getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getLockOwner() {
return lockOwner;
}
public void setLockOwner(String lockOwner) {
this.lockOwner = lockOwner;
}
public String getLockTime() {
return lockTime;
}
public void setLockTime(String lockTime) {
this.lockTime = lockTime;
}
public int getProcessed() {
return isProcessed;
}
public void setProcessed(int isProcessed) {
this.isProcessed = isProcessed;
}
@Override
public String toString() {
return timeStamp.toString() + " : " + type;
}
public interface EventLogEntryEntity extends Entity, EventLogEntry {
void setLogNumber(long logNumber);
void setType(String type);
void setProcessDefinitionId(String processDefinitionId);
void setProcessInstanceId(String processInstanceId);
void setExecutionId(String executionId);
void setTaskId(String taskId);
void setTimeStamp(Date timeStamp);
void setUserId(String userId);
void setData(byte[] data);
String getLockOwner();
void setLockOwner(String lockOwner);
String getLockTime();
void setLockTime(String lockTime);
int getProcessed();
void setProcessed(int isProcessed);
}
/* 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.persistence.entity;
import java.util.Date;
/**
* An event log entry can only be inserted (and maybe deleted).
*
* @author Joram Barrez
*/
public class EventLogEntryEntityImpl implements EventLogEntryEntity {
protected long logNumber; // cant use id here, it would clash with entity
protected String type;
protected String processDefinitionId;
protected String processInstanceId;
protected String executionId;
protected String taskId;
protected Date timeStamp;
protected String userId;
protected byte[] data;
protected String lockOwner;
protected String lockTime;
protected int isProcessed;
public EventLogEntryEntityImpl() {
}
@Override
public String getId() {
return "event-log-" + logNumber; // To avoid clashed, prefixing it (it shouldn't be used)
}
@Override
public void setId(String id) {
// Set id doesn't do anything: auto incremented column
}
@Override
public Object getPersistentState() {
return null; // Not updateable
}
public long getLogNumber() {
return logNumber;
}
public void setLogNumber(long logNumber) {
this.logNumber = logNumber;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
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 getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getLockOwner() {
return lockOwner;
}
public void setLockOwner(String lockOwner) {
this.lockOwner = lockOwner;
}
public String getLockTime() {
return lockTime;
}
public void setLockTime(String lockTime) {
this.lockTime = lockTime;
}
public int getProcessed() {
return isProcessed;
}
public void setProcessed(int isProcessed) {
this.isProcessed = isProcessed;
}
@Override
public String toString() {
return timeStamp.toString() + " : " + type;
}
}
......@@ -13,181 +13,55 @@
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.HasRevision;
import org.activiti.engine.impl.db.Entity;
import org.activiti.engine.impl.db.HasRevision;
/**
* @author Joram Barrez
* @author Tijs Rademakers
*/
public abstract class EventSubscriptionEntity implements Entity, HasRevision, Serializable {
private static final long serialVersionUID = 1L;
// persistent state ///////////////////////////
protected String id;
protected int revision = 1;
protected String eventType;
protected String eventName;
protected String executionId;
protected String processInstanceId;
protected String activityId;
protected String configuration;
protected Date created;
protected String processDefinitionId;
protected String tenantId;
// runtime state /////////////////////////////
protected ExecutionEntity execution;
public EventSubscriptionEntity() {
this.created = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
}
public Object getPersistentState() {
HashMap<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("executionId", executionId);
persistentState.put("configuration", configuration);
return persistentState;
}
// getters & setters ////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
public int getRevisionNext() {
return revision + 1;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getExecutionId() {
return executionId;
}
public void setExecutionId(String executionId) {
this.executionId = executionId;
}
public interface EventSubscriptionEntity extends Entity, HasRevision {
public ExecutionEntity getExecution() {
if (execution == null && executionId != null) {
execution = Context.getCommandContext().getExecutionEntityManager().findById(executionId);
}
return execution;
}
public void setExecution(ExecutionEntity execution) {
this.execution = execution;
if (execution != null) {
this.executionId = execution.getId();
this.processInstanceId = execution.getProcessInstanceId();
}
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getConfiguration() {
return configuration;
}
public void setConfiguration(String configuration) {
this.configuration = configuration;
}
public String getActivityId() {
return activityId;
}
public void setActivityId(String activityId) {
this.activityId = activityId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EventSubscriptionEntity other = (EventSubscriptionEntity) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
String getEventType();
void setEventType(String eventType);
String getEventName();
void setEventName(String eventName);
String getExecutionId();
void setExecutionId(String executionId);
ExecutionEntity getExecution();
void setExecution(ExecutionEntity execution);
String getProcessInstanceId();
void setProcessInstanceId(String processInstanceId);
String getConfiguration();
void setConfiguration(String configuration);
String getActivityId();
void setActivityId(String activityId);
Date getCreated();
void setCreated(Date created);
String getProcessDefinitionId();
void setProcessDefinitionId(String processDefinitionId);
String getTenantId();
void setTenantId(String tenantId);
}
/* 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.persistence.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import org.activiti.engine.impl.context.Context;
/**
* @author Joram Barrez
* @author Tijs Rademakers
*/
public abstract class EventSubscriptionEntityImpl implements EventSubscriptionEntity, Serializable {
private static final long serialVersionUID = 1L;
// persistent state ///////////////////////////
protected String id;
protected int revision = 1;
protected String eventType;
protected String eventName;
protected String executionId;
protected String processInstanceId;
protected String activityId;
protected String configuration;
protected Date created;
protected String processDefinitionId;
protected String tenantId;
// runtime state /////////////////////////////
protected ExecutionEntity execution;
public EventSubscriptionEntityImpl() {
this.created = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
}
public Object getPersistentState() {
HashMap<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("executionId", executionId);
persistentState.put("configuration", configuration);
return persistentState;
}
// getters & setters ////////////////////////////
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
public int getRevisionNext() {
return revision + 1;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}
public String getExecutionId() {
return executionId;
}
public void setExecutionId(String executionId) {
this.executionId = executionId;
}
public ExecutionEntity getExecution() {
if (execution == null && executionId != null) {
execution = Context.getCommandContext().getExecutionEntityManager().findById(executionId);
}
return execution;
}
public void setExecution(ExecutionEntity execution) {
this.execution = execution;
if (execution != null) {
this.executionId = execution.getId();
this.processInstanceId = execution.getProcessInstanceId();
}
}
public String getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}
public String getConfiguration() {
return configuration;
}
public void setConfiguration(String configuration) {
this.configuration = configuration;
}
public String getActivityId() {
return activityId;
}
public void setActivityId(String activityId) {
this.activityId = activityId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public void setProcessDefinitionId(String processDefinitionId) {
this.processDefinitionId = processDefinitionId;
}
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EventSubscriptionEntityImpl other = (EventSubscriptionEntityImpl) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
......@@ -25,6 +25,12 @@ import org.activiti.engine.impl.Page;
*/
public interface EventSubscriptionEntityManager extends EntityManager<EventSubscriptionEntity> {
MessageEventSubscriptionEntity createMessageEventSubscription();
SignalEventSubscriptionEntity createSignalEventSubscription();
CompensateEventSubscriptionEntity createCompensateEventSubscription();
void eventReceived(EventSubscriptionEntity eventSubscriptionEntity, Object payload, boolean processASync);
......
......@@ -51,9 +51,24 @@ public class EventSubscriptionEntityManagerImpl extends AbstractEntityManager<Ev
return eventSubscriptionDataManager;
}
@Override
public CompensateEventSubscriptionEntity createCompensateEventSubscription() {
return eventSubscriptionDataManager.createCompensateEventSubscription();
}
@Override
public MessageEventSubscriptionEntity createMessageEventSubscription() {
return eventSubscriptionDataManager.createMessageEventSubscription();
}
@Override
public SignalEventSubscriptionEntity createSignalEventSubscription() {
return eventSubscriptionDataManager.createSignalEventSubscription();
}
@Override
public SignalEventSubscriptionEntity insertSignalEvent(SignalEventDefinition signalEventDefinition, Signal signal, ExecutionEntity execution) {
SignalEventSubscriptionEntity subscriptionEntity = new SignalEventSubscriptionEntity();
SignalEventSubscriptionEntity subscriptionEntity = createSignalEventSubscription();
subscriptionEntity.setExecution(execution);
if (signal != null) {
subscriptionEntity.setEventName(signal.getName());
......@@ -76,7 +91,7 @@ public class EventSubscriptionEntityManagerImpl extends AbstractEntityManager<Ev
@Override
public MessageEventSubscriptionEntity insertMessageEvent(MessageEventDefinition messageEventDefinition, ExecutionEntity execution) {
MessageEventSubscriptionEntity subscriptionEntity = new MessageEventSubscriptionEntity();
MessageEventSubscriptionEntity subscriptionEntity = createMessageEventSubscription();
subscriptionEntity.setExecution(execution);
subscriptionEntity.setEventName(messageEventDefinition.getMessageRef());
......@@ -92,7 +107,7 @@ public class EventSubscriptionEntityManagerImpl extends AbstractEntityManager<Ev
@Override
public CompensateEventSubscriptionEntity insertCompensationEvent(ExecutionEntity execution, String activityId) {
CompensateEventSubscriptionEntity eventSubscription = new CompensateEventSubscriptionEntity();
CompensateEventSubscriptionEntity eventSubscription = createCompensateEventSubscription();
eventSubscription.setExecution(execution);
eventSubscription.setActivityId(activityId);
if (execution.getTenantId() != null) {
......@@ -246,7 +261,7 @@ public class EventSubscriptionEntityManagerImpl extends AbstractEntityManager<Ev
protected void scheduleEventAsync(EventSubscriptionEntity eventSubscriptionEntity, Object payload) {
MessageEntity message = new MessageEntity();
MessageEntity message = getJobEntityManager().createMessage();
message.setJobHandlerType(ProcessEventJobHandler.TYPE);
message.setJobHandlerConfiguration(eventSubscriptionEntity.getId());
message.setTenantId(eventSubscriptionEntity.getTenantId());
......
......@@ -162,7 +162,7 @@ public class ExecutionEntityManagerImpl extends AbstractEntityManager<ExecutionE
@Override
public ExecutionEntity createProcessInstanceExecution(String processDefinitionId, String businessKey, String tenantId, String initiatorVariableName) {
ExecutionEntity processInstanceExecution = new ExecutionEntity();
ExecutionEntity processInstanceExecution = executionDataManager.create();
processInstanceExecution.setProcessDefinitionId(processDefinitionId);
processInstanceExecution.setBusinessKey(businessKey);
processInstanceExecution.setScope(true); // process instance is always a scope for all child executions
......@@ -202,7 +202,7 @@ public class ExecutionEntityManagerImpl extends AbstractEntityManager<ExecutionE
public ExecutionEntity createChildExecution(ExecutionEntity parentExecutionEntity) {
// create the new child execution
ExecutionEntity childExecution = new ExecutionEntity();
ExecutionEntity childExecution = executionDataManager.create();
// Inherit tenant id (if any)
if (parentExecutionEntity.getTenantId() != null) {
......@@ -213,7 +213,7 @@ public class ExecutionEntityManagerImpl extends AbstractEntityManager<ExecutionE
insert(childExecution, false);
// manage the bidirectional parent-child relation
parentExecutionEntity.getExecutions().add(childExecution);
parentExecutionEntity.addChildExecution(childExecution);
childExecution.setParent(parentExecutionEntity);
// initialize the new execution
......
......@@ -12,73 +12,21 @@
*/
package org.activiti.engine.impl.persistence.entity;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.identity.Group;
import org.activiti.engine.impl.db.HasRevision;
import org.activiti.engine.impl.db.Entity;
import org.activiti.engine.impl.db.HasRevision;
/**
* @author Tom Baeyens
* @author Joram Barrez
*/
public class GroupEntity implements Group, Serializable, Entity, HasRevision {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected String type;
public GroupEntity() {
}
public GroupEntity(String id) {
this.id = id;
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("name", name);
persistentState.put("type", type);
return persistentState;
}
public int getRevisionNext() {
return revision + 1;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public interface GroupEntity extends Group, Entity, HasRevision {
public String getType() {
return type;
}
String getName();
public void setType(String type) {
this.type = type;
}
void setName(String name);
String getType();
public int getRevision() {
return revision;
}
void setType(String type);
public void setRevision(int revision) {
this.revision = revision;
}
}
/* 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.persistence.entity;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* @author Tom Baeyens
*/
public class GroupEntityImpl implements GroupEntity, Serializable {
private static final long serialVersionUID = 1L;
protected String id;
protected int revision;
protected String name;
protected String type;
public GroupEntityImpl() {
}
public GroupEntityImpl(String id) {
this.id = id;
}
public Object getPersistentState() {
Map<String, Object> persistentState = new HashMap<String, Object>();
persistentState.put("name", name);
persistentState.put("type", type);
return persistentState;
}
public int getRevisionNext() {
return revision + 1;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
}
......@@ -48,7 +48,9 @@ public class GroupEntityManagerImpl extends AbstractEntityManager<GroupEntity> i
}
public Group createNewGroup(String groupId) {
return new GroupEntity(groupId);
GroupEntity groupEntity = groupDataManager.create();
groupEntity.setId(groupId);
return groupEntity;
}
@Override
......
......@@ -14,119 +14,28 @@
package org.activiti.engine.impl.persistence.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.history.HistoricActivityInstance;
/**
* @author Christian Stettler
* @author Joram Barrez
*/
public class HistoricActivityInstanceEntity extends HistoricScopeInstanceEntity implements HistoricActivityInstance {
private static final long serialVersionUID = 1L;
protected String activityId;
protected String activityName;
protected String activityType;
protected String executionId;
protected String assignee;
protected String taskId;
protected String calledProcessInstanceId;
protected String tenantId = ProcessEngineConfiguration.NO_TENANT_ID;
public HistoricActivityInstanceEntity() {
}
public Object getPersistentState() {
Map<String, Object> persistentState = (Map<String, Object>) new HashMap<String, Object>();
persistentState.put("endTime", endTime);
persistentState.put("durationInMillis", durationInMillis);
persistentState.put("deleteReason", deleteReason);
persistentState.put("executionId", executionId);
persistentState.put("assignee", assignee);
return persistentState;
}
// getters and setters //////////////////////////////////////////////////////
public String getActivityId() {
return activityId;
}
public void setActivityId(String activityId) {
this.activityId = activityId;
}
public String getActivityName() {
return activityName;
}
public void setActivityName(String activityName) {
this.activityName = activityName;
}
public String getActivityType() {
return activityType;
}
public void setActivityType(String activityType) {
this.activityType = activityType;
}
public String getExecutionId() {
return executionId;
}
public void setExecutionId(String executionId) {
this.executionId = executionId;
}
public String getAssignee() {
return assignee;
}
public void setAssignee(String assignee) {
this.assignee = assignee;
}
public String getTaskId() {
return taskId;
}
public interface HistoricActivityInstanceEntity extends HistoricActivityInstance, HistoricScopeInstanceEntity {
public void setTaskId(String taskId) {
this.taskId = taskId;
}
void setActivityId(String activityId);
public String getCalledProcessInstanceId() {
return calledProcessInstanceId;
}
void setActivityName(String activityName);
public void setCalledProcessInstanceId(String calledProcessInstanceId) {
this.calledProcessInstanceId = calledProcessInstanceId;
}
void setActivityType(String activityType);
public String getTenantId() {
return tenantId;
}
void setExecutionId(String executionId);
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
void setAssignee(String assignee);
public Date getTime() {
return getStartTime();
}
void setTaskId(String taskId);
// common methods //////////////////////////////////////////////////////////
void setCalledProcessInstanceId(String calledProcessInstanceId);
@Override
public String toString() {
return "HistoricActivityInstanceEntity[id=" + id + ", activityId=" + activityId + ", activityName=" + activityName + "]";
}
void setTenantId(String tenantId);
}
......@@ -16,7 +16,6 @@ package org.activiti.engine.impl.persistence.entity;
/**
* @author Tom Baeyens
*/
public class HistoricDetailAssignmentEntity extends HistoricDetailEntity {
public interface HistoricDetailAssignmentEntity extends HistoricDetailEntity {
private static final long serialVersionUID = 1L;
}
/* 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.persistence.entity;
/**
* @author Tom Baeyens
*/
public class HistoricDetailAssignmentEntityImpl extends HistoricDetailEntityImpl implements HistoricDetailAssignmentEntity {
private static final long serialVersionUID = 1L;
}
......@@ -16,6 +16,5 @@ package org.activiti.engine.impl.persistence.entity;
/**
* @author Tom Baeyens
*/
public class HistoricDetailTransitionInstanceEntity extends HistoricDetailEntity {
private static final long serialVersionUID = 1L;
public interface HistoricDetailTransitionInstanceEntity extends HistoricDetailEntity {
}
/* 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.persistence.entity;
/**
* @author Tom Baeyens
*/
public class HistoricDetailTransitionInstanceEntityImpl extends HistoricDetailEntityImpl implements HistoricDetailTransitionInstanceEntity {
private static final long serialVersionUID = 1L;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册