Search in sources :

Example 1 with ProjectSaveException

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

the class Serialization method save.

/**
 * @param project
 * @param root
 * @param format
 * @throws ProjectSaveException
 */
public static void save(final Project project, final Path root) throws ProjectSaveException {
    Objects.requireNonNull(project);
    Objects.requireNonNull(root);
    try {
        new YamlSerializer().serializeProjectTo(project, root);
    } catch (final WriteException e) {
        throw new ProjectSaveException(root, e);
    }
}
Also used : WriteException(com.developmentontheedge.be5.metadata.exception.WriteException) YamlSerializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer) ProjectSaveException(com.developmentontheedge.be5.metadata.exception.ProjectSaveException)

Example 2 with ProjectSaveException

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

the class AppValidate method saveProject.

// private List<ProjectElementException> validateDeps( List<Project> moduleProjects )
// {
// List<ProjectElementException> moduleErrors = new ArrayList<>();
// Map<String, String> entityToModule = new HashMap<>();
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// entityToModule.put( entity.getName(), prj.getName() );
// }
// for(Project prj : moduleProjects)
// {
// for(Entity entity : prj.getApplication().getEntities())
// {
// for(TableReference ref : entity.getAllReferences())
// {
// String moduleTo = entityToModule.get( ref.getTableTo() );
// if(moduleTo != null && prj.getModule( moduleTo ) == null)
// {
// moduleErrors.add( new ProjectElementException( ref, "Reference to entity '" + ref.getTableTo()
// + "' which is defined in module '" + moduleTo + "' which is not specified in dependencies of module '"
// + prj.getName() + "'" ) );
// }
// }
// }
// }
// return moduleErrors;
// }
private void saveProject() throws MojoFailureException {
    if (saveProject) {
        try {
            getLog().info("Saving...");
            Serialization.save(be5Project, be5Project.getLocation());
        } catch (ProjectSaveException e) {
            throw new MojoFailureException("Can not save project.", e);
        }
    }
}
Also used : MojoFailureException(org.apache.maven.plugin.MojoFailureException) ProjectSaveException(com.developmentontheedge.be5.metadata.exception.ProjectSaveException)

Example 3 with ProjectSaveException

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

the class ModuleUtilsTest method getModule.

private Project getModule() throws ProjectSaveException {
    Project module = new Project("module", true);
    Entity entity = new Entity("mentity", module.getApplication(), EntityType.TABLE);
    DataElementUtils.save(entity);
    Query q1 = new Query("q1", entity);
    q1.setQuery("QUERY1");
    q1.setTitleName("Query1 title");
    DataElementUtils.save(q1);
    Query q2 = new Query("q2", entity);
    q2.setQuery("QUERY2");
    q2.setTitleName("Query2 title");
    DataElementUtils.save(q2);
    return module;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Entity(com.developmentontheedge.be5.metadata.model.Entity) Query(com.developmentontheedge.be5.metadata.model.Query)

Example 4 with ProjectSaveException

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

the class ModuleUtilsTest method getProject.

private Project getProject() throws ProjectSaveException {
    Project app = new Project("app");
    Module appModule = new Module("module", app.getModules());
    DataElementUtils.save(appModule);
    Entity appEntity = new Entity("mentity", appModule, EntityType.DICTIONARY);
    DataElementUtils.save(appEntity);
    Query appQ1 = new Query("q1", appEntity);
    appQ1.setQuery("QUERY1 customized");
    DataElementUtils.save(appQ1);
    Query appQ3 = new Query("q3", appEntity);
    appQ3.setQuery("QUERY3");
    appQ3.setTitleName("Query3 title");
    DataElementUtils.save(appQ3);
    return app;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Entity(com.developmentontheedge.be5.metadata.model.Entity) Query(com.developmentontheedge.be5.metadata.model.Query) Module(com.developmentontheedge.be5.metadata.model.Module)

Example 5 with ProjectSaveException

use of com.developmentontheedge.be5.metadata.exception.ProjectSaveException 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)4 Entity (com.developmentontheedge.be5.metadata.model.Entity)3 Query (com.developmentontheedge.be5.metadata.model.Query)3 ProjectSaveException (com.developmentontheedge.be5.metadata.exception.ProjectSaveException)2 Test (org.junit.Test)2 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)1 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 TableDef (com.developmentontheedge.be5.metadata.model.TableDef)1 YamlSerializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlSerializer)1 PrintWriter (java.io.PrintWriter)1 Path (java.nio.file.Path)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1