Search in sources :

Example 6 with TreeConcept

use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept in project conquery by bakdata.

the class SerializationTests method testFormQuery.

@Test
public void testFormQuery() throws IOException, JSONException {
    CQConcept concept = new CQConcept();
    final TreeConcept testConcept = new TreeConcept();
    Dataset dataset = new Dataset();
    dataset.setName("testDataset");
    testConcept.setDataset(dataset);
    testConcept.setName("concept");
    final ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setConcept(testConcept);
    connector.setName("connector1");
    testConcept.setConnectors(List.of(connector));
    concept.setElements(Collections.singletonList(testConcept));
    CQTable[] tables = { new CQTable() };
    connector.setTable(new Table());
    tables[0].setConnector(connector);
    tables[0].setConcept(concept);
    concept.setTables(Arrays.asList(tables));
    ConceptQuery subQuery = new ConceptQuery(concept);
    CQOr features = new CQOr();
    features.setChildren(Collections.singletonList(concept));
    AbsoluteFormQuery query = new AbsoluteFormQuery(subQuery, CDateRange.exactly(LocalDate.now()).toSimpleRange(), ArrayConceptQuery.createFromFeatures(Collections.singletonList(features)), List.of(ExportForm.ResolutionAndAlignment.of(Resolution.COMPLETE, Alignment.NO_ALIGN), ExportForm.ResolutionAndAlignment.of(Resolution.QUARTERS, Alignment.QUARTER)));
    CentralRegistry centralRegistry = new CentralRegistry();
    centralRegistry.register(dataset);
    centralRegistry.register(testConcept);
    centralRegistry.register(connector);
    SerializationTestUtil.forType(AbsoluteFormQuery.class).registry(centralRegistry).test(query);
}
Also used : CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) ArrayConceptQuery(com.bakdata.conquery.apiv1.query.ArrayConceptQuery) AbsoluteFormQuery(com.bakdata.conquery.models.forms.managed.AbsoluteFormQuery) CQOr(com.bakdata.conquery.apiv1.query.concept.specific.CQOr) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 7 with TreeConcept

use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept in project conquery by bakdata.

the class SerializationTests method cqConcept.

@Test
public void cqConcept() throws JSONException, IOException {
    final Dataset dataset = new Dataset();
    dataset.setName("dataset");
    final TreeConcept concept = new TreeConcept();
    concept.setName("concept");
    concept.setDataset(dataset);
    final ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setConcept(concept);
    concept.setConnectors(List.of(connector));
    final CQConcept cqConcept = new CQConcept();
    cqConcept.setElements(List.of(concept));
    cqConcept.setLabel("Label");
    final CQTable cqTable = new CQTable();
    cqTable.setConnector(connector);
    cqTable.setFilters(List.of());
    cqTable.setConcept(cqConcept);
    cqConcept.setTables(List.of(cqTable));
    final CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(concept);
    registry.register(connector);
    SerializationTestUtil.forType(CQConcept.class).registry(registry).test(cqConcept);
}
Also used : Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 8 with TreeConcept

use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept in project conquery by bakdata.

the class CBlockDeserializer method deserialize.

@Override
public CBlock deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    CBlock block = beanDeserializer.deserialize(p, ctxt);
    TreeConcept concept = block.getConnector().getConcept();
    if (block.getMostSpecificChildren() != null) {
        // deduplicate concrete paths after loading from disk.
        for (int event = 0; event < block.getMostSpecificChildren().length; event++) {
            int[] mostSpecificChildren = block.getMostSpecificChildren()[event];
            if (mostSpecificChildren == null || Connector.isNotContained(mostSpecificChildren)) {
                block.getMostSpecificChildren()[event] = Connector.NOT_CONTAINED;
                continue;
            }
            log.trace("Getting Elements for local ids: {}", mostSpecificChildren);
            block.getMostSpecificChildren()[event] = concept.getElementByLocalId(mostSpecificChildren).getPrefix();
        }
    }
    return block;
}
Also used : CBlock(com.bakdata.conquery.models.events.CBlock) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)

Example 9 with TreeConcept

use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept in project conquery by bakdata.

