Class DtoConverters


  • public final class DtoConverters
    extends java.lang.Object
    Utility class to help converting between V3 and V4 DTOs during migration period.
    Since:
    4.0.0
    • Field Detail

      • GENIE_ID_PREFIX

        public static final java.lang.String GENIE_ID_PREFIX
        The Genie 3 prefix for resource ID added to the set of tags by the system.
        See Also:
        Constant Field Values
      • GENIE_NAME_PREFIX

        public static final java.lang.String GENIE_NAME_PREFIX
        The Genie 3 prefix for resource names added to the set of tags by the system.
        See Also:
        Constant Field Values
    • Method Detail

      • toV4ApplicationRequest

        public static ApplicationRequest toV4ApplicationRequest​(Application v3Application)
                                                         throws java.lang.IllegalArgumentException
        Convert a V3 Application to a corresponding V4 ApplicationRequest.
        Parameters:
        v3Application - The application to convert
        Returns:
        An immutable ApplicationRequest instance
        Throws:
        java.lang.IllegalArgumentException - If any field is invalid during the conversion
      • toV4Application

        public static Application toV4Application​(Application v3Application)
                                           throws java.lang.IllegalArgumentException
        Convert a V3 Application DTO to a V4 Application DTO.
        Parameters:
        v3Application - The V3 application to convert
        Returns:
        The V4 application representation of the data in the V3 DTO
        Throws:
        java.lang.IllegalArgumentException - On invalid argument to one of the fields
      • toV3Application

        public static Application toV3Application​(Application v4Application)
                                           throws java.lang.IllegalArgumentException
        Convert a V4 Application DTO to a V3 application DTO.
        Parameters:
        v4Application - The V4 application to convert
        Returns:
        The V3 application representation of the data in the V4 DTO
        Throws:
        java.lang.IllegalArgumentException - On invalid argument for one of the fields
      • toV4ClusterRequest

        public static ClusterRequest toV4ClusterRequest​(Cluster v3Cluster)
        Convert a Cluster to a V4 ClusterRequest.
        Parameters:
        v3Cluster - The V3 cluster instance to convert
        Returns:
        An immutable ClusterRequest instance
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV4Cluster

        public static Cluster toV4Cluster​(Cluster v3Cluster)
                                   throws java.lang.IllegalArgumentException
        Convert a V3 Cluster to a V4 Cluster.
        Parameters:
        v3Cluster - The cluster to convert
        Returns:
        The V4 representation of the cluster
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV3Cluster

        public static Cluster toV3Cluster​(Cluster v4Cluster)
                                   throws java.lang.IllegalArgumentException
        Convert a V4 Cluster to a V3 Cluster.
        Parameters:
        v4Cluster - The cluster to convert
        Returns:
        The v3 cluster
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV4CommandRequest

        public static CommandRequest toV4CommandRequest​(Command v3Command)
                                                 throws java.lang.IllegalArgumentException
        Convert a V3 Command to a V4 CommandRequest.
        Parameters:
        v3Command - The V3 command to convert
        Returns:
        An immutable CommandRequest instance
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV4Command

        public static Command toV4Command​(Command v3Command)
                                   throws java.lang.IllegalArgumentException
        Convert a V3 Command to a V4 Command.
        Parameters:
        v3Command - The V3 Command to convert
        Returns:
        The V4 representation of the supplied command
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV3Command

        public static Command toV3Command​(Command v4Command)
                                   throws java.lang.IllegalArgumentException
        Convert a V4 Command to a V3 Command.
        Parameters:
        v4Command - The V4 command to convert
        Returns:
        An immutable V3 Command instance
        Throws:
        java.lang.IllegalArgumentException - On any invalid field during conversion
      • toV3JobRequest

        public static JobRequest toV3JobRequest​(JobRequest v4JobRequest)
        Helper method to convert a v4 JobRequest to a v3 job request.
        Parameters:
        v4JobRequest - The v4 job request instance
        Returns:
        The v3 job request instance
      • toV3Tags

        public static com.google.common.collect.ImmutableSet<java.lang.String> toV3Tags​(java.lang.String id,
                                                                                        java.lang.String name,
                                                                                        java.util.Set<java.lang.String> tags)
        Convert the V4 values supplied to how the tags would have looked in Genie V3.
        Parameters:
        id - The id of the resource
        name - The name of the resource
        tags - The tags on the resource
        Returns:
        The set of tags as they would have been in Genie 3
      • toV3CriterionTags

        public static com.google.common.collect.ImmutableSet<java.lang.String> toV3CriterionTags​(Criterion criterion)
        Convert a given V4 criterion to the equivalent representation in V3 set of tags.
        Parameters:
        criterion - The Criterion to convert
        Returns:
        A set of String's representing the criterion tags as they would have looked in V3
      • toV4Criterion

        public static Criterion toV4Criterion​(java.util.Set<java.lang.String> tags)
                                       throws GeniePreconditionException
        Convert a set of V3 criterion tags to a V4 criterion object.
        Parameters:
        tags - The tags to convert
        Returns:
        The V4 criterion
        Throws:
        GeniePreconditionException - If the tags convert to an invalid criterion
      • toV4ApplicationStatus

        public static ApplicationStatus toV4ApplicationStatus​(ApplicationStatus v3Status)
                                                       throws java.lang.IllegalArgumentException
        Convert a V3 ApplicationStatus to a V4 ApplicationStatus.
        Parameters:
        v3Status - The V3 status to convert
        Returns:
        The V4 status the V3 status maps to
        Throws:
        java.lang.IllegalArgumentException - if the V3 status has no current V4 mapping
      • toV4ApplicationStatus

        public static ApplicationStatus toV4ApplicationStatus​(java.lang.String status)
                                                       throws java.lang.IllegalArgumentException
        Attempt to convert an Application status string into a known enumeration value from ApplicationStatus.
        Parameters:
        status - The status string. Not null or empty.
        Returns:
        An ApplicationStatus instance
        Throws:
        java.lang.IllegalArgumentException - If the string couldn't be converted
      • toV3ApplicationStatus

        public static ApplicationStatus toV3ApplicationStatus​(ApplicationStatus v4Status)
                                                       throws java.lang.IllegalArgumentException
        Convert a V4 ApplicationStatus to a V3 ApplicationStatus.
        Parameters:
        v4Status - The V4 status to convert
        Returns:
        The V3 status the V4 status maps to
        Throws:
        java.lang.IllegalArgumentException - If the V4 status has no current V3 mapping
      • toV4CommandStatus

        public static CommandStatus toV4CommandStatus​(CommandStatus v3Status)
                                               throws java.lang.IllegalArgumentException
        Convert a V3 CommandStatus to a V4 CommandStatus.
        Parameters:
        v3Status - The V3 status to convert
        Returns:
        The V4 status the V3 status maps to
        Throws:
        java.lang.IllegalArgumentException - if the V3 status has no current V4 mapping
      • toV4CommandStatus

        public static CommandStatus toV4CommandStatus​(java.lang.String status)
                                               throws java.lang.IllegalArgumentException
        Attempt to convert a Command status string into a known enumeration value from CommandStatus.
        Parameters:
        status - The status string. Not null or empty.
        Returns:
        An CommandStatus instance
        Throws:
        java.lang.IllegalArgumentException - If the string couldn't be converted
      • toV3CommandStatus

        public static CommandStatus toV3CommandStatus​(CommandStatus v4Status)
                                               throws java.lang.IllegalArgumentException
        Convert a V4 CommandStatus to a V3 CommandStatus.
        Parameters:
        v4Status - The V4 status to convert
        Returns:
        The V3 status the V4 status maps to
        Throws:
        java.lang.IllegalArgumentException - If the V4 status has no current V3 mapping
      • toV4ClusterStatus

        public static ClusterStatus toV4ClusterStatus​(ClusterStatus v3Status)
                                               throws java.lang.IllegalArgumentException
        Convert a V3 ClusterStatus to a V4 ClusterStatus.
        Parameters:
        v3Status - The V3 status to convert
        Returns:
        The V4 status the V3 status maps to
        Throws:
        java.lang.IllegalArgumentException - if the V3 status has no current V4 mapping
      • toV4ClusterStatus

        public static ClusterStatus toV4ClusterStatus​(java.lang.String status)
                                               throws java.lang.IllegalArgumentException
        Attempt to convert a Cluster status string into a known enumeration value from ClusterStatus.
        Parameters:
        status - The status string. Not null or empty.
        Returns:
        An ClusterStatus instance
        Throws:
        java.lang.IllegalArgumentException - If the string couldn't be converted
      • toV3ClusterStatus

        public static ClusterStatus toV3ClusterStatus​(ClusterStatus v4Status)
                                               throws java.lang.IllegalArgumentException
        Convert a V4 ClusterStatus to a V3 ClusterStatus.
        Parameters:
        v4Status - The V4 status to convert
        Returns:
        The V3 status the V4 status maps to
        Throws:
        java.lang.IllegalArgumentException - If the V4 status has no current V3 mapping
      • toV4JobStatus

        public static JobStatus toV4JobStatus​(JobStatus v3Status)
                                       throws java.lang.IllegalArgumentException
        Convert a V3 JobStatus to a V4 JobStatus.
        Parameters:
        v3Status - The V3 status to convert
        Returns:
        The V4 status the V3 status maps to
        Throws:
        java.lang.IllegalArgumentException - if the V3 status has no current V4 mapping
      • toV3JobStatus

        public static JobStatus toV3JobStatus​(JobStatus v4Status)
                                       throws java.lang.IllegalArgumentException
        Convert a V4 JobStatus to a V3 JobStatus.
        Parameters:
        v4Status - The V4 status to convert
        Returns:
        The V3 status the V4 status maps to
        Throws:
        java.lang.IllegalArgumentException - If the V4 status has no current V3 mapping
      • toV4JobStatus

        public static JobStatus toV4JobStatus​(java.lang.String status)
                                       throws java.lang.IllegalArgumentException
        Attempt to convert a Job status string into a known enumeration value from JobStatus.
        Parameters:
        status - The status string. Not null or empty.
        Returns:
        A JobStatus instance
        Throws:
        java.lang.IllegalArgumentException - If the string couldn't be converted