Package com.adobe.aemds.guide.utils
Class TranslationUtils
- java.lang.Object
-
- com.adobe.aemds.guide.utils.TranslationUtils
-
public class TranslationUtils extends java.lang.Object
Utility helper functions for translation.
-
-
Field Summary
Fields Modifier and Type Field Description static com.fasterxml.jackson.databind.ObjectMapper
mapper
static java.lang.String
PN_TRANSLATION_IDS
static java.lang.String
TRANSLATION_TOKEN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addPropertyToTranslationIds(Resource resource, java.lang.String propertyName, java.lang.String dictKeyForPropertyName)
Adds the given dictionary key to the resource value mapstatic java.lang.String
get(java.lang.String path, java.lang.String propertyOrObjectKey, java.lang.Integer index, boolean isProperty)
Returns unique dictionary key based on path and property provided.static java.lang.String
get(java.lang.String path, java.lang.String propertyOrObjectKey, java.lang.Integer index, boolean isProperty, java.lang.String originalKey)
Returns unique dictionary key based on path and property provided.static java.lang.String
getDictionaryPath(ResourceResolver resourceResolver, java.lang.String guideContainerPath)
Returns path to the old or new dictionary based on the container path providedstatic javax.jcr.Node
getOrAddDictionaryNode(ResourceResolver resolver, java.lang.String containerPath)
Returns or adds dictionary node based on the adaptive form container path providedstatic java.lang.String
getTranslationId(Resource resource, java.lang.String propertyName, java.lang.String propertyValue)
Returns translation id for the property name and property valuestatic java.lang.String
getTranslationId(Resource resource, java.lang.String propertyName, java.lang.String propertyValue, boolean checkArray)
Returns translation id for the property name and property valuestatic java.lang.String
getTranslationId(ValueMap properties, java.lang.String propertyName, java.lang.String propertyValue)
Returns translation id for the property name and property valuestatic java.lang.String
getTranslationId(ValueMap properties, java.lang.String propertyName, java.lang.String propertyValue, boolean checkArray)
Returns translation id for the property name and property valuestatic boolean
isNewTranslation(Resource resource)
Checks if the given resource use's new translation technique (unique keys for each property)static boolean
isNewTranslation(ValueMap properties)
Checks if the given resource use's new translation technique (unique keys for each property)static void
removePropertyFromTranslationIds(Resource resource, java.lang.String propertyName)
Deletes the given dictionary key from the resource value map
-
-
-
Field Detail
-
TRANSLATION_TOKEN
public static final java.lang.String TRANSLATION_TOKEN
- See Also:
- Constant Field Values
-
PN_TRANSLATION_IDS
public static final java.lang.String PN_TRANSLATION_IDS
- See Also:
- Constant Field Values
-
mapper
public static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
get
public static java.lang.String get(java.lang.String path, java.lang.String propertyOrObjectKey, java.lang.Integer index, boolean isProperty, java.lang.String originalKey)
Returns unique dictionary key based on path and property provided. Additionally for array types, index could be provided.- Parameters:
path
- path of the current object from its parentpropertyOrObjectKey
- property or name of the objectindex
- index, if property value is of type arrayisProperty
- isProperty, true if the key is a propertyoriginalKey
- existing dictionary key, if a random id is not provided- Returns:
- unique dictionary key
-
get
public static java.lang.String get(java.lang.String path, java.lang.String propertyOrObjectKey, java.lang.Integer index, boolean isProperty)
Returns unique dictionary key based on path and property provided. Additionally for array types, index could be provided.- Parameters:
path
- path of the current object from its parentpropertyOrObjectKey
- property or name of the objectindex
- index, if property value is of type arrayisProperty
- isProperty, true if the key is a property- Returns:
- unique dictionary key
-
getDictionaryPath
public static java.lang.String getDictionaryPath(ResourceResolver resourceResolver, java.lang.String guideContainerPath)
Returns path to the old or new dictionary based on the container path provided- Parameters:
resourceResolver
- reference to theResourceResolver
guideContainerPath
- path to the form container- Returns:
- path to the dictionary
-
getOrAddDictionaryNode
public static javax.jcr.Node getOrAddDictionaryNode(ResourceResolver resolver, java.lang.String containerPath) throws javax.jcr.RepositoryException
Returns or adds dictionary node based on the adaptive form container path provided- Parameters:
resolver
- reference to theResourceResolver
containerPath
- path to the form container- Returns:
- returns dicitionary node or add's one if it does not exist
- Throws:
javax.jcr.RepositoryException
-
getTranslationId
public static java.lang.String getTranslationId(ValueMap properties, java.lang.String propertyName, java.lang.String propertyValue, boolean checkArray) throws java.io.IOException
Returns translation id for the property name and property value- Parameters:
properties
- reference to the propertiesValueMap
propertyName
- name of the propertypropertyValue
- property valuecheckArray
- if property value is of array type, this should be true- Returns:
- translation id of the property name stored in the resource
- Throws:
java.io.IOException
-
getTranslationId
public static java.lang.String getTranslationId(ValueMap properties, java.lang.String propertyName, java.lang.String propertyValue) throws java.io.IOException
Returns translation id for the property name and property value- Parameters:
properties
- reference to the propertiesValueMap
propertyName
- name of the propertypropertyValue
- property value- Returns:
- translation id of the property name stored in the resource
- Throws:
java.io.IOException
-
isNewTranslation
public static boolean isNewTranslation(ValueMap properties)
Checks if the given resource use's new translation technique (unique keys for each property)- Parameters:
properties
- reference to theValueMap
- Returns:
- true for new translation technique
-
isNewTranslation
public static boolean isNewTranslation(Resource resource)
Checks if the given resource use's new translation technique (unique keys for each property)- Parameters:
resource
- reference to theResource
- Returns:
- true for new translation technique
-
getTranslationId
public static java.lang.String getTranslationId(Resource resource, java.lang.String propertyName, java.lang.String propertyValue) throws java.io.IOException
Returns translation id for the property name and property value- Parameters:
resource
- reference to the resourceResource
propertyName
- name of the propertypropertyValue
- property value- Returns:
- translation id of the property name stored in the resource
- Throws:
java.io.IOException
-
getTranslationId
public static java.lang.String getTranslationId(Resource resource, java.lang.String propertyName, java.lang.String propertyValue, boolean checkArray) throws java.io.IOException
Returns translation id for the property name and property value- Parameters:
resource
- reference to the resourceResource
propertyName
- name of the propertypropertyValue
- property valuecheckArray
- if property value is of array type, this should be true- Returns:
- translation id of the property name stored in the resource
- Throws:
java.io.IOException
-
addPropertyToTranslationIds
public static void addPropertyToTranslationIds(Resource resource, java.lang.String propertyName, java.lang.String dictKeyForPropertyName) throws java.io.IOException, javax.jcr.RepositoryException
Adds the given dictionary key to the resource value map- Parameters:
resource
- reference to theResource
propertyName
- name of the propertydictKeyForPropertyName
- dictionary key for the property- Throws:
java.io.IOException
javax.jcr.RepositoryException
-
removePropertyFromTranslationIds
public static void removePropertyFromTranslationIds(Resource resource, java.lang.String propertyName) throws java.io.IOException, javax.jcr.RepositoryException
Deletes the given dictionary key from the resource value map- Parameters:
resource
- reference to theResource
propertyName
- name of the property- Throws:
java.io.IOException
javax.jcr.RepositoryException
-
-