public void fill(CatalogItem item, ResultSet set) {
}
@Override
public CatalogPage generateAndFillPage(ResultSet set, boolean isParent) {
CatalogPage page = new CatalogPage();
try {
page.setId(set.getInt("id"));
if (isParent) {
page.setParent(-1);
} else {
page.setParent(set.getInt("parent"));
}
page.setOrder(set.getInt("order"));
page.setIconColor(set.getInt("icon_color"));
page.setIconImage(set.getInt("icon_image"));
page.setRank(set.getInt("minimum_rank"));
page.setLayout(CatalogLayout.valueOf(set.getString("layout")));
page.setTitle(set.getString("title"));
page.setHeader("");
page.setDescription("");
page.setEnabled(set.getInt("enabled") == 1);
} catch (Exception ignored) {}
page.setUsingRealData(true);
try (Connection connection = H4J.getStorage().getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(
"SELECT * FROM server_store_page_headers WHERE page_id = ? AND is_parent = ?")) {
statement.setInt(1, page.getId());
statement.setInt(2, (page.getParent() < 0 ? 1 : 0));
GapList<String> list = new GapList<>();
try (ResultSet headers = statement.executeQuery()) {
while(headers.next()) {
list.add(headers.getString("value"));
}
}
page.setHeaders(list);
}
} catch (Exception ex) {
H4J.getLogger(CatalogDAO.class.getName()).error(ex.getMessage());
page.setUsingRealData(false);
page.setHeaders(new GapList<String>());
page.setTexts(new GapList<String>());
}
try (Connection connection = H4J.getStorage().getConnection()) {
try (PreparedStatement statement = connection.prepareStatement(
"SELECT * FROM server_store_page_texts WHERE page_id = ? AND is_parent = ?")) {
statement.setInt(1, page.getId());
statement.setInt(2, (page.getParent() < 0 ? 1 : 0));
GapList<String> list = new GapList<>();
try (ResultSet texts = statement.executeQuery()) {
while(texts.next()) {
list.add(texts.getString("value"));
}
}
page.setTexts(list);
}
} catch (Exception ex) {
H4J.getLogger(CatalogDAO.class.getName()).error(ex.getMessage());
page.setUsingRealData(false);
page.setHeaders(new GapList<String>());
page.setTexts(new GapList<String>());
}
return page;
}