Search in sources :

Example 1 with ExportForm

use of com.bakdata.conquery.apiv1.forms.export_form.ExportForm in project conquery by bakdata.

the class StoredQueriesProcessorTest method mockManagedForm.

private static ManagedForm mockManagedForm(User user, ManagedExecutionId id, ExecutionState execState, final Dataset dataset) {
    return new ManagedInternalForm(new ExportForm(), user, dataset) {

        {
            setState(execState);
            setCreationTime(LocalDateTime.MIN);
            setQueryId(id.getExecution());
        }
    };
}
Also used : ManagedInternalForm(com.bakdata.conquery.models.forms.managed.ManagedInternalForm) ExportForm(com.bakdata.conquery.apiv1.forms.export_form.ExportForm)

Example 2 with ExportForm

use of com.bakdata.conquery.apiv1.forms.export_form.ExportForm 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 3 with ExportForm

use of com.bakdata.conquery.apiv1.forms.export_form.ExportForm in project conquery by bakdata.

the class DefaultLabelTest method autoLabelExportForm.

@ParameterizedTest
@CsvSource({ "de,Datenexport 2020-10-30 12:37", "en,Data Export 2020-10-30 12:37" })
void autoLabelExportForm(Locale locale, String autoLabel) {
    I18n.LOCALE.set(locale);
    ExportForm form = new ExportForm();
    ManagedForm mForm = form.toManagedExecution(user, DATASET);
    mForm.setCreationTime(LocalDateTime.of(2020, 10, 30, 12, 37));
    mForm.setLabel(mForm.makeAutoLabel(getPrintSettings(locale)));
    assertThat(mForm.getLabel()).isEqualTo(autoLabel + AUTO_LABEL_SUFFIX);
    assertThat(mForm.getLabelWithoutAutoLabelSuffix()).isEqualTo(autoLabel);
}
Also used : ManagedForm(com.bakdata.conquery.models.forms.managed.ManagedForm) ExportForm(com.bakdata.conquery.apiv1.forms.export_form.ExportForm) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ExportForm

use of com.bakdata.conquery.apiv1.forms.export_form.ExportForm in project conquery by bakdata.

the class FormConfigTest method getConfigs.

@Test
public void getConfigs() {
    // PREPARE
    user.addPermission(dataset.createPermission(Ability.READ.asSet()));
    user.addPermission(FormPermission.onInstance(Ability.CREATE, form.getFormType()));
    ExportForm form2 = new ExportForm();
    RelativeMode mode3 = new RelativeMode();
    form2.setTimeMode(mode3);
    mode3.setForm(form);
    mode3.setFeatures(List.of(new CQConcept()));
    mode3.setOutcomes(List.of(new CQConcept()));
    TestForm form3 = new TestForm();
    ObjectMapper mapper = FormConfigProcessor.getMAPPER();
    FormConfigAPI formConfig = FormConfigAPI.builder().formType(form.getFormType()).values(mapper.valueToTree(form)).build();
    FormConfigAPI formConfig2 = FormConfigAPI.builder().formType(form2.getFormType()).values(mapper.valueToTree(form2)).build();
    // This should not be retrieved by the user because it does not hold the Permission to create TestForms
    FormConfigAPI formConfig3 = FormConfigAPI.builder().formType(form3.getFormType()).values(mapper.valueToTree(form2)).build();
    FormConfigId formId = processor.addConfig(user, dataset, formConfig).getId();
    FormConfigId formId2 = processor.addConfig(user, dataset, formConfig2).getId();
    FormConfigId _formId3 = processor.addConfig(user, dataset, formConfig3).getId();
    FormScanner.FRONTEND_FORM_CONFIGS = Map.of(form.getFormType(), new FormType(form.getFormType(), new TextNode("dummy")));
    // EXECUTE
    Stream<FormConfigOverviewRepresentation> response = processor.getConfigsByFormType(user, dataset, Collections.emptySet());
    // CHECK
    assertThat(response).containsExactlyInAnyOrder(FormConfigOverviewRepresentation.builder().formType(form.getClass().getAnnotation(CPSType.class).id()).id(formId).label(formConfig.getLabel()).own(true).ownerName(user.getLabel()).shared(false).system(false).tags(formConfig.getTags()).createdAt(formConfig.getCreationTime().atZone(ZoneId.systemDefault())).build(), FormConfigOverviewRepresentation.builder().formType(form2.getClass().getAnnotation(CPSType.class).id()).id(formId2).label(formConfig2.getLabel()).own(true).ownerName(user.getLabel()).shared(false).system(false).tags(formConfig2.getTags()).createdAt(formConfig2.getCreationTime().atZone(ZoneId.systemDefault())).build());
}
Also used : FormConfigAPI(com.bakdata.conquery.apiv1.forms.FormConfigAPI) FormConfigOverviewRepresentation(com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigOverviewRepresentation) FormType(com.bakdata.conquery.models.forms.frontendconfiguration.FormType) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) TextNode(com.fasterxml.jackson.databind.node.TextNode) ExportForm(com.bakdata.conquery.apiv1.forms.export_form.ExportForm) FormConfigId(com.bakdata.conquery.models.identifiable.ids.specific.FormConfigId) RelativeMode(com.bakdata.conquery.apiv1.forms.export_form.RelativeMode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test)

Example 5 with ExportForm

use of com.bakdata.conquery.apiv1.forms.export_form.ExportForm in project conquery by bakdata.

the class FormConfigTest method setupTest.

@BeforeEach
public void setupTest() {
    final ManagedQuery managedQuery = new ManagedQuery(null, null, dataset);
    managedQuery.setQueryId(UUID.randomUUID());
    form = new ExportForm();
    AbsoluteMode mode = new AbsoluteMode();
    form.setTimeMode(mode);
    form.setQueryGroupId(managedQuery.getId());
    mode.setForm(form);
    mode.setFeatures(List.of(new CQConcept()));
    user = new User("test", "test", storage);
    storage.addUser(user);
}
Also used : User(com.bakdata.conquery.models.auth.entities.User) AbsoluteMode(com.bakdata.conquery.apiv1.forms.export_form.AbsoluteMode) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) ManagedQuery(com.bakdata.conquery.models.query.ManagedQuery) ExportForm(com.bakdata.conquery.apiv1.forms.export_form.ExportForm) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ExportForm (com.bakdata.conquery.apiv1.forms.export_form.ExportForm)5 CQConcept (com.bakdata.conquery.apiv1.query.concept.specific.CQConcept)3 AbsoluteMode (com.bakdata.conquery.apiv1.forms.export_form.AbsoluteMode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Test (org.junit.jupiter.api.Test)2 FormConfigAPI (com.bakdata.conquery.apiv1.forms.FormConfigAPI)1 RelativeMode (com.bakdata.conquery.apiv1.forms.export_form.RelativeMode)1 User (com.bakdata.conquery.models.auth.entities.User)1 Dataset (com.bakdata.conquery.models.datasets.Dataset)1 FormConfig (com.bakdata.conquery.models.forms.configs.FormConfig)1 FormConfigOverviewRepresentation (com.bakdata.conquery.models.forms.configs.FormConfig.FormConfigOverviewRepresentation)1 FormType (com.bakdata.conquery.models.forms.frontendconfiguration.FormType)1 ManagedForm (com.bakdata.conquery.models.forms.managed.ManagedForm)1 ManagedInternalForm (com.bakdata.conquery.models.forms.managed.ManagedInternalForm)1 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 FormConfigId (com.bakdata.conquery.models.identifiable.ids.specific.FormConfigId)1 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 TextNode (com.fasterxml.jackson.databind.node.TextNode)1