Search in sources :

Example 6 with FEValue

use of com.bakdata.conquery.apiv1.frontend.FEValue in project conquery by bakdata.

the class FEValueTest method sortedValidityDates.

@Test
public void sortedValidityDates() {
    Dataset dataset = new Dataset();
    dataset.setName("testDataset");
    Table table = new Table();
    table.setDataset(dataset);
    table.setName("testTable");
    Column column = new Column();
    column.setName("testColumn");
    column.setTable(table);
    ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setName("testConnector");
    TreeConcept concept = new TreeConcept();
    concept.setDataset(dataset);
    concept.setName("testConcept");
    ValidityDate val0 = new ValidityDate();
    val0.setName("val0");
    val0.setConnector(connector);
    ValidityDate val1 = new ValidityDate();
    val1.setName("val1");
    val1.setConnector(connector);
    ValidityDate val2 = new ValidityDate();
    val2.setName("val2");
    val2.setConnector(connector);
    List<ValidityDate> validityDates = List.of(val0, val1, val2);
    connector.setColumn(column);
    connector.setConcept(concept);
    connector.setValidityDates(validityDates);
    FETable feTable = FrontEndConceptBuilder.createTable(connector);
    assertThat(feTable.getDateColumn().getOptions()).containsExactly(new FEValue("val0", val0.getId().toString()), new FEValue("val1", val1.getId().toString()), new FEValue("val2", val2.getId().toString()));
}
Also used : FETable(com.bakdata.conquery.apiv1.frontend.FETable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) FETable(com.bakdata.conquery.apiv1.frontend.FETable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) FEValue(com.bakdata.conquery.apiv1.frontend.FEValue) Test(org.junit.jupiter.api.Test)

Example 7 with FEValue

use of com.bakdata.conquery.apiv1.frontend.FEValue in project conquery by bakdata.

the class AbstractSelectFilter method configureFrontend.

@Override
public void configureFrontend(FEFilter f) throws ConceptConfigurationException {
    f.setTemplate(getTemplate());
    f.setType(filterType);
    if (values == null || values.isEmpty()) {
        return;
    }
    if (maximumSize != -1 && values.size() > maximumSize) {
        log.trace("Too many possible values ({} of {} in Filter[{}]). Upgrading to BigMultiSelect", values.size(), maximumSize, getId());
        f.setType(FEFilterType.BIG_MULTI_SELECT);
    }
    if (this.filterType != FEFilterType.BIG_MULTI_SELECT) {
        f.setOptions(values.stream().map(v -> new FEValue(getLabelFor(v), v)).collect(Collectors.toList()));
    }
}
Also used : FEValue(com.bakdata.conquery.apiv1.frontend.FEValue)

Example 8 with FEValue

use of com.bakdata.conquery.apiv1.frontend.FEValue in project conquery by bakdata.

the class FilterResolutionContainsTest method execute.

