Search in sources :

Example 1 with IOService

use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.

the class BPMFinderServiceImpl method scannProcessesForType.

protected void scannProcessesForType(final Path path, final String extension, final GenerationConfig generationConfig) {
    List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
    nioPaths.add(Paths.convert(path));
    Collection<FileUtils.ScanResult> processes = fileUtils.scan(ioService, nioPaths, extension, true);
    processes.stream().map(scanResult -> parse(scanResult)).filter(definitions -> definitions != null && generationConfig.getPredicate().test(definitions)).forEach(definitions -> {
        BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions.get(), path);
        List<TaskFormModel> taskModels = bpmnFormModelGenerator.generateTaskFormModels(definitions.get(), path);
        generationConfig.getConsumer().accept(new JBPMProcessModel(processFormModel, taskModels));
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) URI(org.eclipse.emf.common.util.URI) BPMFinderService(org.kie.workbench.common.forms.jbpm.service.shared.BPMFinderService) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) Paths(org.uberfire.backend.server.util.Paths) Inject(javax.inject.Inject) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) Service(org.jboss.errai.bus.server.annotations.Service) Named(javax.inject.Named) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl) FileUtils(org.kie.workbench.common.services.datamodeller.util.FileUtils) Process(org.eclipse.bpmn2.Process) Logger(org.slf4j.Logger) DroolsPackage(org.jboss.drools.DroolsPackage) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) Predicate(java.util.function.Predicate) Collection(java.util.Collection) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Consumer(java.util.function.Consumer) List(java.util.List) Dependent(javax.enterprise.context.Dependent) PostConstruct(javax.annotation.PostConstruct) Bpmn2ResourceFactoryImpl(org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl) Resource(org.eclipse.emf.ecore.resource.Resource) IOService(org.uberfire.io.IOService) Optional(java.util.Optional) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) Bpmn2Package(org.eclipse.bpmn2.Bpmn2Package) JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)

Example 2 with IOService

use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method init.

@Before
public void init() {
    formModelHandlerManager = new TestFormModelHandlerManager(moduleService, moduleClassLoaderHelper, fieldManager, finderService);
    when(pathModelReaderService.getModelReader(any())).thenReturn(new RuntimeDMOModelReader(moduleClassLoader, new RawMVELEvaluator()));
    when(formFinderService.findFormsForType(anyString(), any())).then((Answer<List<FormDefinition>>) invocationOnMock -> {
        String type = invocationOnMock.getArguments()[0].toString();
        return Collections.singletonList(readFormDefinitionForType(type));
    });
    service = new BPMNVFSFormDefinitionGeneratorService(fieldManager, pathModelReaderService, formModelHandlerManager, formFinderService, formSerializer, ioService, commentedOptionFactory, formModelSynchronizationUtil);
    when(moduleService.resolveModule(any())).thenReturn(module);
    when(moduleClassLoaderHelper.getModuleClassLoader(any())).thenReturn(moduleClassLoader);
    generator = new BPMNFormModelGeneratorImpl(moduleService, moduleClassLoaderHelper);
    final Path rootPathWithNestedForms = PathFactory.newPath(DATA_OBJECTS_FOLDER, getUriOfResource(PREPARED_NESTED_FORMS_FOLDER));
    ;
    processFormModel = generator.generateProcessFormModel(formGenerationProcessDefinitions, rootPathWithNestedForms);
    taskFormModels = generator.generateTaskFormModels(formGenerationProcessDefinitions, rootPathWithNestedForms);
}
Also used : ModelFinderService(org.kie.workbench.common.forms.data.modeller.service.shared.ModelFinderService) Arrays(java.util.Arrays) DocumentFieldType(org.kie.workbench.common.forms.jbpm.model.authoring.document.type.DocumentFieldType) ModuleClassLoaderHelper(org.kie.workbench.common.services.backend.project.ModuleClassLoaderHelper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) FormDefinitionSerializer(org.kie.workbench.common.forms.services.backend.serialization.FormDefinitionSerializer) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) PathFactory(org.uberfire.backend.vfs.PathFactory) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) FieldManager(org.kie.workbench.common.forms.service.shared.FieldManager) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleFormFinderService(org.kie.workbench.common.forms.editor.service.shared.ModuleFormFinderService) SubFormFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.type.SubFormFieldType) KieModule(org.kie.workbench.common.services.shared.project.KieModule) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) Collectors(java.util.stream.Collectors) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Stream(java.util.stream.Stream) ModelReaderService(org.kie.workbench.common.forms.data.modeller.service.ext.ModelReaderService) FormModelPropertiesUtil(org.kie.workbench.common.forms.model.util.formModel.FormModelPropertiesUtil) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) MultipleSubFormFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.type.MultipleSubFormFieldType) IntegerBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.type.IntegerBoxFieldType) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) DatePickerFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.type.DatePickerFieldType) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Iterables(com.google.common.collect.Iterables) BeforeClass(org.junit.BeforeClass) FormGenerationTest_NestedObject(org.kie.workbench.common.forms.integration.tests.formgeneration.model.FormGenerationTest_NestedObject) DecimalBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.type.DecimalBoxFieldType) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) FormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.FormLayoutTemplateGenerator) AbstractJBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.AbstractJBPMFormModel) TextBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.type.TextBoxFieldType) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) TextAreaFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.type.TextAreaFieldType) Answer(org.mockito.stubbing.Answer) Charset(java.nio.charset.Charset) CommentedOptionFactory(org.guvnor.common.services.backend.util.CommentedOptionFactory) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) LayoutRow(org.uberfire.ext.layout.editor.api.editor.LayoutRow) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) IOServiceDotFileImpl(org.uberfire.io.impl.IOServiceDotFileImpl) DocumentFieldProvider(org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider) Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) Before(org.junit.Before) TestUtils(org.kie.workbench.common.forms.integration.tests.TestUtils) AbstractBPMNFormGeneratorService.generateNestedFormName(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.AbstractBPMNFormGeneratorService.generateNestedFormName) CheckBoxFieldType(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.type.CheckBoxFieldType) FormModelSynchronizationUtil(org.kie.workbench.common.forms.editor.service.shared.model.FormModelSynchronizationUtil) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) FormGenerationTest_DataObject(org.kie.workbench.common.forms.integration.tests.formgeneration.model.FormGenerationTest_DataObject) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) IOService(org.uberfire.io.IOService) DOCUMENT_TYPE(org.kie.workbench.common.forms.jbpm.model.authoring.document.type.DocumentFieldType.DOCUMENT_TYPE) SyncBeanManager(org.jboss.errai.ioc.client.container.SyncBeanManager) Collections(java.util.Collections) RuntimeDMOModelReader(org.kie.workbench.common.forms.data.modeller.service.impl.ext.dmo.runtime.RuntimeDMOModelReader) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Path(org.uberfire.backend.vfs.Path) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) TestFormModelHandlerManager(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.test.TestFormModelHandlerManager) List(java.util.List) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) RuntimeDMOModelReader(org.kie.workbench.common.forms.data.modeller.service.impl.ext.dmo.runtime.RuntimeDMOModelReader) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Before(org.junit.Before)

