diff --git a/sources/.classpath b/sources/.classpath index e8e3d2a8..57f2b8df 100644 --- a/sources/.classpath +++ b/sources/.classpath @@ -1,13 +1,13 @@ + + + + + + + - - - - - - - diff --git a/sources/META-INF/MANIFEST.MF b/sources/META-INF/MANIFEST.MF index 1f408f4a..e4331658 100644 --- a/sources/META-INF/MANIFEST.MF +++ b/sources/META-INF/MANIFEST.MF @@ -2,21 +2,21 @@ 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.5 +Bundle-Version: 4.9.6 Bundle-Vendor: Herve Jouin Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 Bundle-ClassPath: ., + lib/neo4j-jdbc-driver-4.0.5.jar, lib/json-simple-1.1.1.jar, lib/log4j-1.2.17.jar, lib/lombok.jar, - lib/mssql-jdbc-8.2.2.jre11.jar, - lib/mysql-connector-java-5.1.48.jar, - lib/neo4j-jdbc-driver-4.0.0.jar, - lib/ojdbc10.jar, - lib/orai18n.jar, - lib/postgresql-42.2.12.jar, - lib/sqlite-jdbc-3.30.1.jar + lib/mssql-jdbc-11.2.0.jre11.jar, + lib/mysql-connector-j-8.0.31.jar, + lib/ojdbc11.jar, + lib/orai18n-21.7.0.0.jar, + lib/postgresql-42.5.0.jar, + lib/sqlite-jdbc-3.39.3.0.jar Bundle-ActivationPolicy: lazy Bundle-Activator: org.archicontribs.database.DBPlugin Require-Bundle: org.eclipse.core.runtime, diff --git a/sources/lib/mssql-jdbc-11.2.0.jre11.jar b/sources/lib/mssql-jdbc-11.2.0.jre11.jar new file mode 100644 index 00000000..7db6da33 Binary files /dev/null and b/sources/lib/mssql-jdbc-11.2.0.jre11.jar differ diff --git a/sources/lib/mssql-jdbc-8.2.2.jre11.jar b/sources/lib/mssql-jdbc-8.2.2.jre11.jar deleted file mode 100644 index 4d565b2c..00000000 Binary files a/sources/lib/mssql-jdbc-8.2.2.jre11.jar and /dev/null differ diff --git a/sources/lib/mysql-connector-j-8.0.31.jar b/sources/lib/mysql-connector-j-8.0.31.jar new file mode 100644 index 00000000..8b74bb87 Binary files /dev/null and b/sources/lib/mysql-connector-j-8.0.31.jar differ diff --git a/sources/lib/mysql-connector-java-5.1.48.jar b/sources/lib/mysql-connector-java-5.1.48.jar deleted file mode 100644 index fcd53a51..00000000 Binary files a/sources/lib/mysql-connector-java-5.1.48.jar and /dev/null differ diff --git a/sources/lib/neo4j-jdbc-driver-4.0.0.jar b/sources/lib/neo4j-jdbc-driver-4.0.5.jar similarity index 56% rename from sources/lib/neo4j-jdbc-driver-4.0.0.jar rename to sources/lib/neo4j-jdbc-driver-4.0.5.jar index 96192289..8a0453e0 100644 Binary files a/sources/lib/neo4j-jdbc-driver-4.0.0.jar and b/sources/lib/neo4j-jdbc-driver-4.0.5.jar differ diff --git a/sources/lib/ojdbc10.jar b/sources/lib/ojdbc10.jar deleted file mode 100644 index 7c37edca..00000000 Binary files a/sources/lib/ojdbc10.jar and /dev/null differ diff --git a/sources/lib/ojdbc11.jar b/sources/lib/ojdbc11.jar new file mode 100644 index 00000000..bda66c64 Binary files /dev/null and b/sources/lib/ojdbc11.jar differ diff --git a/sources/lib/orai18n.jar b/sources/lib/orai18n-21.7.0.0.jar similarity index 81% rename from sources/lib/orai18n.jar rename to sources/lib/orai18n-21.7.0.0.jar index 58d2a9c7..66a1a239 100644 Binary files a/sources/lib/orai18n.jar and b/sources/lib/orai18n-21.7.0.0.jar differ diff --git a/sources/lib/postgresql-42.2.12.jar b/sources/lib/postgresql-42.2.12.jar deleted file mode 100644 index 1f393bb7..00000000 Binary files a/sources/lib/postgresql-42.2.12.jar and /dev/null differ diff --git a/sources/lib/postgresql-42.5.0.jar b/sources/lib/postgresql-42.5.0.jar new file mode 100644 index 00000000..49b95562 Binary files /dev/null and b/sources/lib/postgresql-42.5.0.jar differ diff --git a/sources/lib/sqlite-jdbc-3.30.1.jar b/sources/lib/sqlite-jdbc-3.30.1.jar deleted file mode 100644 index 85837370..00000000 Binary files a/sources/lib/sqlite-jdbc-3.30.1.jar and /dev/null differ diff --git a/sources/lib/sqlite-jdbc-3.39.3.0.jar b/sources/lib/sqlite-jdbc-3.39.3.0.jar new file mode 100644 index 00000000..23ab0735 Binary files /dev/null and b/sources/lib/sqlite-jdbc-3.39.3.0.jar differ diff --git a/sources/src/org/archicontribs/database/DBDatabaseEntry.java b/sources/src/org/archicontribs/database/DBDatabaseEntry.java index 97f6d60e..c2b28cf3 100644 --- a/sources/src/org/archicontribs/database/DBDatabaseEntry.java +++ b/sources/src/org/archicontribs/database/DBDatabaseEntry.java @@ -75,7 +75,7 @@ public String getDriverClass() throws SQLException { switch (this.getDriver()) { case "postgresql": return "org.postgresql.Driver"; case "ms-sql": return "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - case "mysql": return "com.mysql.jdbc.Driver"; + case "mysql": return "com.mysql.cj.jdbc.Driver"; case "neo4j": return "org.neo4j.jdbc.Driver"; case "oracle": return "oracle.jdbc.driver.OracleDriver"; case "sqlite": return "org.sqlite.JDBC"; @@ -270,11 +270,13 @@ public String getJdbcConnectionString() { break; case "ms-sql": this.jdbcConnectionString = "jdbc:sqlserver://" + this.getServer() + ":" + this.getPort() + ";databaseName=" + this.getDatabase(); - try { - if ( DBPlugin.isEmpty(this.getUsername()) && DBPlugin.isEmpty(this.getDecryptedPassword()) ) - this.jdbcConnectionString += ";integratedSecurity=true"; + try { + if ( DBPlugin.isEmpty(this.getUsername()) && DBPlugin.isEmpty(this.getDecryptedPassword()) ) + this.jdbcConnectionString += ";integratedSecurity=true"; + // we enable SSL encryption + this.jdbcConnectionString+=";encrypt=true;trustServerCertificate=true"; } catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchPaddingException e) { - DBGuiUtils.popup(Level.ERROR, "Failed to decrypt password.", e); + DBGuiUtils.popup(Level.ERROR, "Database: "+this.database+"\n\nFailed to decrypt the password. Did you change your network configuration since passwords have been registered ?", e); this.jdbcConnectionString = ""; } break; diff --git a/sources/src/org/archicontribs/database/DBPlugin.java b/sources/src/org/archicontribs/database/DBPlugin.java index b33f5638..bf70ea9c 100644 --- a/sources/src/org/archicontribs/database/DBPlugin.java +++ b/sources/src/org/archicontribs/database/DBPlugin.java @@ -79,6 +79,22 @@ * Fix specialization SQL failures when using PostGreSQL database * Fix canvas import as single component * Fix count images during import model check process + * + * v4.9.6 25/10/2022 + * Update databases drivers + * MySQL: from 5.1.8.4 to 8.0.30 + * PostGreSQL: from 42.2.12 to 42.5.0 + * SQLite: from 3.3.0.1 to 3.39.3.0 + * Sql Server: from 8.22 to 11.2.0 (with SSL encryption activated) + * Oracle: from 10 to 11 + * Neo4J: from 4.0.0 to 4.5.0 + * Fix procedure that checks if a model needs to be exported + * Fix count images to import that was wrong when specializations did not have any attached image + * Fix Neo4J request that caused failures during export + * Fix nested folders import that could lead to components beeing imported in wrong parent + * Change folders checksum calculation as it could change if two objects have got the same name + * Update plugin windows position to center them from Archi main window + * Add stacktrace in error popup in case of exception * * ----------------------------------------------------------------------------------------- * diff --git a/sources/src/org/archicontribs/database/GUI/DBGui.java b/sources/src/org/archicontribs/database/GUI/DBGui.java index 110d98d5..5fc65488 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGui.java +++ b/sources/src/org/archicontribs/database/GUI/DBGui.java @@ -6,6 +6,7 @@ package org.archicontribs.database.GUI; +import java.awt.Toolkit; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -43,6 +44,7 @@ import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageLoader; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FormAttachment; import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.FormLayout; @@ -229,7 +231,8 @@ protected DBGui(String title) { this.dialog = new Shell(display, SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL | SWT.RESIZE); this.dialog.setText(DBPlugin.pluginTitle + " - " + title); - this.dialog.setMinimumSize(1280, 850); + this.dialog.setSize(1280, 900); + this.dialog.setMinimumSize(1280, 900); /** * Calculate the default height of a Label widget @@ -238,10 +241,19 @@ protected DBGui(String title) { label.setText("Test"); this.defaultLabelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; label.dispose(); - - // we center the dialog on the screen - int locationX = (display.getBounds().width - this.dialog.getSize().x)/2; - int locationY = (display.getBounds().height - this.dialog.getSize().y)/2; + + // Use the active shell, if available, to determine the new window placing + int locationX = 0; + int locationY = 0; + Shell parent = display.getActiveShell(); + if (parent!=null) { + Rectangle parentSize = parent.getBounds(); + locationX = (parentSize.width - 1280)/2+parentSize.x; + locationY = (parentSize.height - 850)/2+parentSize.y; + } else { + locationX = (Toolkit.getDefaultToolkit().getScreenSize().width - 500) / 4; + locationY = (Toolkit.getDefaultToolkit().getScreenSize().height - 70) / 4; + } this.dialog.setLocation(new Point(locationX, locationY)); diff --git a/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java b/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java index b2908382..fad62e0d 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java +++ b/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java @@ -160,6 +160,7 @@ public void run() { if ( logger.isDebugEnabled() ) logger.debug("The model has got "+this.exportedModel.getAllProfiles().size()+" specializations and "+this.exportedModel.getAllElements().size()+" elements and "+this.exportedModel.getAllRelationships().size()+" relationships and "+this.exportedModel.getAllFolders().size()+" folders and "+this.exportedModel.getAllViews().size()+" views and "+this.exportedModel.getAllViewObjects().size()+" objects and "+this.exportedModel.getAllViewConnections().size()+" connections."); + this.txtTotalModelItself.setText("1"); this.txtTotalProfiles.setText(toString(this.exportedModel.getProfiles().size())); this.txtTotalElements.setText(toString(this.exportedModel.getAllElements().size())); this.txtTotalRelationships.setText(toString(this.exportedModel.getAllRelationships().size())); @@ -307,7 +308,7 @@ private void createGrpComponents() { this.grpComponents.setText("Your model's components: "); // we calculate the required height - int requiredHeight = 11 * (getDefaultLabelHeight() + getDefaultMargin()) + 2 * getDefaultMargin(); + int requiredHeight = 13 * (getDefaultLabelHeight() + getDefaultMargin()) + 2 * getDefaultMargin(); FormData fd = new FormData(); fd.top = new FormAttachment(100, -requiredHeight); @@ -317,11 +318,19 @@ private void createGrpComponents() { this.grpComponents.setLayoutData(fd); this.grpComponents.setLayout(new FormLayout()); + Label lblModelItself = new Label(this.grpComponents, SWT.NONE); + lblModelItself.setBackground(GROUP_BACKGROUND_COLOR); + lblModelItself.setText("Model itself:"); + fd = new FormData(); + fd.top = new FormAttachment(0, 2*getDefaultLabelHeight()+getDefaultMargin()); + fd.left = new FormAttachment(0, 30); + lblModelItself.setLayoutData(fd); + Label lblProfiles = new Label(this.grpComponents, SWT.NONE); lblProfiles.setBackground(GROUP_BACKGROUND_COLOR); lblProfiles.setText("Specializations:"); fd = new FormData(); - fd.top = new FormAttachment(0, 2*getDefaultLabelHeight()+getDefaultMargin()); + fd.top = new FormAttachment(lblModelItself, getDefaultMargin()); fd.left = new FormAttachment(0, 30); lblProfiles.setLayoutData(fd); @@ -517,6 +526,53 @@ private void createGrpComponents() { /* * * * * */ + this.txtTotalModelItself = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + this.txtTotalModelItself.setEditable(false); + this.txtTotalModelItself.setEnabled(false); + fd = new FormData(26,18); + fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + fd.left = new FormAttachment(this.lblTotal, 0, SWT.LEFT); + fd.right = new FormAttachment(this.lblTotal, 0, SWT.RIGHT); + this.txtTotalModelItself.setLayoutData(fd); + + this.txtNewModelItselfInModel = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + this.txtNewModelItselfInModel.setEditable(false); + this.txtNewModelItselfInModel.setEnabled(false); + fd = new FormData(26,18); + fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + fd.left = new FormAttachment(this.lblModelNew, 0, SWT.LEFT); + fd.right = new FormAttachment(this.lblModelNew, 0, SWT.RIGHT); + this.txtNewModelItselfInModel.setLayoutData(fd); + + this.txtUpdatedModelItselfInModel = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + this.txtUpdatedModelItselfInModel.setEditable(false); + this.txtUpdatedModelItselfInModel.setEnabled(false); + fd = new FormData(26,18); + fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + fd.left = new FormAttachment(this.lblModelUpdated, 0, SWT.LEFT); + fd.right = new FormAttachment(this.lblModelUpdated, 0, SWT.RIGHT); + this.txtUpdatedModelItselfInModel.setLayoutData(fd); + + //this.txtUpdatedModelItselfInDatabase = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + //this.txtUpdatedModelItselfInDatabase.setEditable(false); + //this.txtUpdatedModelItselfInDatabase.setEnabled(false); + //fd = new FormData(26,18); + //fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + //fd.left = new FormAttachment(this.lblDatabaseUpdated, 0, SWT.LEFT); + //fd.right = new FormAttachment(this.lblDatabaseUpdated, 0, SWT.RIGHT); + //this.txtUpdatedModelItselfInDatabase.setLayoutData(fd); + + //this.txtConflictingModelItself = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + //this.txtConflictingModelItself.setEditable(false); + //this.txtConflictingModelItself.setEnabled(false); + //fd = new FormData(26,18); + //fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + //fd.left = new FormAttachment(this.lblConflicts, 0, SWT.LEFT); + //fd.right = new FormAttachment(this.lblConflicts, 0, SWT.RIGHT); + //this.txtConflictingModelItself.setLayoutData(fd); + + /* * * * * */ + this.txtTotalProfiles = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); this.txtTotalProfiles.setEditable(false); this.txtTotalProfiles.setEnabled(false); @@ -1111,59 +1167,72 @@ protected void connectedToDatabase(boolean forceCheckDatabase) { this.databaseHorizontalSeparator.setVisible(!isNeo4j); this.databaseVerticalSeparatorRight.setVisible(!isNeo4j); this.databaseVerticalSeparatorRight.setVisible(!isNeo4j); - + // we hide the comparison between the model and the database in case of a neo4j database this.lblModel.setVisible(!isNeo4j); this.lblModelDeleted.setVisible(!isNeo4j); this.lblModelUpdated.setVisible(!isNeo4j); - this.txtUpdatedElementsInModel.setVisible(!isNeo4j); - this.txtDeletedElementsInModel.setVisible(!isNeo4j); - this.txtUpdatedRelationshipsInModel.setVisible(!isNeo4j); - this.txtDeletedRelationshipsInModel.setVisible(!isNeo4j); - this.txtNewFoldersInModel.setVisible(!isNeo4j); - this.txtUpdatedFoldersInModel.setVisible(!isNeo4j); - this.txtDeletedFoldersInModel.setVisible(!isNeo4j); - this.txtNewViewsInModel.setVisible(!isNeo4j); - this.txtUpdatedViewsInModel.setVisible(!isNeo4j); - this.txtDeletedViewsInModel.setVisible(!isNeo4j); - this.txtNewViewObjectsInModel.setVisible(!isNeo4j); - this.txtUpdatedViewObjectsInModel.setVisible(!isNeo4j); - this.txtDeletedViewObjectsInModel.setVisible(!isNeo4j); - this.txtNewViewConnectionsInModel.setVisible(!isNeo4j); - this.txtUpdatedViewConnectionsInModel.setVisible(!isNeo4j); - this.txtDeletedViewConnectionsInModel.setVisible(!isNeo4j); - this.txtNewImagesInModel.setVisible(!isNeo4j); + this.txtTotalModelItself.setVisible(!isNeo4j); + + this.txtNewModelItselfInModel.setVisible(!isNeo4j); this.txtNewModelItselfInModel.setText(this.ZERO); + this.txtNewProfilesInModel.setText(this.ZERO); + this.txtNewElementsInModel.setText(this.ZERO); + this.txtNewRelationshipsInModel.setText(this.ZERO); + this.txtUpdatedModelItselfInModel.setVisible(!isNeo4j); this.txtUpdatedModelItselfInModel.setText(this.ZERO); + this.txtUpdatedProfilesInModel.setVisible(!isNeo4j); this.txtUpdatedProfilesInModel.setText(this.ZERO); + this.txtDeletedProfilesInModel.setVisible(!isNeo4j); this.txtDeletedProfilesInModel.setText(this.ZERO); + this.txtUpdatedElementsInModel.setVisible(!isNeo4j); this.txtUpdatedElementsInModel.setText(this.ZERO); + this.txtDeletedElementsInModel.setVisible(!isNeo4j); this.txtDeletedElementsInModel.setText(this.ZERO); + this.txtUpdatedRelationshipsInModel.setVisible(!isNeo4j); this.txtUpdatedRelationshipsInModel.setText(this.ZERO); + this.txtDeletedRelationshipsInModel.setVisible(!isNeo4j); this.txtDeletedRelationshipsInModel.setText(this.ZERO); + this.txtNewFoldersInModel.setVisible(!isNeo4j); this.txtNewFoldersInModel.setText(this.ZERO); + this.txtUpdatedFoldersInModel.setVisible(!isNeo4j); this.txtUpdatedFoldersInModel.setText(this.ZERO); + this.txtDeletedFoldersInModel.setVisible(!isNeo4j); this.txtDeletedFoldersInModel.setText(this.ZERO); + this.txtNewViewsInModel.setVisible(!isNeo4j); this.txtNewViewsInModel.setText(this.ZERO); + this.txtUpdatedViewsInModel.setVisible(!isNeo4j); this.txtUpdatedViewsInModel.setText(this.ZERO); + this.txtDeletedViewsInModel.setVisible(!isNeo4j); this.txtDeletedViewsInModel.setText(this.ZERO); + this.txtNewViewObjectsInModel.setVisible(!isNeo4j); this.txtNewViewObjectsInModel.setText(this.ZERO); + this.txtUpdatedViewObjectsInModel.setVisible(!isNeo4j); this.txtUpdatedViewObjectsInModel.setText(this.ZERO); + this.txtDeletedViewObjectsInModel.setVisible(!isNeo4j); this.txtDeletedViewObjectsInModel.setText(this.ZERO); + this.txtNewViewConnectionsInModel.setVisible(!isNeo4j); this.txtNewViewConnectionsInModel.setText(this.ZERO); + this.txtUpdatedViewConnectionsInModel.setVisible(!isNeo4j); this.txtUpdatedViewConnectionsInModel.setText(this.ZERO); + this.txtDeletedViewConnectionsInModel.setVisible(!isNeo4j); this.txtDeletedViewConnectionsInModel.setText(this.ZERO); + this.txtNewImagesInModel.setVisible(!isNeo4j); this.txtNewImagesInModel.setText(this.ZERO); this.lblDatabase.setVisible(!isNeo4j); this.lblDatabaseNew.setVisible(!isNeo4j); this.lblDatabaseDeleted.setVisible(!isNeo4j); this.lblDatabaseUpdated.setVisible(!isNeo4j); this.lblConflicts.setVisible(!isNeo4j); - this.txtNewElementsInDatabase.setVisible(!isNeo4j); - this.txtUpdatedElementsInDatabase.setVisible(!isNeo4j); - this.txtDeletedElementsInDatabase.setVisible(!isNeo4j); - this.txtConflictingElements.setVisible(!isNeo4j); - this.txtNewRelationshipsInDatabase.setVisible(!isNeo4j); - this.txtUpdatedRelationshipsInDatabase.setVisible(!isNeo4j); - this.txtDeletedRelationshipsInDatabase.setVisible(!isNeo4j); - this.txtConflictingRelationships.setVisible(!isNeo4j); - this.txtNewFoldersInDatabase.setVisible(!isNeo4j); - this.txtUpdatedFoldersInDatabase.setVisible(!isNeo4j); - this.txtDeletedFoldersInDatabase.setVisible(!isNeo4j); - this.txtConflictingFolders.setVisible(!isNeo4j); - this.txtNewViewsInDatabase.setVisible(!isNeo4j); - this.txtUpdatedViewsInDatabase.setVisible(!isNeo4j); - this.txtDeletedViewsInDatabase.setVisible(!isNeo4j); - this.txtConflictingViews.setVisible(!isNeo4j); - this.txtNewViewObjectsInDatabase.setVisible(!isNeo4j); - this.txtUpdatedViewObjectsInDatabase.setVisible(!isNeo4j); - this.txtDeletedViewObjectsInDatabase.setVisible(!isNeo4j); - this.txtConflictingViewObjects.setVisible(!isNeo4j); - this.txtNewViewConnectionsInDatabase.setVisible(!isNeo4j); - this.txtUpdatedViewConnectionsInDatabase.setVisible(!isNeo4j); - this.txtDeletedViewConnectionsInDatabase.setVisible(!isNeo4j); - this.txtConflictingViewConnections.setVisible(!isNeo4j); - this.txtNewImagesInDatabase.setVisible(!isNeo4j); + this.txtNewProfilesInDatabase.setVisible(!isNeo4j); this.txtNewProfilesInDatabase.setText(this.ZERO); + this.txtUpdatedProfilesInDatabase.setVisible(!isNeo4j); this.txtUpdatedProfilesInDatabase.setText(this.ZERO); + this.txtDeletedProfilesInDatabase.setVisible(!isNeo4j); this.txtDeletedProfilesInDatabase.setText(this.ZERO); + this.txtConflictingProfiles.setVisible(!isNeo4j); this.txtConflictingProfiles.setText(this.ZERO); + this.txtNewElementsInDatabase.setVisible(!isNeo4j); this.txtNewElementsInDatabase.setText(this.ZERO); + this.txtUpdatedElementsInDatabase.setVisible(!isNeo4j); this.txtUpdatedElementsInDatabase.setText(this.ZERO); + this.txtDeletedElementsInDatabase.setVisible(!isNeo4j); this.txtDeletedElementsInDatabase.setText(this.ZERO); + this.txtConflictingElements.setVisible(!isNeo4j); this.txtConflictingElements.setText(this.ZERO); + this.txtNewRelationshipsInDatabase.setVisible(!isNeo4j); this.txtNewRelationshipsInDatabase.setText(this.ZERO); + this.txtUpdatedRelationshipsInDatabase.setVisible(!isNeo4j); this.txtUpdatedRelationshipsInDatabase.setText(this.ZERO); + this.txtDeletedRelationshipsInDatabase.setVisible(!isNeo4j); this.txtDeletedRelationshipsInDatabase.setText(this.ZERO); + this.txtConflictingRelationships.setVisible(!isNeo4j); this.txtConflictingRelationships.setText(this.ZERO); + this.txtNewFoldersInDatabase.setVisible(!isNeo4j); this.txtNewFoldersInDatabase.setText(this.ZERO); + this.txtUpdatedFoldersInDatabase.setVisible(!isNeo4j); this.txtUpdatedFoldersInDatabase.setText(this.ZERO); + this.txtDeletedFoldersInDatabase.setVisible(!isNeo4j); this.txtDeletedFoldersInDatabase.setText(this.ZERO); + this.txtConflictingFolders.setVisible(!isNeo4j); this.txtConflictingFolders.setText(this.ZERO); + this.txtNewViewsInDatabase.setVisible(!isNeo4j); this.txtNewViewsInDatabase.setText(this.ZERO); + this.txtUpdatedViewsInDatabase.setVisible(!isNeo4j); this.txtUpdatedViewsInDatabase.setText(this.ZERO); + this.txtDeletedViewsInDatabase.setVisible(!isNeo4j); this.txtDeletedViewsInDatabase.setText(this.ZERO); + this.txtConflictingViews.setVisible(!isNeo4j); this.txtConflictingViews.setText(this.ZERO); + this.txtNewViewObjectsInDatabase.setVisible(!isNeo4j); this.txtNewViewObjectsInDatabase.setText(this.ZERO); + this.txtUpdatedViewObjectsInDatabase.setVisible(!isNeo4j); this.txtUpdatedViewObjectsInDatabase.setText(this.ZERO); + this.txtDeletedViewObjectsInDatabase.setVisible(!isNeo4j); this.txtDeletedViewObjectsInDatabase.setText(this.ZERO); + this.txtConflictingViewObjects.setVisible(!isNeo4j); this.txtConflictingViewObjects.setText(this.ZERO); + this.txtNewViewConnectionsInDatabase.setVisible(!isNeo4j); this.txtNewViewConnectionsInDatabase.setText(this.ZERO); + this.txtUpdatedViewConnectionsInDatabase.setVisible(!isNeo4j); this.txtUpdatedViewConnectionsInDatabase.setText(this.ZERO); + this.txtDeletedViewConnectionsInDatabase.setVisible(!isNeo4j); this.txtDeletedViewConnectionsInDatabase.setText(this.ZERO); + this.txtConflictingViewConnections.setVisible(!isNeo4j); this.txtConflictingViewConnections.setText(this.ZERO); + this.txtNewImagesInDatabase.setVisible(!isNeo4j); this.txtNewImagesInDatabase.setText(this.ZERO); DBGuiExportModel.this.tblModelVersions.removeAll(); @@ -1249,6 +1318,7 @@ protected void notConnectedToDatabase() { this.lblModelDeleted.setVisible(!isNeo4j); this.lblModelUpdated.setVisible(!isNeo4j); this.txtNewProfilesInModel.setVisible(!isNeo4j); + this.txtUpdatedModelItselfInModel.setVisible(!isNeo4j); this.txtUpdatedProfilesInModel.setVisible(!isNeo4j); this.txtDeletedProfilesInModel.setVisible(!isNeo4j); this.txtNewRelationshipsInModel.setVisible(!isNeo4j); @@ -1279,6 +1349,7 @@ protected void notConnectedToDatabase() { this.lblDatabaseDeleted.setVisible(!isNeo4j); this.lblDatabaseUpdated.setVisible(!isNeo4j); this.lblConflicts.setVisible(!isNeo4j); + //this.txtUpdatedModelItselfInDatabase.setVisible(!isNeo4j); this.txtNewProfilesInDatabase.setVisible(!isNeo4j); this.txtUpdatedProfilesInDatabase.setVisible(!isNeo4j); this.txtDeletedProfilesInDatabase.setVisible(!isNeo4j); @@ -1309,6 +1380,7 @@ protected void notConnectedToDatabase() { this.txtConflictingViewConnections.setVisible(!isNeo4j); this.txtNewImagesInDatabase.setVisible(!isNeo4j); + this.txtUpdatedModelItselfInModel.setText(this.ZERO); /*this.txtUpdatedModelItselfInDatabase.setText(this.ZERO); this.txtConflictingModelItself.setText(this.ZERO);*/ this.txtNewProfilesInModel.setText(this.ZERO); this.txtUpdatedProfilesInModel.setText(this.ZERO); this.txtNewProfilesInDatabase.setText(this.ZERO); this.txtUpdatedProfilesInDatabase.setText(this.ZERO); this.txtConflictingProfiles.setText(this.ZERO); this.txtNewElementsInModel.setText(this.ZERO); this.txtUpdatedElementsInModel.setText(this.ZERO); this.txtNewElementsInDatabase.setText(this.ZERO); this.txtUpdatedElementsInDatabase.setText(this.ZERO); this.txtConflictingElements.setText(this.ZERO); this.txtNewRelationshipsInModel.setText(this.ZERO); this.txtUpdatedRelationshipsInModel.setText(this.ZERO); this.txtNewRelationshipsInDatabase.setText(this.ZERO); this.txtUpdatedRelationshipsInDatabase.setText(this.ZERO); this.txtConflictingRelationships.setText(this.ZERO); @@ -1328,6 +1400,9 @@ protected boolean compareModelToDatabase(boolean updateTextFields) throws Except if ( DBPlugin.areEqual(this.selectedDatabase.getDriver().toLowerCase(), "neo4j") ) return true; + // calculating model's checksum + this.exportedModel.getCurrentVersion().setChecksum(DBChecksum.calculateChecksum(this.exportedModel, this.txtReleaseNote.getText())); + int progressBarWidth = this.exportedModel.getAllElements().size() + this.exportedModel.getAllRelationships().size() + this.exportedModel.getAllFolders().size() + this.exportedModel.getAllViews().size() + this.exportedModel.getAllViewObjects().size() + this.exportedModel.getAllViewConnections().size(); createProgressBar("Comparing the model to the database ...", 1, progressBarWidth); @@ -1372,6 +1447,20 @@ protected boolean compareModelToDatabase(boolean updateTextFields) throws Except int total = 0; + /** + * if the model's database version equals zero, the the model does not exist in the database + * else if the model's checksum differs from the database, then it has been updated + */ + if ( this.exportedModel.getDatabaseVersion().getVersion() == 0 ) { + this.txtNewModelItselfInModel.setText("1"); + ++total; + } else if ( ! this.exportedModel.getCurrentVersion().getChecksum().toString().equals(this.exportedModel.getDatabaseVersion().getChecksum().toString())) { + this.txtUpdatedModelItselfInModel.setText("1"); + ++total ; + } + + // TODO: check if model has been updated in database and manage conflict as every other component + int nbNew = 0; int nbNewInDb = 0; int nbUpdated = 0; @@ -1835,9 +1924,10 @@ protected boolean compareModelToDatabase(boolean updateTextFields) throws Except this.txtNewImagesInModel.setText(toString(this.exportConnection.getImagesNotInDatabase().size())); this.txtNewImagesInDatabase.setText(toString(this.exportConnection.getImagesNotInModel().size())); - // we log the values uniquely if the updateTextFields has been requestes, else the values are zero + // we log the values uniquely if the updateTextFields has been requested, else the values are zero logger.info(String.format(" <------ In model ------> <----- In database ---->")); logger.info(String.format(" Total New Updated Deleted New Updated Deleted Conflict")); + logger.info(String.format(" Model itself: %6d %6d %6d %6d %6d",1, toInt(this.txtNewModelItselfInModel.getText()), toInt(this.txtUpdatedModelItselfInModel.getText()),0,0)); logger.info(String.format(" Specializations: %6d %6d %6d %6d %6d %6d %6d %6d", this.exportedModel.getAllProfiles().size(), toInt(this.txtNewProfilesInModel.getText()), toInt(this.txtUpdatedProfilesInModel.getText()), toInt(this.txtDeletedProfilesInModel.getText()), toInt(this.txtNewProfilesInDatabase.getText()), toInt(this.txtUpdatedProfilesInDatabase.getText()), toInt(this.txtDeletedProfilesInDatabase.getText()), toInt(this.txtConflictingProfiles.getText())) ); logger.info(String.format(" Elements: %6d %6d %6d %6d %6d %6d %6d %6d", this.exportedModel.getAllElements().size(), toInt(this.txtNewElementsInModel.getText()), toInt(this.txtUpdatedElementsInModel.getText()), toInt(this.txtDeletedElementsInModel.getText()), toInt(this.txtNewElementsInDatabase.getText()), toInt(this.txtUpdatedElementsInDatabase.getText()), toInt(this.txtDeletedElementsInDatabase.getText()), toInt(this.txtConflictingElements.getText())) ); logger.info(String.format(" Relationships: %6d %6d %6d %6d %6d %6d %6d %6d", this.exportedModel.getAllRelationships().size(), toInt(this.txtNewRelationshipsInModel.getText()), toInt(this.txtUpdatedRelationshipsInModel.getText()), toInt(this.txtDeletedRelationshipsInModel.getText()), toInt(this.txtNewRelationshipsInDatabase.getText()), toInt(this.txtUpdatedRelationshipsInDatabase.getText()), toInt(this.txtDeletedRelationshipsInDatabase.getText()), toInt(this.txtConflictingRelationships.getText())) ); @@ -1853,7 +1943,7 @@ protected boolean compareModelToDatabase(boolean updateTextFields) throws Except closeMessage(); - if ( total == 0 && (this.exportedModel.getCurrentVersion().getChecksum().toString().equals(this.exportedModel.getDatabaseVersion().getChecksum().toString()))) { + if ( total == 0 ) { logger.info("The model does not need to be exported to the database."); return true; } @@ -1909,6 +1999,7 @@ protected void export() { this.exportedModel.getCurrentVersion().setChecksum(DBChecksum.calculateChecksum(this.exportedModel, this.txtReleaseNote.getText())); // we reset the counters as they will be updated during the import and export process + this.txtTotalModelItself.setText(this.ZERO); this.txtNewModelItselfInModel.setText(this.ZERO); this.txtUpdatedModelItselfInModel.setText(this.ZERO); /* this.txtUpdatedModelItselfInDatabase.setText(this.ZERO); this.txtConflictingModelItself.setText(this.ZERO); */ this.txtTotalProfiles.setText(this.ZERO); this.txtNewProfilesInModel.setText(this.ZERO); this.txtUpdatedProfilesInModel.setText(this.ZERO); this.txtDeletedProfilesInModel.setText(this.ZERO); this.txtNewProfilesInDatabase.setText(this.ZERO); this.txtUpdatedProfilesInDatabase.setText(this.ZERO); this.txtDeletedProfilesInDatabase.setText(this.ZERO); this.txtConflictingProfiles.setText(this.ZERO); this.txtTotalElements.setText(this.ZERO); this.txtNewElementsInModel.setText(this.ZERO); this.txtUpdatedElementsInModel.setText(this.ZERO); this.txtDeletedElementsInModel.setText(this.ZERO); this.txtNewElementsInDatabase.setText(this.ZERO); this.txtUpdatedElementsInDatabase.setText(this.ZERO); this.txtDeletedElementsInDatabase.setText(this.ZERO); this.txtConflictingElements.setText(this.ZERO); this.txtTotalRelationships.setText(this.ZERO); this.txtNewRelationshipsInModel.setText(this.ZERO); this.txtUpdatedRelationshipsInModel.setText(this.ZERO); this.txtDeletedRelationshipsInModel.setText(this.ZERO); this.txtNewRelationshipsInDatabase.setText(this.ZERO); this.txtUpdatedRelationshipsInDatabase.setText(this.ZERO); this.txtDeletedRelationshipsInDatabase.setText(this.ZERO); this.txtConflictingRelationships.setText(this.ZERO); @@ -2018,7 +2109,7 @@ protected void export() { // If there are some conflicts to resolve, then we show the grpConflict group //TODO: ameliorate the conflict resolution by keeping all the conflicts in the tblListConflict but add a column with the resolution choosen by the user - //TODO: in that case, the export could be effectively done when all the tableItems hve got a solution distinct from askUser + //TODO: in that case, the export could be effectively done when all the tableItems have got a solution distinct from askUser if ( this.tblListConflicts.getItemCount() > 0 ) { this.tblListConflicts.setSelection(0); @@ -2478,6 +2569,7 @@ protected void export() { if ( !isNeo4JDatabase ) { logger.info("Exporting the model itself ..."); + this.txtTotalModelItself.setText("1"); this.exportConnection.exportModel(this.exportedModel, this.txtReleaseNote.getText()); } else { if ( this.selectedDatabase.shouldEmptyNeo4jDB() ) { @@ -2634,6 +2726,7 @@ else if ( dbStatus == DATABASE_STATUS.isUpdatedInModel ) for ( String path: this.exportedModel.getAllImagePaths() ) { if ( this.exportConnection.exportImage(path, archiveMgr.getBytesFromEntry(path)) ) incrementText(this.txtNewImagesInModel); + incrementText(this.txtTotalImages); increaseProgressBar(); } @@ -3069,6 +3162,12 @@ public void close() { private Label databaseVerticalSeparatorLeft; private Label databaseVerticalSeparatorRight; + private Text txtTotalModelItself; + private Text txtNewModelItselfInModel; + private Text txtUpdatedModelItselfInModel; + //private Text txtUpdatedModelItselfInDatabase; + //private Text txtConflictingModelItself; + private Text txtTotalProfiles; private Text txtNewProfilesInModel; private Text txtUpdatedProfilesInModel; diff --git a/sources/src/org/archicontribs/database/GUI/DBGuiImportModel.java b/sources/src/org/archicontribs/database/GUI/DBGuiImportModel.java index fcb1ccfd..60ba351e 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGuiImportModel.java +++ b/sources/src/org/archicontribs/database/GUI/DBGuiImportModel.java @@ -81,6 +81,7 @@ public class DBGuiImportModel extends DBGui { private Label lblReleaseNote; Text txtReleaseNote; + private Text txtTotalModelItself; private Text txtTotalProfiles; private Text txtTotalElements; private Text txtTotalRelationships; @@ -90,6 +91,7 @@ public class DBGuiImportModel extends DBGui { private Text txtTotalViewConnections; private Text txtTotalImages; + private Text txtImportedModelItself; private Text txtImportedProfiles; private Text txtImportedElements; private Text txtImportedRelationships; @@ -495,7 +497,7 @@ private void createGrpComponents() { this.grpComponents.setText("Your model components: "); // we calculate the required height of the grpComponents group - int requiredHeight = 10 * (getDefaultLabelHeight() + getDefaultMargin()); + int requiredHeight = 11 * (getDefaultLabelHeight() + getDefaultMargin()); FormData fd = new FormData(); fd.top = new FormAttachment(100, -requiredHeight); @@ -505,11 +507,19 @@ private void createGrpComponents() { this.grpComponents.setLayoutData(fd); this.grpComponents.setLayout(new FormLayout()); + Label lblModelItself = new Label(this.grpComponents, SWT.NONE); + lblModelItself.setBackground(GROUP_BACKGROUND_COLOR); + lblModelItself.setText("Model itself:"); + fd = new FormData(); + fd.top = new FormAttachment(0, 25); + fd.left = new FormAttachment(0, 30); + lblModelItself.setLayoutData(fd); + Label lblProfiles = new Label(this.grpComponents, SWT.NONE); lblProfiles.setBackground(GROUP_BACKGROUND_COLOR); lblProfiles.setText("Specializations:"); fd = new FormData(); - fd.top = new FormAttachment(0, 25); + fd.top = new FormAttachment(lblModelItself, getDefaultMargin()); fd.left = new FormAttachment(0, 30); lblProfiles.setLayoutData(fd); @@ -591,6 +601,24 @@ private void createGrpComponents() { /* * * * * */ + this.txtTotalModelItself = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + this.txtTotalModelItself.setEditable(false); + this.txtTotalModelItself.setEnabled(false); + fd = new FormData(26,18); + fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + fd.left = new FormAttachment(lblTotal, 0, SWT.LEFT); + fd.right = new FormAttachment(lblTotal, 0, SWT.RIGHT); + this.txtTotalModelItself.setLayoutData(fd); + + this.txtImportedModelItself = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); + this.txtImportedModelItself.setEditable(false); + this.txtImportedModelItself.setEnabled(false); + fd = new FormData(26,18); + fd.top = new FormAttachment(lblModelItself, 0, SWT.CENTER); + fd.left = new FormAttachment(lblImported, 0, SWT.LEFT); + fd.right = new FormAttachment(lblImported, 0, SWT.RIGHT); + this.txtImportedModelItself.setLayoutData(fd); + this.txtTotalProfiles = new Text(this.grpComponents, SWT.BORDER | SWT.CENTER); this.txtTotalProfiles.setEditable(false); this.txtTotalProfiles.setEnabled(false); @@ -849,6 +877,7 @@ public void doImport() { setProgressBarMinAndMax(0, importSize); + this.txtTotalModelItself.setText("1"); this.txtTotalProfiles.setText(toString(this.importConnection.getCountProfilesToImport())); this.txtTotalElements.setText(toString(this.importConnection.getCountElementsToImport())); this.txtTotalRelationships.setText(toString(this.importConnection.getCountRelationshipsToImport())); @@ -858,6 +887,7 @@ public void doImport() { this.txtTotalViewConnections.setText(toString(this.importConnection.getCountViewConnectionsToImport())); this.txtTotalImages.setText(toString(this.importConnection.getCountImagesToImport())); + this.txtImportedModelItself.setText("1"); this.txtImportedProfiles.setText(toString(0)); this.txtImportedElements.setText(toString(0)); this.txtImportedRelationships.setText(toString(0)); diff --git a/sources/src/org/archicontribs/database/GUI/DBGuiUtils.java b/sources/src/org/archicontribs/database/GUI/DBGuiUtils.java index 49a16031..0624fbc6 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGuiUtils.java +++ b/sources/src/org/archicontribs/database/GUI/DBGuiUtils.java @@ -12,7 +12,11 @@ import org.archicontribs.database.DBLogger; import org.archicontribs.database.DBPlugin; import org.archicontribs.database.model.DBMetadata; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -158,29 +162,42 @@ public static void popup(Level level, String msg, Exception e) { display.syncExec(new Runnable() { @Override public void run() { - String popupMessage = msg; - Throwable cause = e; - while ( cause != null ) { - if ( cause.getMessage() != null ) { - if ( !popupMessage.endsWith(cause.getMessage()) ) - popupMessage += "\n\n" + cause.getClass().getSimpleName() + ": " + cause.getMessage(); - } else - popupMessage += "\n\n" + cause.getClass().getSimpleName(); - cause = cause.getCause(); - } + int statusSeverity; + int dialogKind; switch ( level.toInt() ) { case Priority.FATAL_INT: case Priority.ERROR_INT: - MessageDialog.openError(display.getActiveShell(), DBPlugin.pluginTitle, popupMessage); + statusSeverity = IStatus.ERROR; + dialogKind = MessageDialog.ERROR; break; case Priority.WARN_INT: - MessageDialog.openWarning(display.getActiveShell(), DBPlugin.pluginTitle, popupMessage); + statusSeverity = IStatus.WARNING; + dialogKind = MessageDialog.WARNING; break; default: - MessageDialog.openInformation(display.getActiveShell(), DBPlugin.pluginTitle, popupMessage); + statusSeverity = IStatus.INFO; + dialogKind = MessageDialog.INFORMATION; break; } + + if ( e != null ) { + List childStatuses = new ArrayList<>(); + Throwable err = e; + while ( err != null ) { + for (StackTraceElement stackTrace: e.getStackTrace()) + childStatuses.add(new Status(statusSeverity, DBPlugin.pluginTitle, stackTrace.toString())); + err = err.getCause(); + if ( err != null ) { + childStatuses.add(new Status(statusSeverity, DBPlugin.pluginTitle, "")); + childStatuses.add(new Status(statusSeverity, DBPlugin.pluginTitle, "Caused by ...")); + childStatuses.add(new Status(statusSeverity, DBPlugin.pluginTitle, "")); + } + } + MultiStatus multiStatus = new MultiStatus(DBPlugin.pluginTitle, statusSeverity, childStatuses.toArray(new Status[] {}), e.toString(), e); + ErrorDialog.openError(display.getActiveShell(), DBPlugin.pluginTitle, msg, multiStatus); + } else + MessageDialog.open(dialogKind, display.getActiveShell(), DBPlugin.pluginTitle, msg, SWT.NONE); } }); diff --git a/sources/src/org/archicontribs/database/connection/DBDatabaseConnection.java b/sources/src/org/archicontribs/database/connection/DBDatabaseConnection.java index f609e7a9..bf27fbb4 100644 --- a/sources/src/org/archicontribs/database/connection/DBDatabaseConnection.java +++ b/sources/src/org/archicontribs/database/connection/DBDatabaseConnection.java @@ -21,6 +21,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; + import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; @@ -40,6 +41,7 @@ import org.archicontribs.database.model.DBArchimateModel; import org.archicontribs.database.model.DBMetadata; import org.archicontribs.database.model.commands.DBImportViewFromIdCommand; + import com.archimatetool.model.IDiagramModel; import com.archimatetool.model.IDiagramModelContainer; import com.archimatetool.model.IDiagramModelObject; @@ -195,12 +197,12 @@ private void openConnection() throws SQLException { try { password = this.databaseEntry.getDecryptedPassword(); } catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchPaddingException err) { - DBGuiUtils.popup(Level.ERROR, "Failed to decrypt the password.", err); + DBGuiUtils.popup(Level.ERROR, "Database: "+this.databaseEntry.getName()+"\n\nFailed to decrypt the password. Did you change your network configuration since passwords have been registered ?", err); } // if the username is set but not the password, then we show a popup to ask for the password if ( DBPlugin.isEmpty(password) ) { - password = DBGuiUtils.passwordDialog("Please provide the database password", "Database password:"); + password = DBGuiUtils.passwordDialog("Please provide the database password", "Password for "+this.databaseEntry.getName()+":"); if ( password == null ) { // password is null if the user clicked on cancel throw new SQLException("No password provided."); @@ -209,7 +211,7 @@ private void openConnection() throws SQLException { try { this.databaseEntry.setDecryptedPassword(password); } catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchPaddingException err) { - DBGuiUtils.popup(Level.ERROR, "Failed to decrypt the password.", err); + DBGuiUtils.popup(Level.ERROR, "Database: "+this.databaseEntry.getName()+"\n\nFailed to decrypt the password. Did you change your network configuration since passwords have been registered ?", err); } } } diff --git a/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java b/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java index cbd39ef0..b63c5c09 100644 --- a/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java +++ b/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java @@ -1396,9 +1396,9 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m /** * Empty a Neo4J database - * @throws Exception + * @throws SQLException */ - public void emptyNeo4jDB() throws Exception { + public void emptyNeo4jDB() throws SQLException { if ( logger.isDebugEnabled() ) logger.debug("Emptying Neo4J database."); executeRequest("MATCH (n) DETACH DELETE n"); } @@ -2106,7 +2106,7 @@ private void exportProfile(IProfile profile) throws SQLException { if ( logger.isDebugEnabled() ) logger.debug("Exporting "+dbMetadata.getDebugName()+" (initial version = "+dbMetadata.getInitialVersion().getVersion()+", exported version = "+dbMetadata.getCurrentVersion().getVersion()+", database_version = "+dbMetadata.getDatabaseVersion().getVersion()+", latest_database_version = "+dbMetadata.getLatestDatabaseVersion().getVersion()+")"); if ( DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.NEO4J.getDriverName()) ) { - executeRequest("CREATE (new:profiles {id:?, version:?, name:?, is_specialization:?, image_path:?, concept_type:?})" + executeRequest("CREATE (new:profiles {id:?, version:?, name:?, is_specialization:?, image_path:?, concept_type:?, created_by:?, created_on:?})" ,profile.getId() ,dbMetadata.getCurrentVersion().getVersion() ,profile.getName() @@ -2115,7 +2115,6 @@ private void exportProfile(IProfile profile) throws SQLException { ,profile.getConceptType() ,System.getProperty("user.name") ,dbMetadata.getCurrentVersion().getTimestamp() - ,dbMetadata.getCurrentVersion().getChecksum() ); } else { insert(this.schemaPrefix+"profiles", profilesColumns diff --git a/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java b/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java index beb2fb49..9484f1cf 100644 --- a/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java +++ b/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java @@ -179,7 +179,7 @@ public HashMap getObjectFromDatabase(String id, String clazz, in int version = objectVersion; HashMap hashResult = null; - if ( logger.isDebugEnabled() ) logger.debug(" Getting "+clazz); + if ( logger.isDebugEnabled() ) logger.debug(" Getting "+clazz+" #"+id+" from the database"); try { if ( version == 0 ) { @@ -481,7 +481,7 @@ public int countModelComponents(DBArchimateModel model) throws Exception { " UNION "+ " SELECT DISTINCT image_path FROM "+this.schemaPrefix+"profiles_in_model"+ " JOIN "+this.schemaPrefix+"profiles ON profiles.id = profiles_in_model.profile_id AND profiles.version = "+profilesVersionToImport+ - " WHERE model_id = ? AND model_version = ?"+ + " WHERE model_id = ? AND model_version = ? AND image_path IS NOT NULL"+ ") pldr" ,model.getId() ,model.getInitialVersion().getVersion() diff --git a/sources/src/org/archicontribs/database/data/DBChecksum.java b/sources/src/org/archicontribs/database/data/DBChecksum.java index 8091a342..fe4e49d0 100644 --- a/sources/src/org/archicontribs/database/data/DBChecksum.java +++ b/sources/src/org/archicontribs/database/data/DBChecksum.java @@ -47,6 +47,7 @@ import com.archimatetool.model.ILockable; import com.archimatetool.model.INameable; import com.archimatetool.model.IProfile; +import com.archimatetool.model.IProfiles; import com.archimatetool.model.IProperties; import com.archimatetool.model.IProperty; import com.archimatetool.model.ISketchModel; @@ -250,6 +251,9 @@ public static String calculateChecksum(EObject eObject) throws NoSuchAlgorithmEx append(checksumBuilder, "concept type", ((IProfile)eObject).getConceptType()); } + if ( eObject instanceof IProfiles) { for ( IProfile profile: ((IProfiles)eObject).getProfiles() ) + append(checksumBuilder, "has profile", profile.getId()); + } return calculateChecksum(checksumBuilder); } diff --git a/sources/src/org/archicontribs/database/model/DBArchimateModel.java b/sources/src/org/archicontribs/database/model/DBArchimateModel.java index 3db80293..d8b2050b 100644 --- a/sources/src/org/archicontribs/database/model/DBArchimateModel.java +++ b/sources/src/org/archicontribs/database/model/DBArchimateModel.java @@ -46,7 +46,6 @@ import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.IFolder; import com.archimatetool.model.IIdentifier; -import com.archimatetool.model.INameable; import com.archimatetool.model.IProfile; import com.archimatetool.model.IProfiles; import com.archimatetool.model.ModelVersion; @@ -632,14 +631,16 @@ public String countObject(EObject eObject, boolean mustCalculateChecksum) throws private Comparator folderComparator = new Comparator() { @Override public int compare(IFolder f1, IFolder f2) { - return f1.getName().compareTo(f2.getName()); + //return f1.getName().compareTo(f2.getName()); + return f1.getId().compareTo(f2.getId()); } }; private Comparator objectComparator = new Comparator() { @Override public int compare(EObject o1, EObject o2) { - return ((INameable)o1).getName().compareTo(((INameable)o2).getName()); + //return ((INameable)o1).getName().compareTo(((INameable)o2).getName()); + return ((IIdentifier)o1).getId().compareTo(((IIdentifier)o2).getId()); } }; diff --git a/sources/src/org/archicontribs/database/model/DBMetadata.java b/sources/src/org/archicontribs/database/model/DBMetadata.java index 1ed47b24..b2464fa5 100644 --- a/sources/src/org/archicontribs/database/model/DBMetadata.java +++ b/sources/src/org/archicontribs/database/model/DBMetadata.java @@ -433,7 +433,8 @@ public static int getDefaultFolderType(String clazz) { case "capability": case "courseofaction": case "resource": - return FolderType.STRATEGY_VALUE; + case "valuestream": + return FolderType.STRATEGY_VALUE; // 1 case "product": case "businessactor": @@ -448,9 +449,9 @@ public static int getDefaultFolderType(String clazz) { case "businessobject": case "contract": case "representation": - return FolderType.BUSINESS_VALUE; + return FolderType.BUSINESS_VALUE; // 2 - case "applicationcomponentlabel": + case "applicationcomponent": case "applicationcollaboration": case "applicationinterface": case "applicationfunction": @@ -458,8 +459,8 @@ public static int getDefaultFolderType(String clazz) { case "applicationevent": case "applicationservice": case "applicationprocess": - case "dataObject": - return FolderType.APPLICATION_VALUE; + case "dataobject": + return FolderType.APPLICATION_VALUE; //3 case "artifact": case "technologyfunction": @@ -479,12 +480,17 @@ public static int getDefaultFolderType(String clazz) { case "equipment": case "facility": case "distributionnetwork": - case "workpackage": - case "deliverable": - case "implementationevent": - case "plateau": - case "gap": - return FolderType.TECHNOLOGY_VALUE; + return FolderType.TECHNOLOGY_VALUE; //4 + + case "grouping": + case "location": + case "junction": + return FolderType.OTHER_VALUE; // 6 + + case "archimatediagrammodel": + case "canvasmodel": + case "sketchmodel": + return FolderType.DIAGRAMS_VALUE; // 7 case "stakeholder": case "driver": @@ -493,24 +499,21 @@ public static int getDefaultFolderType(String clazz) { case "outcome": case "principle": case "requirement": - case "constaint": - case "smeaning": + case "constraint": + case "meaning": case "value": - return FolderType.MOTIVATION_VALUE; - - case "grouping": - case "location": - case "junction": - return FolderType.OTHER_VALUE; - - case "archimatediagrammodel": - case "canvasmodel": - case "sketchmodel": - return FolderType.DIAGRAMS_VALUE; + return FolderType.MOTIVATION_VALUE; // 8 + case "workpackage": + case "deliverable": + case "implementationevent": + case "plateau": + case "gap": + return FolderType.IMPLEMENTATION_MIGRATION_VALUE; // 9 + default: if ( clazz.toLowerCase().endsWith("relationship") ) - return FolderType.RELATIONS_VALUE; + return FolderType.RELATIONS_VALUE; // 5 return 0; } } diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java index e1ddbe08..3f4d68ee 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java @@ -98,7 +98,7 @@ public DBImportElementFromIdCommand(DBDatabaseImportConnection importConnection, this.mustImportTheRelationships = mustImportRelationships; if ( logger.isDebugEnabled() ) - logger.debug(" Importing element id " + this.id + " version " + versionToImport +" in " + importMode.getLabel() + ((archimateDiagramModel != null) ? " into view."+archimateDiagramModel.getId() : ".")); + logger.debug(" Importing element id " + this.id + " version " + versionToImport +" in " + importMode.getLabel() + ((archimateDiagramModel != null) ? ", into view."+archimateDiagramModel.getName()+"("+archimateDiagramModel.getId()+")" : ", no view") + ((parentFolder != null) ? ", into folder "+parentFolder.getName()+"("+parentFolder.getId()+")" : ", no folder")); try { // we get the new values from the database to allow execute and redo diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java index ad635549..96e24a78 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java @@ -91,10 +91,8 @@ public DBImportRelationshipFromIdCommand(DBDatabaseImportConnection importConnec this.view = archimateDiagramModel; this.id = idToImport; - DBMetadata dbMetadata = archimateModel.getDBMetadata(archimateDiagramModel); - if ( logger.isDebugEnabled() ) - logger.debug(" Importing relationship id " + idToImport + " version " + versionToImport + " in " + importMode.getLabel() + ((archimateDiagramModel != null) ? " into view."+dbMetadata.getDebugName() : ".")); + logger.debug(" Importing relationship id " + this.id + " version " + versionToImport +" in " + importMode.getLabel() + ((archimateDiagramModel != null) ? ", into view."+archimateDiagramModel.getName()+"("+archimateDiagramModel.getId()+")" : ", no view") + ((parentFolder != null) ? ", into folder "+parentFolder.getName()+"("+parentFolder.getId()+")" : ", no folder")); try { @@ -258,10 +256,12 @@ public void execute() { } } } - - if ( this.newParentFolder == null ) - dbMetadata.setParentFolder(this.model.getDefaultFolderForObject(this.importedRelationship)); - else + + if ( this.newParentFolder == null ) { + if ( this.oldParentFolder == null) + dbMetadata.setParentFolder(this.model.getDefaultFolderForObject(this.importedRelationship)); + // else we keep the existing folder + } else dbMetadata.setParentFolder(this.newParentFolder); if ( this.isNew ) diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java index 5a62cd28..8a02a14a 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java @@ -306,11 +306,11 @@ public void execute() { if ( (newContainer != null) && (newContainer != this.oldContainer) ) { if ( this.oldContainer != null ) { - if ( logger.isTraceEnabled() ) logger.trace(" Removing from container "+this.model.getDBMetadata(this.oldContainer).getDebugName()); + if ( logger.isTraceEnabled() ) logger.trace(" Removing "+this.model.getDBMetadata(this.importedViewObject).getDebugName()+" from container "+this.model.getDBMetadata(this.oldContainer).getDebugName()); this.oldContainer.getChildren().remove((IDiagramModelObject)this.importedViewObject); } - if ( logger.isTraceEnabled() ) logger.trace(" Assigning to container "+this.model.getDBMetadata(newContainer).getDebugName()); + if ( logger.isTraceEnabled() ) logger.trace(" Assigning "+this.model.getDBMetadata(this.importedViewObject).getDebugName()+" to container "+this.model.getDBMetadata(newContainer).getDebugName()); newContainer.getChildren().add((IDiagramModelObject)this.importedViewObject); } } diff --git a/sources/src/org/archicontribs/database/preferences/DBDatabaseEntryTableEditor.java b/sources/src/org/archicontribs/database/preferences/DBDatabaseEntryTableEditor.java index 354c91a9..a8852cd2 100644 --- a/sources/src/org/archicontribs/database/preferences/DBDatabaseEntryTableEditor.java +++ b/sources/src/org/archicontribs/database/preferences/DBDatabaseEntryTableEditor.java @@ -1170,7 +1170,7 @@ void setDatabaseDetails(boolean editMode) { try { this.txtPassword.setText(databaseEntry.getDecryptedPassword()); } catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException | InvalidAlgorithmParameterException | NoSuchAlgorithmException | NoSuchPaddingException err) { - DBGuiUtils.popup(Level.ERROR, "Failed to decrypt the password.", err); + DBGuiUtils.popup(Level.ERROR, "Database: "+databaseEntry.getName()+"\n\nFailed to decrypt the password. Did you change your network configuration since passwords have been registered ?", err); this.txtPassword.setText(""); } this.btnExpertMode.setSelection(databaseEntry.isExpertMode());