Skip to content

Commit

Permalink
v4.9.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
herve91 committed Apr 26, 2023
1 parent a05861e commit 3f08f3f
Show file tree
Hide file tree
Showing 36 changed files with 2,909 additions and 2,157 deletions.
2 changes: 1 addition & 1 deletion sources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Database export / import plugin for Archimate Tool
Bundle-SymbolicName: org.archicontribs.database;singleton:=true
Bundle-Version: 4.9.0.alpha
Bundle-Version: 4.9.0.beta
Bundle-Vendor: Herve Jouin
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
38 changes: 19 additions & 19 deletions sources/src/org/archicontribs/database/DBCheckForPluginUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.net.ssl.HttpsURLConnection;

import org.apache.log4j.Level;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
Expand Down Expand Up @@ -87,25 +87,25 @@ public DBCheckForPluginUpdate(boolean showPopup, String pluginApiUrl, String rel
dropinsFolderName = dropinsFolder.getCanonicalPath();
} catch (IOException err) {
if ( showPopup )
DBGui.popup(Level.ERROR, "Failed to get dropins folder.", err);
DBGuiUtils.popup(Level.ERROR, "Failed to get dropins folder.", err);
else
logger.error("Failed to get dropins folder.", err);
return;
}

if ( !dropinsFolder.canWrite() ) {
if ( showPopup )
DBGui.popup(Level.ERROR, "Can't write to \""+dropinsFolderName+"\" folder.");
DBGuiUtils.popup(Level.ERROR, "Can't write to \""+dropinsFolderName+"\" folder.");
else
DBGui.popup(Level.ERROR, "Can't write to \""+dropinsFolderName+"\" folder.");
DBGuiUtils.popup(Level.ERROR, "Can't write to \""+dropinsFolderName+"\" folder.");
return;
}

Map<String, String> versions = new TreeMap<String, String>(Collections.reverseOrder());
JSONParser parser = new JSONParser();

if ( showPopup )
DBGui.popup("Checking for a new database plugin version on GitHub ...");
DBGuiUtils.showPopupMessage("Checking for a new database plugin version on GitHub ...");
else
logger.debug("Checking for a new database plugin version on GitHub");

