Search in sources :

Example 11 with Query

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

the class QuerySelector method getTags.

@Override
public String[] getTags() {
    try {
        List<String> queries = new ArrayList<>();
        Query query;
        if (getBean() instanceof Query) {
            query = (Query) getBean();
            queries.add("");
        } else {
            query = ((QuickFilter) getBean()).getQuery();
        }
        queries.addAll(query.getEntity().getQueries().getNameList());
        return queries.toArray(new String[queries.size()]);
    } catch (Exception e) {
        return Strings2.EMPTY;
    }
}
Also used : Query(com.developmentontheedge.be5.metadata.model.Query) ArrayList(java.util.ArrayList)

Example 12 with Query

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

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

the class TestUtils method setUp.

@Before
public void setUp() throws Exception {
    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 moduleProject = createModule(project, "testModule", modulePath);
    Serialization.save(project, tpmProjectPath);
    ArrayList<URL> urls = new ArrayList<>();
    urls.add(modulePath.resolve("project.yaml").toUri().toURL());
    urls.add(tpmProjectPath.resolve("project.yaml").toUri().toURL());
    ModuleLoader2.loadAllProjects(urls);
    LoadContext ctx = new LoadContext();
    ModuleLoader2.mergeAllModules(project, Collections.singletonList(moduleProject), ctx);
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) LoadContext(com.developmentontheedge.be5.metadata.serialization.LoadContext) URL(java.net.URL) Before(org.junit.Before)

Example 14 with Query

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

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

Aggregations

Query (com.developmentontheedge.be5.metadata.model.Query)29 Entity (com.developmentontheedge.be5.metadata.model.Entity)16 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 Project (com.developmentontheedge.be5.metadata.model.Project)12 Module (com.developmentontheedge.be5.metadata.model.Module)8 Path (java.nio.file.Path)8 Operation (com.developmentontheedge.be5.metadata.model.Operation)6 HashMap (java.util.HashMap)6 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)4 ProjectElementException (com.developmentontheedge.be5.metadata.exception.ProjectElementException)4 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)4 Map (java.util.Map)4 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)3 ReadException (com.developmentontheedge.be5.metadata.exception.ReadException)3 DataElementPath (com.developmentontheedge.be5.metadata.model.base.DataElementPath)3 LoadContext (com.developmentontheedge.be5.metadata.serialization.LoadContext)3 LinkedHashMap (java.util.LinkedHashMap)3 BeModelElement (com.developmentontheedge.be5.metadata.model.base.BeModelElement)2 Action (com.developmentontheedge.be5.model.Action)2