Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds predefined resolution sets for export form #2818

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.bakdata.conquery.models.forms.managed.ManagedInternalForm;
import com.bakdata.conquery.models.forms.util.Alignment;
import com.bakdata.conquery.models.forms.util.Resolution;
import com.bakdata.conquery.models.forms.util.ResolutionShortNames;
import com.bakdata.conquery.models.i18n.I18n;
import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import com.bakdata.conquery.models.query.ManagedQuery;
Expand Down Expand Up @@ -55,11 +56,12 @@ public class ExportForm extends Form {

@NotNull @Valid @JsonManagedReference
private Mode timeMode;

@NotNull @NotEmpty
private List<Resolution> resolution = List.of(Resolution.COMPLETE);

private boolean alsoCreateCoarserSubdivisions = true;

@NotNull
@NotEmpty
private List<ResolutionShortNames> resolution = List.of(ResolutionShortNames.COMPLETE);

private boolean alsoCreateCoarserSubdivisions = false;

@JsonIgnore
private Query prerequisite;
Expand Down Expand Up @@ -94,15 +96,20 @@ public void resolve(QueryResolveContext context) {
timeMode.resolve(context);
prerequisite = queryGroup.getQuery();

List<Resolution> resolutionsFlat = resolution.stream()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heißt das, dass ich effektiv ein Export Formular machen kann, mit mehreren unterschiedlichen Resolutions auf einmal?
Also geschlüsselt auf Quartale, und dann noch für's ganze Jahr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genau, das geht schon immer und das JupyEnd hat das auch schon immer so genutzt :)

.flatMap(ResolutionShortNames::correspondingResolutions)
.distinct()
.toList();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ich glaube set wäre hier sogar sinnvoller, du hast es ja eh schon distinct

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es beeinflusst die Reihenfolge der DateContexts und somit die Sortierung der Zeilen in einem Export Formular ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Es soll immer grob nach fein sein



if(isAlsoCreateCoarserSubdivisions()) {
if(getResolution().size() != 1) {
if (isAlsoCreateCoarserSubdivisions()) {
if (resolutionsFlat.size() != 1) {
throw new IllegalStateException("Abort Form creation, because coarser subdivision are requested and multiple resolutions are given. With 'alsoCreateCoarserSubdivisions' set to true, provide only one resolution.");
}
resolvedResolutions = getResolution().get(0).getThisAndCoarserSubdivisions();
resolvedResolutions = resolutionsFlat.get(0).getThisAndCoarserSubdivisions();
}
else {
resolvedResolutions = getResolution();
resolvedResolutions = resolutionsFlat;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.bakdata.conquery.models.forms.util;

import java.util.stream.Stream;

/**
* This enum exists for compatibility reasons with the stratification
* dropdown menu in the frontend. This way the actual Resolution/Alignment logic does not need to be touched.
* <br><br>
* Because of uniformity and accessibility there are options like
* {@link ResolutionShortNames#COMPLETE_YEARS_QUARTERS}, for which the frontend could send a list of resolutions (<code>"value": ["COMPLETE","YEARS", "QUARTERS"]</code>).
* <br>
* However, setting this list as the <strong>default option</strong> does not work (see export_form.frontend_conf.json).
* Only a string applies, hence <code>"value": "COMPLETE_YEARS_QUARTERS"</code>.
*/
public enum ResolutionShortNames {

// SINGLE RESOLUTIONS (map directly to Resolution)
COMPLETE {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.COMPLETE);
}
},
YEARS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.YEARS);
}
},
QUARTERS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.QUARTERS);
}
},
DAYS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.DAYS);
}
},
// SPECIAL RESOLUTION SETS
YEARS_QUARTERS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.YEARS, Resolution.QUARTERS);
}
},
COMPLETE_YEARS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.COMPLETE, Resolution.YEARS);
}
},
COMPLETE_QUARTERS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.COMPLETE, Resolution.QUARTERS);
}
},
COMPLETE_YEARS_QUARTERS {
@Override
public Stream<Resolution> correspondingResolutions() {
return Stream.of(Resolution.COMPLETE, Resolution.YEARS, Resolution.QUARTERS);
}
};

