Package io.jmix.rest.impl.config
Class RestJsonTransformations
java.lang.Object
io.jmix.rest.impl.config.RestJsonTransformations
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 Summary
Modifier and TypeFieldDescriptionprotected org.springframework.core.env.Environment
protected com.google.common.collect.Table<String,
String, EntityJsonTransformer> protected boolean
protected static final String
protected ReadWriteLock
protected Resources
protected org.springframework.web.context.WebApplicationContext
protected com.google.common.collect.Table<String,
String, EntityJsonTransformer> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
getTransformer
(String entityName, String modelVersion, JsonTransformationDirection transformerDirection) Tries to find the transformer for the given entity, model version and transformation direction.protected void
init()
protected void
loadConfig
(org.dom4j.Element rootElem) protected void
parseCustomTransformers
(String currentEntityName, String oldEntityName, String version, org.dom4j.Element customElem) protected void
parseStandardTransformers
(String currentEntityName, String oldEntityName, String version, org.dom4j.Element transformationElem) protected void
processOneDirectionConfig
(org.dom4j.Element element, StandardEntityJsonTransformer transformer)
-
Field Details
-
JMIX_REST_JSON_TRANSFORMATION_CONFIG_PROP_NAME
- See Also:
-
initialized
protected volatile boolean initialized -
lock
-
toVersionTransformers
protected com.google.common.collect.Table<String,String, toVersionTransformersEntityJsonTransformer> -
fromVersionTransformers
protected com.google.common.collect.Table<String,String, fromVersionTransformersEntityJsonTransformer> -
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 namemodelVersion
- domain model versiontransformerDirection
- 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
-
parseCustomTransformers
-
processOneDirectionConfig
protected void processOneDirectionConfig(org.dom4j.Element element, StandardEntityJsonTransformer transformer)
-