@Override
public void execute(StandaloneSupport conquery) throws Exception {
    // read test sepcification
    String testJson = In.resource("/tests/query/MULTI_SELECT_DATE_RESTRICTION_OR_CONCEPT_QUERY/MULTI_SELECT_DATE_RESTRICTION_OR_CONCEPT_QUERY.test.json").withUTF8().readAll();
    DatasetId dataset = conquery.getDataset().getId();
    ConqueryTestSpec test = JsonIntegrationTest.readJson(dataset, testJson);
    ValidatorHelper.failOnError(log, conquery.getValidator().validate(test));
    test.importRequiredData(conquery);
    CSVConfig csvConf = conquery.getConfig().getCsv();
    FilterSearch.updateSearch(conquery.getNamespace().getNamespaces(), Collections.singleton(conquery.getNamespace().getDataset()), conquery.getDatasetsProcessor().getJobManager(), csvConf);
    conquery.waitUntilWorkDone();
    Concept<?> concept = conquery.getNamespace().getStorage().getAllConcepts().iterator().next();
    Connector connector = concept.getConnectors().iterator().next();
    AbstractSelectFilter<?> filter = (AbstractSelectFilter<?>) connector.getFilters().iterator().next();
    // Copy search csv from resources to tmp folder.
    final Path tmpCSv = Files.createTempFile("conquery_search", ".csv");
    Out.file(tmpCSv.toFile()).withUTF8().writeLines(lines);
    Files.write(tmpCSv, String.join(csvConf.getLineSeparator(), lines).getBytes(), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
    filter.setSearchType(FilterSearch.FilterSearchType.CONTAINS);
    filter.setTemplate(new FilterTemplate(tmpCSv.toString(), Arrays.asList("HEADER"), "HEADER", "", ""));
    FilterSearch.createSourceSearch(filter, csvConf);
    assertThat(filter.getSourceSearch()).isNotNull();
    ConceptsProcessor processor = new ConceptsProcessor(conquery.getNamespace().getNamespaces());
    // from csv
    {
        ResolvedConceptsResult resolved = processor.resolveFilterValues(filter, List.of("a", "unknown"));
        // check the resolved values
        assertThat(resolved.getResolvedFilter().getValue().stream().map(FEValue::getValue)).containsExactlyInAnyOrder("a", "aaa", "aab", "baaa");
        assertThat(resolved.getUnknownCodes()).containsExactlyInAnyOrder("unknown");
    }
    // from column values
    {
        ResolvedConceptsResult resolved = processor.resolveFilterValues(filter, List.of("f", "unknown"));
        // check the resolved values
        assertThat(resolved.getResolvedFilter().getValue().stream().map(FEValue::getValue)).containsExactlyInAnyOrder("f");
        assertThat(resolved.getUnknownCodes()).containsExactlyInAnyOrder("unknown");
    }
}
Also used : Path(java.nio.file.Path) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) AbstractSelectFilter(com.bakdata.conquery.models.datasets.concepts.filters.specific.AbstractSelectFilter) ConqueryTestSpec(com.bakdata.conquery.integration.json.ConqueryTestSpec) ConceptsProcessor(com.bakdata.conquery.resources.api.ConceptsProcessor) CSVConfig(com.bakdata.conquery.models.config.CSVConfig) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) FilterTemplate(com.bakdata.conquery.apiv1.FilterTemplate) ResolvedConceptsResult(com.bakdata.conquery.resources.api.ConceptsProcessor.ResolvedConceptsResult)

Aggregations

FEValue (com.bakdata.conquery.apiv1.frontend.FEValue)5 AbstractSelectFilter (com.bakdata.conquery.models.datasets.concepts.filters.specific.AbstractSelectFilter)5 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)5 FilterTemplate (com.bakdata.conquery.apiv1.FilterTemplate)3 ConqueryTestSpec (com.bakdata.conquery.integration.json.ConqueryTestSpec)3 CSVConfig (com.bakdata.conquery.models.config.CSVConfig)3 Dataset (com.bakdata.conquery.models.datasets.Dataset)3 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)3 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)3 ConceptsProcessor (com.bakdata.conquery.resources.api.ConceptsProcessor)3 ResolvedConceptsResult (com.bakdata.conquery.resources.api.ConceptsProcessor.ResolvedConceptsResult)3 FilterSearch (com.bakdata.conquery.apiv1.FilterSearch)2 FilterSearchItem (com.bakdata.conquery.apiv1.FilterSearchItem)2 IdLabel (com.bakdata.conquery.apiv1.IdLabel)2 FEList (com.bakdata.conquery.apiv1.frontend.FEList)2 FERoot (com.bakdata.conquery.apiv1.frontend.FERoot)2 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)2 Subject (com.bakdata.conquery.models.auth.entities.Subject)2 Ability (com.bakdata.conquery.models.auth.permissions.Ability)2 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)2