Search in sources :

Example 1 with ConceptTreeConnector

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

the class BucketManager method addConcept.

public void addConcept(Concept<?> concept) {
    storage.updateConcept(concept);
    if (!(concept instanceof TreeConcept)) {
        return;
    }
    CalculateCBlocksJob job = new CalculateCBlocksJob(storage, this, worker.getJobsExecutorService());
    for (ConceptTreeConnector connector : ((TreeConcept) concept).getConnectors()) {
        for (Bucket bucket : storage.getAllBuckets()) {
            if (!bucket.getTable().equals(connector.getTable())) {
                continue;
            }
            final CBlockId cBlockId = new CBlockId(bucket.getId(), connector.getId());
            if (hasCBlock(cBlockId)) {
                continue;
            }
            job.addCBlock(bucket, connector);
        }
    }
    jobManager.addSlowJob(job);
}
Also used : CBlockId(com.bakdata.conquery.models.identifiable.ids.specific.CBlockId) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CalculateCBlocksJob(com.bakdata.conquery.models.jobs.CalculateCBlocksJob)

Example 2 with ConceptTreeConnector

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

the class BucketManager method addBucket.

public void addBucket(Bucket bucket) {
    storage.addBucket(bucket);
    registerBucket(bucket, entities, tableToBuckets);
    CalculateCBlocksJob job = new CalculateCBlocksJob(storage, this, worker.getJobsExecutorService());
    for (Concept<?> concept : storage.getAllConcepts()) {
        if (!(concept instanceof TreeConcept)) {
            continue;
        }
        for (ConceptTreeConnector connector : ((TreeConcept) concept).getConnectors()) {
            if (!connector.getTable().equals(bucket.getTable())) {
                continue;
            }
            CBlockId cBlockId = new CBlockId(bucket.getId(), connector.getId());
            if (hasCBlock(cBlockId)) {
                continue;
            }
            job.addCBlock(bucket, connector);
        }
    }
    jobManager.addSlowJob(job);
}
Also used : CBlockId(com.bakdata.conquery.models.identifiable.ids.specific.CBlockId) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CalculateCBlocksJob(com.bakdata.conquery.models.jobs.CalculateCBlocksJob)

Example 3 with ConceptTreeConnector

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

the class FilterTest method importConcepts.

private void importConcepts(StandaloneSupport support) throws JSONException, IOException {
    Dataset dataset = support.getDataset();
    concept = new TreeConcept();
    concept.setLabel("concept");
    concept.setValidator(support.getValidator());
    concept.setDataset(support.getDataset());
    rawConnector.put("name", "connector");
    rawConnector.put("table", "table");
    ((ObjectNode) rawConnector.get("filters")).put("name", "filter");
    connector = parseSubTree(support, rawConnector, ConceptTreeConnector.class, conn -> conn.setConcept(concept));
    concept.setConnectors(Collections.singletonList((ConceptTreeConnector) connector));
    support.getDatasetsProcessor().addConcept(dataset, concept);
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Setter(lombok.Setter) Getter(lombok.Getter) RequiredData(com.bakdata.conquery.integration.common.RequiredData) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Connector(com.bakdata.conquery.models.datasets.concepts.Connector) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) JSONException(com.bakdata.conquery.models.exceptions.JSONException) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) Range(com.bakdata.conquery.models.common.Range) ResourceFile(com.bakdata.conquery.integration.common.ResourceFile) CPSType(com.bakdata.conquery.io.cps.CPSType) IOException(java.io.IOException) NotNull(javax.validation.constraints.NotNull) LoadingUtil(com.bakdata.conquery.integration.common.LoadingUtil) StandaloneSupport(com.bakdata.conquery.util.support.StandaloneSupport) AbstractQueryEngineTest(com.bakdata.conquery.integration.json.AbstractQueryEngineTest) Dataset(com.bakdata.conquery.models.datasets.Dataset) FilterValue(com.bakdata.conquery.apiv1.query.concept.filter.FilterValue) CQDateRestriction(com.bakdata.conquery.apiv1.query.concept.specific.CQDateRestriction) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) Slf4j(lombok.extern.slf4j.Slf4j) LocalDate(java.time.LocalDate) Query(com.bakdata.conquery.apiv1.query.Query) Jackson(com.bakdata.conquery.io.jackson.Jackson) ConqueryTestSpec(com.bakdata.conquery.integration.json.ConqueryTestSpec) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) Collections(java.util.Collections) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) 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)

Example 4 with ConceptTreeConnector

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

the class SerializationTests method treeConcept.

@Test
public void treeConcept() throws IOException, JSONException {
    Dataset dataset = new Dataset();
    dataset.setName("datasetName");
    TreeConcept concept = new TreeConcept();
    concept.setDataset(dataset);
    concept.setLabel("conceptLabel");
    concept.setName("conceptName");
    Table table = new Table();
    Column column = new Column();
    column.setLabel("colLabel");
    column.setName("colName");
    column.setType(MajorTypeId.STRING);
    column.setTable(table);
    Column dateColumn = new Column();
    dateColumn.setLabel("colLabel2");
    dateColumn.setName("colName2");
    dateColumn.setType(MajorTypeId.DATE);
    dateColumn.setTable(table);
    table.setColumns(new Column[] { column, dateColumn });
    table.setDataset(dataset);
    table.setLabel("tableLabel");
    table.setName("tableName");
    column.setTable(table);
    ConceptTreeConnector connector = new ConceptTreeConnector();
    connector.setConcept(concept);
    connector.setLabel("connLabel");
    connector.setName("connName");
    connector.setColumn(column);
    concept.setConnectors(List.of(connector));
    ValidityDate valDate = new ValidityDate();
    valDate.setColumn(dateColumn);
    valDate.setConnector(connector);
    valDate.setLabel("valLabel");
    valDate.setName("valName");
    connector.setValidityDates(List.of(valDate));
    CentralRegistry registry = new CentralRegistry();
    registry.register(dataset);
    registry.register(concept);
    registry.register(column);
    registry.register(dateColumn);
    registry.register(table);
    registry.register(connector);
    registry.register(valDate);
    final Validator validator = Validators.newValidator();
    concept.setValidator(validator);
    SerializationTestUtil.forType(TreeConcept.class).registry(registry).injectables(new Injectable() {

        @Override
        public MutableInjectableValues inject(MutableInjectableValues values) {
            return values.add(Validator.class, validator);
        }
    }).test(concept);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) 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) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 5 with ConceptTreeConnector

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

Aggregations

ConceptTreeConnector (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector)9 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)9 Dataset (com.bakdata.conquery.models.datasets.Dataset)6 Test (org.junit.jupiter.api.Test)5 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)4 Table (com.bakdata.conquery.models.datasets.Table)4 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)4 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)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 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)2 Column (com.bakdata.conquery.models.datasets.Column)2 ValidityDate (com.bakdata.conquery.models.datasets.concepts.ValidityDate)2 SneakyThrows (lombok.SneakyThrows)2 FETable (com.bakdata.conquery.apiv1.frontend.FETable)1 FEValue (com.bakdata.conquery.apiv1.frontend.FEValue)1 ArrayConceptQuery (com.bakdata.conquery.apiv1.query.ArrayConceptQuery)1 Query (com.bakdata.conquery.apiv1.query.Query)1 FilterValue (com.bakdata.conquery.apiv1.query.concept.filter.FilterValue)1