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;
}
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);
}
}
Aggregations