mirror of
https://github.com/Wisser/Jailer.git
synced 2026-04-30 03:17:51 -05:00
Import/Export of connections and models, WIP
This commit is contained in:
@@ -2764,6 +2764,8 @@ public abstract class DataModelManagerDialog extends javax.swing.JFrame {
|
||||
|
||||
private void importButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importButtonActionPerformed
|
||||
dbConnectionDialog.importConnections(SwingUtilities.getWindowAncestor(importButton));
|
||||
loadModelList();
|
||||
refresh();
|
||||
}//GEN-LAST:event_importButtonActionPerformed
|
||||
|
||||
private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportButtonActionPerformed
|
||||
|
||||
@@ -31,11 +31,9 @@ import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -218,18 +216,6 @@ public class DbConnectionDialog extends javax.swing.JDialog {
|
||||
connectionTypeName = ci.connectionTypeName;
|
||||
}
|
||||
|
||||
public boolean encrypt() {
|
||||
if (!encrypted && System.getProperty("unencrypted-credentials") == null) {
|
||||
url = stringObfuscator.encrypt(url);
|
||||
user = stringObfuscator.encrypt(user);
|
||||
password = stringObfuscator.encrypt(password);
|
||||
encrypted = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean decrypt() {
|
||||
if (encrypted) {
|
||||
url = stringObfuscator.decrypt(url);
|
||||
|
||||
@@ -67,7 +67,6 @@ import org.fife.rsta.ui.EscapableDialog;
|
||||
import net.sf.jailer.ExecutionContext;
|
||||
import net.sf.jailer.configuration.Configuration;
|
||||
import net.sf.jailer.ui.DbConnectionDialog.ConnectionInfo;
|
||||
import net.sf.jailer.ui.Environment.CopyFileVisitor;
|
||||
import net.sf.jailer.ui.UIUtil.PLAF;
|
||||
import net.sf.jailer.ui.util.CompoundIcon;
|
||||
import net.sf.jailer.util.LogUtil;
|
||||
@@ -140,7 +139,7 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
}
|
||||
|
||||
int y = 1;
|
||||
List<ConnectionInfo> connections = new ArrayList<>(connectionList);
|
||||
List<ConnectionInfo> connections = connectionList == null? new ArrayList<>() : new ArrayList<>(connectionList);
|
||||
connections.sort((a, b) -> a.alias.compareToIgnoreCase(b.alias));
|
||||
List<ConnectionInfo> rest = new ArrayList<>(connections);
|
||||
List<Entry<String, String>> entryList = new ArrayList<>(modelNames.entrySet());
|
||||
@@ -527,7 +526,9 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
sourcePath = dir;
|
||||
}
|
||||
Path targetDir = targetPath.resolve(sourcePath.relativize(dir));
|
||||
if (!targetDir.toFile().exists()) {
|
||||
if (targetDir.toFile().exists()) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
} else {
|
||||
tabuModels.add(dir.toFile().getName());
|
||||
}
|
||||
Files.createDirectories(targetDir);
|
||||
@@ -554,6 +555,7 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
};
|
||||
exportPanel.okButton.setText(" Import ");
|
||||
if (exportPanel.openDialog(owner, true, connectionList, tabuModels, "Import data models and connections", connectionDialog)) {
|
||||
executionContext.setDatamodelFolder(oldDatamodelFolder);
|
||||
return doImport(owner, file, false, exportPanel.selectedConnections, exportPanel.selectedModels, connectionDialog);
|
||||
}
|
||||
}
|
||||
@@ -619,6 +621,7 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
|
||||
entry = zipIn.getNextEntry();
|
||||
Set<String> models = new HashSet<>();
|
||||
Set<String> seenTopLevelDirs = new HashSet<>();
|
||||
// iterates over entries in the zip file
|
||||
while (entry != null) {
|
||||
String name = entry.getName();
|
||||
@@ -636,6 +639,12 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
cFile.delete();
|
||||
} else {
|
||||
String filePath = executionContext.getDatamodelFolder() + File.separator + name;
|
||||
String topLevelDir = name.replaceFirst("[/\\\\].*", "");
|
||||
if (!topLevelDir.equals(name)) {
|
||||
if (seenTopLevelDirs.add(topLevelDir)) {
|
||||
deleteDir(new File(executionContext.getDatamodelFolder() + File.separator + topLevelDir));
|
||||
}
|
||||
}
|
||||
if (!entry.isDirectory()) {
|
||||
// if the entry is a file, extracts it
|
||||
models.add(new File(filePath).getParentFile().getName());
|
||||
@@ -678,7 +687,8 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
}
|
||||
info = info + " imported.";
|
||||
if (!silent) {
|
||||
JOptionPane.showMessageDialog(owner, info);
|
||||
String message = info;
|
||||
UIUtil.invokeLater(() -> JOptionPane.showMessageDialog(owner, message));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
UIUtil.showException(owner, "Error", e);
|
||||
@@ -763,3 +773,15 @@ public class ExportPanel extends javax.swing.JPanel {
|
||||
|
||||
//TODO
|
||||
//TODO test with linux
|
||||
|
||||
//TODO
|
||||
//TODO test basics!
|
||||
|
||||
//TODO
|
||||
//TODO file chooser: initial pattern: *.gz weg, *.zip wohl doppelt
|
||||
|
||||
//TODO
|
||||
//TODO file chooser: initial pattern: vorschlag dateiname? (? exakt 1 Ding -> danach benennen?)
|
||||
|
||||
//TODO
|
||||
//TODO delete model folder before importing it (bc. exclude-associations.csv etc.)
|
||||
|
||||
Reference in New Issue
Block a user