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

plugin: fix webui model's mutability of collection properties #54

Merged
merged 1 commit into from
Mar 14, 2024
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 @@ -17,7 +17,7 @@
public class MutableAccessRequest implements Serializable {

private String user;
private Set<String> roles = new HashSet<>();
private final Set<String> roles = new HashSet<>();
private String sourceAddress;

private String service;
Expand All @@ -27,6 +27,11 @@ public class MutableAccessRequest implements Serializable {
private String workspace;
private String layer;

public void setRoles(Set<String> roles) {
this.roles.clear();
if (roles != null) this.roles.addAll(roles);
}

public AccessRequest toRequest() {
return AccessRequest.builder()
.layer(layer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class MutableLayerDetails implements Serializable {
private MultiPolygon<?> area;
private SpatialFilterType spatialFilterType;
private CatalogMode catalogMode;
private Set<String> allowedStyles = new TreeSet<>();
private List<MutableLayerAttribute> attributes = new ArrayList<>();
private final Set<String> allowedStyles = new TreeSet<>();
private final List<MutableLayerAttribute> attributes = new ArrayList<>();

public MutableLayerDetails() {}

Expand All @@ -50,17 +50,25 @@ public MutableLayerDetails(@NonNull LayerDetails ld) {
setArea(ld.getArea());
setCatalogMode(ld.getCatalogMode());
setSpatialFilterType(ld.getSpatialFilterType());
setAllowedStyles(new TreeSet<>(ld.getAllowedStyles()));
setAllowedStyles(ld.getAllowedStyles());
setAttributes(ld.getAttributes().stream().map(MutableLayerAttribute::new).toList());
}

public void setAllowedStyles(Set<String> styles) {
this.allowedStyles.clear();
if (null != styles) this.allowedStyles.addAll(styles);
}

public void setAttributes(List<MutableLayerAttribute> list) {
this.attributes.clear();
if (null != list) this.attributes.addAll(list);
}

public LayerDetails toLayerDetails() {
Set<LayerAttribute> atts =
attributes == null || attributes.isEmpty()
? Set.of()
: attributes.stream()
.map(MutableLayerAttribute::toLayerAttribute)
.collect(Collectors.toSet());
attributes.stream()
.map(MutableLayerAttribute::toLayerAttribute)
.collect(Collectors.toSet());
Builder builder =
LayerDetails.builder()
.type(layerType)
Expand Down
Loading