Class EntityArchiveUtils


  • public class EntityArchiveUtils
    extends Object
    Provides utility methods to copy attributes between entity data objects and XML element child element values. This class is intended to be used by archive import and export classes.
    • Constructor Detail

      • EntityArchiveUtils

        public EntityArchiveUtils()
    • Method Detail

      • setAttributeValueBase64Encoded

        public static void setAttributeValueBase64Encoded​(Element element,
                                                          String value)
        Set the given value base64 encoded on the XML element.
        Parameters:
        element - the XML element to add the attribute to (required)
        value - the value to encode as an attribute value
        Since:
        4.2.0
      • getAttributeValueBase64Decoded

        public static String getAttributeValueBase64Decoded​(Element element)
        Return the decoded base64 attribute value of the XML element.
        Parameters:
        element - the XML element to add the attribute to (required)
        Returns:
        the decoded base64 attribute value of the XML element.
        Since:
        4.2.0
      • copyFromEntityToElement

        public static void copyFromEntityToElement​(BaseEntity entity,
                                                   Element element)
        Copy the attributes of the given entity to the XML element.
        Parameters:
        entity - the data object element
        element - the XML element
      • copyFromEntityToElement

        public static void copyFromEntityToElement​(BaseEntity entity,
                                                   Element parent,
                                                   List<String> exclusions)
        Copy the attributes of the given entity to the XML element, excluding the attribute values defined in the exclusions list.
        Parameters:
        entity - the data object element
        parent - the XML element
        exclusions - the entity attribute names not to copy to the XML element
      • copyFromElementToEntity

        public static void copyFromElementToEntity​(Element element,
                                                   BaseEntity entity,
                                                   List<String> warnings)
        Copy the given XML element child values to the given data object entity.
        Parameters:
        element - the XML element to copy the child values from
        entity - the data object entity to copy the values to
        warnings - a list of warning to log any errors to
      • copyFromElementToEntity

        public static void copyFromElementToEntity​(Element element,
                                                   BaseEntity entity,
                                                   List<String> exclusions,
                                                   List<String> warnings)
        Copy the given XML element child values to the given data object entity, excluding the values defined in the exclusions list.
        Parameters:
        element - the XML element to copy the child values from
        entity - the data object entity to copy the values to
        exclusions - the list of property values to exclude
        warnings - a list of warning to log any errors to
      • copyFromEntityToEntity

        public static void copyFromEntityToEntity​(BaseEntity sourceEntity,
                                                  BaseEntity targetEntity,
                                                  Set<String> exclusionSet)
        Copy the attributes of the given source entity to the target entity, excluding the attribute values defined in the exclusion set. Note: This method copies any and all properties for which a getter is found, i.e. it is not limited to primitive types. Therefore, the exclusion set MUST contain entries for any getters that should not be used (e.g. TemplateVersion.CURRENT_VERSION_PROPERTY). This method is not part of the TM public API. Do not use it in scripts.
        Parameters:
        sourceEntity - the entity to copy from (required)
        targetEntity - the entity to copy to (required)
        exclusionSet - the entity attribute names not to copy to the target entity (required but can be empty)
        Since:
        5.1.5.1
      • copySubsetFromElementToEntity

        public static void copySubsetFromElementToEntity​(Element element,
                                                         BaseEntity entity,
                                                         List<String> propertiesToInclude,
                                                         List<String> warnings)
        Copy the given XML element child values to the given data object entity, using only the properties defined in the inclusion list.
        Parameters:
        element - the XML element to copy the child values from
        entity - the data object entity to copy the values to
        propertiesToInclude - the list of property values to set in the entity. No other properties will be set.
        warnings - a list of warning to log any errors to
      • hasXmlChars

        public static boolean hasXmlChars​(String value)
        Has XML characters
        Parameters:
        value - the value to test (optional)
        Returns:
        true if has XML characters
        Since:
        4.3.4