Package io.jmix.rest.transform
Class AbstractEntityJsonTransformer
java.lang.Object
io.jmix.rest.transform.AbstractEntityJsonTransformer
- All Implemented Interfaces:
EntityJsonTransformer
- Direct Known Subclasses:
StandardEntityJsonTransformer
Class containing a basic functionality of standard JSON transformer. It doest the following transformations:
- change entity name
- change attribute name
- remove attribute
-
Field Summary
Modifier and TypeFieldDescriptionprotected JsonTransformationDirection
protected String
protected RestJsonTransformations
protected static final org.slf4j.Logger
protected String
protected String
-
Constructor Summary
ConstructorDescriptionAbstractEntityJsonTransformer
(String fromEntityName, String toEntityName, String version, JsonTransformationDirection direction) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doCustomTransformations
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Override this method in the subclass to perform custom transformationsprotected void
removeAttributes
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) protected void
renameAttributes
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) protected void
replaceEntityName
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) void
setAttributesToRemove
(Set<String> attributesToRemove) void
setAttributesToRename
(Map<String, String> attributesToRename) void
setDirection
(JsonTransformationDirection direction) void
setFromEntityName
(String fromEntityName) void
setToEntityName
(String toEntityName) void
setVersion
(String version) protected void
transformEntityJson
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) transformJson
(String json) Method checks whether the passed JSON is an array of entities and if so it executes thetransformEntityJson(ObjectNode, ObjectMapper)
method for each array element.protected void
transformNestedToManyReferences
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) protected void
transformNestedToOneReferences
(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Field Details
-
log
protected static final org.slf4j.Logger log -
fromEntityName
-
toEntityName
-
attributesToRename
-
version
-
direction
-
attributesToRemove
-
jsonTransformations
-
-
Constructor Details
-
AbstractEntityJsonTransformer
public AbstractEntityJsonTransformer(String fromEntityName, String toEntityName, String version, JsonTransformationDirection direction)
-
-
Method Details
-
getTransformedEntityName
- Specified by:
getTransformedEntityName
in interfaceEntityJsonTransformer
-
transformJson
Method checks whether the passed JSON is an array of entities and if so it executes thetransformEntityJson(ObjectNode, ObjectMapper)
method for each array element. Method executes thetransformEntityJson(ObjectNode, ObjectMapper)
method otherwise.- Specified by:
transformJson
in interfaceEntityJsonTransformer
- Parameters:
json
- JSON containing an entity or a list of entities- Returns:
- transformed JSON
-
transformEntityJson
protected void transformEntityJson(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) throws IOException - Throws:
IOException
-
removeAttributes
protected void removeAttributes(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) -
transformNestedToOneReferences
protected void transformNestedToOneReferences(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) throws IOException - Throws:
IOException
-
transformNestedToManyReferences
protected void transformNestedToManyReferences(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) throws IOException - Throws:
IOException
-
renameAttributes
protected void renameAttributes(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) -
replaceEntityName
protected void replaceEntityName(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode) -
doCustomTransformations
protected void doCustomTransformations(com.fasterxml.jackson.databind.node.ObjectNode rootObjectNode, com.fasterxml.jackson.databind.ObjectMapper objectMapper) Override this method in the subclass to perform custom transformations -
getFromEntityName
-
setFromEntityName
-
getToEntityName
-
setToEntityName
-
getAttributesToRename
-
setAttributesToRename
-
getVersion
-
setVersion
-
getDirection
-
setDirection
-
getAttributesToRemove
-
setAttributesToRemove
-