Search in sources :

Example 1 with AdvanceCaseRuntimeDataService

use of org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService in project droolsjbpm-integration by kiegroup.

the class CaseKieServerExtension method configureServices.

protected void configureServices(KieServerImpl kieServer, KieServerRegistry registry) {
    KieServerExtension jbpmExtension = registry.getServerExtension("jBPM");
    List<Object> jbpmServices = jbpmExtension.getServices();
    RuntimeDataService runtimeDataService = null;
    ProcessService processService = null;
    DeploymentService deploymentService = null;
    ProcessInstanceMigrationService processInstanceMigrationService = null;
    for (Object object : jbpmServices) {
        // in case given service is null (meaning was not configured) continue with next one
        if (object == null) {
            continue;
        }
        if (RuntimeDataService.class.isAssignableFrom(object.getClass())) {
            runtimeDataService = (RuntimeDataService) object;
            continue;
        } else if (ProcessService.class.isAssignableFrom(object.getClass())) {
            processService = (ProcessService) object;
            continue;
        } else if (DeploymentService.class.isAssignableFrom(object.getClass())) {
            deploymentService = (DeploymentService) object;
            continue;
        } else if (ProcessInstanceMigrationService.class.isAssignableFrom(object.getClass())) {
            processInstanceMigrationService = (ProcessInstanceMigrationService) object;
            continue;
        }
    }
    CaseIdGenerator caseIdGenerator = getCaseIdGenerator();
    EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName);
    // build case runtime data service
    caseRuntimeDataService = new CaseRuntimeDataServiceImpl();
    ((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setCaseIdGenerator(caseIdGenerator);
    ((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setRuntimeDataService(runtimeDataService);
    ((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setCommandService(new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName)));
    ((CaseRuntimeDataServiceImpl) caseRuntimeDataService).setIdentityProvider(registry.getIdentityProvider());
    // build case service
    CaseServiceImpl caseService = new CaseServiceImpl();
    ((CaseServiceImpl) caseService).setCaseIdGenerator(caseIdGenerator);
    ((CaseServiceImpl) caseService).setCaseRuntimeDataService(caseRuntimeDataService);
    ((CaseServiceImpl) caseService).setProcessService(processService);
    ((CaseServiceImpl) caseService).setDeploymentService(deploymentService);
    ((CaseServiceImpl) caseService).setRuntimeDataService(runtimeDataService);
    ((CaseServiceImpl) caseService).setCommandService(new TransactionalCommandService(emf));
    ((CaseServiceImpl) caseService).setAuthorizationManager(new AuthorizationManagerImpl(registry.getIdentityProvider(), new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName))));
    ((CaseServiceImpl) caseService).setIdentityProvider(registry.getIdentityProvider());
    // build case configuration on deployment listener
    CaseConfigurationDeploymentListener configurationListener = new CaseConfigurationDeploymentListener(registry.getIdentityProvider());
    // configure case mgmt services as listeners
    ((KModuleDeploymentService) deploymentService).addListener((CaseRuntimeDataServiceImpl) caseRuntimeDataService);
    ((KModuleDeploymentService) deploymentService).addListener(configurationListener);
    CaseInstanceMigrationService caseInstanceMigrationService = new CaseInstanceMigrationServiceImpl();
    ((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setCaseRuntimeDataService(caseRuntimeDataService);
    ((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setCommandService(new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(persistenceUnitName)));
    ((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setProcessInstanceMigrationService(processInstanceMigrationService);
    ((CaseInstanceMigrationServiceImpl) caseInstanceMigrationService).setProcessService(processService);
    advanceCaseRuntimeDataService = new AdvanceCaseRuntimeDataServiceImpl();
    ((AdvanceCaseRuntimeDataServiceImpl) advanceCaseRuntimeDataService).setEmf(emf);
    ((AdvanceCaseRuntimeDataServiceImpl) advanceCaseRuntimeDataService).setCommandService(new TransactionalCommandService(emf));
    this.caseManagementServiceBase = new CaseManagementServiceBase(caseService, caseRuntimeDataService, registry);
    this.caseManagementRuntimeDataService = new CaseManagementRuntimeDataServiceBase(caseRuntimeDataService, advanceCaseRuntimeDataService, registry);
    this.caseAdminServiceBase = new CaseAdminServiceBase(caseInstanceMigrationService, registry);
}
Also used : CaseRuntimeDataService(org.jbpm.casemgmt.api.CaseRuntimeDataService) AdvanceCaseRuntimeDataService(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService) RuntimeDataService(org.jbpm.services.api.RuntimeDataService) CaseConfigurationDeploymentListener(org.jbpm.casemgmt.impl.event.CaseConfigurationDeploymentListener) KieServerExtension(org.kie.server.services.api.KieServerExtension) CaseInstanceMigrationService(org.jbpm.casemgmt.api.admin.CaseInstanceMigrationService) CaseInstanceMigrationServiceImpl(org.jbpm.casemgmt.impl.admin.CaseInstanceMigrationServiceImpl) AdvanceCaseRuntimeDataServiceImpl(org.jbpm.casemgmt.impl.AdvanceCaseRuntimeDataServiceImpl) KModuleDeploymentService(org.jbpm.kie.services.impl.KModuleDeploymentService) TableCaseIdGenerator(org.jbpm.casemgmt.impl.generator.TableCaseIdGenerator) CaseIdGenerator(org.jbpm.casemgmt.api.generator.CaseIdGenerator) EntityManagerFactory(javax.persistence.EntityManagerFactory) DeploymentService(org.jbpm.services.api.DeploymentService) KModuleDeploymentService(org.jbpm.kie.services.impl.KModuleDeploymentService) ProcessInstanceMigrationService(org.jbpm.services.api.admin.ProcessInstanceMigrationService) TransactionalCommandService(org.jbpm.shared.services.impl.TransactionalCommandService) CaseServiceImpl(org.jbpm.casemgmt.impl.CaseServiceImpl) AdvanceCaseRuntimeDataServiceImpl(org.jbpm.casemgmt.impl.AdvanceCaseRuntimeDataServiceImpl) CaseRuntimeDataServiceImpl(org.jbpm.casemgmt.impl.CaseRuntimeDataServiceImpl) ProcessService(org.jbpm.services.api.ProcessService) AuthorizationManagerImpl(org.jbpm.casemgmt.impl.AuthorizationManagerImpl)

Aggregations

EntityManagerFactory (javax.persistence.EntityManagerFactory)1 AdvanceCaseRuntimeDataService (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService)1 CaseRuntimeDataService (org.jbpm.casemgmt.api.CaseRuntimeDataService)1 CaseInstanceMigrationService (org.jbpm.casemgmt.api.admin.CaseInstanceMigrationService)1 CaseIdGenerator (org.jbpm.casemgmt.api.generator.CaseIdGenerator)1 AdvanceCaseRuntimeDataServiceImpl (org.jbpm.casemgmt.impl.AdvanceCaseRuntimeDataServiceImpl)1 AuthorizationManagerImpl (org.jbpm.casemgmt.impl.AuthorizationManagerImpl)1 CaseRuntimeDataServiceImpl (org.jbpm.casemgmt.impl.CaseRuntimeDataServiceImpl)1 CaseServiceImpl (org.jbpm.casemgmt.impl.CaseServiceImpl)1 CaseInstanceMigrationServiceImpl (org.jbpm.casemgmt.impl.admin.CaseInstanceMigrationServiceImpl)1 CaseConfigurationDeploymentListener (org.jbpm.casemgmt.impl.event.CaseConfigurationDeploymentListener)1 TableCaseIdGenerator (org.jbpm.casemgmt.impl.generator.TableCaseIdGenerator)1 KModuleDeploymentService (org.jbpm.kie.services.impl.KModuleDeploymentService)1 DeploymentService (org.jbpm.services.api.DeploymentService)1 ProcessService (org.jbpm.services.api.ProcessService)1 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)1 ProcessInstanceMigrationService (org.jbpm.services.api.admin.ProcessInstanceMigrationService)1 TransactionalCommandService (org.jbpm.shared.services.impl.TransactionalCommandService)1 KieServerExtension (org.kie.server.services.api.KieServerExtension)1