Search in sources :

Example 1 with QuickFilter

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;
    }
}
Also used : Query(com.developmentontheedge.be5.metadata.model.Query) ArrayList(java.util.ArrayList)

Example 2 with QuickFilter

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);
}
Also used : Path(java.nio.file.Path) 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) QuickFilter(com.developmentontheedge.be5.metadata.model.QuickFilter) Test(org.junit.Test)

Aggregations

Query (com.developmentontheedge.be5.metadata.model.Query)2 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 Project (com.developmentontheedge.be5.metadata.model.Project)1 QuickFilter (com.developmentontheedge.be5.metadata.model.QuickFilter)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1