Search in sources :

Example 16 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class ReadModelFromXmlTest method testWriteReadLocalizations.

@Test
public void testWriteReadLocalizations() throws Exception {
    final Project project = new Project("test");
    final Localizations localizations = project.getApplication().getLocalizations();
    localizations.addLocalization("en", "entity", Arrays.asList("topic"), "hello", "Hello!");
    localizations.addLocalization("de", "entity", Arrays.asList("topic", "topic2"), "hello", "Guten Tag!");
    localizations.addLocalization("it", "entity", Arrays.asList("topic2"), "hello", "Buon giorno!");
    final Path tempFolder = Files.createTempDirectory("be4-temp");
    Serialization.save(project, tempFolder);
    final Project project2 = Serialization.load(tempFolder);
    final Localizations localizations2 = project2.getApplication().getLocalizations();
    assertEquals("Hello!", localizations2.get("en").get("entity").elements().iterator().next().getValue());
    assertEquals("Guten Tag!", localizations2.get("de").get("entity").elements().iterator().next().getValue());
    assertEquals("Buon giorno!", localizations2.get("it").get("entity").elements().iterator().next().getValue());
    FileUtils.deleteRecursively(tempFolder);
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) Test(org.junit.Test)

Example 17 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class VariableSelector method getTags.

@Override
public String[] getTags() {
    Project project = ((BeModelElement) getBean()).getProject();
    Map<String, String> variableNames = project.getVariables();
    String[] result = new String[variableNames.size() + 1];
    result[0] = "(none)";
    int i = 1;
    for (Entry<String, String> entry : variableNames.entrySet()) {
        result[i++] = entry.getKey() + " (" + entry.getValue() + ")";
    }
    return result;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement)

Example 18 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class SelectorTest method testMatch.

@Test
public void testMatch() throws ParseException {
    Project project = new Project("test");
    Module app = project.getApplication();
    Module mod = new Module("mod", project.getModules());
    DataElementUtils.save(mod);
    Entity appTable = new Entity("appTable", app, EntityType.TABLE);
    DataElementUtils.save(appTable);
    DataElementUtils.save(new Query("All records", appTable));
    Entity appDict = new Entity("appDict", app, EntityType.DICTIONARY);
    DataElementUtils.save(appDict);
    Query dictRecords = new Query("All records", appDict);
    dictRecords.setInvisible(true);
    DataElementUtils.save(dictRecords);
    Entity modTable = new Entity("modTable", mod, EntityType.DICTIONARY);
    DataElementUtils.save(modTable);
    DataElementUtils.save(new Query("All records", modTable));
    SelectorRule rule1 = UnionSelectorRule.create("Query[invisible=true]");
    assertEquals("Query[invisible=true]", rule1.toString());
    checkRule(rule1, "test/application/Entities/appDict/Queries/All records", project);
    SelectorRule rule2 = UnionSelectorRule.create(".table Query[name=\"All records\"]");
    assertEquals(".table Query[name=\"All records\"]", rule2.toString());
    checkRule(rule2, "test/application/Entities/appTable/Queries/All records", project);
    SelectorRule rule3 = UnionSelectorRule.create("Module#mod Query[name=\"All records\"]");
    assertEquals("Module#mod Query[name=\"All records\"]", rule3.toString());
    checkRule(rule3, "test/Modules/mod/Entities/modTable/Queries/All records", project);
    SelectorRule rule4 = UnionSelectorRule.create("Entity:not(.dictionary)");
    assertEquals("Entity:not(.dictionary)", rule4.toString());
    checkRule(rule4, "test/application/Entities/appTable", project);
}
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) Test(org.junit.Test)

Example 19 with Project

use of com.developmentontheedge.be5.metadata.model.Project 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 20 with Project

use of com.developmentontheedge.be5.metadata.model.Project in project be5 by DevelopmentOnTheEdge.

the class AppValidate method validateProject.

private void validateProject() throws MojoFailureException {
    List<ProjectElementException> errors = new ArrayList<>();
    if (skipValidation) {
        getLog().info("Validation skipped");
    } else {
        getLog().info("Validating...");
        errors.addAll(be5Project.getErrors());
        int count = 0;
        for (ProjectElementException error : errors) {
            if (error.getPath().equals(be5Project.getName()) && error.getProperty().equals("connectionProfileName"))
                continue;
            count++;
            displayError(error);
        }
        if (count > 0) {
            throw new MojoFailureException("Project has " + count + " errors.");
        }
        getLog().info("Project is valid.");
        skipValidation = true;
    }
}
Also used : ProjectElementException(com.developmentontheedge.be5.metadata.exception.ProjectElementException) ArrayList(java.util.ArrayList) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

Project (com.developmentontheedge.be5.metadata.model.Project)40 Module (com.developmentontheedge.be5.metadata.model.Module)19 Test (org.junit.Test)19 Entity (com.developmentontheedge.be5.metadata.model.Entity)14 Path (java.nio.file.Path)13 Query (com.developmentontheedge.be5.metadata.model.Query)12 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)7 ArrayList (java.util.ArrayList)7 ProjectLoadException (com.developmentontheedge.be5.metadata.exception.ProjectLoadException)6 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)5 URL (java.net.URL)5 Map (java.util.Map)5 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)4 BeConnectionProfile (com.developmentontheedge.be5.metadata.model.BeConnectionProfile)4 Operation (com.developmentontheedge.be5.metadata.model.Operation)4 IOException (java.io.IOException)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 WriteException (com.developmentontheedge.be5.metadata.exception.WriteException)3 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)3 Localizations (com.developmentontheedge.be5.metadata.model.Localizations)3