Expand Down Expand Up @@ -164,8 +164,8 @@ protected PasswordAuthentication getPasswordAuthentication() {

if ( result == null ) {
if ( showPopup ) {
DBGui.closePopup();
DBGui.popup(Level.ERROR, "Failed to check for new database plugin version.\n\nParsing error.");
DBGuiUtils.closePopupMessage();
DBGuiUtils.popup(Level.ERROR, "Failed to check for new database plugin version.\n\nParsing error.");
} else
logger.error("Failed to check for new database plugin version.\n\nParsing error.");
return;
Expand All @@ -184,19 +184,19 @@ protected PasswordAuthentication getPasswordAuthentication() {
}
}

if ( showPopup ) DBGui.closePopup();
if ( showPopup ) DBGuiUtils.closePopupMessage();

if ( versions.isEmpty() ) {
if ( showPopup )
DBGui.popup(Level.ERROR, "Failed to check for new database plugin version.\n\nDid not find any "+DBPlugin.pluginsPackage+"_*.archiplugin file.");
DBGuiUtils.popup(Level.ERROR, "Failed to check for new database plugin version.\n\nDid not find any "+DBPlugin.pluginsPackage+"_*.archiplugin file.");
else
logger.error("Failed to check for new database plugin version.\n\nDid not find any "+DBPlugin.pluginsPackage+"_*.archiplugin file.");
return;
}
} catch (Exception e) {
if ( showPopup ) {
DBGui.closePopup();
DBGui.popup(Level.ERROR, "Failed to check for new version on GitHub.", e);
DBGuiUtils.closePopupMessage();
DBGuiUtils.popup(Level.ERROR, "Failed to check for new version on GitHub.", e);
} else {
logger.error("Failed to check for new version on GitHub.", e);
}
Expand All @@ -210,23 +210,23 @@ protected PasswordAuthentication getPasswordAuthentication() {

if ( DBPlugin.pluginVersion.compareTo(new Version(entry.getKey())) >= 0 ) {
if ( showPopup )
DBGui.popup(Level.INFO, "You already have got the latest version: "+DBPlugin.pluginVersion.toString());
DBGuiUtils.popup(Level.INFO, "You already have got the latest version: "+DBPlugin.pluginVersion.toString());
else
logger.info("You already have got the latest version: "+DBPlugin.pluginVersion.toString());
return;
}

if ( !DBPlugin.pluginsFilename.endsWith(".jar") ) {
if ( showPopup )
DBGui.popup(Level.ERROR,"A new version of the database plugin is available:\n actual version: "+DBPlugin.pluginVersion.toString()+"\n new version: "+entry.getKey()+"\n\nUnfortunately, it cannot be downloaded while Archi is running inside Eclipse.");
DBGuiUtils.popup(Level.ERROR,"A new version of the database plugin is available:\n actual version: "+DBPlugin.pluginVersion.toString()+"\n new version: "+entry.getKey()+"\n\nUnfortunately, it cannot be downloaded while Archi is running inside Eclipse.");
else
logger.error("A new version of the database plugin is available:\n actual version: "+DBPlugin.pluginVersion.toString()+"\n new version: "+entry.getKey()+"\n\nUnfortunately, it cannot be downloaded while Archi is running inside Eclipse.");
return;
}

boolean ask = true;
while ( ask ) {
this.display.syncExec(new Runnable() { @Override public void run() { DBCheckForPluginUpdate.this.answer = DBGui.question("A new version of the database plugin is available:\n actual version: "+DBPlugin.pluginVersion.toString()+"\n new version: "+entry.getKey()+"\n\nDo you wish to download and install it ?", new String[] {"Yes", "No", "Check release note"}); }});
this.display.syncExec(new Runnable() { @Override public void run() { DBCheckForPluginUpdate.this.answer = DBGuiUtils.question("A new version of the database plugin is available:\n actual version: "+DBPlugin.pluginVersion.toString()+"\n new version: "+entry.getKey()+"\n\nDo you wish to download and install it ?", new String[] {"Yes", "No", "Check release note"}); }});
switch ( this.answer ) {
case 0: ask = false ; break; // Yes
case 1: return ; // No
Expand Down Expand Up @@ -285,10 +285,10 @@ protected PasswordAuthentication getPasswordAuthentication() {
try {
Files.deleteIfExists(this.fileSystem.getPath(newPluginFilename));
} catch (Exception err) {
DBGui.popup(Level.ERROR, "Failed to delete partially downloaded file \""+newPluginFilename+"\".", err);
DBGuiUtils.popup(Level.ERROR, "Failed to delete partially downloaded file \""+newPluginFilename+"\".", err);
}
if ( showPopup )
DBGui.popup(Level.ERROR, "Failed to download the new version of the database plugin.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to download the new version of the database plugin.", e);
else
logger.error("Failed to download the new version of the database plugin.",e);
return;
Expand All @@ -301,21 +301,21 @@ protected PasswordAuthentication getPasswordAuthentication() {
IStatus status = this.dropinsPluginHandler.installFile(new File(newPluginFilename));
if ( !status.isOK() ) {
if ( showPopup )
DBGui.popup(Level.ERROR, "Failed to install new plugin version.");
DBGuiUtils.popup(Level.ERROR, "Failed to install new plugin version.");
else
logger.error("Failed to install new plugin version.");
return;
}
} catch (IOException e) {
if ( showPopup )
DBGui.popup(Level.ERROR, "Failed to install new plugin version.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to install new plugin version.", e);
else
logger.error("Failed to install new plugin version.",e);
return;
}


if( DBGui.question("A new version on the database plugin has been downloaded. Archi needs to be restarted to install it.\n\nDo you wish to restart Archi now ?") ) {
if( DBGuiUtils.question("A new version on the database plugin has been downloaded. Archi needs to be restarted to install it.\n\nDo you wish to restart Archi now ?") ) {
this.display.syncExec(new Runnable() {
@Override public void run() {
PlatformUI.getWorkbench().restart();
Expand Down
10 changes: 5 additions & 5 deletions sources/src/org/archicontribs/database/DBDatabaseEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.crypto.spec.SecretKeySpec;

import org.apache.log4j.Level;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;
import org.archicontribs.database.data.DBDatabase;
import org.eclipse.jface.preference.IPersistentPreferenceStore;

Expand Down Expand Up @@ -274,7 +274,7 @@ public String getJdbcConnectionString() {
if ( DBPlugin.isEmpty(this.getUsername()) && DBPlugin.isEmpty(this.getDecryptedPassword()) )
this.jdbcConnectionString += ";integratedSecurity=true";
} catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchPaddingException e) {
DBGui.popup(Level.ERROR, "Failed to decrypt password.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to decrypt password.", e);
this.jdbcConnectionString = "";
}
break;
Expand Down Expand Up @@ -401,14 +401,14 @@ public static List<DBDatabaseEntry> getAllDatabasesFromPreferenceStore() {
store.setValue(preferenceName+"_encrypted_password_"+String.valueOf(line), databaseEntry.getEncryptedPassword());
store.setValue(preferenceName+"_password_"+String.valueOf(line), "");
} catch (InvalidKeyException|IllegalBlockSizeException|BadPaddingException|InvalidAlgorithmParameterException|NoSuchAlgorithmException|NoSuchPaddingException e) {
DBGui.popup(Level.ERROR, "Failed to encrypt password for database entry \""+databaseEntry.getName()+"\".\n\nYour password will be left unencrypted in your preference store.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to encrypt password for database entry \""+databaseEntry.getName()+"\".\n\nYour password will be left unencrypted in your preference store.", e);
}
}
}

databaseEntries.add(databaseEntry);
} catch (Exception e) {
DBGui.popup(Level.ERROR, "Failed to get database entry \""+databaseEntry.getName()+"\" from preference store.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to get database entry \""+databaseEntry.getName()+"\" from preference store.", e);
}
}
return databaseEntries;
Expand Down Expand Up @@ -514,7 +514,7 @@ public static void persistDatabaseEntryListIntoPreferenceStore(List<DBDatabaseEn
try {
store.save();
} catch (IOException e) {
DBGui.popup(Level.ERROR, "Failed to save your preferences.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to save your preferences.", e);
}
}

Expand Down
4 changes: 2 additions & 2 deletions sources/src/org/archicontribs/database/DBExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.io.IOException;

import org.apache.log4j.Level;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;
import org.archicontribs.database.GUI.DBGuiExportModel;
import org.archicontribs.database.model.DBArchimateModel;
import com.archimatetool.editor.model.IModelExporter;
Expand All @@ -35,7 +35,7 @@ public void export(IArchimateModel archimateModel) throws IOException {
DBGuiExportModel exportModel = new DBGuiExportModel((DBArchimateModel)archimateModel, "Export model");
exportModel.run();
} catch (Exception e) {
DBGui.popup(Level.ERROR,"Cannot export model", e);
DBGuiUtils.popup(Level.ERROR,"Cannot export model", e);
}
}
}
4 changes: 2 additions & 2 deletions sources/src/org/archicontribs/database/DBImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.lang.invoke.MethodHandles;

import org.apache.log4j.Level;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;
import org.archicontribs.database.GUI.DBGuiImportModel;
import com.archimatetool.editor.model.IModelImporter;
import com.archimatetool.editor.model.ISelectedModelImporter;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void doImport(IArchimateModel notUsed) throws IOException {
DBGuiImportModel importModel = new DBGuiImportModel("Import model");
importModel.run();
} catch (Exception e) {
DBGui.popup(Level.ERROR,"Cannot import model", e);
DBGuiUtils.popup(Level.ERROR,"Cannot import model", e);
}
}
}
4 changes: 2 additions & 2 deletions sources/src/org/archicontribs/database/DBLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;

import lombok.Getter;

Expand Down Expand Up @@ -50,7 +50,7 @@ public <T> DBLogger(Class<T> clazz) {
configure();
} catch (Exception e) {
initialised = false;
DBGui.popup(Level.ERROR, "Failed to configure logger", e);
DBGuiUtils.popup(Level.ERROR, "Failed to configure logger", e);
}
}
this.logger = Logger.getLogger(clazz);
Expand Down
41 changes: 28 additions & 13 deletions sources/src/org/archicontribs/database/DBPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import java.util.UUID;

