Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6914 dpurdie 1
package com.erggroup.buildtool.ripple;
2
 
3
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
4
 
5
//  This class contains data about the package currently being built
6
//  The information is used for reporting purposes
7
//
8
//  Much of the data is extracted from the ANT project
9
 
10
public class ReportingData
11
{
12
    /**Release Identifier for the build
13
     */
14
    public int rtagId;
15
 
16
    /**Package name
17
     */
18
    public String packageName;
19
 
20
    /**Package version
21
     */
22
    public String packageVersion;
23
 
24
    /**Package extension
25
     */
26
    public String packageExtension;
27
 
28
    /**Package location
29
     * Not currently used
30
     */
31
    public String packageLocation;
32
 
33
    /**Package dependencies
34
     */
35
    public String packageDepends;
36
 
37
    /** Package Owners
38
     *  An email list
39
     */
40
    public String packageOwners;
41
 
42
    /** Build info for this package
43
     * 
44
     */
45
    public String packageBuildInfo;
46
 
47
    /**Is ripple flag
48
     */
49
    public boolean isRipple;
50
 
51
    /**Build Reason
52
     */
53
    public BuildReason buildReason;
54
 
55
    /**Package version identifier
56
     */
57
    public int packageVersionId;
58
 
59
    /**Fully published flag
60
     */
61
    public boolean isFullyPublished;
62
 
63
    /**New label
64
     */
65
    public String newVcsTag;
66
 
67
    /**Source control interaction
68
     * Not currently used
69
     */
70
    public boolean doesNotRequireSourceControlInteraction;
71
 
72
    /**Indicates that the build is a test build
73
     */
74
    public boolean isaTestBuild;
75
 
76
    /**Log file location
77
     */
78
    public String buildFailureLogFile;
79
 
80
    /** Publishing error message
81
     *  Must be less than 50 Characters as it may be fed into the RM Database
82
     */
83
    public String errMsg;
84
 
85
    /** Addition information
86
     */
87
    public String errMsgDetail;
88
 
89
    /**
90
     * Build Id
91
     */
92
    public int buildId;
93
 
94
    /**
95
     * BuildRef - unique build reference. 
96
     *   Bases for the build directory
97
     *   Bases for the saved log files
98
     */
99
    public String buildRef;
100
 
101
    /**
102
     * Constructor
103
     */
104
    public ReportingData()
105
    {
106
    }
107
 
108
    /**
109
     * Reset the values to their initial state
110
     * Used at the start of a build sub-task
111
     */
112
    public void resetData()
113
    {
114
        rtagId = 0;
115
        packageName = null;
116
        packageVersion = null;
117
        packageExtension = null;
118
        packageLocation = null;
119
        packageDepends = null;
120
        packageOwners = null;
121
        packageVersionId = 0;
122
        newVcsTag = null;
123
        errMsg = null;
124
        errMsgDetail = null;
125
        packageBuildInfo = null;
126
        buildId = 0;
127
        buildRef = null;
128
 
129
        isRipple = false;
130
        buildReason = null;
131
        doesNotRequireSourceControlInteraction = false;
132
        isaTestBuild = false;
133
        isFullyPublished = false;
134
    }
135
 
136
 
137
    /**
138
     * Convert a string to an integer, allowing for invalid strings.
139
     * 
140
     * @param arg    String to convert. May be null, May be surrounded with whitespace
141
     * @param defInt Return default value if 'arg' is not a numeric string
142
     * 
143
     * @return The integer value of the string, or the default value.
144
     */
145
    public static int toInt(String arg, int defInt)
146
    {
147
        if (arg != null)
148
        {
149
            try
150
            {
151
                return Integer.parseInt(arg.trim());
152
            } 
153
 
154
            catch (Exception e)
155
            {
156
            }
157
        }   
158
        return defInt;
159
    }
160
 
161
    /** Convert text to a boolean
162
     *  Utility function to convert things that look like a False into
163
     *  a false, and things that look like true into a true;
164
     *  
165
     *  Non-zero numbers are considered to be true
166
     * 
167
     * @param   arg     Null, 0, false, no are treated as false
168
     *
169
     */
170
    public static boolean toBool(String arg)
171
    {
172
        // Things that look FALSE
173
        if (arg == null)
174
            return false;
175
        if (arg.compareToIgnoreCase( "0" ) == 0)
176
            return false;
177
        if (arg.compareToIgnoreCase( "null" ) == 0)
178
            return false;
179
        if (arg.compareToIgnoreCase( "no" ) == 0)
180
            return false;
181
        if (arg.compareToIgnoreCase( "false" ) == 0)
182
            return false;
183
 
184
        //  Things that look TRUE
185
        if (arg.compareToIgnoreCase( "yes" ) == 0)
186
            return true;
187
        if (arg.compareToIgnoreCase( "true" ) == 0)
188
            return true;
189
 
190
        try
191
        {
192
            if (Integer.parseInt(arg) != 0)
193
                return true;
194
        } 
195
        catch (NumberFormatException nfe)
196
        {
197
        }
198
 
199
        return false;
200
    }
201
 
202
    /**
203
     * Convert a string to a BuildReason, allowing for invalid strings.
204
     * 
205
     * @param arg    String to convert. May be null, May be surrounded with whitespace
206
 
207
     * 
208
     * @return The integer value of the string, or the default value.
209
     */
210
    public static BuildReason toBuildReason(String arg)
211
    {
212
        return BuildReason.fromValue(arg);
213
    }
214
}