blob: cf4cf01ea3691b609b7c02ab775b5bba42e89f22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
package org.openslx.bwlp.sat.database.mappers;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openslx.bwlp.sat.database.Database;
import org.openslx.bwlp.sat.database.MysqlConnection;
import org.openslx.bwlp.sat.database.MysqlStatement;
public class DbSoftwareTag {
private static final Logger LOGGER = LogManager.getLogger(DbSoftwareTag.class);
/**
* Get list of software installed in a certain image version.
*
* @param connection database connection to use
* @param imageVersionId UUID of image version
* @return list of software products
* @throws SQLException
*/
public static List<String> getImageVersionSoftwareList(MysqlConnection connection, String imageVersionId)
throws SQLException {
MysqlStatement stmt = connection.prepareStatement("SELECT softwarestring FROM software"
+ " INNER JOIN imageversion_x_software USING (softwareid)"
+ " WHERE imageversionid = :imageversionid");
stmt.setString("imageversionid", imageVersionId);
ResultSet rs = stmt.executeQuery();
List<String> softwareList = new ArrayList<>();
while (rs.next()) {
softwareList.add(rs.getString("softwarestring"));
}
stmt.close();
return softwareList;
}
/**
* Get list of software installed in a certain image version.
*
* @param imageVersionId UUID of image version
* @return list of software products
* @throws SQLException
*/
public static List<String> getImageVersionSoftwareList(String imageVersionId) throws SQLException {
try (MysqlConnection connection = Database.getConnection()) {
return getImageVersionSoftwareList(connection, imageVersionId);
} catch (SQLException e) {
LOGGER.error("Query failed in DbSoftware.getImageVersionSoftwareList()", e);
throw e;
}
}
public static List<String> getImageTags(MysqlConnection connection, String imageBaseId) throws SQLException {
MysqlStatement stmt = connection.prepareStatement("SELECT tagname FROM imagetag"
+ " WHERE imagebaseid = :imagebaseid");
stmt.setString("imagebaseid", imageBaseId);
ResultSet rs = stmt.executeQuery();
List<String> tagList = new ArrayList<>();
while (rs.next()) {
tagList.add(rs.getString("displayname"));
}
stmt.close();
return tagList;
}
}
|