Search in sources :

Example 1 with ModelDriver

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);
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) DataModel(org.kie.workbench.common.services.datamodeller.core.DataModel) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ModelDriver(org.kie.workbench.common.services.datamodeller.driver.ModelDriver) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) Package(org.guvnor.common.services.project.model.Package) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ModelDriverException(org.kie.workbench.common.services.datamodeller.driver.ModelDriverException) ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException) Pair(org.uberfire.commons.data.Pair)

Aggregations

Package (org.guvnor.common.services.project.model.Package)1 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)1 ServiceException (org.kie.workbench.common.screens.datamodeller.service.ServiceException)1 DataModel (org.kie.workbench.common.services.datamodeller.core.DataModel)1 ModelDriver (org.kie.workbench.common.services.datamodeller.driver.ModelDriver)1 ModelDriverException (org.kie.workbench.common.services.datamodeller.driver.ModelDriverException)1 JavaRoasterModelDriver (org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver)1 ModelDriverResult (org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult)1 Path (org.uberfire.backend.vfs.Path)1 Pair (org.uberfire.commons.data.Pair)1 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)1