Search in sources :

Example 1 with ActivitiResourceMapper

use of io.crnk.data.activiti.mapper.ActivitiResourceMapper in project crnk-framework by crnk-project.

the class ActivitiModule method setupModule.

@Override
public void setupModule(ModuleContext context) {
    this.moduleContext = context;
    TaskService taskService = processEngine.getTaskService();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    FormService formService = processEngine.getFormService();
    resourceMapper = new ActivitiResourceMapper(context.getTypeParser(), config.getDateTimeMapper());
    HistoryService historyService = processEngine.getHistoryService();
    for (ProcessInstanceConfig processInstanceConfig : config.getProcessInstances().values()) {
        context.addRepository(new ProcessInstanceResourceRepository(runtimeService, historyService, resourceMapper, processInstanceConfig.getProcessInstanceClass(), processInstanceConfig.getBaseFilters()));
        Class<? extends HistoricProcessInstanceResource> historyClass = processInstanceConfig.getHistoryClass();
        if (historyClass != null) {
            context.addRepository(new HistoricProcessInstanceResourceRepository(historyService, resourceMapper, historyClass, processInstanceConfig.getBaseFilters()));
        }
        for (ProcessInstanceConfig.TaskRelationshipConfig taskRel : processInstanceConfig.getTaskRelationships().values()) {
            context.addRepository(new TaskRelationshipRepository(processInstanceConfig.getProcessInstanceClass(), taskRel.getTaskClass(), taskRel.getRelationshipName(), taskRel.getTaskDefinitionKey()));
        }
    }
    for (TaskRepositoryConfig taskConfig : config.getTasks().values()) {
        context.addRepository(new TaskResourceRepository(taskService, resourceMapper, taskConfig.getTaskClass(), taskConfig.getBaseFilters()));
        Class<? extends TaskResource> historyClass = taskConfig.getHistoryClass();
        if (historyClass != null) {
            context.addRepository(new HistoricTaskResourceRepository(historyService, resourceMapper, historyClass, taskConfig.getBaseFilters()));
        }
        Class<? extends FormResource> formClass = taskConfig.getFormClass();
        if (formClass != null) {
            context.addRepository(new FormResourceRepository(formService, taskService, resourceMapper, formClass));
        }
    }
    context.addRepository(new FormRelationshipRepository());
}
Also used : HistoricProcessInstanceResourceRepository(io.crnk.data.activiti.internal.repository.HistoricProcessInstanceResourceRepository) RuntimeService(org.activiti.engine.RuntimeService) ActivitiResourceMapper(io.crnk.data.activiti.mapper.ActivitiResourceMapper) TaskService(org.activiti.engine.TaskService) FormService(org.activiti.engine.FormService) HistoryService(org.activiti.engine.HistoryService) HistoricProcessInstanceResourceRepository(io.crnk.data.activiti.internal.repository.HistoricProcessInstanceResourceRepository) ProcessInstanceResourceRepository(io.crnk.data.activiti.internal.repository.ProcessInstanceResourceRepository) HistoricTaskResourceRepository(io.crnk.data.activiti.internal.repository.HistoricTaskResourceRepository) TaskResourceRepository(io.crnk.data.activiti.internal.repository.TaskResourceRepository) HistoricTaskResourceRepository(io.crnk.data.activiti.internal.repository.HistoricTaskResourceRepository) FormResourceRepository(io.crnk.data.activiti.internal.repository.FormResourceRepository) FormRelationshipRepository(io.crnk.data.activiti.internal.repository.FormRelationshipRepository) TaskRelationshipRepository(io.crnk.data.activiti.internal.repository.TaskRelationshipRepository)

Example 2 with ActivitiResourceMapper

use of io.crnk.data.activiti.mapper.ActivitiResourceMapper in project crnk-framework by crnk-project.

the class ApprovalManagerTest method setup.

