Subversion Repositories DevTools

Rev

Rev 6914 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.erggroup.buildtool.ripple;

import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;

//  This class contains data about the package currently being built
//  The information is used for reporting purposes
//
//  Much of the data is extracted from the ANT project

public class ReportingData
{
    /**Release Identifier for the build
     */
    public int rtagId;
    
    /**Package name
     */
    public String packageName;

    /**Package version
     */
    public String packageVersion;

    /**Package extension
     */
    public String packageExtension;

    /**Package location
     * Not currently used
     */
    public String packageLocation;

    /**Package dependencies
     */
    public String packageDepends;

    /** Package Owners
     *  An email list
     */
    public String packageOwners;
    
    /** Build info for this package
     * 
     */
    public String packageBuildInfo;

    /**Is ripple flag
     */
    public boolean isRipple;
    
    /**Build Reason
     */
    public BuildReason buildReason;

    /**Package version identifier
     */
    public int packageVersionId;

    /**Fully published flag
     */
    public boolean isFullyPublished;

    /**New label
     */
    public String newVcsTag;

    /**Source control interaction
     * Not currently used
     */
    public boolean doesNotRequireSourceControlInteraction;

    /**Indicates that the build is a test build
     */
    public boolean isaTestBuild;

    /**Log file location
     */
    public String buildFailureLogFile;
    
    /** Publishing error message
     *  Must be less than 50 Characters as it may be fed into the RM Database
     */
    public String errMsg;
    
    /** Addition information
     */
    public String errMsgDetail;
    
    /**
     * Build Id
     */
    public int buildId;

    /**
     * BuildRef - unique build reference. 
     *   Bases for the build directory
     *   Bases for the saved log files
     */
    public String buildRef;

    /**
     * >0 Daemon Instruction ID, if a test build. 
     * <0 Not a daemon instruction
     */
    public int testBuildId;

    /**
     * The VCS tag of the package
     * Used in reporting a test build
     */
    public String vcsTag;
    
    /**
     * Constructor
     */
    public ReportingData()
    {
    }

    /**
     * Reset the values to their initial state
     * Used at the start of a build sub-task
     */
    public void resetData()
    {
        rtagId = 0;
        packageName = null;
        packageVersion = null;
        packageExtension = null;
        packageLocation = null;
        packageDepends = null;
        packageOwners = null;
        packageVersionId = 0;
        newVcsTag = null;
        vcsTag = null;
        errMsg = null;
        errMsgDetail = null;
        packageBuildInfo = null;
        buildId = 0;
        buildRef = null;
        
        isRipple = false;
        buildReason = null;
        doesNotRequireSourceControlInteraction = false;
        isaTestBuild = false;
        isFullyPublished = false;
        testBuildId = -1;
    }
    

    /**
     * Convert a string to an integer, allowing for invalid strings.
     * 
     * @param arg    String to convert. May be null, May be surrounded with whitespace
     * @param defInt Return default value if 'arg' is not a numeric string
     * 
     * @return The integer value of the string, or the default value.
     */
    public static int toInt(String arg, int defInt)
    {
        if (arg != null)
        {
            try
            {
                return Integer.parseInt(arg.trim());
            } 
            
            catch (Exception e)
            {
            }
        }   
        return defInt;
    }
    
    /** Convert text to a boolean
     *  Utility function to convert things that look like a False into
     *  a false, and things that look like true into a true;
     *  
     *  Non-zero numbers are considered to be true
     * 
     * @param   arg     Null, 0, false, no are treated as false
     *
     */
    public static boolean toBool(String arg)
    {
        // Things that look FALSE
        if (arg == null)
            return false;
        if (arg.compareToIgnoreCase( "0" ) == 0)
            return false;
        if (arg.compareToIgnoreCase( "null" ) == 0)
            return false;
        if (arg.compareToIgnoreCase( "no" ) == 0)
            return false;
        if (arg.compareToIgnoreCase( "false" ) == 0)
            return false;
        
        //  Things that look TRUE
        if (arg.compareToIgnoreCase( "yes" ) == 0)
            return true;
        if (arg.compareToIgnoreCase( "true" ) == 0)
            return true;
        
        try
        {
            if (Integer.parseInt(arg) != 0)
                return true;
        } 
        catch (NumberFormatException nfe)
        {
        }
    
        return false;
    }
    
    /**
     * Convert a string to a BuildReason, allowing for invalid strings.
     * 
     * @param arg    String to convert. May be null, May be surrounded with whitespace

     * 
     * @return The integer value of the string, or the default value.
     */
    public static BuildReason toBuildReason(String arg)
    {
        return BuildReason.fromValue(arg);
    }
}