protected String getAuthenticatedUserId() { CommandContext commandContext = Context.getCommandContext(); return commandContext.getAuthenticatedUserId(); }
protected String getAuthenticatedUserId() { CommandContext commandContext = Context.getCommandContext(); return commandContext.getAuthenticatedUserId(); }
public static String currentUser() { CommandContext commandContext = Context.getCommandContext(); if (commandContext != null) { return commandContext.getAuthenticatedUserId(); } else { return null; } }
public static String currentUser() { CommandContext commandContext = Context.getCommandContext(); if (commandContext != null) { return commandContext.getAuthenticatedUserId(); } else { return null; } }
protected void setUserId(HistoricDecisionInstanceEntity event) { event.setUserId(Context.getCommandContext().getAuthenticatedUserId()); }
/** * @return true if the passed-in user is currently authenticated */ protected boolean isAuthenticatedUser(UserEntity user) { if(user.getId() == null) { return false; } return user.getId().equalsIgnoreCase(org.camunda.bpm.engine.impl.context.Context.getCommandContext().getAuthenticatedUserId()); }
protected void setUserId(HistoricDecisionInstanceEntity event) { event.setUserId(Context.getCommandContext().getAuthenticatedUserId()); }
public void insertBatch(BatchEntity batch) { batch.setCreateUserId(getCommandContext().getAuthenticatedUserId()); getDbEntityManager().insert(batch); }
public void insertBatch(BatchEntity batch) { batch.setCreateUserId(getCommandContext().getAuthenticatedUserId()); getDbEntityManager().insert(batch); }
public Object getValue(ELContext context, Object base, Object property) { Object object = context.getContext(VariableScope.class); if(object != null) { VariableScope variableScope = (VariableScope) object; if (base == null) { String variable = (String) property; // according to javadoc, can only be a String if( (EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity) || (TASK_KEY.equals(property) && variableScope instanceof TaskEntity) || (variableScope instanceof CaseExecutionEntity && (CASE_EXECUTION_KEY.equals(property) || EXECUTION_KEY.equals(property))) ) { context.setPropertyResolved(true); return variableScope; } else if (EXECUTION_KEY.equals(property) && variableScope instanceof TaskEntity) { context.setPropertyResolved(true); return ((TaskEntity) variableScope).getExecution(); } else if(LOGGED_IN_USER_KEY.equals(property)){ context.setPropertyResolved(true); return Context.getCommandContext().getAuthenticatedUserId(); } else { if (variableScope.hasVariable(variable)) { context.setPropertyResolved(true); // if not set, the next elResolver in the CompositeElResolver will be called return variableScope.getVariable(variable); } } } } // property resolution (eg. bean.value) will be done by the BeanElResolver (part of the CompositeElResolver) // It will use the bean resolved in this resolver as base. return null; }
public Object getValue(ELContext context, Object base, Object property) { Object object = context.getContext(VariableScope.class); if(object != null) { VariableScope variableScope = (VariableScope) object; if (base == null) { String variable = (String) property; // according to javadoc, can only be a String if( (EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity) || (TASK_KEY.equals(property) && variableScope instanceof TaskEntity) || (variableScope instanceof CaseExecutionEntity && (CASE_EXECUTION_KEY.equals(property) || EXECUTION_KEY.equals(property))) ) { context.setPropertyResolved(true); return variableScope; } else if (EXECUTION_KEY.equals(property) && variableScope instanceof TaskEntity) { context.setPropertyResolved(true); return ((TaskEntity) variableScope).getExecution(); } else if(LOGGED_IN_USER_KEY.equals(property)){ context.setPropertyResolved(true); return Context.getCommandContext().getAuthenticatedUserId(); } else { if (variableScope.hasVariable(variable)) { context.setPropertyResolved(true); // if not set, the next elResolver in the CompositeElResolver will be called return variableScope.getVariable(variable); } } } } // property resolution (eg. bean.value) will be done by the BeanElResolver (part of the CompositeElResolver) // It will use the bean resolved in this resolver as base. return null; }
@Override @SuppressWarnings("unchecked") public void initialize() { LOG.initializeExecution(this); ScopeImpl scope = getScopeActivity(); ensureParentInitialized(); List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS); if (variableDeclarations != null) { for (VariableDeclaration variableDeclaration : variableDeclarations) { variableDeclaration.initialize(this, parent); } } if (isProcessInstanceExecution()) { String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME); if (initiatorVariableName != null) { String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId(); setVariable(initiatorVariableName, authenticatedUserId); } } // create event subscriptions for the current scope for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) { if(!declaration.isStartEvent()) { declaration.createSubscriptionForExecution(this); } } }
@Override @SuppressWarnings("unchecked") public void initialize() { LOG.initializeExecution(this); ScopeImpl scope = getScopeActivity(); ensureParentInitialized(); List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS); if (variableDeclarations != null) { for (VariableDeclaration variableDeclaration : variableDeclarations) { variableDeclaration.initialize(this, parent); } } if (isProcessInstanceExecution()) { String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME); if (initiatorVariableName != null) { String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId(); setVariable(initiatorVariableName, authenticatedUserId); } } // create event subscriptions for the current scope for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) { if(!declaration.isStartEvent()) { declaration.createSubscriptionForExecution(this); } } }
String userId = commandContext.getAuthenticatedUserId(); CommentEntity comment = new CommentEntity(); comment.setUserId(userId);
public HistoryEvent createCaseInstanceCreateEvt(DelegateCaseExecution caseExecution) { final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution; // create event instance HistoricCaseInstanceEventEntity evt = newCaseInstanceEventEntity(caseExecutionEntity); // initialize event initCaseInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_INSTANCE_CREATE); // set create time evt.setCreateTime(ClockUtil.getCurrentTime()); // set create user id evt.setCreateUserId(Context.getCommandContext().getAuthenticatedUserId()); // set super case instance id CmmnExecution superCaseExecution = caseExecutionEntity.getSuperCaseExecution(); if (superCaseExecution != null) { evt.setSuperCaseInstanceId(superCaseExecution.getCaseInstanceId()); } // set super process instance id ExecutionEntity superExecution = caseExecutionEntity.getSuperExecution(); if (superExecution != null) { evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId()); } return evt; }
public HistoryEvent createCaseInstanceCreateEvt(DelegateCaseExecution caseExecution) { final CaseExecutionEntity caseExecutionEntity = (CaseExecutionEntity) caseExecution; // create event instance HistoricCaseInstanceEventEntity evt = newCaseInstanceEventEntity(caseExecutionEntity); // initialize event initCaseInstanceEvent(evt, caseExecutionEntity, HistoryEventTypes.CASE_INSTANCE_CREATE); // set create time evt.setCreateTime(ClockUtil.getCurrentTime()); // set create user id evt.setCreateUserId(Context.getCommandContext().getAuthenticatedUserId()); // set super case instance id CmmnExecution superCaseExecution = caseExecutionEntity.getSuperCaseExecution(); if (superCaseExecution != null) { evt.setSuperCaseInstanceId(superCaseExecution.getCaseInstanceId()); } // set super process instance id ExecutionEntity superExecution = caseExecutionEntity.getSuperExecution(); if (superExecution != null) { evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId()); } return evt; }
public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; // create event instance HistoricProcessInstanceEventEntity evt = newProcessInstanceEventEntity(executionEntity); // initialize event initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_START); evt.setStartActivityId(executionEntity.getActivityId()); evt.setStartTime(ClockUtil.getCurrentTime()); // set super process instance id ExecutionEntity superExecution = executionEntity.getSuperExecution(); if (superExecution != null) { evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId()); } //state evt.setState(HistoricProcessInstance.STATE_ACTIVE); // set start user Id evt.setStartUserId(Context.getCommandContext().getAuthenticatedUserId()); if (isHistoryRemovalTimeStrategyStart()) { if (isRootProcessInstance(evt)) { Date removalTime = calculateRemovalTime(evt); evt.setRemovalTime(removalTime); } else { provideRemovalTime(evt); } } return evt; }
public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; // create event instance HistoricProcessInstanceEventEntity evt = newProcessInstanceEventEntity(executionEntity); // initialize event initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_START); evt.setStartActivityId(executionEntity.getActivityId()); evt.setStartTime(ClockUtil.getCurrentTime()); // set super process instance id ExecutionEntity superExecution = executionEntity.getSuperExecution(); if (superExecution != null) { evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId()); } //state evt.setState(HistoricProcessInstance.STATE_ACTIVE); // set start user Id evt.setStartUserId(Context.getCommandContext().getAuthenticatedUserId()); if (isHistoryRemovalTimeStrategyStart()) { if (isRootProcessInstance(evt)) { Date removalTime = calculateRemovalTime(evt); evt.setRemovalTime(removalTime); } else { provideRemovalTime(evt); } } return evt; }
protected HistoryEvent createBatchEvent(BatchEntity batch, HistoryEventTypes eventType) { HistoricBatchEntity event = loadBatchEntity(batch); event.setId(batch.getId()); event.setType(batch.getType()); event.setTotalJobs(batch.getTotalJobs()); event.setBatchJobsPerSeed(batch.getBatchJobsPerSeed()); event.setInvocationsPerBatchJob(batch.getInvocationsPerBatchJob()); event.setSeedJobDefinitionId(batch.getSeedJobDefinitionId()); event.setMonitorJobDefinitionId(batch.getMonitorJobDefinitionId()); event.setBatchJobDefinitionId(batch.getBatchJobDefinitionId()); event.setTenantId(batch.getTenantId()); event.setEventType(eventType.getEventName()); if (HistoryEventTypes.BATCH_START.equals(eventType)) { event.setStartTime(ClockUtil.getCurrentTime()); event.setCreateUserId(Context.getCommandContext().getAuthenticatedUserId()); } if (HistoryEventTypes.BATCH_END.equals(eventType)) { event.setEndTime(ClockUtil.getCurrentTime()); } return event; }
protected HistoryEvent createBatchEvent(BatchEntity batch, HistoryEventTypes eventType) { HistoricBatchEntity event = loadBatchEntity(batch); event.setId(batch.getId()); event.setType(batch.getType()); event.setTotalJobs(batch.getTotalJobs()); event.setBatchJobsPerSeed(batch.getBatchJobsPerSeed()); event.setInvocationsPerBatchJob(batch.getInvocationsPerBatchJob()); event.setSeedJobDefinitionId(batch.getSeedJobDefinitionId()); event.setMonitorJobDefinitionId(batch.getMonitorJobDefinitionId()); event.setBatchJobDefinitionId(batch.getBatchJobDefinitionId()); event.setTenantId(batch.getTenantId()); event.setEventType(eventType.getEventName()); if (HistoryEventTypes.BATCH_START.equals(eventType)) { event.setStartTime(ClockUtil.getCurrentTime()); event.setCreateUserId(Context.getCommandContext().getAuthenticatedUserId()); } if (HistoryEventTypes.BATCH_END.equals(eventType)) { event.setEndTime(ClockUtil.getCurrentTime()); } return event; }