Skip to content

Commit

Permalink
Merge pull request #2984 from ingef/fix/previewconfig-check-null-or-e…
Browse files Browse the repository at this point in the history
…mpty

enforce non-null in EntityPreviewConfig Fields
  • Loading branch information
awildturtok authored Aug 1, 2024
2 parents 6b5962a + 2b3571b commit 55af633
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public class PreviewConfig {
* @implSpec the order of selects is the order of the output fields.
*/
@Valid
@NotNull
private List<InfoCardSelect> infoCardSelects = List.of();

@Valid
Expand All @@ -62,23 +63,27 @@ public class PreviewConfig {
/**
* Columns that should not be displayed to users in entity preview.
*/
@NotNull
private Set<ColumnId> hidden = Collections.emptySet();

/**
* SecondaryIds where the columns should be grouped together.
*/
@NotNull
private Set<SecondaryIdDescriptionId> grouping = Collections.emptySet();

/**
* All Connectors that may be used by users in the EntityPreview.
*
* @implNote This is purely for the frontend, the backend can theoretically be queried for all Connectors.
*/
@NotNull
private Set<ConnectorId> allConnectors = Collections.emptySet();

/**
* Connectors that shall be selected by default by the frontend.
*/
@NotNull
private Set<ConnectorId> defaultConnectors = Collections.emptySet();

/**
Expand All @@ -88,6 +93,7 @@ public class PreviewConfig {
* <p>
* The Frontend will use the concepts filters to render a search for entity preview.
*/
@NotNull
private Set<FilterId> searchFilters = Collections.emptySet();

@JacksonInject(useInput = OptBoolean.FALSE)
Expand Down Expand Up @@ -186,24 +192,19 @@ public List<Select> getSelects() {
}

public List<Filter<?>> resolveSearchFilters() {
if (searchFilters == null) {
return Collections.emptyList();
}

return searchFilters.stream()
.map(filterId -> datasetRegistry.findRegistry(filterId.getDataset()).getOptional(filterId))
return getSearchFilters().stream()
.map(filterId -> getDatasetRegistry().findRegistry(filterId.getDataset()).getOptional(filterId))
.flatMap(Optional::stream)
.toList();
}

public Concept<?> resolveSearchConcept() {
if (searchFilters == null) {
if (getSearchFilters().isEmpty()) {
return null;
}


return searchFilters.stream()
.map(filterId -> datasetRegistry.findRegistry(filterId.getDataset()).getOptional(filterId))
return getSearchFilters().stream()
.map(filterId -> getDatasetRegistry().findRegistry(filterId.getDataset()).getOptional(filterId))
.flatMap(Optional::stream)
.map(filter -> filter.getConnector().getConcept())
.distinct()
Expand Down

0 comments on commit 55af633

Please sign in to comment.