Search in sources :

Example 6 with CQConcept

use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept 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 7 with CQConcept

use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.

the class DefaultLabelTest method makeCQConcept.

private static CQConcept makeCQConcept(String label) {
    CQConcept concept = new CQConcept();
    concept.setLabel(label);
    concept.setElements(List.of(CONCEPT));
    return concept;
}
Also used : CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)

Example 8 with CQConcept

use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.

the class DefaultLabelTest method autoLabelComplexQuery.

@ParameterizedTest
@CsvSource({ "de,Hochgeladene-Liste Anfrage Concept1 Concept2 und weitere", "en,Uploaded-List Query Concept1 Concept2 and further" })
void autoLabelComplexQuery(Locale locale, String autoLabel) {
    I18n.LOCALE.set(locale);
    final ManagedQuery managedQuery = new ManagedQuery(null, null, DATASET);
    managedQuery.setQueryId(UUID.randomUUID());
    CQAnd and = new CQAnd();
    CQConcept concept1 = makeCQConcept("Concept1");
    CQConcept concept2 = makeCQConcept("Concept2");
    CQConcept concept3 = makeCQConcept("Concept3veryveryveryveryveryveryveryverylooooooooooooooooooooonglabel");
    and.setChildren(List.of(new CQExternal(List.of(), new String[0][0]), new CQReusedQuery(managedQuery.getId()), concept1, concept2, concept3));
    ConceptQuery cq = new ConceptQuery(and);
    ManagedQuery mQuery = cq.toManagedExecution(user, DATASET);
    mQuery.setLabel(mQuery.makeAutoLabel(getPrintSettings(locale)));
    assertThat(mQuery.getLabel()).isEqualTo(autoLabel + AUTO_LABEL_SUFFIX);
    assertThat(mQuery.getLabelWithoutAutoLabelSuffix()).isEqualTo(autoLabel);
}
Also used : CQReusedQuery(com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) CQExternal(com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) CQAnd(com.bakdata.conquery.apiv1.query.concept.specific.CQAnd) ConceptQuery(com.bakdata.conquery.apiv1.query.ConceptQuery) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with CQConcept

use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.

the class DefaultColumnNameTest method checkCombinations.

@ParameterizedTest
@MethodSource("provideCombinations")
void checkCombinations(TestConcept concept, boolean hasCQConceptLabel, String expectedColumnName) {
    doAnswer(invocation -> {
        final ConceptId id = invocation.getArgument(0);
        if (!concept.getId().equals(id)) {
            throw new IllegalStateException("Expected the id " + concept.getId() + " but got " + id);
        }
        return concept;
    }).when(DATASET_REGISTRY).resolve(any());
    final CQConcept cqConcept = concept.createCQConcept(hasCQConceptLabel);
    final UniqueNamer uniqNamer = new UniqueNamer(SETTINGS);
    SelectResultInfo info = new SelectResultInfo(concept.extractSelect(cqConcept), cqConcept);
    assertThat(uniqNamer.getUniqueName(info)).isEqualTo(expectedColumnName);
}
Also used : UniqueNamer(com.bakdata.conquery.models.query.resultinfo.UniqueNamer) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) SelectResultInfo(com.bakdata.conquery.models.query.resultinfo.SelectResultInfo) ConceptId(com.bakdata.conquery.models.identifiable.ids.specific.ConceptId) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 10 with CQConcept

use of com.bakdata.conquery.apiv1.query.concept.specific.CQConcept in project conquery by bakdata.

the class ExcelResultRenderTest method writeAndRead.

