use of org.kie.workbench.common.services.datamodeller.driver.ModelDriver in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method loadModel.
private Pair<DataModel, ModelDriverResult> loadModel(final KieModule module, boolean processErrors) {
if (logger.isDebugEnabled()) {
logger.debug("Loading data model from path: " + module.getRootPath());
}
Long startTime = System.currentTimeMillis();
DataModel dataModel = null;
Path modulePath = null;
Package defaultPackage = null;
try {
modulePath = module.getRootPath();
defaultPackage = moduleService.resolveDefaultPackage(module);
if (logger.isDebugEnabled()) {
logger.debug("Current module path is: " + modulePath);
}
ClassLoader classLoader = classLoaderHelper.getModuleClassLoader(module);
ModelDriver modelDriver = new JavaRoasterModelDriver(ioService, Paths.convert(defaultPackage.getPackageMainSrcPath()), classLoader, filterHolder);
ModelDriverResult result = modelDriver.loadModel();
dataModel = result.getDataModel();
if (processErrors && result.hasErrors()) {
processErrors(module, result);
}
// by now we still use the DMO to calculate module external dependencies.
ModuleDataModelOracle moduleDataModelOracle = dataModelService.getModuleDataModel(modulePath);
ModuleDataModelOracleUtils.loadExternalDependencies(dataModel, moduleDataModelOracle, classLoader);
Long endTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("Time elapsed when loading " + modulePath.getFileName() + ": " + (endTime - startTime) + " ms");
}
return new Pair<DataModel, ModelDriverResult>(dataModel, result);
} catch (Exception e) {
logger.error("Data model couldn't be loaded, path: " + modulePath + ", modulePath: " + modulePath + ".", e);
throw new ServiceException("Data model couldn't be loaded, path: " + modulePath + ", modulePath: " + modulePath + ".", e);
}
}
Aggregations