Search in sources :

Example 16 with Entity

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

the class MetaImpl method getColumns.

@Override
@SuppressWarnings(value = "unchecked")
public Map<String, ColumnDef> getColumns(Entity entity) {
    BeModelElement scheme = entity.getAvailableElement("Scheme");
    if (scheme == null)
        return new HashMap<>();
    BeCaseInsensitiveCollection<ColumnDef> columns = (BeCaseInsensitiveCollection<ColumnDef>) ((TableDef) scheme).get("Columns");
    return StreamSupport.stream(columns.spliterator(), false).collect(Utils.toLinkedMap(ColumnDef::getName, Function.identity()));
}
Also used : BeCaseInsensitiveCollection(com.developmentontheedge.be5.metadata.model.base.BeCaseInsensitiveCollection) BeModelElement(com.developmentontheedge.be5.metadata.model.base.BeModelElement) ColumnDef(com.developmentontheedge.be5.metadata.model.ColumnDef)

Example 17 with Entity

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

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

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

the class ModuleLoader2MergeModulesTest method setUp.

@Before
public void setUp() throws Exception {
    Path tpmProjectPath = tmp.newFolder().toPath();
    project = ProjectTestUtils.getProject("test");
    // Entity entity = ProjectTestUtils.createEntity( project, "entity", "ID" );
    // ProjectTestUtils.createScheme( entity );
    // ProjectTestUtils.createScript( project, "delete from entity;\nINSERT INTO entity (name) VALUES ('foo')" );
    ProjectTestUtils.createH2Profile(project, "profileTestMavenPlugin");
    // Query query = ProjectTestUtils.createQuery(entity, "All records", Arrays.asList('@' + SpecialRoleGroup.ALL_ROLES_EXCEPT_GUEST_GROUP, "-User"));
    // query.getOperationNames().setValues( Collections.singleton( "op" ) );
    // ProjectTestUtils.createOperation( entity );
    Path modulePath = tmp.newFolder().toPath();
    Project moduleProject1 = createModuleWithQueryRoles(project, null, "testModule1", "testQuery1", "testRole1", modulePath);
    Path modulePath2 = tmp.newFolder().toPath();
    Project moduleProject2 = createModuleWithQueryRoles(project, moduleProject1, "testModule2", "testQuery2", "testRole2", modulePath2);
    project.setRoles(Arrays.asList("testRole1", "testRole2"));
    Serialization.save(project, tpmProjectPath);
    ArrayList<URL> urls = new ArrayList<>();
    urls.add(modulePath.resolve("project.yaml").toUri().toURL());
    urls.add(modulePath2.resolve("project.yaml").toUri().toURL());
    urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
    ModuleLoader2.loadAllProjects(urls);
    LoadContext ctx = new LoadContext();
    ModuleLoader2.mergeAllModules(project, Arrays.asList(moduleProject1, moduleProject2), ctx);
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) ArrayList(java.util.ArrayList) URL(java.net.URL) Before(org.junit.Before)

Example 20 with Entity

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

the class BaseTypeManagerTest method createTable.

protected TableDef createTable(Rdbms dbms) {
    Project proj = new Project("test");
    proj.setDatabaseSystem(dbms);
    Entity ent = new Entity("table", proj.getApplication(), EntityType.TABLE);
    DataElementUtils.save(ent);
    TableDef def = new TableDef(ent);
    DataElementUtils.save(def);
    return def;
}
Also used : Project(com.developmentontheedge.be5.metadata.model.Project) Entity(com.developmentontheedge.be5.metadata.model.Entity) TableDef(com.developmentontheedge.be5.metadata.model.TableDef)

Aggregations

Entity (com.developmentontheedge.be5.metadata.model.Entity)36 Query (com.developmentontheedge.be5.metadata.model.Query)19 Module (com.developmentontheedge.be5.metadata.model.Module)16 Project (com.developmentontheedge.be5.metadata.model.Project)16 Test (org.junit.Test)11 Path (java.nio.file.Path)9 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 ColumnDef (com.developmentontheedge.be5.metadata.model.ColumnDef)7 Operation (com.developmentontheedge.be5.metadata.model.Operation)7 TableDef (com.developmentontheedge.be5.metadata.model.TableDef)7 Meta (com.developmentontheedge.be5.api.services.Meta)4 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)4 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)4 Map (java.util.Map)4 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)3 DdlElement (com.developmentontheedge.be5.metadata.model.DdlElement)3 Localizations (com.developmentontheedge.be5.metadata.model.Localizations)3 LinkedHashMap (java.util.LinkedHashMap)3 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)2