Java Code Examples for org.flowable.engine.repository.ProcessDefinition#getTenantId()
The following examples show how to use
org.flowable.engine.repository.ProcessDefinition#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: DeploymentEntityManagerImpl.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void restoreTimerStartEvent(ProcessDefinition previousProcessDefinition, StartEvent startEvent, EventDefinition eventDefinition) { TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition; TimerJobEntity timer = TimerUtil.createTimerEntityForTimerEventDefinition((TimerEventDefinition) eventDefinition, startEvent, false, null, TimerStartEventJobHandler.TYPE, TimerEventHandler.createConfiguration(startEvent.getId(), timerEventDefinition.getEndDate(), timerEventDefinition.getCalendarName())); if (timer != null) { TimerJobEntity timerJob = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition, startEvent, false, null, TimerStartEventJobHandler.TYPE, TimerEventHandler.createConfiguration(startEvent.getId(), timerEventDefinition.getEndDate(), timerEventDefinition.getCalendarName())); timerJob.setProcessDefinitionId(previousProcessDefinition.getId()); if (previousProcessDefinition.getTenantId() != null) { timerJob.setTenantId(previousProcessDefinition.getTenantId()); } CommandContextUtil.getTimerJobService().scheduleTimerJob(timerJob); } }
Example 2
Source File: DeploymentEntityManagerImpl.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void restoreSignalStartEvent(ProcessDefinition previousProcessDefinition, BpmnModel bpmnModel, StartEvent startEvent, EventDefinition eventDefinition) { CommandContext commandContext = Context.getCommandContext(); SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition; SignalEventSubscriptionEntity subscriptionEntity = CommandContextUtil.getEventSubscriptionService(commandContext).createSignalEventSubscription(); String eventName = EventDefinitionExpressionUtil.determineSignalName(commandContext, signalEventDefinition, bpmnModel, null); subscriptionEntity.setEventName(eventName); subscriptionEntity.setActivityId(startEvent.getId()); subscriptionEntity.setProcessDefinitionId(previousProcessDefinition.getId()); if (previousProcessDefinition.getTenantId() != null) { subscriptionEntity.setTenantId(previousProcessDefinition.getTenantId()); } CommandContextUtil.getEventSubscriptionService(commandContext).insertEventSubscription(subscriptionEntity); CountingEntityUtil.handleInsertEventSubscriptionEntityCount(subscriptionEntity); }
Example 3
Source File: DeploymentEntityManagerImpl.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void restoreMessageStartEvent(ProcessDefinition previousProcessDefinition, BpmnModel bpmnModel, StartEvent startEvent, EventDefinition eventDefinition) { MessageEventDefinition messageEventDefinition = (MessageEventDefinition) eventDefinition; if (bpmnModel.containsMessageId(messageEventDefinition.getMessageRef())) { Message message = bpmnModel.getMessage(messageEventDefinition.getMessageRef()); messageEventDefinition.setMessageRef(message.getName()); } CommandContext commandContext = Context.getCommandContext(); MessageEventSubscriptionEntity newSubscription = CommandContextUtil.getEventSubscriptionService(commandContext).createMessageEventSubscription(); String messageName = EventDefinitionExpressionUtil.determineMessageName(commandContext, messageEventDefinition, null); newSubscription.setEventName(messageName); newSubscription.setActivityId(startEvent.getId()); newSubscription.setConfiguration(previousProcessDefinition.getId()); newSubscription.setProcessDefinitionId(previousProcessDefinition.getId()); if (previousProcessDefinition.getTenantId() != null) { newSubscription.setTenantId(previousProcessDefinition.getTenantId()); } CommandContextUtil.getEventSubscriptionService().insertEventSubscription(newSubscription); CountingEntityUtil.handleInsertEventSubscriptionEntityCount(newSubscription); }
Example 4
Source File: DeploymentEntityManager.java From flowable-engine with Apache License 2.0 | 6 votes |
protected ProcessDefinition findNewLatestProcessDefinitionAfterRemovalOf(ProcessDefinition processDefinitionToBeRemoved) { // The latest process definition is not necessarily the one with 'version -1' (some versions could have been deleted) // Hence, the following logic ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(); query.processDefinitionKey(processDefinitionToBeRemoved.getKey()); if (processDefinitionToBeRemoved.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinitionToBeRemoved.getTenantId())) { query.processDefinitionTenantId(processDefinitionToBeRemoved.getTenantId()); } else { query.processDefinitionWithoutTenantId(); } query.processDefinitionVersionLowerThan(processDefinitionToBeRemoved.getVersion()); query.orderByProcessDefinitionVersion().desc(); List<ProcessDefinition> processDefinitions = getProcessDefinitionManager().findProcessDefinitionsByQueryCriteria(query, new Page(0, 1)); if (processDefinitions != null && processDefinitions.size() > 0) { return processDefinitions.get(0); } return null; }
Example 5
Source File: ProcessDefinitionRepresentation.java From flowable-engine with Apache License 2.0 | 5 votes |
public ProcessDefinitionRepresentation(ProcessDefinition processDefinition) { this.id = processDefinition.getId(); this.name = processDefinition.getName(); this.description = processDefinition.getDescription(); this.key = processDefinition.getKey(); this.category = processDefinition.getCategory(); this.version = processDefinition.getVersion(); this.deploymentId = processDefinition.getDeploymentId(); this.tenantId = processDefinition.getTenantId(); this.hasStartForm = processDefinition.hasStartFormKey(); }
Example 6
Source File: DeploymentEntityManagerImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
protected ProcessDefinitionEntity findLatestProcessDefinition(ProcessDefinition processDefinition) { ProcessDefinitionEntity latestProcessDefinition = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { latestProcessDefinition = getProcessDefinitionEntityManager() .findLatestProcessDefinitionByKeyAndTenantId(processDefinition.getKey(), processDefinition.getTenantId()); } else { latestProcessDefinition = getProcessDefinitionEntityManager() .findLatestProcessDefinitionByKey(processDefinition.getKey()); } return latestProcessDefinition; }
Example 7
Source File: DeploymentEntityManagerImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
protected ProcessDefinition findNewLatestProcessDefinitionAfterRemovalOf(ProcessDefinition processDefinitionToBeRemoved) { // The latest process definition is not necessarily the one with 'version -1' (some versions could have been deleted) // Hence, the following logic ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(); query.processDefinitionKey(processDefinitionToBeRemoved.getKey()); if (processDefinitionToBeRemoved.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinitionToBeRemoved.getTenantId())) { query.processDefinitionTenantId(processDefinitionToBeRemoved.getTenantId()); } else { query.processDefinitionWithoutTenantId(); } if (processDefinitionToBeRemoved.getVersion() > 0) { query.processDefinitionVersionLowerThan(processDefinitionToBeRemoved.getVersion()); } query.orderByProcessDefinitionVersion().desc(); query.setFirstResult(0); query.setMaxResults(1); List<ProcessDefinition> processDefinitions = getProcessDefinitionEntityManager().findProcessDefinitionsByQueryCriteria(query); if (processDefinitions != null && processDefinitions.size() > 0) { return processDefinitions.get(0); } return null; }
Example 8
Source File: SignalThrowingEventListener.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void onEvent(FlowableEvent event) { if (isValidEvent(event) && event instanceof FlowableEngineEvent) { FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; if (engineEvent.getProcessInstanceId() == null && processInstanceScope) { throw new FlowableIllegalArgumentException("Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance"); } CommandContext commandContext = Context.getCommandContext(); EventSubscriptionService eventSubscriptionService = CommandContextUtil.getEventSubscriptionService(commandContext); List<SignalEventSubscriptionEntity> subscriptionEntities = null; if (processInstanceScope) { subscriptionEntities = eventSubscriptionService.findSignalEventSubscriptionsByProcessInstanceAndEventName(engineEvent.getProcessInstanceId(), signalName); } else { String tenantId = null; if (engineEvent.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = CommandContextUtil.getProcessEngineConfiguration(commandContext) .getDeploymentManager() .findDeployedProcessDefinitionById(engineEvent.getProcessDefinitionId()); tenantId = processDefinition.getTenantId(); } subscriptionEntities = eventSubscriptionService.findSignalEventSubscriptionsByEventName(signalName, tenantId); } for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) { EventSubscriptionUtil.eventReceived(signalEventSubscriptionEntity, null, false); } } }
Example 9
Source File: DeploymentEntityManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected ProcessDefinitionEntity findLatestProcessDefinition(ProcessDefinition processDefinition) { ProcessDefinitionEntity latestProcessDefinition = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { latestProcessDefinition = Context.getCommandContext().getProcessDefinitionEntityManager() .findLatestProcessDefinitionByKeyAndTenantId(processDefinition.getKey(), processDefinition.getTenantId()); } else { latestProcessDefinition = Context.getCommandContext().getProcessDefinitionEntityManager() .findLatestProcessDefinitionByKey(processDefinition.getKey()); } return latestProcessDefinition; }
Example 10
Source File: SignalThrowingEventListener.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void onEvent(FlowableEvent event) { if (isValidEvent(event) && event instanceof FlowableEngineEvent) { FlowableEngineEvent engineEvent = (FlowableEngineEvent) event; if (engineEvent.getProcessInstanceId() == null && processInstanceScope) { throw new ActivitiIllegalArgumentException( "Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance"); } CommandContext commandContext = Context.getCommandContext(); List<SignalEventSubscriptionEntity> subscriptionEntities = null; if (processInstanceScope) { subscriptionEntities = commandContext.getEventSubscriptionEntityManager() .findSignalEventSubscriptionsByProcessInstanceAndEventName(engineEvent.getProcessInstanceId(), signalName); } else { String tenantId = null; if (engineEvent.getProcessDefinitionId() != null) { ProcessDefinition processDefinition = commandContext.getProcessEngineConfiguration() .getDeploymentManager().findDeployedProcessDefinitionById(engineEvent.getProcessDefinitionId()); tenantId = processDefinition.getTenantId(); } subscriptionEntities = commandContext.getEventSubscriptionEntityManager() .findSignalEventSubscriptionsByEventName(signalName, tenantId); } for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) { signalEventSubscriptionEntity.eventReceived(null, false); } } }
Example 11
Source File: TenancyTest.java From flowable-engine with Apache License 2.0 | 4 votes |
public void testGetLatestProcessDefinitionVersionForSameProcessDefinitionKey() { String tenant1 = "tenant1"; String tenant2 = "tenant2"; // Tenant 1 ==> version 4 for (int i = 0; i < 4; i++) { deployTestProcessWithTestTenant(tenant1); } // Tenant 2 ==> version 2 for (int i = 0; i < 2; i++) { deployTestProcessWithTestTenant(tenant2); } // No tenant ==> version 3 for (int i = 0; i < 3; i++) { deployTestProcessWithTwoTasksNoTenant(); } ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionTenantId(tenant1) .latestVersion() .singleResult(); assertEquals(4, processDefinition.getVersion()); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionTenantId(tenant2) .latestVersion() .singleResult(); assertEquals(2, processDefinition.getVersion()); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionWithoutTenantId() .latestVersion() .singleResult(); assertEquals(3, processDefinition.getVersion()); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().latestVersion().list(); assertEquals(3, processDefinitions.size()); // Verify they have different tenant ids int tenant1Count = 0; int tenant2Count = 0; int noTenantCount = 0; for (ProcessDefinition p : processDefinitions) { if (p.getTenantId() == null || p.getTenantId().equals(ProcessEngineConfiguration.NO_TENANT_ID)) { noTenantCount++; } else if (p.getTenantId().equals(tenant1)) { tenant1Count++; } else if (p.getTenantId().equals(tenant2)) { tenant2Count++; } } assertEquals(1, tenant1Count); assertEquals(1, tenant2Count); assertEquals(1, noTenantCount); }
Example 12
Source File: TenancyTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void testGetLatestProcessDefinitionVersionForSameProcessDefinitionKey() { String tenant1 = "tenant1"; String tenant2 = "tenant2"; // Tenant 1 ==> version 4 for (int i = 0; i < 4; i++) { deployTestProcessWithTestTenant(tenant1); } // Tenant 2 ==> version 2 for (int i = 0; i < 2; i++) { deployTestProcessWithTestTenant(tenant2); } // No tenant ==> version 3 for (int i = 0; i < 3; i++) { deployTestProcessWithTwoTasksNoTenant(); } ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionTenantId(tenant1) .latestVersion() .singleResult(); assertThat(processDefinition.getVersion()).isEqualTo(4); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionTenantId(tenant2) .latestVersion() .singleResult(); assertThat(processDefinition.getVersion()).isEqualTo(2); processDefinition = repositoryService.createProcessDefinitionQuery() .processDefinitionWithoutTenantId() .latestVersion() .singleResult(); assertThat(processDefinition.getVersion()).isEqualTo(3); List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().latestVersion().list(); assertThat(processDefinitions).hasSize(3); // Verify they have different tenant ids int tenant1Count = 0; int tenant2Count = 0; int noTenantCount = 0; for (ProcessDefinition p : processDefinitions) { if (p.getTenantId() == null || p.getTenantId().equals(ProcessEngineConfiguration.NO_TENANT_ID)) { noTenantCount++; } else if (p.getTenantId().equals(tenant1)) { tenant1Count++; } else if (p.getTenantId().equals(tenant2)) { tenant2Count++; } } assertThat(tenant1Count).isEqualTo(1); assertThat(tenant2Count).isEqualTo(1); assertThat(noTenantCount).isEqualTo(1); }