Search in sources :

Example 1 with FileUtils

use of org.kie.workbench.common.services.datamodeller.util.FileUtils in project kie-wb-common by kiegroup.

the class VFSFormFinderServiceImpl method findForms.

private List<FormDefinition> findForms(final Path path, final FormSearchConstraint constraint) {
    List<FormDefinition> result = new ArrayList<>();
    Module module = moduleService.resolveModule(path);
    FileUtils utils = FileUtils.getInstance();
    List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
    nioPaths.add(Paths.convert(module.getRootPath()));
    Collection<FileUtils.ScanResult> forms = utils.scan(ioService, nioPaths, FormResourceTypeDefinition.EXTENSION, true);
    for (FileUtils.ScanResult form : forms) {
        org.uberfire.java.nio.file.Path formPath = form.getFile();
        try {
            FormDefinition formDefinition = serializer.deserialize(ioService.readAllString(formPath).trim());
            if (constraint == null || constraint.accepts(formDefinition)) {
                result.add(formDefinition);
            }
        } catch (Exception ex) {
            logger.warn("Unable to generate FormDefinition for {}", path, ex);
        }
    }
    return result;
}
Also used : Path(org.uberfire.backend.vfs.Path) FileUtils(org.kie.workbench.common.services.datamodeller.util.FileUtils) ArrayList(java.util.ArrayList) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Module(org.guvnor.common.services.project.model.Module)

Aggregations

ArrayList (java.util.ArrayList)1 Module (org.guvnor.common.services.project.model.Module)1 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)1 FileUtils (org.kie.workbench.common.services.datamodeller.util.FileUtils)1 Path (org.uberfire.backend.vfs.Path)1