-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from xenit-eu/ACC-1761-profile
[ACC-1761] Update HAL-FORMS entity profile endpoint with entity information
- Loading branch information
Showing
43 changed files
with
1,422 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...contentgrid/spring/data/rest/webmvc/blueprint/AttributeConstraintRepresentationModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.contentgrid.spring.data.rest.webmvc.blueprint; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Value; | ||
import org.springframework.hateoas.server.core.Relation; | ||
|
||
public sealed interface AttributeConstraintRepresentationModel { | ||
|
||
@JsonProperty | ||
String getType(); | ||
|
||
static AllowedValuesConstraintRepresentationModel allowedValues(List<String> values) { | ||
return AllowedValuesConstraintRepresentationModel.builder() | ||
.values(values) | ||
.build(); | ||
} | ||
|
||
static RequiredConstraintRepresentationModel required() { | ||
return new RequiredConstraintRepresentationModel(); | ||
} | ||
|
||
static UniqueConstraintRepresentationModel unique() { | ||
return new UniqueConstraintRepresentationModel(); | ||
} | ||
|
||
@Builder | ||
@Value | ||
@Relation(BlueprintLinkRelations.CONSTRAINT_STRING) | ||
class AllowedValuesConstraintRepresentationModel implements AttributeConstraintRepresentationModel { | ||
|
||
@Builder.Default | ||
List<String> values = new ArrayList<>(); | ||
|
||
@Override | ||
public String getType() { | ||
return "allowed-values"; | ||
} | ||
} | ||
|
||
@Relation(BlueprintLinkRelations.CONSTRAINT_STRING) | ||
final class RequiredConstraintRepresentationModel implements AttributeConstraintRepresentationModel { | ||
|
||
@Override | ||
public String getType() { | ||
return "required"; | ||
} | ||
} | ||
|
||
@Relation(BlueprintLinkRelations.CONSTRAINT_STRING) | ||
final class UniqueConstraintRepresentationModel implements AttributeConstraintRepresentationModel { | ||
|
||
@Override | ||
public String getType() { | ||
return "unique"; | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
.../java/com/contentgrid/spring/data/rest/webmvc/blueprint/AttributeRepresentationModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.contentgrid.spring.data.rest.webmvc.blueprint; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonUnwrapped; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import org.springframework.hateoas.CollectionModel; | ||
import org.springframework.hateoas.RepresentationModel; | ||
import org.springframework.hateoas.server.core.EmbeddedWrapper; | ||
import org.springframework.hateoas.server.core.EmbeddedWrappers; | ||
import org.springframework.hateoas.server.core.Relation; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@Relation(BlueprintLinkRelations.ATTRIBUTE_STRING) | ||
public class AttributeRepresentationModel extends RepresentationModel<AttributeRepresentationModel> { | ||
|
||
@NonNull | ||
private final String name; | ||
@JsonInclude(Include.NON_EMPTY) | ||
private final String title; | ||
|
||
private final String type; | ||
|
||
private final String description; | ||
|
||
private final boolean readOnly; | ||
|
||
private final boolean required; | ||
|
||
@JsonIgnore | ||
@Builder.Default | ||
private final Collection<AttributeConstraintRepresentationModel> constraints = List.of(); | ||
|
||
@JsonIgnore | ||
@Builder.Default | ||
private final Collection<SearchParamRepresentationModel> searchParams = List.of(); | ||
|
||
@JsonIgnore | ||
@Builder.Default | ||
private final Collection<AttributeRepresentationModel> attributes = List.of(); | ||
|
||
@JsonProperty | ||
@JsonUnwrapped | ||
public CollectionModel<EmbeddedWrapper> getEmbeddeds() { | ||
var embeddedWrappers = new EmbeddedWrappers(true); | ||
|
||
return CollectionModel.of(List.of( | ||
embeddedWrappers.wrap(constraints, BlueprintLinkRelations.CONSTRAINT), | ||
embeddedWrappers.wrap(searchParams, BlueprintLinkRelations.SEARCH_PARAM), | ||
embeddedWrappers.wrap(attributes, BlueprintLinkRelations.ATTRIBUTE) | ||
)); | ||
} | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@Relation(BlueprintLinkRelations.SEARCH_PARAM_STRING) | ||
public static class SearchParamRepresentationModel { | ||
|
||
String name; | ||
@JsonInclude(Include.NON_EMPTY) | ||
String title; | ||
String type; | ||
|
||
} | ||
} |
Oops, something went wrong.