Subversion Repositories DevTools

Rev

Rev 6914 | Details | Compare with Previous | 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;
7155 dpurdie 100
 
101
    /**
102
     * >0 Daemon Instruction ID, if a test build. 
103
     * <0 Not a daemon instruction
104
     */
105
    public int testBuildId;
106
 
107
    /**
108
     * The VCS tag of the package
109
     * Used in reporting a test build
110
     */
111
    public String vcsTag;
6914 dpurdie 112
 
113
    /**
114
     * Constructor
115
     */
116
    public ReportingData()
117
    {
118
    }
119
 
120
    /**
121
     * Reset the values to their initial state
122
     * Used at the start of a build sub-task
123
     */
124
    public void resetData()
125
    {
126
        rtagId = 0;
127
        packageName = null;
128
        packageVersion = null;
129
        packageExtension = null;
130
        packageLocation = null;
131
        packageDepends = null;
132
        packageOwners = null;
133
        packageVersionId = 0;
134
        newVcsTag = null;
7155 dpurdie 135
        vcsTag = null;
6914 dpurdie 136
        errMsg = null;
137
        errMsgDetail = null;
138
        packageBuildInfo = null;
139
        buildId = 0;
140
        buildRef = null;
141
 
142
        isRipple = false;
143
        buildReason = null;
144
        doesNotRequireSourceControlInteraction = false;
145
        isaTestBuild = false;
146
        isFullyPublished = false;
7155 dpurdie 147
        testBuildId = -1;
6914 dpurdie 148
    }
149
 
150
 
151
    /**
152
     * Convert a string to an integer, allowing for invalid strings.
153
     * 
154
     * @param arg    String to convert. May be null, May be surrounded with whitespace
155
     * @param defInt Return default value if 'arg' is not a numeric string
156
     * 
157
     * @return The integer value of the string, or the default value.
158
     */
159
    public static int toInt(String arg, int defInt)
160
    {
161
        if (arg != null)
162
        {
163
            try
164
            {
165
                return Integer.parseInt(arg.trim());
166
            } 
167
 
168
            catch (Exception e)
169
            {
170
            }
171
        }   
172
        return defInt;
173
    }
174
 
175
    /** Convert text to a boolean
176
     *  Utility function to convert things that look like a False into
177
     *  a false, and things that look like true into a true;
178
     *  
179
     *  Non-zero numbers are considered to be true
180
     * 
181
     * @param   arg     Null, 0, false, no are treated as false
182
     *
183
     */
184
    public static boolean toBool(String arg)
185
    {
186
        // Things that look FALSE
187
        if (arg == null)
188
            return false;
189
        if (arg.compareToIgnoreCase( "0" ) == 0)
190
            return false;
191
        if (arg.compareToIgnoreCase( "null" ) == 0)
192
            return false;
193
        if (arg.compareToIgnoreCase( "no" ) == 0)
194
            return false;
195
        if (arg.compareToIgnoreCase( "false" ) == 0)
196
            return false;
197
 
198
        //  Things that look TRUE
199
        if (arg.compareToIgnoreCase( "yes" ) == 0)
200
            return true;
201
        if (arg.compareToIgnoreCase( "true" ) == 0)
202
            return true;
203
 
204
        try
205
        {
206
            if (Integer.parseInt(arg) != 0)
207
                return true;
208
        } 
209
        catch (NumberFormatException nfe)
210
        {
211
        }
212
 
213
        return false;
214
    }
215
 
216
    /**
217
     * Convert a string to a BuildReason, allowing for invalid strings.
218
     * 
219
     * @param arg    String to convert. May be null, May be surrounded with whitespace
220
 
221
     * 
222
     * @return The integer value of the string, or the default value.
223
     */
224
    public static BuildReason toBuildReason(String arg)
225
    {
226
        return BuildReason.fromValue(arg);
227
    }
228
}