Java Code Examples for org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getTenantId()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getTenantId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractSetProcessDefinitionStateCmd.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void createTimerForDelayedExecution(CommandContext commandContext, List<ProcessDefinitionEntity> processDefinitions) { for (ProcessDefinitionEntity processDefinition : processDefinitions) { if (Activiti5Util.isActiviti5ProcessDefinition(commandContext, processDefinition)) continue; TimerJobEntity timer = commandContext.getTimerJobEntityManager().create(); timer.setJobType(JobEntity.JOB_TYPE_TIMER); timer.setProcessDefinitionId(processDefinition.getId()); // Inherit tenant identifier (if applicable) if (processDefinition.getTenantId() != null) { timer.setTenantId(processDefinition.getTenantId()); } timer.setDuedate(executionDate); timer.setJobHandlerType(getDelayedExecutionJobHandlerType()); timer.setJobHandlerConfiguration(TimerChangeProcessDefinitionSuspensionStateJobHandler.createJobHandlerConfiguration(includeProcessInstances)); commandContext.getJobManager().scheduleTimerJob(timer); } }
Example 2
Source File: BpmnDeploymentHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Gets the most recent persisted process definition that matches this one for tenant and key. * If none is found, returns null. This method assumes that the tenant and key are properly * set on the process definition entity. */ public ProcessDefinitionEntity getMostRecentVersionOfProcessDefinition(ProcessDefinitionEntity processDefinition) { String key = processDefinition.getKey(); String tenantId = processDefinition.getTenantId(); ProcessDefinitionEntityManager processDefinitionManager = Context.getCommandContext().getProcessEngineConfiguration().getProcessDefinitionEntityManager(); ProcessDefinitionEntity existingDefinition = null; if (tenantId != null && !tenantId.equals(ProcessEngineConfiguration.NO_TENANT_ID)) { existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKeyAndTenantId(key, tenantId); } else { existingDefinition = processDefinitionManager.findLatestProcessDefinitionByKey(key); } return existingDefinition; }
Example 3
Source File: BpmnDeploymentHelper.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Gets the persisted version of the already-deployed process definition. Note that this is * different from {@link #getMostRecentVersionOfProcessDefinition} as it looks specifically for * a process definition that is already persisted and attached to a particular deployment, * rather than the latest version across all deployments. */ public ProcessDefinitionEntity getPersistedInstanceOfProcessDefinition(ProcessDefinitionEntity processDefinition) { String deploymentId = processDefinition.getDeploymentId(); if (StringUtils.isEmpty(processDefinition.getDeploymentId())) { throw new IllegalStateException("Provided process definition must have a deployment id."); } ProcessDefinitionEntityManager processDefinitionManager = Context.getCommandContext().getProcessEngineConfiguration().getProcessDefinitionEntityManager(); ProcessDefinitionEntity persistedProcessDefinition = null; if (processDefinition.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKey(deploymentId, processDefinition.getKey()); } else { persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKeyAndTenantId(deploymentId, processDefinition.getKey(), processDefinition.getTenantId()); } return persistedProcessDefinition; }
Example 4
Source File: TimerManager.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<TimerJobEntity> jobsToDelete = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findJobsByTypeAndProcessDefinitionKeyAndTenantId( TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); } else { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager() .findJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey()); } if (jobsToDelete != null) { for (TimerJobEntity job :jobsToDelete) { new CancelJobsCmd(job.getId()).execute(Context.getCommandContext()); } } }
Example 5
Source File: AbstractSetProcessDefinitionStateCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void createTimerForDelayedExecution(CommandContext commandContext, List<ProcessDefinitionEntity> processDefinitions) { for (ProcessDefinitionEntity processDefinition : processDefinitions) { TimerJobEntity timer = new TimerJobEntity(); timer.setJobType(Job.JOB_TYPE_TIMER); timer.setRevision(1); timer.setProcessDefinitionId(processDefinition.getId()); // Inherit tenant identifier (if applicable) if (processDefinition.getTenantId() != null) { timer.setTenantId(processDefinition.getTenantId()); } timer.setDuedate(executionDate); timer.setJobHandlerType(getDelayedExecutionJobHandlerType()); timer.setJobHandlerConfiguration(TimerChangeProcessDefinitionSuspensionStateJobHandler.createJobHandlerConfiguration(includeProcessInstances)); commandContext.getJobEntityManager().schedule(timer); } }
Example 6
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected void addTimerDeclarations(ProcessDefinitionEntity processDefinition, List<TimerJobEntity> timers) { List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_START_TIMER); if (timerDeclarations != null) { for (TimerDeclarationImpl timerDeclaration : timerDeclarations) { TimerJobEntity timer = timerDeclaration.prepareTimerEntity(null); if (timer != null) { timer.setProcessDefinitionId(processDefinition.getId()); // Inherit timer (if applicable) if (processDefinition.getTenantId() != null) { timer.setTenantId(processDefinition.getTenantId()); } timers.add(timer); } } } }
Example 7
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<Job> jobsToDelete = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findTimerJobsByTypeAndProcessDefinitionKeyAndTenantId( TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); } else { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager() .findTimerJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey()); } if (jobsToDelete != null) { for (Job job : jobsToDelete) { new CancelJobsCmd(job.getId()).execute(Context.getCommandContext()); } } }
Example 8
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected void addSignalEventSubscriptions(ProcessDefinitionEntity processDefinition) { List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION); if (eventDefinitions != null) { for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) { if (eventDefinition.getEventType().equals("signal") && eventDefinition.isStartEvent()) { SignalEventSubscriptionEntity subscriptionEntity = new SignalEventSubscriptionEntity(); subscriptionEntity.setEventName(eventDefinition.getEventName()); subscriptionEntity.setActivityId(eventDefinition.getActivityId()); subscriptionEntity.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { subscriptionEntity.setTenantId(processDefinition.getTenantId()); } subscriptionEntity.insert(); } } } }
Example 9
Source File: EventSubscriptionManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void insertMessageEvent(MessageEventDefinition messageEventDefinition, StartEvent startEvent, ProcessDefinitionEntity processDefinition, BpmnModel bpmnModel) { CommandContext commandContext = Context.getCommandContext(); if (bpmnModel.containsMessageId(messageEventDefinition.getMessageRef())) { Message message = bpmnModel.getMessage(messageEventDefinition.getMessageRef()); messageEventDefinition.setMessageRef(message.getName()); } // look for subscriptions for the same name in db: List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext.getEventSubscriptionEntityManager() .findEventSubscriptionsByName(MessageEventHandler.EVENT_HANDLER_TYPE, messageEventDefinition.getMessageRef(), processDefinition.getTenantId()); for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsForSameMessageName) { // throw exception only if there's already a subscription as start event if (eventSubscriptionEntity.getProcessInstanceId() == null || eventSubscriptionEntity.getProcessInstanceId().isEmpty()) { // processInstanceId != null or not empty -> it's a message related to an execution // the event subscription has no instance-id, so it's a message start event throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName() + "': there already is a message event subscription for the message with name '" + messageEventDefinition.getMessageRef() + "'."); } } MessageEventSubscriptionEntity newSubscription = commandContext.getEventSubscriptionEntityManager().createMessageEventSubscription(); newSubscription.setEventName(messageEventDefinition.getMessageRef()); newSubscription.setActivityId(startEvent.getId()); newSubscription.setConfiguration(processDefinition.getId()); newSubscription.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { newSubscription.setTenantId(processDefinition.getTenantId()); } commandContext.getEventSubscriptionEntityManager().insert(newSubscription); }
Example 10
Source File: EventSubscriptionManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void addSignalEventSubscriptions(CommandContext commandContext, ProcessDefinitionEntity processDefinition, org.activiti.bpmn.model.Process process, BpmnModel bpmnModel) { if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof SignalEventDefinition) { SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; SignalEventSubscriptionEntity subscriptionEntity = commandContext.getEventSubscriptionEntityManager().createSignalEventSubscription(); Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { subscriptionEntity.setEventName(signal.getName()); } else { subscriptionEntity.setEventName(signalEventDefinition.getSignalRef()); } subscriptionEntity.setActivityId(startEvent.getId()); subscriptionEntity.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { subscriptionEntity.setTenantId(processDefinition.getTenantId()); } Context.getCommandContext().getEventSubscriptionEntityManager().insert(subscriptionEntity); } } } } } }
Example 11
Source File: TimerManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<TimerJobEntity> getTimerDeclarations(ProcessDefinitionEntity processDefinition, Process process) { JobManager jobManager = Context.getCommandContext().getJobManager(); List<TimerJobEntity> timers = new ArrayList<TimerJobEntity>(); if (CollectionUtil.isNotEmpty(process.getFlowElements())) { for (FlowElement element : process.getFlowElements()) { if (element instanceof StartEvent) { StartEvent startEvent = (StartEvent) element; if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) { EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0); if (eventDefinition instanceof TimerEventDefinition) { TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; TimerJobEntity timerJob = jobManager.createTimerJob(timerEventDefinition, false, null, TimerStartEventJobHandler.TYPE, TimerEventHandler.createConfiguration(startEvent.getId(), timerEventDefinition.getEndDate(), timerEventDefinition.getCalendarName())); if (timerJob != null) { timerJob.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { timerJob.setTenantId(processDefinition.getTenantId()); } timers.add(timerJob); } } } } } } return timers; }
Example 12
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition) { CommandContext commandContext = Context.getCommandContext(); List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION); if (eventDefinitions != null) { Set<String> messageNames = new HashSet<>(); for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) { if (eventDefinition.getEventType().equals("message") && eventDefinition.isStartEvent()) { if (!messageNames.contains(eventDefinition.getEventName())) { messageNames.add(eventDefinition.getEventName()); } else { throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName() + "': there multiple message event subscriptions for the message with name '" + eventDefinition.getEventName() + "'."); } // look for subscriptions for the same name in db: List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext.getEventSubscriptionEntityManager() .findEventSubscriptionsByName(MessageEventHandler.EVENT_HANDLER_TYPE, eventDefinition.getEventName(), processDefinition.getTenantId()); // also look for subscriptions created in the session: List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext .getDbSqlSession() .findInCache(MessageEventSubscriptionEntity.class); for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) { if (eventDefinition.getEventName().equals(cachedSubscription.getEventName()) && !subscriptionsForSameMessageName.contains(cachedSubscription)) { subscriptionsForSameMessageName.add(cachedSubscription); } } // remove subscriptions deleted in the same command subscriptionsForSameMessageName = commandContext .getDbSqlSession() .pruneDeletedEntities(subscriptionsForSameMessageName); for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsForSameMessageName) { // throw exception only if there's already a subscription as start event if (eventSubscriptionEntity.getProcessInstanceId() == null || eventSubscriptionEntity.getProcessInstanceId().isEmpty()) { // the event subscription has no instance-id, so it's a message start event throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName() + "': there already is a message event subscription for the message with name '" + eventDefinition.getEventName() + "'."); } } MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity(); newSubscription.setEventName(eventDefinition.getEventName()); newSubscription.setActivityId(eventDefinition.getActivityId()); newSubscription.setConfiguration(processDefinition.getId()); newSubscription.setProcessDefinitionId(processDefinition.getId()); if (processDefinition.getTenantId() != null) { newSubscription.setTenantId(processDefinition.getTenantId()); } newSubscription.insert(); } } } }