Search in sources :

Example 16 with Module

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

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

the class MetaImpl method getLocalization.

private String getLocalization(Project project, String language, String entity, Predicate<LocalizationElement> accept) {
    for (Module module : project.getModulesAndApplication()) {
        Localizations localizations = module.getLocalizations();
        LanguageLocalizations languageLocalizations = localizations.get(language);
        if (languageLocalizations == null)
            continue;
        EntityLocalizations entityLocalizations = languageLocalizations.get(entity);
        if (entityLocalizations == null)
            continue;
        for (LocalizationElement element : entityLocalizations.elements()) if (accept.test(element))
            return element.getValue();
    }
    return "";
}
Also used : EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) Module(com.developmentontheedge.be5.metadata.model.Module) LocalizationElement(com.developmentontheedge.be5.metadata.model.LocalizationElement)

Example 18 with Module

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

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

the class ModuleUtilsTest method testMergeAllModules.

@Test
public void testMergeAllModules() throws Exception {
    Project module = getModule();
    Project app = getProject();
    LoadContext ctx = new LoadContext();
    ModuleLoader2.mergeAllModules(app, Collections.singletonList(module), ctx);
    ctx.check();
    assertEquals(Collections.singleton("mentity"), app.getEntityNames());
    assertEquals(EntityType.DICTIONARY, app.getEntity("mentity").getType());
    BeModelCollection<Query> queries = app.getEntity("mentity").getQueries();
    assertEquals("QUERY1 customized", queries.get("q1").getQuery());
    assertEquals("Query1 title", queries.get("q1").getTitleName());
    assertEquals("QUERY2", queries.get("q2").getQuery());
    assertEquals("Query2 title", queries.get("q2").getTitleName());
    assertEquals("QUERY3", queries.get("q3").getQuery());
    assertEquals("Query3 title", queries.get("q3").getTitleName());
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Query(com.developmentontheedge.be5.metadata.model.Query) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext) Test(org.junit.Test)

Example 20 with Module

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

the class Project method getContext.

/**
 * Creates and returns FreeMarker context for given element
 * @param element to create context for (can be null)
 * @return
 */
public Map<String, Object> getContext(TemplateElement element) {
    Map<String, Object> context = new HashMap<>();
    BeModelElement parent = element;
    while (parent != null) {
        if (parent instanceof PageCustomization) {
            context.put("customization", parent);
        } else if (parent instanceof Query) {
            context.put("query", parent);
        } else if (parent instanceof Operation) {
            context.put("operation", parent);
        } else if (parent instanceof Entity) {
            context.put("entity", parent);
        } else if (parent instanceof Module) {
            context.put("module", parent);
        }
        parent = parent.getOrigin();
    }
    for (String name : getPropertyNames()) {
        context.put(name, getProperty(name));
    }
    BeConnectionProfile profile = getConnectionProfile();
    if (profile != null) {
        for (String name : profile.getPropertyNames()) {
            context.put(name, profile.getProperty(name));
        }
    }
    return context;
}
Also used : BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Module (com.developmentontheedge.be5.metadata.model.Module)26 Project (com.developmentontheedge.be5.metadata.model.Project)21 Entity (com.developmentontheedge.be5.metadata.model.Entity)19 Query (com.developmentontheedge.be5.metadata.model.Query)12 Test (org.junit.Test)9 Path (java.nio.file.Path)8 ArrayList (java.util.ArrayList)6 Operation (com.developmentontheedge.be5.metadata.model.Operation)5 YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)5 HashMap (java.util.HashMap)5 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)4 TableDef (com.developmentontheedge.be5.metadata.model.TableDef)4 Map (java.util.Map)4 FreemarkerCatalog (com.developmentontheedge.be5.metadata.model.FreemarkerCatalog)3 FreemarkerScript (com.developmentontheedge.be5.metadata.model.FreemarkerScript)3 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)3 List (java.util.List)3 FreemarkerSqlException (com.developmentontheedge.be5.metadata.exception.FreemarkerSqlException)2 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)2 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)2