public abstract Stream<Resolution> correspondingResolutions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@
"de": "Quartale"
},
"value": "QUARTERS"
},
{
"label": {
"de": "Jahre und Quartale"
},
"value": "YEARS_QUARTERS"
},
{
"label": {
"de": "Gesamter Zeitraum und Jahre"
},
"value": "COMPLETE_YEARS"
},
{
"label": {
"de": "Gesamter Zeitraum und Quartale"
},
"value": "COMPLETE_QUARTERS"
},
{
"label": {
"de": "Gesamter Zeitraum, Jahre und Quartale"
},
"value": "COMPLETE_YEARS_QUARTERS"
}
],
"validations": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ABSOLUTE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ABSOLUTE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ABSOLUTE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ENTITY_DATE",
"dateAggregationMode": "LOGICAL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ENTITY_DATE",
"dateAggregationMode": "LOGICAL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ENTITY_DATE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ENTITY_DATE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "ENTITY_DATE",
"features": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"timeMode":{
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "RELATIVE",
"indexSelector": "EARLIEST",
"timeUnit" : "QUARTERS",
"timeUnit": "QUARTERS",
"features": [
{
"ids": [
"alter"
],
"type": "CONCEPT",
{
"ids": [
"alter"
],
"type": "CONCEPT",
"tables": [
{
"id": "alter.alter",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
{
"type": "FORM_TEST",
"label": "REL-EXPORT-FORM Test",
"expectedCsv": {
"results": "tests/form/EXPORT_FORM/RELATIVE/RELATIVE_ONLY_OUTCOME/expected.csv"
},
"form": {
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"timeMode": {
"value": "RELATIVE",
"indexSelector": "EARLIEST",
"timeUnit": "QUARTERS",
"features": [
{
"type": "OR",
"children": [
{
"ids": [
"alter"
],
"type": "CONCEPT",
"tables": [
"type": "FORM_TEST",
"label": "REL-EXPORT-FORM Test",
"expectedCsv": {
"results": "tests/form/EXPORT_FORM/RELATIVE/RELATIVE_ONLY_OUTCOME/expected.csv"
},
"form": {
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "RELATIVE",
"indexSelector": "EARLIEST",
"timeUnit": "QUARTERS",
"features": [
{
"id": "alter.alter",
"filters": []
"type": "OR",
"children": [
{
"ids": [
"alter"
],
"type": "CONCEPT",
"tables": [
{
"id": "alter.alter",
"filters": []
}
]
}
]
},
{
"ids": [
"alter"
],
"type": "CONCEPT",
"tables": [
{
"id": "alter.alter",
"filters": []
}
]
}
]
}
]
},
{
"ids": [
"alter"
],
"type": "CONCEPT",
"tables": [
{
"id": "alter.alter",
"filters": []
}
]
],
"timeCountAfter": 4,
"indexPlacement": "BEFORE"
}
],
"timeCountAfter": 4,
"indexPlacement": "BEFORE"
}
},
"concepts": [
"/tests/form/shared/alter.concept.json",
"/tests/form/shared/geschlecht.concept.json",
"/tests/form/shared/versichertentage.concept.json"
],
"content": {
"tables": [
"/tests/form/shared/vers_stamm.table.json",
"/tests/form/shared/vers_tage_range.table.json"
},
"concepts": [
"/tests/form/shared/alter.concept.json",
"/tests/form/shared/geschlecht.concept.json",
"/tests/form/shared/versichertentage.concept.json"
],
"previousQueryResults": [
"tests/form/EXPORT_FORM/RELATIVE/RELATIVE_ONLY_OUTCOME/query_results_1.csv"
]
}
"content": {
"tables": [
"/tests/form/shared/vers_stamm.table.json",
"/tests/form/shared/vers_tage_range.table.json"
],
"previousQueryResults": [
"tests/form/EXPORT_FORM/RELATIVE/RELATIVE_ONLY_OUTCOME/query_results_1.csv"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"type": "EXPORT_FORM",
"queryGroup": "00000000-0000-0000-0000-000000000001",
"resolution": "QUARTERS",
"alsoCreateCoarserSubdivisions": true,
"timeMode": {
"value": "RELATIVE",
"indexSelector": "EARLIEST",
"timeUnit" : "QUARTERS",
"indexPlacement" : "BEFORE",
"timeCountBefore" : 4,
"timeUnit": "QUARTERS",
"indexPlacement": "BEFORE",
"timeCountBefore": 4,
"features": [
{
"ids": [
Expand Down
Loading