use of dev.rosewood.rosestacker.conversion.ConverterType in project RoseStacker by Rosewood-Development.
the class DataManager method setConversionHandlers.
public void setConversionHandlers(Set<ConverterType> converterTypes) {
this.databaseConnector.connect(connection -> {
String insertIgnore;
if (this.databaseConnector instanceof SQLiteConnector) {
insertIgnore = "INSERT OR IGNORE INTO ";
} else {
insertIgnore = "INSERT IGNORE ";
}
String query = insertIgnore + this.getTablePrefix() + "convert_handler (name) VALUES (?)";
try (PreparedStatement statement = connection.prepareStatement(query)) {
for (ConverterType converterType : converterTypes) {
statement.setString(1, converterType.name());
statement.addBatch();
}
statement.executeBatch();
}
});
}
use of dev.rosewood.rosestacker.conversion.ConverterType in project RoseStacker by Rosewood-Development.
the class DataManager method getConversionHandlers.
public Set<ConverterType> getConversionHandlers() {
Set<ConverterType> conversionHandlers = EnumSet.noneOf(ConverterType.class);
this.databaseConnector.connect(connection -> {
String query = "SELECT name FROM " + this.getTablePrefix() + "convert_handler";
try (Statement statement = connection.createStatement()) {
ResultSet result = statement.executeQuery(query);
while (result.next()) {
ConverterType converterType = ConverterType.get(result.getString(1));
if (converterType != null)
conversionHandlers.add(converterType);
}
}
});
return conversionHandlers;
}
Aggregations