-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -94,15 +96,20 @@ public void resolve(QueryResolveContext context) { | |
timeMode.resolve(context); | ||
prerequisite = queryGroup.getQuery(); | ||
|
||
List<Resolution> resolutionsFlat = resolution.stream() | ||
.flatMap(ResolutionShortNames::correspondingResolutions) | ||
.distinct() | ||
.toList(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -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" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)