Search in sources :

Example 1 with ProjectLoadException

use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2 method loadModules.

public static List<Project> loadModules(Project application, ProcessController logger, LoadContext loadContext) throws ProjectLoadException {
    List<Project> result = new ArrayList<>();
    for (Module module : application.getModules()) {
        if (containsModule(module.getName())) {
            Project moduleProject = modulesMap.get(module.getName());
            result.add(moduleProject);
        } else {
            throw new RuntimeException("Module project not found " + module.getName());
        }
    }
    // todo ????? topological sort?
    result.sort((o1, o2) -> {
        if (o1.getModules().contains(o2.getName()))
            return 1;
        if (o2.getModules().contains(o1.getName()))
            return -1;
        return 0;
    });
    return result;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) ArrayList(java.util.ArrayList) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 2 with ProjectLoadException

use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.

the class Be5Mojo method init.

// /////////////////////////////////////////////////////////////////
public void init() throws MojoFailureException {
    long startTime = System.nanoTime();
    initLogging();
    if (be5Project == null) {
        if (projectPath == null)
            throw new MojoFailureException("Please specify projectPath attribute");
        getLog().info("Reading be5 project from '" + projectPath + "'...");
        be5Project = loadProject(projectPath.toPath());
        if (debug) {
            be5Project.setDebugStream(System.err);
        }
        try {
            ModuleLoader2.mergeModules(be5Project, logger);
        } catch (ProjectLoadException e) {
            e.printStackTrace();
            throw new MojoFailureException(e.getMessage());
        }
    }
    if (connectionProfileName != null) {
        be5Project.setConnectionProfileName(connectionProfileName);
    }
    BeConnectionProfile profile = be5Project.getConnectionProfile();
    if (profile != null) {
        this.be5Project.setDatabaseSystem(Rdbms.getRdbms(profile.getConnectionUrl()));
        this.connector = new SimpleConnector(Rdbms.getRdbms(profile.getConnectionUrl()).getType(), profile.getConnectionUrl(), profile.getUsername(), connectionPassword != null ? connectionPassword : profile.getPassword());
        getLog().info("Using connection " + DatabaseUtils.formatUrl(profile.getConnectionUrl(), profile.getUsername(), "xxxxx"));
    } else {
        throw new MojoFailureException("Please specify connection profile: create " + be5Project.getProjectFileStructure().getSelectedProfileFile() + " file with profile name or use -DBE5_PROFILE=...");
    }
    getLog().info(ModuleLoader2.logLoadedProject(be5Project, startTime));
}
Also used : ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) BeConnectionProfile(com.developmentontheedge.be5.metadata.model.BeConnectionProfile) SimpleConnector(com.developmentontheedge.dbms.SimpleConnector) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 3 with ProjectLoadException

use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.

the class Be5Mojo method loadProject.

protected Project loadProject(final Path root) throws MojoFailureException {
    final LoadContext loadContext = new LoadContext();
    Project prj;
    try {
        prj = Serialization.load(root, loadContext);
    } catch (final ProjectLoadException e) {
        throw new MojoFailureException("Can not load project", e);
    }
    checkErrors(loadContext, "Project has %d error(s)");
    return prj;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext)

Example 4 with ProjectLoadException

use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.

the class Serialization method load.

/**
 * @param root
 * @param fuseTemplates whether to fuse templates into entities (useful for modules loading)
 * @param loadContext
 * @return
 * @throws ProjectLoadException
 * @see Serialization#canBeLoaded(Path)
 */
public static Project load(final Path root, final boolean fuseTemplates, final LoadContext loadContext) throws ProjectLoadException {
    Objects.requireNonNull(root);
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(loadContext == null ? new LoadContext() : loadContext, fuseTemplates).readProject(root);
    } catch (final ReadException e) {
        throw new ProjectLoadException(root, e);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : ReadException(com.developmentontheedge.be5.metadata.exception.ReadException) ProjectLoadException(com.developmentontheedge.be5.metadata.exception.ProjectLoadException) YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 5 with ProjectLoadException

use of com.developmentontheedge.be5.metadata.exception.ProjectLoadException in project be5 by DevelopmentOnTheEdge.

the class ModuleLoader2Test method loadAllProjectsTestWithDev.

@Test
public void loadAllProjectsTestWithDev() throws IOException, ProjectSaveException, ProjectLoadException {
    try (PrintWriter out = new PrintWriter(path.resolve("dev.yaml").toFile())) {
        out.println("paths:" + "\n    test: " + path.toAbsolutePath());
    }
    ModuleLoader2.loadAllProjects(Collections.singletonList(path.resolve("project.yaml").toUri().toURL()));
    ModuleLoader2.readDevPathsToSourceProjects(Collections.singletonList(path.resolve("dev.yaml").toUri().toURL()));
    assertTrue(ModuleLoader2.getPathsToProjectsToHotReload().toString().startsWith("{test="));
    assertEquals(1, ModuleLoader2.getPathsToProjectsToHotReload().size());
    Project loadProject = ModuleLoader2.findAndLoadProjectWithModules();
    assertEquals("test", loadProject.getAppName());
    ModuleLoader2.getFileSystem(loadProject, "test");
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Project (com.developmentontheedge.be5.metadata.model.Project)8 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)6 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)2 Entity (com.developmentontheedge.be5.metadata.model.Entity)2 Module (com.developmentontheedge.be5.metadata.model.Module)2 TableDef (com.developmentontheedge.be5.metadata.model.TableDef)2 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.Test)2 FreemarkerSqlException (com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException)1 ProcessInterruptedException (com.developmentontheedge.be5.metadata.exception.ProcessInterruptedException)1 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)1 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)1 DataElementUtils (com.developmentontheedge.be5.metadata.model.DataElementUtils)1 DdlElement (com.developmentontheedge.be5.metadata.model.DdlElement)1 EntityType (com.developmentontheedge.be5.metadata.model.EntityType)1