Class Translation

java.lang.Object
com.broadleafcommerce.translation.domain.Translation
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable, com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class Translation extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable

Defines an entity that holds the value for a translation of a String field on another entity in a particular Locale. This is used to override the default value of that field in a matching locale.

Translations are designed to be unique per locale, entityType, entityId and entityField within a particular tenant context.

Author:
Nathan Moore (nathandmoore)
See Also:
  • Constructor Details

    • Translation

      public Translation(String id, Locale locale, String entityType, String entityId, String entityField, Object value)
    • Translation

      public Translation(String id, String entityField, Object value)
      Convenience constructor for commonly used id, field, value combination. Primarily in the context of tests.
      Parameters:
      id - - the translation id
      entityField - - the entity field to translate
      value - - the translation value.
    • Translation

      public Translation(String entityField, Object value)
      Convenience constructor for commonly used entity field, value combination. Primarily in the context of tests.
      Parameters:
      entityField - - the entity field to translate
      value - - the translation value.
    • Translation

      public Translation()
  • Method Details

    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
    • getId

      public String getId()
      The context ID of this Translation
      Returns:
      The context ID of this Translation
    • getLocale

      public Locale getLocale()
      The Locale wherein this Translation is applicable
      Returns:
      The Locale wherein this Translation is applicable.
    • getEntityType

      public String getEntityType()
      The type of the entity to which this translation applies represented by the repository domain class name.
      Returns:
      The type of the entity to which this translation applies represented by the repository domain class name.
    • getEntityId

      public String getEntityId()
      The ID of the entity to which this translation applies.
      Returns:
      The ID of the entity to which this translation applies.
    • getEntityField

      public String getEntityField()
      The name of the field on the entity to which this translation applies.
      Returns:
      The name of the field on the entity to which this translation applies.
    • getValue

      public Object getValue()
      This field holds the actual translated value. This is an Object to allow flexibility for what can be translated (ex: a String or a List of Strings). This should ideally match the type of the value held by entityField.

      Note, however, that for certain value types, there may be type mismatches with entityField once Jackson deserializes the value received in a request. For example, if a JSON array is received as the value, Jackson will simply deserialize it to a List. If your entityField was of type Set, it would produce an error in TranslationPostMapperMember when the value needed to be copied into the entity. Custom deserialization or custom translation logic in TranslationPostMapperMember may be used to resolve these differences.

      Returns:
      the actual translated value
      See Also:
    • getTypeHint

      public String getTypeHint()
      A type hint for this translation entity. This field indicates what kind of entity this translation belongs to. This is not populated by default, and is not persisted. In the case that it is needed, it is up to a service to manually populate this value.

      See TranslationTypeHint

    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getOverrideChangeContainer

      public com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer getOverrideChangeContainer()
      Optional. The override change container that should be used when mapping over the projection domain to set the change container for the repository domain. This is typically useful in bulk operations like import.
      Specified by:
      getOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • setId

      public void setId(String id)
      The context ID of this Translation
      Parameters:
      id - The context ID of this Translation
    • setLocale

      public void setLocale(Locale locale)
      The Locale wherein this Translation is applicable
      Parameters:
      locale - The Locale wherein this Translation is applicable.
    • setEntityType

      public void setEntityType(String entityType)
      The type of the entity to which this translation applies represented by the repository domain class name.
      Parameters:
      entityType - The type of the entity to which this translation applies represented by the repository domain class name. CATEGORY, OFFER.
    • setEntityId

      public void setEntityId(String entityId)
      The ID of the entity to which this translation applies.
      Parameters:
      entityId - The ID of the entity to which this translation applies.
    • setEntityField

      public void setEntityField(String entityField)
      The name of the field on the entity to which this translation applies.
      Parameters:
      entityField - The name of the field on the entity to which this translation applies.
    • setValue

      public void setValue(Object value)
      This field holds the actual translated value. This is an Object to allow flexibility for what can be translated (ex: a String or a List of Strings). This should ideally match the type of the value held by entityField.

      Note, however, that for certain value types, there may be type mismatches with entityField once Jackson deserializes the value received in a request. For example, if a JSON array is received as the value, Jackson will simply deserialize it to a List. If your entityField was of type Set, it would produce an error in TranslationPostMapperMember when the value needed to be copied into the entity. Custom deserialization or custom translation logic in TranslationPostMapperMember may be used to resolve these differences.

      Parameters:
      value - the actual translated value
      See Also:
    • setTypeHint

      public void setTypeHint(String typeHint)
      A type hint for this translation entity. This field indicates what kind of entity this translation belongs to. This is not populated by default, and is not persisted. In the case that it is needed, it is up to a service to manually populate this value.

      See TranslationTypeHint

    • setOverrideChangeContainer

      public void setOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
      Optional. The override change container that should be used when mapping over the projection domain to set the change container for the repository domain. This is typically useful in bulk operations like import.
      Specified by:
      setOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object