import org.apache.log4j.Level;
import org.archicontribs.database.GUI.DBGui;
import org.archicontribs.database.GUI.DBGuiUtils;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
Expand All @@ -22,6 +22,7 @@
import org.eclipse.ui.preferences.ScopedPreferenceStore;

import com.archimatetool.model.IIdentifier;
import com.archimatetool.model.ModelVersion;

import lombok.Getter;

Expand All @@ -32,14 +33,27 @@
* The DBPlugin class implements static methods and properties used everywhere else in the database plugin.
*
* @author Herve Jouin
*
* v4.9.0 22/09/2021 Change plugin version numbering to match Archi version
* Adapt plugin to Archi 4.9, especially specialization
*
* v4.8.1 22/09/2021 fix coherence checking
* change plugin numbering to follow Archi's and indicate more clearly that this version is compatible with Archi 4.8 and not Archi 4.9
* v4.8.1 22/09/2021 fix coherence checking
* change plugin numbering to follow Archi's and indicate more clearly that this version is compatible with Archi 4.8 and not Archi 4.9
*
* v4.8.2 22/09/2021 fix exception raised when model purpose is null rather than an empty string
* v4.8.2 22/09/2021 fix exception raised when model purpose is null rather than an empty string
*
* -----------------------------------------------------------------------------------------
*
* v4.9.0a 22/09/2021 Change plugin version numbering to match Archi version
* Adapt plugin to Archi 4.9, especially specialization
*
* v4.9.0b 26/10/2021 Fix database model update
* fix SQL Server exception caused by missing column in GROUP BY clause
* Fix folder when import individual component
* Fix import and export windows default location
* Fix import relationships in right folder
* Improve specializations management during export to database
* Add Options tab in preference page to reduce window size
* Add model metadata in compare to database process
*
* -----------------------------------------------------------------------------------------
*
* TO-DO list:
* ----------
Expand Down Expand Up @@ -161,14 +175,14 @@ public DBPlugin() {
"log4j.appender.file.layout = org.apache.log4j.PatternLayout\n"+
"log4j.appender.file.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %4L:%-40.40C{1} %m%n");
logger = new DBLogger(DBPlugin.class);
logger.info("Initialising "+pluginName+" plugin ...");
logger.info("Initialising "+pluginTitle+" ...");

