Skip to content

Commit

Permalink
v4.9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
herve91 committed Apr 26, 2023
1 parent d8b56e5 commit ec58385
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 48 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.4
Bundle-Version: 4.9.5
Bundle-Vendor: Herve Jouin
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
6 changes: 3 additions & 3 deletions sources/build.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
source.. = src/
output.. = bin/
jars.compile.order = .
bin.includes = META-INF/,\
.,\
plugin.xml,\
help/,\
img/,\
build.properties,\
help_contexts.xml,\
bin/,\
lib/log4j-1.2.17.jar
.,\
lib/
src.includes = src/
source.. = src/
7 changes: 6 additions & 1 deletion sources/src/org/archicontribs/database/DBPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* Few other GUI improvements
* Remove ID conversion from former size to new one as it is not needed anymore
*
* v4.9.4 04/01/2022
* v4.9.4 04/01/2022
* Fix initial version of components which was incorrectly set to zero on some occasions
* Fix missing Value Stream icon on import components window
* Fix preferences apply button is greyed on new plugin installations
Expand All @@ -75,6 +75,11 @@
* Add model specializations comparison when checking model history from database
* Effort done to update the plugin documentation
*
* v4.9.5 23/07/2022
* Fix specialization SQL failures when using PostGreSQL database
* Fix canvas import as single component
* Fix count images during import model check process
*
* -----------------------------------------------------------------------------------------
*
* TO-DO list:
Expand Down
21 changes: 4 additions & 17 deletions sources/src/org/archicontribs/database/GUI/DBGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
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;
Expand All @@ -55,7 +54,6 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
Expand Down Expand Up @@ -119,7 +117,6 @@ public class DBGui {

protected static final Display display = Display.getCurrent() == null ? Display.getDefault() : Display.getCurrent();
protected Shell dialog;
protected Shell parentDialog;

protected boolean includeNeo4j = true;

Expand Down Expand Up @@ -230,11 +227,9 @@ protected DBGui(String title) {

DBGuiUtils.setWaitCursor();

this.parentDialog = display.getActiveShell();
Rectangle parentBounds = this.parentDialog.getBounds();
this.dialog = new Shell(display, SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL | SWT.RESIZE);
this.dialog.setText(DBPlugin.pluginTitle + " - " + title);
this.dialog.setMinimumSize(1024, 768);
this.dialog.setMinimumSize(1280, 850);

/**
* Calculate the default height of a Label widget
Expand All @@ -243,18 +238,10 @@ protected DBGui(String title) {
label.setText("Test");
this.defaultLabelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
label.dispose();

// in case the monitor is smaller than 1280x850 (which may be the case on some laptops)
Monitor[] monitors = display.getMonitors();

for (int i = 0; i < monitors.length; i++) {
Rectangle monitorBounds = monitors[i].getBounds();
if (monitorBounds.intersects(parentBounds))
this.dialog.setSize(Math.min(monitorBounds.width, 1400), Math.min(monitorBounds.height, 1024));
}

int locationX = parentBounds.x + (parentBounds.width - this.dialog.getSize().x)/2;
int locationY = parentBounds.y + (parentBounds.height - this.dialog.getSize().y)/2;
// 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;

this.dialog.setLocation(new Point(locationX, locationY));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ private void exportProfile(IProfile profile) throws SQLException {
,profile.getId()
,dbMetadata.getCurrentVersion().getVersion()
,profile.getName()
,profile.isSpecialization()
,dbMetadata.isSpecializationAsInteger()
,profile.getImagePath()
,profile.getConceptType()
,System.getProperty("user.name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,27 +374,22 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
this.toCharStrength = DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.ORACLE.getDriverName()) ? "TO_CHAR(strength)" : "strength";
this.toCharStrengthAsStrength = DBPlugin.areEqual(this.databaseEntry.getDriver(), DBDatabase.ORACLE.getDriverName()) ? "TO_CHAR(strength) AS strength" : "strength";

String versionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"profiles WHERE profiles.id = profiles_in_model.profile_id)" : "profiles_in_model.profile_version";
String profilesVersionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"profiles WHERE profiles.id = profiles_in_model.profile_id)" : "profiles_in_model.profile_version";
String selectProfilesRequest = "SELECT DISTINCT profile_id, profile_version, name, is_specialization, image_path, concept_type, created_on, checksum, pos"
+ " FROM "+this.schemaPrefix+"profiles_in_model"
+ " JOIN "+this.schemaPrefix+"profiles ON profiles.id = profiles_in_model.profile_id AND profiles.version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"profiles ON profiles.id = profiles_in_model.profile_id AND profiles.version = "+profilesVersionToImport
+ " WHERE model_id = ? AND model_version = ?";
try ( DBSelect resultProfiles = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countProfiles FROM ("+selectProfilesRequest+") pldrs", model.getId(), model.getInitialVersion().getVersion()) ) {
resultProfiles.next();
this.countProfilesToImport = resultProfiles.getInt("countProfiles");
this.countProfilesImported = 0;
}
// images can also be found in profiles
try ( DBSelect resultProfiles = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countImages FROM ("+selectProfilesRequest+" AND image_path IS NOT null) pldr", model.getId(), model.getInitialVersion().getVersion()) ) {
resultProfiles.next();
this.countImagesToImport = resultProfiles.getInt("countImages");
}
this.importProfilesRequest = selectProfilesRequest + " ORDER BY pos"; // we need to put aside the ORDER BY from the SELECT FROM SELECT because of SQL Server

versionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"folders WHERE folders.id = folders_in_model.folder_id)" : "folders_in_model.folder_version";
String foldersVersionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"folders WHERE folders.id = folders_in_model.folder_id)" : "folders_in_model.folder_version";
String selectFoldersRequest = "SELECT DISTINCT folder_id, folder_version, parent_folder_id, type, root_type, name, "+this.toCharDocumentationAsDocumentation+", created_on, properties, features, checksum, pos"
+ " FROM "+this.schemaPrefix+"folders_in_model"
+ " JOIN "+this.schemaPrefix+"folders ON folders.id = folders_in_model.folder_id AND folders.version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"folders ON folders.id = folders_in_model.folder_id AND folders.version = "+foldersVersionToImport
+ " WHERE model_id = ? AND model_version = ?";
try ( DBSelect resultFolders = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countFolders FROM ("+selectFoldersRequest+") fldrs", model.getId(), model.getInitialVersion().getVersion()) ) {
resultFolders.next();
Expand All @@ -403,10 +398,10 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
}
this.importFoldersRequest = selectFoldersRequest + " ORDER BY pos"; // we need to put aside the ORDER BY from the SELECT FROM SELECT because of SQL Server

versionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"elements WHERE id = element_id)" : "element_version";
String elementsVersionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"elements WHERE id = element_id)" : "element_version";
this.importElementsRequest = "SELECT DISTINCT element_id, parent_folder_id, version, class, name, type, "+this.toCharDocumentationAsDocumentation+", profile, created_on, properties, features, checksum"
+ " FROM "+this.schemaPrefix+"elements_in_model"
+ " JOIN "+this.schemaPrefix+"elements ON elements.id = element_id AND version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"elements ON elements.id = element_id AND version = "+elementsVersionToImport
+ " WHERE model_id = ? AND model_version = ?"
+ " GROUP BY element_id, parent_folder_id, version, class, name, type, "+this.toCharDocumentation+", profile, created_on, properties, features, checksum";
try (DBSelect resultElements = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countElements FROM ("+this.importElementsRequest+") elts", model.getId(), model.getInitialVersion().getVersion()) ) {
Expand All @@ -416,10 +411,10 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
}


versionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"relationships WHERE id = relationship_id)" : "relationship_version";
String relationshipsVersionToImport = model.isLatestVersionImported() ? "(SELECT MAX(version) FROM "+this.schemaPrefix+"relationships WHERE id = relationship_id)" : "relationship_version";
this.importRelationshipsRequest = "SELECT DISTINCT relationship_id, parent_folder_id, version, class, name, "+this.toCharDocumentationAsDocumentation+", source_id, target_id, "+this.toCharStrengthAsStrength+", access_type, is_directed, profile, created_on, properties, features, checksum"
+ " FROM "+this.schemaPrefix+"relationships_in_model"
+ " INNER JOIN "+this.schemaPrefix+"relationships ON id = relationship_id AND version = "+versionToImport
+ " INNER JOIN "+this.schemaPrefix+"relationships ON id = relationship_id AND version = "+relationshipsVersionToImport
+ " WHERE model_id = ? AND model_version = ?"
+ " GROUP BY relationship_id, parent_folder_id, version, class, name, "+this.toCharDocumentation+", source_id, target_id, "+this.toCharStrength+", access_type, is_directed, profile, created_on, properties, features, checksum";
try ( DBSelect resultRelationships = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countRelationships FROM ("+this.importRelationshipsRequest+") relts"
Expand All @@ -431,10 +426,10 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
this.countRelationshipsImported = 0;
}

versionToImport = model.isLatestVersionImported() ? "(select max(version) from "+this.schemaPrefix+"views where views.id = views_in_model.view_id)" : "views_in_model.view_version";
String viewsVersionToImport = model.isLatestVersionImported() ? "(select max(version) from "+this.schemaPrefix+"views where views.id = views_in_model.view_id)" : "views_in_model.view_version";
String selectViewsRequest = "SELECT DISTINCT id, version, parent_folder_id, class, name, "+this.toCharDocumentationAsDocumentation+", background, connection_router_type, viewpoint, created_on, properties, features, checksum, container_checksum, pos"
+ " FROM "+this.schemaPrefix+"views_in_model"
+ " JOIN "+this.schemaPrefix+"views ON views.id = views_in_model.view_id AND views.version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"views ON views.id = views_in_model.view_id AND views.version = "+viewsVersionToImport
+ " WHERE model_id = ? AND model_version = ?";
try ( DBSelect resultViews = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countViews FROM ("+selectViewsRequest+") vws", model.getId(), model.getInitialVersion().getVersion()) ) {
resultViews.next();
Expand All @@ -447,7 +442,7 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
String selectViewsObjectsRequest = "SELECT DISTINCT id, version, class, container_id, element_id, diagram_ref_id, border_color, border_type, "+this.toCharContentAsContent+", "+this.toCharDocumentationAsDocumentation+", is_locked, image_path, image_position, line_color, line_width, fill_color, alpha, font, font_color, name, "+this.toCharNotesAsNotes+", text_alignment, text_position, type, x, y, width, height, properties, features, checksum"
+ " FROM "+this.schemaPrefix+"views_objects"
+ " JOIN "+this.schemaPrefix+"views_objects_in_view ON views_objects_in_view.object_id = views_objects.id AND views_objects_in_view.object_version = views_objects.version"
+ " JOIN "+this.schemaPrefix+"views_in_model ON views_objects_in_view.view_id = views_in_model.view_id AND views_objects_in_view.view_version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"views_in_model ON views_objects_in_view.view_id = views_in_model.view_id AND views_objects_in_view.view_version = "+viewsVersionToImport
+ " WHERE model_id = ? AND model_version = ?";
try ( DBSelect resultViewObjects = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countViewsObjects FROM ("+selectViewsObjectsRequest+") vobjs", model.getId(), model.getInitialVersion().getVersion()) ) {
resultViewObjects.next();
Expand All @@ -460,7 +455,7 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
String selectViewsConnectionsRequest = "SELECT DISTINCT id, version, class, container_id, name, "+this.toCharDocumentationAsDocumentation+", is_locked, line_color, line_width, font, font_color, relationship_id, source_object_id, target_object_id, text_position, type, properties, features, checksum "
+ " FROM "+this.schemaPrefix+"views_connections"
+ " JOIN "+this.schemaPrefix+"views_connections_in_view ON views_connections_in_view.connection_id = views_connections.id AND views_connections_in_view.connection_version = views_connections.version"
+ " JOIN "+this.schemaPrefix+"views_in_model ON views_connections_in_view.view_id = views_in_model.view_id AND views_connections_in_view.view_version = "+versionToImport
+ " JOIN "+this.schemaPrefix+"views_in_model ON views_connections_in_view.view_id = views_in_model.view_id AND views_connections_in_view.view_version = "+viewsVersionToImport
+ " WHERE model_id = ? AND model_version = ?";
try ( DBSelect resultViewConnections = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countViewsConnections FROM ("+selectViewsConnectionsRequest+") vcons", model.getId(), model.getInitialVersion().getVersion()) ) {
resultViewConnections.next();
Expand All @@ -469,12 +464,27 @@ public int countModelComponents(DBArchimateModel model) throws Exception {
}
// (unused) this.importViewsConnectionsRequest = this.selectViewsConnectionsRequest + " ORDER BY views_connections.pos"; // we need to put aside the ORDER BY from the SELECT FROM SELECT because of SQL Server

try ( DBSelect resultImages = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(DISTINCT image_path) AS countImages"+
" FROM "+this.schemaPrefix+"views_in_model"+


//try ( DBSelect resultProfiles = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(DISTINCT image_path) AS countImages FROM ("+selectProfilesRequest+" AND image_path IS NOT null) pldr", model.getId(), model.getInitialVersion().getVersion()) ) {
// resultProfiles.next();
// this.countImagesToImport = resultProfiles.getInt("countImages");
//}

// images can be found in views and in profiles
try ( DBSelect resultImages = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT COUNT(*) AS countImages FROM ("+
" SELECT DISTINCT image_path FROM "+this.schemaPrefix+"views_in_model"+
" INNER JOIN "+this.schemaPrefix+"views ON views_in_model.view_id = views.id AND views_in_model.view_version = views.version"+
" INNER JOIN "+this.schemaPrefix+"views_objects_in_view ON views_objects_in_view.view_id = views.id AND views_objects_in_view.view_version = views.version"+
" INNER JOIN "+this.schemaPrefix+"views_objects ON views_objects.id = views_objects_in_view.object_id AND views_objects.version = views_objects_in_view.object_version"+
" WHERE model_id = ? AND model_version = ? AND image_path IS NOT NULL"
" WHERE model_id = ? AND model_version = ? AND image_path IS NOT NULL"+
" 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 = ?"+
") pldr"
,model.getId()
,model.getInitialVersion().getVersion()
,model.getId()
,model.getInitialVersion().getVersion()
))
Expand Down
22 changes: 22 additions & 0 deletions sources/src/org/archicontribs/database/model/DBMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,28 @@ public EList<IProfile> getProfiles() {
return null;
}

public Boolean isSpecialization() {
if ( this.component instanceof IProfile )
return ((IProfile)this.component).isSpecialization();
return null;
}
public Integer isSpecializationAsInteger() {
if ( this.component instanceof IProfile )
return ((IProfile)this.component).isSpecialization() ? 1 : 0;
return null;
}

public void setSpecialization(boolean specialization) {
if ( this.component instanceof IProfile )
((IProfile)this.component).setSpecialization(specialization);
}

public void setSpecialization(Object specialization) {
if ( this.component instanceof IProfile )
((IProfile)this.component).setSpecialization(DBPlugin.getBooleanValue(specialization));
}


public IProfile getPrimaryProfile() {
try {
if ( this.component instanceof IProfiles )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public void execute() {
this.importedView = this.model.getAllViews().get(this.id);

if ( this.importedView == null ) {
if ( DBPlugin.areEqual((String)this.newValues.get("class"), "CanvasModel") )
this.importedView = (IDiagramModel) ICanvasFactory.eINSTANCE.create((EClass)(IArchimateFactory.eINSTANCE.getEPackage().getEClassifier("com.archimatetool.canvas.model."+(String)this.newValues.get("class"))));
if ( ((String)this.newValues.get("class")).startsWith("Canvas") )
this.importedView = (IDiagramModel) ICanvasFactory.eINSTANCE.create((EClass)(ICanvasFactory.eINSTANCE.getEPackage().getEClassifier((String)this.newValues.get("class"))));
else
this.importedView = (IDiagramModel) IArchimateFactory.eINSTANCE.create((EClass)(IArchimateFactory.eINSTANCE.getEPackage().getEClassifier((String)this.newValues.get("class"))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ public void execute() {

if ( this.importedViewObject == null ) {
if ( ((String)this.newValues.get("class")).startsWith("Canvas") )
this.importedViewObject = ICanvasFactory.eINSTANCE.create((EClass)(IArchimateFactory.eINSTANCE.getEPackage().getEClassifier("com.archimatetool.canvas.model."+(String)this.newValues.get("class"))));
else
this.importedViewObject = IArchimateFactory.eINSTANCE.create((EClass)(IArchimateFactory.eINSTANCE.getEPackage().getEClassifier((String)this.newValues.get("class"))));
this.importedViewObject = ICanvasFactory.eINSTANCE.create((EClass)(ICanvasFactory.eINSTANCE.getEPackage().getEClassifier((String)this.newValues.get("class"))));
else
this.importedViewObject = IArchimateFactory.eINSTANCE.create((EClass)(IArchimateFactory.eINSTANCE.getEPackage().getEClassifier((String)this.newValues.get("class"))));

this.isNew = true;
} else {
Expand Down

0 comments on commit ec58385

Please sign in to comment.