use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept 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);
}
use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept 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);
}
use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept in project conquery by bakdata.
the class MetadataCollectionTest method execute.
@Override
public void execute(StandaloneSupport conquery) throws Exception {
// read test sepcification
String testJson = In.resource("/tests/query/SIMPLE_TREECONCEPT_QUERY/SIMPLE_TREECONCEPT_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);
// ensure the metadata is collected
conquery.getNamespace().sendToAll(new UpdateMatchingStatsMessage());
conquery.waitUntilWorkDone();
TreeConcept concept = (TreeConcept) conquery.getNamespace().getStorage().getAllConcepts().iterator().next();
// check the number of matched events
assertThat(concept.getMatchingStats().countEvents()).isEqualTo(4);
assertThat(concept.getChildren()).allSatisfy(c -> {
assertThat(c.getMatchingStats().countEvents()).isEqualTo(2);
});
// check the date ranges
assertThat(concept.getMatchingStats().spanEvents()).isEqualTo(CDateRange.of(LocalDate.parse("2010-07-15"), LocalDate.parse("2013-11-10")));
assertThat(concept.getChildren().get(0).getMatchingStats().spanEvents()).isEqualTo(CDateRange.of(LocalDate.parse("2012-01-01"), LocalDate.parse("2013-11-10")));
assertThat(concept.getChildren().get(1).getMatchingStats().spanEvents()).isEqualTo(CDateRange.of(LocalDate.parse("2010-07-15"), LocalDate.parse("2012-11-11")));
}
use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept 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);
}
use of com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept 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);
}
Aggregations