logger.info("===============================================");
// we force the class initialization by the SWT thread
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
DBGui.closePopup();
DBGuiUtils.closePopupMessage();
}
});

Expand All @@ -177,7 +191,7 @@ public void run() {

if ( maxMemory < 950 ) {
if ( getPreferenceStore().getBoolean("checkMaxMemory") )
DBGui.popup(Level.WARN, "Archi is configured with "+maxMemory+" MB max memory.\n\n"
DBGuiUtils.popup(Level.WARN, "Archi is configured with "+maxMemory+" MB max memory.\n\n"
+ "If you plan to use the database plugin with huge models, we recommand to configure Archi\n"
+ "with 1 GB of memory (you may add or update the \"-Xmx\" parameter in the Archi.ini file).\n\n"
+ "You may deactivate the memory check in the database plugin preference page.");
Expand Down Expand Up @@ -214,9 +228,9 @@ public void run() {
DBDatabaseEntry.getAllDatabasesFromPreferenceStore();
preferenceStore.save();
} catch (IOException e) {
DBGui.popup(Level.ERROR, "Failed to save your preferences.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to save your preferences.", e);
}
DBGui.popup(Level.INFO, welcomeMessage);
DBGuiUtils.popup(Level.INFO, welcomeMessage);
}

// we check if the plugin has been upgraded using the automatic procedure
Expand All @@ -228,6 +242,7 @@ public void run() {
if ( logger.isDebugEnabled() ) {
logger.debug("Plugin's package = "+pluginsPackage);
logger.debug("Plugin's version = "+pluginVersion.toString());
logger.debug("Archi's version = "+ModelVersion.VERSION);
logger.debug("Plugin's folder = "+pluginsFolder);
logger.debug("Plugin's filename = "+pluginsFilename);
}
Expand All @@ -239,7 +254,7 @@ public void run() {
checkForUpdate(false);
}
} catch ( IOException e ) {
DBGui.popup(Level.ERROR, "Failed to get database plugin's folder.", e);
DBGuiUtils.popup(Level.ERROR, "Failed to get database plugin's folder.", e);
}
}

Expand Down
Loading

0 comments on commit 3f08f3f

Please sign in to comment.