@Test
void writeAndRead() throws IOException {
    // Prepare every input data
    PrintSettings printSettings = new PrintSettings(true, Locale.GERMAN, null, CONFIG, (cer) -> EntityPrintId.from(Integer.toString(cer.getEntityId()), Integer.toString(cer.getEntityId())), (selectInfo) -> selectInfo.getSelect().getLabel());
    // The Shard nodes send Object[] but since Jackson is used for deserialization, nested collections are always a list because they are not further specialized
    List<EntityResult> results = getTestEntityResults();
    ManagedQuery mquery = new ManagedQuery(null, null, null) {

        public List<ResultInfo> getResultInfos() {
            return getResultTypes().stream().map(ResultTestUtil.TypedSelectDummy::new).map(select -> new SelectResultInfo(select, new CQConcept())).collect(Collectors.toList());
        }

        @Override
        public Stream<EntityResult> streamResults() {
            return results.stream();
        }
    };
    // First we write to the buffer, than we read from it and parse it as TSV
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    ExcelRenderer renderer = new ExcelRenderer(new ExcelConfig(), printSettings);
    renderer.renderToStream(ResultTestUtil.ID_FIELDS, mquery, output);
    InputStream inputStream = new ByteArrayInputStream(output.toByteArray());
    List<String> computed = readComputed(inputStream, printSettings);
    List<String> expected = generateExpectedTSV(results, mquery.getResultInfos(), printSettings);
    log.info("Wrote and than read this excel data: {}", computed);
    assertThat(computed).isNotEmpty();
    assertThat(computed).isEqualTo(expected);
}
Also used : ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ConqueryConfig(com.bakdata.conquery.models.config.ConqueryConfig) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EntityResult(com.bakdata.conquery.models.query.results.EntityResult) ArrayList(java.util.ArrayList) PrintSettings(com.bakdata.conquery.models.query.PrintSettings) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) EntityPrintId(com.bakdata.conquery.models.identifiable.mapping.EntityPrintId) ByteArrayInputStream(java.io.ByteArrayInputStream) Locale(java.util.Locale) DataFormatter(org.apache.poi.ss.usermodel.DataFormatter) Cell(org.apache.poi.ss.usermodel.Cell) I18n(com.bakdata.conquery.models.i18n.I18n) ResultType(com.bakdata.conquery.models.externalservice.ResultType) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo) ResultTestUtil.getTestEntityResults(com.bakdata.conquery.io.result.ResultTestUtil.getTestEntityResults) SelectResultInfo(com.bakdata.conquery.models.query.resultinfo.SelectResultInfo) ResultTestUtil.getResultTypes(com.bakdata.conquery.io.result.ResultTestUtil.getResultTypes) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ExcelConfig(com.bakdata.conquery.models.config.ExcelConfig) Test(org.junit.jupiter.api.Test) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) ResultTestUtil(com.bakdata.conquery.io.result.ResultTestUtil) StringJoiner(java.util.StringJoiner) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) Row(org.apache.poi.ss.usermodel.Row) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) NotNull(org.jetbrains.annotations.NotNull) InputStream(java.io.InputStream) NonPersistentStoreFactory(com.bakdata.conquery.util.NonPersistentStoreFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EntityResult(com.bakdata.conquery.models.query.results.EntityResult) SelectResultInfo(com.bakdata.conquery.models.query.resultinfo.SelectResultInfo) ByteArrayInputStream(java.io.ByteArrayInputStream) PrintSettings(com.bakdata.conquery.models.query.PrintSettings) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ResultInfo(com.bakdata.conquery.models.query.resultinfo.ResultInfo) SelectResultInfo(com.bakdata.conquery.models.query.resultinfo.SelectResultInfo) ExcelConfig(com.bakdata.conquery.models.config.ExcelConfig) Test(org.junit.jupiter.api.Test)

Aggregations

CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)18 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)8 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)7 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)6 Test (org.junit.jupiter.api.Test)6 Dataset (com.bakdata.conquery.models.datasets.Dataset)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CQReusedQuery (com.bakdata.conquery.apiv1.query.concept.specific.CQReusedQuery)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 ExportForm (com.bakdata.conquery.apiv1.forms.export_form.ExportForm)3 CQAnd (com.bakdata.conquery.apiv1.query.concept.specific.CQAnd)3 CQExternal (com.bakdata.conquery.apiv1.query.concept.specific.external.CQExternal)3 ConqueryConfig (com.bakdata.conquery.models.config.ConqueryConfig)3 ResultType (com.bakdata.conquery.models.externalservice.ResultType)3 I18n (com.bakdata.conquery.models.i18n.I18n)3 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)3 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)3 UniqueNamer (com.bakdata.conquery.models.query.resultinfo.UniqueNamer)3 CsvSource (org.junit.jupiter.params.provider.CsvSource)3