Class RestJsonTransformations

java.lang.Object
io.jmix.rest.impl.config.RestJsonTransformations

@Component("rest_RestJsonTransformations") public class RestJsonTransformations extends Object
Class is used for loading and storing JSON transformers. These transformers are used when a request to the REST API is made by the client that works with a data model of the previous version. In this case transformer transforms a JSON from the old data model version to the current or vice versa. JSON transformers are loaded from configuration files defined by the jmix.rest.jsonTransformationConfig application property.
  • Field Details

    • JMIX_REST_JSON_TRANSFORMATION_CONFIG_PROP_NAME

      protected static final String JMIX_REST_JSON_TRANSFORMATION_CONFIG_PROP_NAME
      See Also:
    • initialized

      protected volatile boolean initialized
    • lock

      protected ReadWriteLock lock
    • toVersionTransformers

      protected com.google.common.collect.Table<String,String,EntityJsonTransformer> toVersionTransformers
    • fromVersionTransformers

      protected com.google.common.collect.Table<String,String,EntityJsonTransformer> fromVersionTransformers
    • resources

      @Autowired protected Resources resources
    • restApiContext

      @Autowired protected org.springframework.web.context.WebApplicationContext restApiContext
    • environment

      @Autowired protected org.springframework.core.env.Environment environment
  • Constructor Details

    • RestJsonTransformations

      public RestJsonTransformations()
  • Method Details

    • getTransformer

      public EntityJsonTransformer getTransformer(String entityName, String modelVersion, JsonTransformationDirection transformerDirection)
      Tries to find the transformer for the given entity, model version and transformation direction. If such transformer is defined in the transformers configuration file then it will be returned. If there is no transformer defined, a dummy transformer that doesn't do any transformation will be returned.
      Parameters:
      entityName - entity name
      modelVersion - domain model version
      transformerDirection - transformation direction (to version or from version)
      Returns:
      a JSON transformer instance
    • checkInitialized

      protected void checkInitialized()
    • init

      protected void init()
    • loadConfig

      protected void loadConfig(org.dom4j.Element rootElem)
    • parseStandardTransformers

      protected void parseStandardTransformers(String currentEntityName, String oldEntityName, String version, org.dom4j.Element transformationElem)
    • parseCustomTransformers

      protected void parseCustomTransformers(String currentEntityName, String oldEntityName, String version, org.dom4j.Element customElem)
    • processOneDirectionConfig

      protected void processOneDirectionConfig(org.dom4j.Element element, StandardEntityJsonTransformer transformer)