| 4736 |
rpuchmay |
1 |
package releaseManager;
|
|
|
2 |
|
|
|
3 |
import java.sql.Connection;
|
|
|
4 |
import java.sql.PreparedStatement;
|
|
|
5 |
import java.sql.ResultSet;
|
|
|
6 |
import java.sql.SQLException;
|
|
|
7 |
import java.util.ArrayList;
|
|
|
8 |
import java.util.List;
|
|
|
9 |
|
|
|
10 |
public class ReleaseManager
|
|
|
11 |
{
|
|
|
12 |
private Connection dbConnection;
|
|
|
13 |
|
|
|
14 |
private static final String RELEASE_TAG_NAME_COLUMN = "rtag_name";
|
|
|
15 |
private static final String PACKAGE_NAME_COLUMN = "pkg_name";
|
|
|
16 |
private static final String PACKAGE_VERSION_COLUMN = "pkg_version";
|
|
|
17 |
|
|
|
18 |
// If this query changes then the column names above likely change too
|
|
|
19 |
private static final String queryString =
|
|
|
20 |
"Select " +
|
|
|
21 |
"RELEASE_TAGS.RTAG_NAME, " +
|
|
|
22 |
"PACKAGES.PKG_NAME, " +
|
|
|
23 |
"PACKAGE_VERSIONS.PKG_VERSION, " +
|
|
|
24 |
"PACKAGE_VERSIONS.PV_ID " +
|
|
|
25 |
"from " +
|
|
|
26 |
"UNIT_TESTS, " +
|
|
|
27 |
"PACKAGE_VERSIONS, " +
|
|
|
28 |
"PACKAGES, " +
|
|
|
29 |
"RELEASE_CONTENT, " +
|
|
|
30 |
"RELEASE_TAGS, " +
|
|
|
31 |
"PROJECTS " +
|
|
|
32 |
"where PACKAGE_VERSIONS.PKG_ID = PACKAGES.PKG_ID " +
|
|
|
33 |
"and RELEASE_CONTENT.PV_ID = UNIT_TESTS.PV_ID " +
|
|
|
34 |
"and RELEASE_CONTENT.PV_ID = PACKAGE_VERSIONS.PV_ID " +
|
|
|
35 |
"and RELEASE_CONTENT.RTAG_ID = RELEASE_TAGS.RTAG_ID " +
|
|
|
36 |
"and PROJECTS.PROJ_ID = RELEASE_TAGS.PROJ_ID " +
|
|
|
37 |
"and UNIT_TESTS.TEST_TYPES_FK = 7 " +
|
|
|
38 |
"and RELEASE_TAGS.RTAG_ID = ? " + // This parameter needs to be substituted
|
|
|
39 |
"order by RELEASE_TAGS.RTAG_NAME asc";
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Constructor
|
|
|
43 |
* @param pDbConnection - An open connection to the Release Manager
|
|
|
44 |
* database
|
|
|
45 |
*/
|
|
|
46 |
public ReleaseManager(Connection pDbConnection)
|
|
|
47 |
{
|
|
|
48 |
dbConnection = pDbConnection;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Queries the Release Manager database for any packages that have UTF
|
|
|
53 |
* tests, and returns the result in a list.
|
|
|
54 |
* @param rtag_id - The rtag_id as displayed by Release Manager in the URL
|
|
|
55 |
* for the desired project.
|
|
|
56 |
* E.g.: if the URL is:http://bms:8002/ManagerSuite/Release_Manager/dependencies.asp?envtab=3&rtag_id=30684
|
|
|
57 |
* then the rtagId is 30684 (this happens to be Stockholm
|
|
|
58 |
* Rel 10.1.1.0)
|
|
|
59 |
* @return - A list of Packages, having UTF tests, that are associated with
|
|
|
60 |
* the given rtagId. Never null.
|
|
|
61 |
* @throws SQLException - If there was an error in the query.
|
|
|
62 |
*/
|
|
|
63 |
public List<VixPackage> getTestedPackages(int rtagId) throws SQLException
|
|
|
64 |
{
|
|
|
65 |
List<VixPackage> result = new ArrayList<VixPackage>();
|
|
|
66 |
ResultSet queryResult = runQuery(rtagId);
|
|
|
67 |
while (queryResult.next())
|
|
|
68 |
{
|
|
|
69 |
VixPackage pkg = parsePackage(rtagId, queryResult);
|
|
|
70 |
result.add(pkg);
|
|
|
71 |
}
|
|
|
72 |
return result;
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Create a new VixPackage and fill it with data
|
|
|
77 |
*
|
|
|
78 |
* @param rtagId - The release tag ID. This is gleaned from the Release
|
|
|
79 |
* Manager URL
|
|
|
80 |
* @param queryResult - The results of running the query against the
|
|
|
81 |
* Release Manager database
|
|
|
82 |
* @return - A list, possibly empty, of any packages that had UTF tests
|
|
|
83 |
* in the specified release.
|
|
|
84 |
* @throws SQLException - If the column names change in the database.
|
|
|
85 |
*/
|
|
|
86 |
private VixPackage parsePackage(int rtagId, ResultSet queryResult) throws SQLException
|
|
|
87 |
{
|
|
|
88 |
VixPackage pkg = new VixPackage();
|
|
|
89 |
pkg.releaseTagId = rtagId;
|
|
|
90 |
pkg.releaseTagName = queryResult.getNString(RELEASE_TAG_NAME_COLUMN);
|
|
|
91 |
pkg.packageName = queryResult.getNString(PACKAGE_NAME_COLUMN);
|
|
|
92 |
pkg.packageVersion = queryResult.getNString(PACKAGE_VERSION_COLUMN);
|
|
|
93 |
return pkg;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
/**
|
|
|
97 |
* Create the SQL query to run against the Release Manager database
|
|
|
98 |
* ensuring all parameters are substituted
|
|
|
99 |
*
|
|
|
100 |
* @param rtagId - The release tag ID. This is gleaned from the Release
|
|
|
101 |
* Manager URL.
|
|
|
102 |
* @return - The results from the query. Never null.
|
|
|
103 |
* @throws SQLException - If there was an error in the query.
|
|
|
104 |
*/
|
|
|
105 |
private ResultSet runQuery(int rtagId) throws SQLException
|
|
|
106 |
{
|
|
|
107 |
PreparedStatement query;
|
|
|
108 |
query = dbConnection.prepareStatement(queryString);
|
|
|
109 |
query.setInt(1, rtagId);
|
|
|
110 |
ResultSet queryResult = query.executeQuery();
|
|
|
111 |
return queryResult;
|
|
|
112 |
}
|
|
|
113 |
}
|