use of com.developmentontheedge.be5.metadata.model.QuickFilter 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.QuickFilter in project be5 by DevelopmentOnTheEdge.
the class ReadModelFromXmlTest method testWriteReadQueryFilters.
@Test
public void testWriteReadQueryFilters() throws Exception {
final Project project = new Project("TestProject");
final Module module = project.getApplication();
DataElementUtils.saveQuiet(module);
final Entity table = new Entity("table", module, EntityType.TABLE);
DataElementUtils.saveQuiet(table);
final Query query = new Query("q", table);
DataElementUtils.saveQuiet(query);
final Query query2 = new Query("q2", table);
DataElementUtils.saveQuiet(query2);
final Query filterQuery = new Query("filter query", table);
DataElementUtils.saveQuiet(filterQuery);
final QuickFilter qf1 = new QuickFilter("filter1", query);
qf1.setTargetQueryName(filterQuery.getName());
qf1.setQueryParam("param");
qf1.setFilteringClass("test.class");
DataElementUtils.saveQuiet(qf1);
final QuickFilter qf2 = new QuickFilter("filter2", query2);
qf2.setTargetQueryName(filterQuery.getName());
qf2.setQueryParam("param2");
DataElementUtils.saveQuiet(qf2);
final Path tempFolder = Files.createTempDirectory("be4-temp");
Serialization.save(project, tempFolder);
final Project readProject = Serialization.load(tempFolder);
final Entity readEntity = readProject.getApplication().getEntity("table");
assertEquals("filter1", readEntity.getQueries().get("q").getQuickFilters()[0].getName());
assertEquals("param", readEntity.getQueries().get("q").getQuickFilters()[0].getQueryParam());
assertEquals("test.class", readEntity.getQueries().get("q").getQuickFilters()[0].getFilteringClass());
assertSame(readEntity.getQueries().get("filter query"), readEntity.getQueries().get("q").getQuickFilters()[0].getTargetQuery());
assertEquals("filter2", readEntity.getQueries().get("q2").getQuickFilters()[0].getName());
assertEquals("param2", readEntity.getQueries().get("q2").getQuickFilters()[0].getQueryParam());
assertNull(readEntity.getQueries().get("q2").getQuickFilters()[0].getFilteringClass());
assertSame(readEntity.getQueries().get("filter query"), readEntity.getQueries().get("q2").getQuickFilters()[0].getTargetQuery());
FileUtils.deleteRecursively(tempFolder);
}
Aggregations