Search in sources :

Example 1 with DataEnumLoader

use of org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader in project drools-wb by kiegroup.

the class EnumFileIndexer method fillIndexBuilder.

@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
    final String enumDefinition = ioService.readAllString(path);
    final DataEnumLoader enumLoader = new DataEnumLoader(enumDefinition, mvelEvaluator);
    if (enumLoader.hasErrors()) {
        logger.info("Unable to index '" + path.toUri().toString() + "'. Related errors follow:");
        for (String e : enumLoader.getErrors()) {
            logger.info(e);
        }
    }
    final ModuleDataModelOracle dmo = getModuleDataModelOracle(path);
    final DefaultIndexBuilder builder = getIndexBuilder(path);
    if (builder == null) {
        return null;
    }
    final EnumIndexVisitor visitor = new EnumIndexVisitor(dmo, path, enumLoader);
    visitor.visit();
    addReferencedResourcesToIndexBuilder(builder, visitor);
    return builder;
}
Also used : ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) DefaultIndexBuilder(org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder) DataEnumLoader(org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader)

Example 2 with DataEnumLoader

use of org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader in project drools-wb by kiegroup.

the class EnumServiceImpl method doValidation.

private List<ValidationMessage> doValidation(final Path path, final String content) {
    try {
        final KieModule module = moduleService.resolveModule(path);
        final org.kie.api.builder.KieModule kieModule = buildInfoService.getBuildInfo(module).getKieModuleIgnoringErrors();
        final ClassLoader classLoader = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule).getClassLoader();
        final DataEnumLoader loader = new DataEnumLoader(content, classLoader, evaluator);
        if (!loader.hasErrors()) {
            return Collections.emptyList();
        } else {
            final List<ValidationMessage> validationMessages = new ArrayList<>();
            final List<String> loaderErrors = loader.getErrors();
            for (final String message : loaderErrors) {
                validationMessages.add(makeValidationMessages(path, message));
            }
            return validationMessages;
        }
    } catch (Exception e) {
        throw ExceptionUtilities.handleException(e);
    }
}
Also used : ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) ArrayList(java.util.ArrayList) DataEnumLoader(org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader) KieModule(org.kie.workbench.common.services.shared.project.KieModule) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Aggregations

DataEnumLoader (org.kie.workbench.common.services.datamodel.backend.server.builder.util.DataEnumLoader)2 ArrayList (java.util.ArrayList)1 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 DefaultIndexBuilder (org.kie.workbench.common.services.refactoring.backend.server.indexing.DefaultIndexBuilder)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)1