small DBController code clean up
This commit is contained in:
parent
c70786cdf4
commit
9b443dfeae
|
@ -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);
|
||||
|
|
|
@ -226,38 +226,30 @@ 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");
|
||||
}
|
||||
appFile = new File(file.getParent() + "/app.xml");
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
Document document = documentBuilder.parse(appFile);
|
||||
String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); //get titile_ID from app.xml
|
||||
String title_ID = document.getElementsByTagName("title_id").item(0).getTextContent(); // get titile_ID from app.xml
|
||||
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+"';");
|
||||
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))) {
|
||||
LOGGER.info(rs.getString(2) + ": game already in database");
|
||||
}else{
|
||||
} else {
|
||||
LOGGER.info("adding cover to cache ...");
|
||||
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";
|
||||
}
|
||||
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);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue