src/main/java/de/uapcore/lightpit/dao/ModuleDao.java

changeset 31
58f78f0142e8
parent 30
fb30f7b78f9b
child 33
fd8c40ff78c3
equal deleted inserted replaced
30:fb30f7b78f9b 31:58f78f0142e8
48 */ 48 */
49 protected void mapColumns(ResultSet result, Module mod) throws SQLException { 49 protected void mapColumns(ResultSet result, Module mod) throws SQLException {
50 mod.setModID(result.getInt("modid")); 50 mod.setModID(result.getInt("modid"));
51 mod.setClassname(result.getString("classname")); 51 mod.setClassname(result.getString("classname"));
52 mod.setVisible(result.getBoolean("visible")); 52 mod.setVisible(result.getBoolean("visible"));
53 mod.setPriority(result.getInt("priority"));
53 } 54 }
54 55
55 56
56 /** 57 /**
57 * Must return a prepared statement for a single object query with the specified properties. 58 * Must return a prepared statement for a single object query with the specified properties.
66 * @throws SQLException 67 * @throws SQLException
67 */ 68 */
68 protected PreparedStatement moduleCheckStatement(Connection conn) throws SQLException { 69 protected PreparedStatement moduleCheckStatement(Connection conn) throws SQLException {
69 return conn.prepareStatement("SELECT visible FROM lpitcore_module WHERE classname = ?"); 70 return conn.prepareStatement("SELECT visible FROM lpitcore_module WHERE classname = ?");
70 } 71 }
71 72
72 /** 73 /**
73 * Must return a prepared statement for insertion with the specified properties. 74 * Must return a prepared statement for insertion with the specified properties.
74 * 75 *
75 * <ul> 76 * <ul>
76 * <li>Parameter 1: classname</li> 77 * <li>Parameter 1: classname</li>
77 * <li>Parameter 2: visible</li> 78 * <li>Parameter 2: visible</li>
79 * <li>Parameter 3: priority</li>
78 * </ul> 80 * </ul>
79 * 81 *
80 * @param conn the connection to use 82 * @param conn the connection to use
81 * @return the prepared statement 83 * @return the prepared statement
82 * @throws SQLException 84 * @throws SQLException
83 */ 85 */
84 protected PreparedStatement moduleInsertStatement(Connection conn) throws SQLException { 86 protected PreparedStatement moduleInsertStatement(Connection conn) throws SQLException {
85 return conn.prepareStatement("INSERT INTO lpitcore_module (classname, visible) VALUES (?, ?)"); 87 return conn.prepareStatement("INSERT INTO lpitcore_module (classname, visible, priority) VALUES (?, ?, ?)");
86 } 88 }
87 89
88 /** 90 /**
89 * Synchronizes a set of registered module classes with the database. 91 * Synchronizes a set of registered module classes with the database.
90 * 92 *
108 110
109 check.setString(1, modEntry.getKey()); 111 check.setString(1, modEntry.getKey());
110 try (ResultSet r = check.executeQuery()) { 112 try (ResultSet r = check.executeQuery()) {
111 if (!r.next()) { 113 if (!r.next()) {
112 insert.setString(1, modEntry.getKey()); 114 insert.setString(1, modEntry.getKey());
115 insert.setInt(3, modEntry.getValue().defaultPriority());
113 insert.executeUpdate(); 116 insert.executeUpdate();
114 } 117 }
115 } 118 }
116 } 119 }
117 } 120 }

mercurial