Search in sources :

Example 16 with Dataset

use of com.bakdata.conquery.models.datasets.Dataset in project conquery by bakdata.

the class IdDeserializer method findDatasetName.

private static String findDatasetName(DeserializationContext ctx) throws JsonMappingException {
    Dataset dataset = Jackson.findInjectable(ctx, Dataset.class);
    if (dataset != null) {
        return dataset.getName();
    }
    // Sometimes injected via @PathParam
    DatasetId id = Jackson.findInjectable(ctx, DatasetId.class);
    if (id != null) {
        return id.getName();
    }
    return null;
}
Also used : Dataset(com.bakdata.conquery.models.datasets.Dataset) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)

Example 17 with Dataset

use of com.bakdata.conquery.models.datasets.Dataset in project conquery by bakdata.

the class AuthorizationHelper method authorizeDownloadDatasets.

/**
 * Checks if an execution is allowed to be downloaded by a user.
 * This checks all used {@link DatasetId}s for the {@link Ability#DOWNLOAD} on the user.
 */
public static void authorizeDownloadDatasets(@NonNull Subject subject, @NonNull Visitable visitable) {
    NamespacedIdentifiableCollector collector = new NamespacedIdentifiableCollector();
    visitable.visit(collector);
    Set<Dataset> datasets = collector.getIdentifiables().stream().map(NamespacedIdentifiable::getDataset).collect(Collectors.toSet());
    subject.authorize(datasets, Ability.DOWNLOAD);
}
Also used : NamespacedIdentifiableCollector(com.bakdata.conquery.util.QueryUtils.NamespacedIdentifiableCollector) Dataset(com.bakdata.conquery.models.datasets.Dataset)

Example 18 with Dataset

use of com.bakdata.conquery.models.datasets.Dataset 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 19 with Dataset

use of com.bakdata.conquery.models.datasets.Dataset in project conquery by bakdata.

the class SerializationTests method formConfig.

@Test
public void formConfig() throws JSONException, IOException {
    final CentralRegistry registry = new CentralRegistry();
    final Dataset dataset = new Dataset("test-dataset");
    registry.register(dataset);
    ExportForm form = new ExportForm();
    AbsoluteMode mode = new AbsoluteMode();
    form.setTimeMode(mode);
    mode.setForm(form);
    mode.setFeatures(List.of(new CQConcept()));
    ObjectMapper mapper = FormConfigProcessor.getMAPPER();
    JsonNode values = mapper.valueToTree(form);
    FormConfig formConfig = new FormConfig(form.getClass().getAnnotation(CPSType.class).id(), values);
    formConfig.setDataset(dataset);
    SerializationTestUtil.forType(FormConfig.class).registry(registry).test(formConfig);
}
Also used : FormConfig(com.bakdata.conquery.models.forms.configs.FormConfig) AbsoluteMode(com.bakdata.conquery.apiv1.forms.export_form.AbsoluteMode) Dataset(com.bakdata.conquery.models.datasets.Dataset) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) JsonNode(com.fasterxml.jackson.databind.JsonNode) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) ExportForm(com.bakdata.conquery.apiv1.forms.export_form.ExportForm) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 20 with Dataset

use of com.bakdata.conquery.models.datasets.Dataset 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

Dataset (com.bakdata.conquery.models.datasets.Dataset)46 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)14 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)12 Test (org.junit.jupiter.api.Test)12 Slf4j (lombok.extern.slf4j.Slf4j)10 Table (com.bakdata.conquery.models.datasets.Table)9 Namespace (com.bakdata.conquery.models.worker.Namespace)9 Query (com.bakdata.conquery.apiv1.query.Query)8 User (com.bakdata.conquery.models.auth.entities.User)8 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)8 StandaloneSupport (com.bakdata.conquery.util.support.StandaloneSupport)8 Response (javax.ws.rs.core.Response)8 QueryTest (com.bakdata.conquery.integration.json.QueryTest)7 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)7 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)7 List (java.util.List)7 LoadingUtil (com.bakdata.conquery.integration.common.LoadingUtil)6 Role (com.bakdata.conquery.models.auth.entities.Role)6 ExecutionState (com.bakdata.conquery.models.execution.ExecutionState)6 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)6