small DBController code clean up

This commit is contained in:
Jannik 2017-12-12 19:19:01 +01:00
parent c70786cdf4
commit 9b443dfeae
2 changed files with 15 additions and 23 deletions

View File

@ -1131,7 +1131,7 @@ public class MainWindowController {
BufferedImage originalImage = ImageIO.read(new File(coverPath)); //load cover
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
coverPath = pictureCache + "/" + coverName; // TODO test path
coverPath = pictureCache + "/" + coverName;
ImageIO.write(resizeImagePNG, "png", new File(coverPath)); //save image to pictureCache
} catch (IOException e) {
LOGGER.error("Ops something went wrong! Error while resizing cover.", e);

View File

@ -226,11 +226,7 @@ public class DBController {
LOGGER.info("Getting all .rpx files in " + dir.getCanonicalPath()+" including those in subdirectories");
// for all files in dir get the app.xml
for (File file : files) {
if(System.getProperty("os.name").equals("Linux")){
appFile = new File(file.getParent() + "/app.xml");
} else {
appFile = new File(file.getParent()+"\\app.xml");
}
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(appFile);
@ -238,6 +234,7 @@ public class DBController {
title_ID = title_ID.substring(0, 8) + "-" + title_ID.substring(8, title_ID.length());
LOGGER.info("Name: " + file.getName() + "; Title ID: " + title_ID);
ResultSet rs = stmt.executeQuery("SELECT * FROM games WHERE TitleID = '" + title_ID + "';");
// for all elements in the games table check if it's already present, else add it
while (rs.next()) {
if (checkEntry(rs.getString(2))) {
@ -247,17 +244,12 @@ public class DBController {
BufferedImage originalImage = ImageIO.read(new URL(rs.getString(6)));// change path to where file is located
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 400, 600);
// TODO rework paths
if(System.getProperty("os.name").equals("Linux")) {
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"/"+rs.getString(3)+".png")); //change path where you want it saved
coverPath = pictureCache+"/"+rs.getString(3)+".png";
} else {
ImageIO.write(resizeImagePNG, "png", new File(pictureCache+"\\"+rs.getString(3)+".png")); //change path where you want it saved
coverPath = pictureCache+"\\"+rs.getString(3)+".png";
}
ImageIO.write(resizeImagePNG, "png", new File(pictureCache + "/" + rs.getString(3) + ".png"));
coverPath = pictureCache + "/" + rs.getString(3) + ".png";
LOGGER.info(rs.getString(2) + ": adding ROM");
addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3), rs.getString(5),"","0");
addGame(rs.getString(2), coverPath, file.getCanonicalPath(), rs.getString(1), rs.getString(3),
rs.getString(5), "", "0");
}
}
}