@Before
public void setup() {
    runtimeService = Mockito.mock(RuntimeService.class);
    TaskService taskService = Mockito.mock(TaskService.class);
    repositoryFacade = Mockito.mock(ResourceRepository.class);
    ApprovalMapper approvalMapper = new ApprovalMapper();
    ActivitiResourceMapper resourceMapper = new ActivitiResourceMapper(new TypeParser(), new DefaultDateTimeMapper());
    ResourceInformation information = Mockito.mock(ResourceInformation.class);
    registryEntry = Mockito.mock(RegistryEntry.class);
    ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
    Mockito.when(registryEntry.getResourceInformation()).thenReturn(information);
    Mockito.when(registryEntry.getResourceRepositoryFacade()).thenReturn(repositoryFacade);
    Mockito.when(information.getResourceType()).thenReturn("schedule");
    Mockito.when(information.getId(Mockito.any())).thenReturn(mockId);
    Mockito.when(resourceRegistry.getEntry(Mockito.any(Class.class))).thenReturn(registryEntry);
    Mockito.when(resourceRegistry.getEntry(Mockito.any(String.class))).thenReturn(registryEntry);
    ModuleRegistry moduleRegistry = Mockito.mock(ModuleRegistry.class);
    Mockito.when(moduleRegistry.getResourceRegistry()).thenReturn(resourceRegistry);
    originalResource = new Schedule();
    originalResource.setId(mockId);
    originalResource.setName("Jane");
    Mockito.when(repositoryFacade.findOne(Mockito.any(Long.class), Mockito.any(QuerySpec.class))).thenReturn(originalResource);
    manager = new ApprovalManager();
    manager.init(runtimeService, taskService, resourceMapper, approvalMapper, moduleRegistry);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) TypeParser(io.crnk.core.engine.parser.TypeParser) RuntimeService(org.activiti.engine.RuntimeService) ActivitiResourceMapper(io.crnk.data.activiti.mapper.ActivitiResourceMapper) TaskService(org.activiti.engine.TaskService) DefaultDateTimeMapper(io.crnk.data.activiti.mapper.DefaultDateTimeMapper) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) ApprovalManager(io.crnk.data.activiti.example.approval.ApprovalManager) Schedule(io.crnk.test.mock.models.Schedule) ResourceRepository(io.crnk.core.repository.ResourceRepository) QuerySpec(io.crnk.core.queryspec.QuerySpec) ApprovalMapper(io.crnk.data.activiti.example.approval.ApprovalMapper) Before(org.junit.Before)

Aggregations

ActivitiResourceMapper (io.crnk.data.activiti.mapper.ActivitiResourceMapper)2 RuntimeService (org.activiti.engine.RuntimeService)2 TaskService (org.activiti.engine.TaskService)2 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 TypeParser (io.crnk.core.engine.parser.TypeParser)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 QuerySpec (io.crnk.core.queryspec.QuerySpec)1 ResourceRepository (io.crnk.core.repository.ResourceRepository)1 ApprovalManager (io.crnk.data.activiti.example.approval.ApprovalManager)1 ApprovalMapper (io.crnk.data.activiti.example.approval.ApprovalMapper)1 FormRelationshipRepository (io.crnk.data.activiti.internal.repository.FormRelationshipRepository)1 FormResourceRepository (io.crnk.data.activiti.internal.repository.FormResourceRepository)1 HistoricProcessInstanceResourceRepository (io.crnk.data.activiti.internal.repository.HistoricProcessInstanceResourceRepository)1 HistoricTaskResourceRepository (io.crnk.data.activiti.internal.repository.HistoricTaskResourceRepository)1 ProcessInstanceResourceRepository (io.crnk.data.activiti.internal.repository.ProcessInstanceResourceRepository)1 TaskRelationshipRepository (io.crnk.data.activiti.internal.repository.TaskRelationshipRepository)1 TaskResourceRepository (io.crnk.data.activiti.internal.repository.TaskResourceRepository)1 DefaultDateTimeMapper (io.crnk.data.activiti.mapper.DefaultDateTimeMapper)1