Example 3 with IOService

use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.

the class MigrationConfigurationServiceImplTest method mockIoService.

private IOService mockIoService() {
    final IOService ioService = spy(fileSystemTestingUtils.getIoService());
    doNothing().when(ioService).startBatch(any(FileSystem.class));
    doNothing().when(ioService).endBatch();
    doReturn(fileSystemTestingUtils.getFileSystem()).when(ioService).newFileSystem(any(URI.class), anyMap());
    return ioService;
}
Also used : IOService(org.uberfire.io.IOService) FileSystem(org.uberfire.java.nio.file.FileSystem) URI(java.net.URI)

Example 4 with IOService

use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.

the class PomMigrationTool method systemMigrationWasExecuted.

private boolean systemMigrationWasExecuted(MigrationServicesCDIWrapper cdiWrapper) {
    if (!systemMigrationCheck) {
        systemMigrationCheck = true;
        final IOService systemIoService = cdiWrapper.getSystemIoService();
        final Repository systemRepository = cdiWrapper.getSystemRepository();
        if (!systemIoService.exists(systemIoService.get(systemRepository.getUri()).resolve("spaces"))) {
            system.err().println(String.format("The SYSTEM CONFIGURATION DIRECTORY STRUCTURE MIGRATION must be ran before this one."));
            return false;
        }
        return true;
    } else {
        return true;
    }
}
Also used : Repository(org.guvnor.structure.repositories.Repository) IOService(org.uberfire.io.IOService)

Example 5 with IOService

use of org.uberfire.io.IOService in project kie-wb-common by kiegroup.

the class ImpactAnalysisJavaFileTest method setupForThisTest.

@Before
public void setupForThisTest() throws Exception {
    // setup
    IOService ioService = ioService();
    // Get this class location
    String fileName = this.getClass().getSimpleName() + ".java";
    String fileLoc = getLocationOfTestClass(fileName);
    // Add this class to the repository/index
    Path path = basePath.resolve(fileName);
    String javaSourceText = loadText(fileLoc);
    ioService.write(path, javaSourceText);
    // Get test java file indexer class location
    fileName = TestJavaFileIndexer.class.getSimpleName() + ".java";
    fileLoc = getLocationOfTestClass(fileName);
    // create new branch
    String randomBranchName = UUID.randomUUID().toString();
    randomBranchName = randomBranchName.substring(0, randomBranchName.indexOf("-"));
    final Path source = ioService.get(URI.create("git://master@" + getRepositoryName()));
    final Path target = ioService.get(URI.create("git://" + randomBranchName + "@" + getRepositoryName()));
    ioService.copy(source, target);
    // Add this class to the repository/index
    final Path branchedBasePath = ioService.get(URI.create("git://" + randomBranchName + "@" + getRepositoryName() + "/_someDir" + seed));
    path = branchedBasePath.resolve(fileName);
    javaSourceText = loadText(fileLoc);
    ioService.write(path, javaSourceText);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
}
Also used : Path(org.uberfire.java.nio.file.Path) IOService(org.uberfire.io.IOService) Before(org.junit.Before)

Aggregations

IOService (org.uberfire.io.IOService)25 Before (org.junit.Before)18 Test (org.junit.Test)15 IOException (java.io.IOException)14 Mock (org.mockito.Mock)14 RunWith (org.junit.runner.RunWith)13 List (java.util.List)12 Paths (org.uberfire.backend.server.util.Paths)12 Mockito (org.mockito.Mockito)11 Path (org.uberfire.backend.vfs.Path)11 File (java.io.File)10 InputStream (java.io.InputStream)10 ArrayList (java.util.ArrayList)10 Collections (java.util.Collections)10 URI (java.net.URI)9 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)9 Logger (org.slf4j.Logger)9 Path (org.uberfire.java.nio.file.Path)9 Arrays (java.util.Arrays)8 LoggerFactory (org.slf4j.LoggerFactory)8