Class AbstractEntityJsonTransformer

java.lang.Object
io.jmix.rest.transform.AbstractEntityJsonTransformer
All Implemented Interfaces:
EntityJsonTransformer
Direct Known Subclasses:
StandardEntityJsonTransformer

public abstract class AbstractEntityJsonTransformer extends Object implements EntityJsonTransformer
Class containing a basic functionality of standard JSON transformer. It doest the following transformations:
  • change entity name
  • change attribute name
  • remove attribute
  • Field Details

  • Constructor Details

  • Method Details

    • getTransformedEntityName

      public String getTransformedEntityName()
      Specified by:
      getTransformedEntityName in interface EntityJsonTransformer
    • transformJson

      public String transformJson(String json)
      Method checks whether the passed JSON is an array of entities and if so it executes the transformEntityJson(ObjectNode, ObjectMapper) method for each array element. Method executes the transformEntityJson(ObjectNode, ObjectMapper) method otherwise.
      Specified by:
      transformJson in interface EntityJsonTransformer
      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

      public String getFromEntityName()
    • setFromEntityName

      public void setFromEntityName(String fromEntityName)
    • getToEntityName

      public String getToEntityName()
    • setToEntityName

      public void setToEntityName(String toEntityName)
    • getAttributesToRename

      public Map<String,String> getAttributesToRename()
    • setAttributesToRename

      public void setAttributesToRename(Map<String,String> attributesToRename)
    • getVersion

      public String getVersion()
    • setVersion

      public void setVersion(String version)
    • getDirection

      public JsonTransformationDirection getDirection()
    • setDirection

      public void setDirection(JsonTransformationDirection direction)
    • getAttributesToRemove

      public Set<String> getAttributesToRemove()
    • setAttributesToRemove

      public void setAttributesToRemove(Set<String> attributesToRemove)