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;
}
}
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);
}
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);
}
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;
}
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());
}
Aggregations