@Override protected VariableScopeImpl getParentVariableScope() { if (caseInstanceId != null) { return (VariableScopeImpl) CommandContextUtil.getCaseInstanceEntityManager().findById(caseInstanceId); } return null; }
public static CaseInstanceEntityManager getCaseInstanceEntityManager() { return getCaseInstanceEntityManager(getCommandContext()); }
@Override public List<CaseInstance> executeList(CommandContext commandContext) { ensureVariablesInitialized(); if (this.isIncludeCaseVariables()) { return CommandContextUtil.getCaseInstanceEntityManager(commandContext).findWithVariablesByCriteria(this); } return CommandContextUtil.getCaseInstanceEntityManager(commandContext).findByCriteria(this); }
@Override public long executeCount(CommandContext commandContext) { ensureVariablesInitialized(); return CommandContextUtil.getCaseInstanceEntityManager(commandContext).countByCriteria(this); }
@Override public void run() { if (caseInstanceEntity == null) { caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceEntityId); } if (caseInstanceEntityId == null) { caseInstanceEntityId = caseInstanceEntity.getId(); } }
@Override public Void execute(CommandContext commandContext) { CaseInstanceEntityManager caseInstanceEntityManager = CommandContextUtil.getCaseInstanceEntityManager(commandContext); CaseInstanceEntity caseInstance = caseInstanceEntityManager.findById(caseInstanceId); if (caseInstance == null) { throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class); } IdentityLinkUtil.createCaseInstanceIdentityLink(caseInstance, userId, groupId, type); return null; }
@Override public Void execute(CommandContext commandContext) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstance == null) { throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class); } IdentityLinkUtil.deleteCaseInstanceIdentityLinks(caseInstance, userId, groupId, type); return null; }
@Override public List<EntityLink> execute(CommandContext commandContext) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstance == null) { throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class); } return CommandContextUtil.getEntityLinkService(commandContext).findEntityLinksByScopeIdAndType( caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public List<IdentityLink> execute(CommandContext commandContext) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstance == null) { throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class); } return (List) CommandContextUtil.getIdentityLinkService(commandContext).findIdentityLinksByScopeIdAndType( caseInstanceId, ScopeTypes.CMMN); }
@Override public Void execute(CommandContext commandContext) { if (caseInstanceId == null) { throw new FlowableIllegalArgumentException("Case instance id is null"); } CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstanceEntity == null) { throw new FlowableObjectNotFoundException("Cannot find case instance for id " + caseInstanceEntity, CaseInstanceEntity.class); } internalExecute(commandContext, caseInstanceEntity); return null; }
@Override public List<EntityLink> execute(CommandContext commandContext) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstance == null) { throw new FlowableObjectNotFoundException("Cannot find case instance with id " + caseInstanceId, CaseInstanceEntity.class); } return CommandContextUtil.getEntityLinkService(commandContext).findEntityLinksByReferenceScopeIdAndType( caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD); }
@Override public void execute(JobEntity job, String caseInstanceId, VariableScope variableScope, CommandContext commandContext) { CaseInstanceEntity caseInstance = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstance != null) { CommandContextUtil.getAgenda(commandContext).planInitPlanModelOperation(caseInstance); } else { throw new FlowableException("Invalid usage of " + TYPE + " job handler, case instance " + caseInstanceId + " was not found."); } }
protected void addPlanItemInstanceToParent(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity) { if (planItemInstanceEntity.getStageInstanceId() != null) { PlanItemInstanceEntity stagePlanItemInstanceEntity = CommandContextUtil.getPlanItemInstanceEntityManager(commandContext) .findById(planItemInstanceEntity.getStageInstanceId()); stagePlanItemInstanceEntity.getChildPlanItemInstances().add(planItemInstanceEntity); } else { CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(planItemInstanceEntity.getCaseInstanceId()); caseInstanceEntity.getChildPlanItemInstances().add(planItemInstanceEntity); } }
@Override public void addUserIdentityLinkToParent(Task task, String userId) { if (userId != null && ScopeTypes.CMMN.equals(task.getScopeType()) && StringUtils.isNotEmpty(task.getScopeId())) { CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager().findById(task.getScopeId()); if (caseInstanceEntity != null) { List<IdentityLinkEntity> identityLinks = CommandContextUtil.getIdentityLinkService() .findIdentityLinksByScopeIdAndType(caseInstanceEntity.getId(), ScopeTypes.CMMN); for (IdentityLinkEntity identityLink : identityLinks) { if (identityLink.isUser() && identityLink.getUserId().equals(userId) && parentIdentityLinkType.equals(identityLink.getType())) { return; } } IdentityLinkUtil.createCaseInstanceIdentityLink(caseInstanceEntity, userId, null, parentIdentityLinkType); } } }
@Override public Void execute(CommandContext commandContext) { if (caseInstanceId == null) { throw new FlowableIllegalArgumentException("caseInstanceId is null"); } if (variableName == null) { throw new FlowableIllegalArgumentException("variableName is null"); } CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstanceEntity == null) { throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class); } caseInstanceEntity.removeVariable(variableName); return null; }
@Override public Void execute(CommandContext commandContext) { if (caseInstanceId == null) { throw new FlowableIllegalArgumentException("caseInstanceId is null"); } if (variableNames == null) { throw new FlowableIllegalArgumentException("variableNames is null"); } CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstanceEntity == null) { throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class); } caseInstanceEntity.removeVariables(variableNames); return null; }
@Override public Void execute(CommandContext commandContext) { if (caseInstanceId == null) { throw new FlowableIllegalArgumentException("You need to provide the case instance id in order to set its name"); } CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstanceEntity == null) { throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class); } caseInstanceEntity.setName(caseName); CommandContextUtil.getCmmnHistoryManager().recordUpdateCaseInstanceName(caseInstanceEntity, caseName); return null; }
protected CaseDefinition getCaseDefinition(IdentityLinkEntity identityLink) { String caseDefinitionId = null; if (ScopeTypes.CMMN.equals(identityLink.getScopeType()) && identityLink.getScopeId() != null) { CaseInstance caseInstance = CommandContextUtil.getCaseInstanceEntityManager().findById(identityLink.getScopeId()); if (caseInstance != null) { caseDefinitionId = caseInstance.getCaseDefinitionId(); } } else if (identityLink.getTaskId() != null) { TaskEntity task = CommandContextUtil.getTaskService().getTask(identityLink.getTaskId()); if (task != null && ScopeTypes.CMMN.equals(task.getScopeType())) { caseDefinitionId = task.getScopeDefinitionId(); } } return CaseDefinitionUtil.getCaseDefinition(caseDefinitionId); }
@Override public Void execute(CommandContext commandContext) { if (caseInstanceId == null) { throw new FlowableIllegalArgumentException("caseInstanceId is null"); } if (variableName == null) { throw new FlowableIllegalArgumentException("variable name is null"); } CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId); if (caseInstanceEntity == null) { throw new FlowableObjectNotFoundException("No case instance found for id " + caseInstanceId, CaseInstanceEntity.class); } caseInstanceEntity.setVariable(variableName, variableValue); CommandContextUtil.getAgenda(commandContext).planEvaluateCriteriaOperation(caseInstanceId); return null; }
protected void deleteCaseInstance() { updateChildPlanItemInstancesState(); CommandContextUtil.getCaseInstanceEntityManager(commandContext).delete(caseInstanceEntity.getId(), false, getDeleteReason()); String newState = getNewState(); CommandContextUtil.getCaseInstanceHelper(commandContext).callCaseInstanceStateChangeCallbacks(commandContext, caseInstanceEntity, caseInstanceEntity.getState(), newState); CommandContextUtil.getCmmnHistoryManager(commandContext).recordCaseInstanceEnd(caseInstanceEntity, newState); }