Skip to content

Commit

Permalink
Merge pull request #53 from groldan/plugin/fix_mutable_objects
Browse files Browse the repository at this point in the history
plugin: fix webui model's mutability of collection properties
  • Loading branch information
groldan authored Mar 14, 2024
2 parents 9bf85c6 + bff8b2b commit 8be6798
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
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

0 comments on commit 8be6798

Please sign in to comment.