Skip to content

Commit

Permalink
Release candidate 1
Browse files Browse the repository at this point in the history
Updtates to auto import of old files #143
  • Loading branch information
witmoca committed Jun 6, 2023
1 parent b71258b commit 4feeea8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>be.witmoca</groupId>
<artifactId>BEATs</artifactId>
<version>2.0.0</version>
<version>2.0.0-rc1</version>
<packaging>jar</packaging>

<name>BEATs (Burning Ember Archival Tool Suite)</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
Expand Down Expand Up @@ -117,7 +116,6 @@ public void actionPerformed(ActionEvent e) {
try {
SQLConnection.loadNewInternalDb(loadFile, this.skipSanity);
} catch (ConnectionException e1) {
e1.printStackTrace();
String errorMessage = "";
boolean isRecoveredDb = SQLConnection.isRecoveredDb();
if (isRecoveredDb) {
Expand All @@ -140,9 +138,16 @@ public void actionPerformed(ActionEvent e) {
errorMessage += "Another instance is already running.\nOnly one instance is allowed.";
break;
case DB_MAJOR_OUTDATED:
errorMessage += "This file was made with an older version of Burning Ember.\nPlease try to import instead.";
loadEmptyFile = true;
break;
JOptionPane.showMessageDialog(ApplicationWindow.getAPP_WINDOW(), Lang.getUI("loadFileAction.importOlderVersion"), "Update",
JOptionPane.INFORMATION_MESSAGE);
try {
(new BEATsFileFilter()).importFile(loadFile);
} catch (Exception e2) {
e2.printStackTrace();
JOptionPane.showMessageDialog(ApplicationWindow.getAPP_WINDOW(), e2.getLocalizedMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
return;
case FOREIGN_KEYS_CONSTRAINTS:
errorMessage += "The loaded database contains errors.\n\n" + e1.getCause().getLocalizedMessage();
loadEmptyFile = true;
Expand All @@ -159,9 +164,9 @@ public void actionPerformed(ActionEvent e) {
break;
}


JOptionPane.showMessageDialog(ApplicationWindow.getAPP_WINDOW(), errorMessage, "Error",
JOptionPane.ERROR_MESSAGE);
JOptionPane.ERROR_MESSAGE);
e1.printStackTrace();

// If flag is set, load empty file. If not, crash the application due to critical error
if(loadEmptyFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public String getDescription() {
@Override
public void importFile(File source) throws Exception {
// Load file without checking versions, etc
LoadFileAction.getLoadWithoutSanity(source).actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "import"));;
LoadFileAction.getLoadWithoutSanity(source).actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "import"));
SQLConnection db = SQLConnection.getDbConn();

// Check application_id
Expand Down Expand Up @@ -97,12 +97,14 @@ public void importFile(File source) throws Exception {
// Save this file, with random filename in the backup directory
String importedFile = ResourceLoader.BACKUP_DIR + File.separator + "Import_1_" + ThreadLocalRandom.current().nextInt(0, Integer.MAX_VALUE) + "_" + source.getName();
db.saveDatabase(importedFile, false);
db.close();
// Recursively import again
importFile(new File(importedFile).getAbsoluteFile());
break;
return;
// Current major version should be 2
case 2:
// just load like normal
db.close();
LoadFileAction.getLoadFileAction(source).actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "load"));
return;
default:
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/Langs/UserInterface.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ checkFileSavedAction.dialogTitle = Confirm save

loadFileAction.recovered = Recovered
loadFileAction.recoveredMsg = Database recovered!\nBurning Ember detected an unusual shutdown.\nThe previously opened database has been recovered.
loadFileAction.importOlderVersion = Older version of database detected. The file will be updated automatically to the new version.

savedFileAction.overwrite = Do you want to overwrite this file?
savedFileAction.overwriteTitle = File Exists
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/Langs/UserInterface_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ checkFileSavedAction.dialogTitle = Confirm save

loadFileAction.recovered = Recovered
loadFileAction.recoveredMsg = Database recovered!\nBurning Ember detected an unusual shutdown.\nThe previously opened database has been recovered.
loadFileAction.importOlderVersion = Older version of database detected. The file will be updated automatically to the new version.

savedFileAction.overwrite = Do you want to overwrite this file?
savedFileAction.overwriteTitle = File Exists
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/Langs/UserInterface_nl_BE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ checkFileSavedAction.dialogTitle = Bevestig Opslaan

loadFileAction.recovered = Hersteld
loadFileAction.recoveredMsg = Database Hersteld!\nBurning Ember detecteerde een probleem bij de vorige sessie.\nDe vorige database is hersteld.
loadFileAction.importOlderVersion = Oude database versie gedetecteerd. Dit bestand wordt automatisch geupdate naar de nieuwste versie.

savedFileAction.overwrite = Wilt u dit bestand overschrijven?
savedFileAction.overwriteTitle = Bestand bestaat al
Expand Down

0 comments on commit 4feeea8

Please sign in to comment.