the class NamespacedStorage method decorateConceptStore.

private void decorateConceptStore(IdentifiableStore<Concept<?>> store) {
    store.onAdd(concept -> {
        if (concept.getDataset() != null && !concept.getDataset().equals(dataset.get())) {
            throw new IllegalStateException("Concept is not for this dataset.");
        }
        concept.setDataset(dataset.get());
        concept.initElements();
        concept.getSelects().forEach(centralRegistry::register);
        for (Connector connector : concept.getConnectors()) {
            centralRegistry.register(connector);
            connector.collectAllFilters().forEach(centralRegistry::register);
            connector.getSelects().forEach(centralRegistry::register);
            connector.getValidityDates().forEach(centralRegistry::register);
        }
        // add imports of table
        if (isRegisterImports()) {
            for (Import imp : getAllImports()) {
                for (Connector con : concept.getConnectors()) {
                    if (con.getTable().equals(imp.getTable())) {
                        con.addImport(imp);
                    }
                }
            }
        }
        if (concept instanceof TreeConcept) {
            ((TreeConcept) concept).getAllChildren().values().forEach(centralRegistry::register);
        }
    }).onRemove(concept -> {
        concept.getSelects().forEach(centralRegistry::remove);
        // see #146  remove from Dataset.concepts
        for (Connector connector : concept.getConnectors()) {
            connector.getSelects().forEach(centralRegistry::remove);
            connector.collectAllFilters().forEach(centralRegistry::remove);
            connector.getValidityDates().forEach(centralRegistry::remove);
            centralRegistry.remove(connector);
        }
        if (concept instanceof TreeConcept) {
            ((TreeConcept) concept).getAllChildren().values().forEach(centralRegistry::remove);
        }
    });
}
Also used : Dictionary(com.bakdata.conquery.models.dictionary.Dictionary) Getter(lombok.Getter) SneakyThrows(lombok.SneakyThrows) SecondaryIdDescriptionId(com.bakdata.conquery.models.identifiable.ids.specific.SecondaryIdDescriptionId) StoreFactory(com.bakdata.conquery.models.config.StoreFactory) Import(com.bakdata.conquery.models.datasets.Import) ArrayList(java.util.ArrayList) SingletonStore(com.bakdata.conquery.io.storage.xodus.stores.SingletonStore) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) DictionaryId(com.bakdata.conquery.models.identifiable.ids.specific.DictionaryId) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) ToString(lombok.ToString) TableId(com.bakdata.conquery.models.identifiable.ids.specific.TableId) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) Collection(java.util.Collection) Table(com.bakdata.conquery.models.datasets.Table) Concept(com.bakdata.conquery.models.datasets.concepts.Concept) Validator(javax.validation.Validator) IOException(java.io.IOException) ImportId(com.bakdata.conquery.models.identifiable.ids.specific.ImportId) Dataset(com.bakdata.conquery.models.datasets.Dataset) SecondaryIdDescription(com.bakdata.conquery.models.datasets.SecondaryIdDescription) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Column(com.bakdata.conquery.models.datasets.Column) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) Import(com.bakdata.conquery.models.datasets.Import) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)

Example 10 with TreeConcept

use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept 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)

Aggregations

TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)14 ConceptTreeConnector (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector)9 Dataset (com.bakdata.conquery.models.datasets.Dataset)7 Table (com.bakdata.conquery.models.datasets.Table)5 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)5 Test (org.junit.jupiter.api.Test)5 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)4 Column (com.bakdata.conquery.models.datasets.Column)4 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)3 ConqueryTestSpec (com.bakdata.conquery.integration.json.ConqueryTestSpec)3 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)3 CBlockId (com.bakdata.conquery.models.identifiable.ids.specific.CBlockId)3 CalculateCBlocksJob (com.bakdata.conquery.models.jobs.CalculateCBlocksJob)3 SneakyThrows (lombok.SneakyThrows)3 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)2 Import (com.bakdata.conquery.models.datasets.Import)2 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)2 ValidityDate (com.bakdata.conquery.models.datasets.concepts.ValidityDate)2 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)2 IOException (java.io.IOException)2