From 4f256ff0123a2f045fe2ecd2a9758d6f78904561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Jouin?= Date: Wed, 26 Apr 2023 04:11:18 +0200 Subject: [PATCH] v4.9.3 --- sources/META-INF/MANIFEST.MF | 2 +- sources/plugin.xml | 5 - .../org/archicontribs/database/DBPlugin.java | 26 ++- .../org/archicontribs/database/GUI/DBGui.java | 86 ++++++++-- .../database/GUI/DBGuiComponentHistory.java | 38 +++-- .../database/GUI/DBGuiExportModel.java | 4 +- .../DBDatabaseExportConnection.java | 160 ++++++++++-------- .../DBDatabaseImportConnection.java | 11 +- .../database/data/DBVersion.java | 34 +++- .../archicontribs/database/menu/DBMenu.java | 25 +-- .../menu/DBMenuConvertIdsHandler.java | 125 -------------- .../DBImportElementFromIdCommand.java | 4 +- .../commands/DBImportFolderFromIdCommand.java | 4 +- .../DBImportProfileFromIdCommand.java | 4 +- .../DBImportRelationshipFromIdCommand.java | 4 +- .../DBImportViewConnectionFromIdCommand.java | 4 +- .../commands/DBImportViewFromIdCommand.java | 4 +- .../DBImportViewObjectFromIdCommand.java | 4 +- .../preferences/DBFileFieldEditor.java | 16 +- 19 files changed, 261 insertions(+), 299 deletions(-) delete mode 100644 sources/src/org/archicontribs/database/menu/DBMenuConvertIdsHandler.java diff --git a/sources/META-INF/MANIFEST.MF b/sources/META-INF/MANIFEST.MF index 14dbb1f6..69c42ba8 100644 --- a/sources/META-INF/MANIFEST.MF +++ b/sources/META-INF/MANIFEST.MF @@ -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.2 +Bundle-Version: 4.9.3 Bundle-Vendor: Herve Jouin Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/sources/plugin.xml b/sources/plugin.xml index 9cb5fb58..dc36a3e9 100644 --- a/sources/plugin.xml +++ b/sources/plugin.xml @@ -79,11 +79,6 @@ defaultHandler="org.archicontribs.database.menu.DBMenuShowDebugHandler" id="org.archicontribs.database.showDebugCommand" name="showDebugCommand"> - -
* Replaces string.equals() to avoid nullPointerException * @param str1 first string to compare - * @param str2 secong string to compare + * @param str2 second string to compare * @return true if the strings are both null or have the same content, false if they are different */ public static boolean areEqual(String str1, String str2) { - if ( str1 == null ) - return str2 == null; + if ( isEmpty(str1) ) + return isEmpty(str2); - if ( str2 == null ) - return false; // as str1 cannot be null at this stage + if ( isEmpty(str2) ) + return false; // as str1 cannot be empty at this stage return str1.equals(str2); } @@ -298,11 +306,11 @@ public static boolean areEqual(String str1, String str2) { * @return true if the strings are both null or have the same content, false if they are different */ public static boolean areEqualIgnoreCase(String str1, String str2) { - if ( str1 == null ) - return str2 == null; + if ( isEmpty(str1) ) + return isEmpty(str2); - if ( str2 == null ) - return false; // as str1 cannot be null at this stage + if ( isEmpty(str2) ) + return false; // as str1 cannot be empty at this stage return str1.equalsIgnoreCase(str2); } diff --git a/sources/src/org/archicontribs/database/GUI/DBGui.java b/sources/src/org/archicontribs/database/GUI/DBGui.java index 9d28c8ce..a08d6e87 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGui.java +++ b/sources/src/org/archicontribs/database/GUI/DBGui.java @@ -70,6 +70,7 @@ import com.archimatetool.model.FolderType; import com.archimatetool.model.IAccessRelationship; import com.archimatetool.model.IArchimateDiagramModel; +import com.archimatetool.model.IArchimateModel; import com.archimatetool.model.IArchimateRelationship; import com.archimatetool.model.IBorderObject; import com.archimatetool.model.IBounds; @@ -90,6 +91,7 @@ import com.archimatetool.model.ILineObject; import com.archimatetool.model.ILockable; import com.archimatetool.model.INameable; +import com.archimatetool.model.IProfiles; import com.archimatetool.model.IProperties; import com.archimatetool.model.ISketchModel; import com.archimatetool.model.ITextAlignment; @@ -612,9 +614,9 @@ protected void getDatabases(boolean mustIncludeNeo4j, String defaultDatabaseId, if ( mustIncludeNeo4j || !databaseEntry.getDriver().equals(DBDatabase.NEO4J.getDriverName()) ) { this.comboDatabases.add(databaseEntry.getName()); this.comboDatabaseEntries.add(databaseEntry); - if ( defaultDatabaseId != null && databaseEntry.getId().equals(defaultDatabaseId) ) + if ( !DBPlugin.isEmpty(defaultDatabaseId) && databaseEntry.getId().equals(defaultDatabaseId) ) databaseToSelect = line; - if ( defaultDatabaseName != null && databaseToSelect != 0 && databaseEntry.getName().equals(defaultDatabaseName) ) + else if ( !DBPlugin.isEmpty(defaultDatabaseName) && databaseEntry.getName().equals(defaultDatabaseName) ) databaseToSelect = line; ++line; } @@ -623,12 +625,10 @@ protected void getDatabases(boolean mustIncludeNeo4j, String defaultDatabaseId, DBGuiUtils.popup(Level.ERROR, "You haven't configure any SQL database yet.\n\nPlease setup at least one SQL database in Archi preferences."); else { // if no default database is provided, then we select the first database in the combo - if ( defaultDatabaseId == null && defaultDatabaseName == null ) + if ( databaseToSelect == -1 ) databaseToSelect = 0; - if ( databaseToSelect != -1 ) { - this.comboDatabases.select(databaseToSelect); - this.comboDatabases.notifyListeners(SWT.Selection, new Event()); // calls the databaseSelected() method - } + this.comboDatabases.select(databaseToSelect); + this.comboDatabases.notifyListeners(SWT.Selection, new Event()); // calls the databaseSelected() method } } } @@ -1185,10 +1185,12 @@ protected Boolean fillInCompareTable(Tree tree, TreeItem treeItem, EObject memor TreeItem item = new TreeItem(tree, SWT.NONE); item.setText(new String[] {"Version", String.valueOf(dbMetadata.getInitialVersion().getVersion()), String.valueOf(databaseObject.get("version"))}); - + + areIdentical &= addItemToCompareTable(tree, treeItem, "Checksum", String.valueOf(dbMetadata.getInitialVersion().getChecksum()), String.valueOf(databaseObject.get("checksum"))); + if ( (String)databaseObject.get("created_by") != null ) { item = new TreeItem(tree, SWT.NONE); - item.setText(new String[] {"Created by", System.getProperty("user.name"), (String)databaseObject.get("created_by")}); + item.setText(new String[] {"Created by", dbMetadata.getInitialVersion().getUsername(), (String)databaseObject.get("created_by")}); } if ( databaseObject.get("created_on") != null ) { @@ -1199,10 +1201,21 @@ protected Boolean fillInCompareTable(Tree tree, TreeItem treeItem, EObject memor item.setText(new String[] {"Created on", "", new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(databaseObject.get("created_on"))}); } } + - areIdentical &= areIdentical &= addItemToCompareTable(tree, treeItem, "Class", memoryObject.getClass().getSimpleName(), (String)databaseObject.get("class")); + // we replace the DBArchimateModel class name by a simple ArchimateModel + String className = memoryObject.getClass().getSimpleName(); + if ( className.equals("DBArchimateModel") ) className = "ArchimateModel"; + areIdentical &= addItemToCompareTable(tree, treeItem, "Class", className, (String)databaseObject.get("class")); + areIdentical &= addItemToCompareTable(tree, treeItem, "Name", ((INameable)memoryObject).getName(), (String)databaseObject.get("name")); + if (memoryObject instanceof IArchimateModel ) { + areIdentical &= addItemToCompareTable(tree, treeItem, "Purpose", ((IArchimateModel)memoryObject).getPurpose(), (String)databaseObject.get("purpose")); + // the note does not participate to the model comparison + addItemToCompareTable(tree, treeItem, "Note", "", (String)databaseObject.get("note")); + } + if ( memoryObject instanceof IDocumentable ) areIdentical &= addItemToCompareTable(tree, treeItem, "Documentation", ((IDocumentable)memoryObject).getDocumentation(), (String)databaseObject.get("documentation")); @@ -1331,7 +1344,7 @@ protected Boolean fillInCompareTable(Tree tree, TreeItem treeItem, EObject memor } //Arrays.sort(componentBendpoints, this.integerComparator);www - // we get a list of properties from the database + // we get a list of bendpoints from the database Integer[][] databaseBendpoints = new Integer[((ArrayList)databaseObject.get("bendpoints")).size()][4]; int i = 0; for (DBBendpoint bp: (ArrayList)databaseObject.get("bendpoints") ) { @@ -1370,6 +1383,57 @@ protected Boolean fillInCompareTable(Tree tree, TreeItem treeItem, EObject memor } } } + + // we show up the profiles if both exist + if ( databaseObject.containsKey("profiles") ) { + if ( memoryObject instanceof IProfiles && ((IProfiles)memoryObject).getProfiles().size() != 0) { + TreeItem profilesTreeItem; + if ( treeItem == null ) + profilesTreeItem = new TreeItem(tree, SWT.NONE); + else + profilesTreeItem = new TreeItem(treeItem, SWT.NONE); + profilesTreeItem.setText("Spécializations"); + profilesTreeItem.setExpanded(true); + + // we get a sorted list of component's profiles + ArrayList componentProfiles = new ArrayList(); + for (int i = 0; i < ((IProfiles)memoryObject).getProfiles().size(); ++i) { + componentProfiles.add(new DBProperty(((IProfiles)memoryObject).getProfiles().get(i).getName(), ((IProfiles)memoryObject).getProfiles().get(i).getImagePath())); + } + Collections.sort(componentProfiles, this.propertyComparator); + + // we get a sorted list of profiles from the database + ArrayList databaseProfiles = (ArrayList)databaseObject.get("profiles"); + Collections.sort(databaseProfiles, this.propertyComparator); + + Collator collator = Collator.getInstance(); + int indexComponent = 0; + int indexDatabase = 0; + int compare; + while ( (indexComponent < componentProfiles.size()) || (indexDatabase < databaseProfiles.size()) ) { + if ( indexComponent >= componentProfiles.size() ) + compare = 1; + else { + if ( indexDatabase >= databaseProfiles.size() ) + compare = -1; + else + compare = collator.compare(componentProfiles.get(indexComponent).getKey(), databaseProfiles.get(indexDatabase).getKey()); + } + + if ( compare == 0 ) { // both have got the same property + areIdentical &= addItemToCompareTable(tree, profilesTreeItem, componentProfiles.get(indexComponent).getKey(), componentProfiles.get(indexComponent).getValue(), databaseProfiles.get(indexDatabase).getValue()); + ++indexComponent; + ++indexDatabase; + } else if ( compare < 0 ) { // only the component has got the property + areIdentical &= addItemToCompareTable(tree, profilesTreeItem, componentProfiles.get(indexComponent).getKey(), componentProfiles.get(indexComponent).getValue(), null); + ++indexComponent; + } else { // only the database has got the property + areIdentical &= addItemToCompareTable(tree, profilesTreeItem, componentProfiles.get(indexDatabase).getKey(), null, databaseProfiles.get(indexDatabase).getValue()); + ++indexDatabase; + } + } + } + } // we show up the properties if both exist if ( databaseObject.containsKey("properties") ) { diff --git a/sources/src/org/archicontribs/database/GUI/DBGuiComponentHistory.java b/sources/src/org/archicontribs/database/GUI/DBGuiComponentHistory.java index 491bee18..0ca0c574 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGuiComponentHistory.java +++ b/sources/src/org/archicontribs/database/GUI/DBGuiComponentHistory.java @@ -15,6 +15,7 @@ import org.archicontribs.database.connection.DBDatabaseExportConnection; import org.archicontribs.database.connection.DBDatabaseImportConnection; import org.archicontribs.database.connection.DBSelect; +import org.archicontribs.database.data.DBChecksum; import org.archicontribs.database.data.DBImportMode; import org.archicontribs.database.model.commands.DBImportElementFromIdCommand; import org.archicontribs.database.model.commands.DBImportFolderFromIdCommand; @@ -51,6 +52,7 @@ import com.archimatetool.model.IDiagramModelObject; import com.archimatetool.model.IFolder; import com.archimatetool.model.ISketchModel; +import com.archimatetool.model.impl.ArchimateModel; /** * This class manages the GUI that shows a component history @@ -83,10 +85,15 @@ public DBGuiComponentHistory(IArchimateModelObject component) throws Exception { this.includeNeo4j = false; - ((DBArchimateModel)this.selectedComponent.getArchimateModel()).countObject(component, true); - if ( logger.isDebugEnabled() ) logger.debug("Setting up GUI for showing history of "+DBMetadata.getDBMetadata(component).getDebugName()+" (plugin version "+DBPlugin.pluginVersion.toString()+")."); + // we calculate the checksum of the component + if ( component instanceof ArchimateModel ) + ((DBArchimateModel)this.selectedComponent).getCurrentVersion().setChecksum(DBChecksum.calculateChecksum(this.selectedComponent)); + else + ((DBArchimateModel)this.selectedComponent.getArchimateModel()).countObject(component, true); + + setCompoRight(); this.compoRightBottom.setVisible(true); this.compoRightBottom.layout(); @@ -138,7 +145,12 @@ public void handleEvent(Event e) { DBGuiComponentHistory.this.lblCompareComponents.setText("Versions are identical"); else DBGuiComponentHistory.this.lblCompareComponents.setText("Versions are different (check highlighted lines):"); + + // the export button is activated if the component is different from the latest version in the database + // so the latest database version must be selected to activate the export button DBGuiComponentHistory.this.btnExportModelVersion.setEnabled(!areIdentical.booleanValue() && DBGuiComponentHistory.this.tblVersions.getSelectionIndex() == 0); + + // the import button is activated if the component is different from the selected version of the database DBGuiComponentHistory.this.btnImportDatabaseVersion.setEnabled(!areIdentical.booleanValue()); } } @@ -151,15 +163,15 @@ public void handleEvent(Event e) { this.tblVersions.setLayoutData(fd); TableColumn colVersion = new TableColumn(this.tblVersions, SWT.NONE); - colVersion.setWidth(47); + colVersion.setWidth(70); colVersion.setText("Version"); TableColumn colCreatedBy = new TableColumn(this.tblVersions, SWT.NONE); - colCreatedBy.setWidth(121); + colCreatedBy.setWidth(150); colCreatedBy.setText("Created by"); TableColumn colCreatedOn = new TableColumn(this.tblVersions, SWT.NONE); - colCreatedOn.setWidth(145); + colCreatedOn.setWidth(220); colCreatedOn.setText("Created on"); this.lblCompareComponents = new Label(grpComponents, SWT.NONE); @@ -183,15 +195,15 @@ public void handleEvent(Event e) { this.tblContent.setLayoutData(fd); TreeColumn colItem = new TreeColumn(this.tblContent, SWT.NONE); - colItem.setWidth(120); + colItem.setWidth(160); colItem.setText("Items"); TreeColumn colYourVersion = new TreeColumn(this.tblContent, SWT.NONE); - colYourVersion.setWidth(220); - colYourVersion.setText("Your version"); + colYourVersion.setWidth(320); + colYourVersion.setText("Local version"); TreeColumn colDatabaseVersion = new TreeColumn(this.tblContent, SWT.NONE); - colDatabaseVersion.setWidth(220); + colDatabaseVersion.setWidth(320); colDatabaseVersion.setText("Database version"); this.btnImportDatabaseVersion = new Button(grpComponents, SWT.NONE); @@ -230,7 +242,6 @@ else if ( importedComponent instanceof IArchimateDiagramModel || importedCompone DBGuiUtils.popup(Level.INFO, "The current version of the component has been replaced by the selected version from the database."); connectedToDatabase(true); - } catch (Exception err) { DBGuiUtils.popup(Level.ERROR, "Failed to import component.", err); } @@ -245,7 +256,7 @@ else if ( importedComponent instanceof IArchimateDiagramModel || importedCompone this.btnExportModelVersion = new Button(grpComponents, SWT.NONE); this.btnExportModelVersion.setImage(EXPORT_TO_DATABASE_IMAGE); - this.btnExportModelVersion.setText("Export your version to the database"); + this.btnExportModelVersion.setText("Export local version to the database"); this.btnExportModelVersion.setEnabled(false); this.btnExportModelVersion.addSelectionListener(new SelectionListener() { @Override @@ -292,7 +303,9 @@ protected void connectedToDatabase(boolean forceCheck) { this.btnExportModelVersion.setEnabled(false); String tableName = null; - if ( this.selectedComponent instanceof IArchimateElement ) + if ( this.selectedComponent instanceof ArchimateModel ) + tableName = "models"; + else if ( this.selectedComponent instanceof IArchimateElement ) tableName = "elements"; else if ( this.selectedComponent instanceof IArchimateRelationship ) tableName = "relationships"; @@ -325,6 +338,7 @@ else if ( this.selectedComponent instanceof IDiagramModelConnection ) this.lblVersions.setText(this.tblVersions.getItemCount()+" versions have been found in the database:"); } else { this.lblVersions.setText(this.tblVersions.getItemCount()+" version has been found in the database:"); + this.lblCompareComponents.setText(""); } if ( this.tblVersions.getItemCount() != 0 ) { diff --git a/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java b/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java index 5a9c29e9..b2908382 100644 --- a/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java +++ b/sources/src/org/archicontribs/database/GUI/DBGuiExportModel.java @@ -2859,7 +2859,7 @@ public void widgetSelected(SelectionEvent e) { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); - fd = new FormData(80,25); + fd = new FormData(); fd.right = new FormAttachment(100, -getDefaultMargin()); fd.bottom = new FormAttachment(100, -getDefaultMargin()); this.btnImportDatabaseVersion.setLayoutData(fd); @@ -2885,7 +2885,7 @@ public void widgetSelected(SelectionEvent e) { @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); - fd = new FormData(80,25); + fd = new FormData(); fd.right = new FormAttachment(this.btnImportDatabaseVersion, -getDefaultMargin()); fd.bottom = new FormAttachment(100, -getDefaultMargin()); this.btnExportMyVersion.setLayoutData(fd); diff --git a/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java b/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java index faa6938d..c0833a78 100644 --- a/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java +++ b/sources/src/org/archicontribs/database/connection/DBDatabaseExportConnection.java @@ -181,7 +181,7 @@ public void getVersionFromDatabase(IIdentifier component) throws SQLException { String request; String modelId; - int modelInitialVersion; + //int modelInitialVersion; int modelDatabaseVersion; DBMetadata metadata = DBMetadata.getDBMetadata(component); @@ -190,52 +190,62 @@ public void getVersionFromDatabase(IIdentifier component) throws SQLException { logger.trace(" Getting version of "+metadata.getDebugName()+" from the database."); } - if ( component instanceof IArchimateElement ) { - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + if ( component instanceof DBArchimateModel ) { + request = "select id, name, version, checksum, created_on, created_by, id AS model_id, version AS model_version" + + " FROM "+this.schemaPrefix+" models" + + " WHERE id = ?" + + " ORDER BY version"; + DBArchimateModel model = (DBArchimateModel)component; + modelId = model.getId(); + //modelInitialVersion = model.getInitialVersion().getVersion(); + modelDatabaseVersion = model.getDatabaseVersion().getVersion(); + } + else if ( component instanceof IArchimateElement ) { + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"elements" + " LEFT JOIN "+this.schemaPrefix+"elements_in_model ON element_id = id AND element_version = version" + " WHERE id = ?" + " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IArchimateElement)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); + //modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IArchimateRelationship ) { - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"relationships" + " LEFT JOIN "+this.schemaPrefix+"relationships_in_model ON relationship_id = id AND relationship_version = version" + " WHERE id = ?" + " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IArchimateRelationship)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); + //modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IFolder ) { - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"folders" + " LEFT JOIN "+this.schemaPrefix+"folders_in_model ON folder_id = id AND folder_version = version" + " WHERE id = ?" + " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IFolder)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); + //modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModel ) { - request = "SELECT id, name, version, checksum, container_checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, container_checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"views" + " LEFT JOIN "+this.schemaPrefix+"views_in_model ON view_id = id AND view_version = version" + " WHERE id = ?" + " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IDiagramModel)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); + //modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModelObject ) { - request = "SELECT id, name, version, checksum, created_on, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + request = "SELECT id, name, version, checksum, created_on, created_by, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + " FROM "+this.schemaPrefix+"views_objects" + " LEFT JOIN "+this.schemaPrefix+"views_objects_in_view ON object_id = id AND object_version = version" + " WHERE id = ?" @@ -243,11 +253,11 @@ else if ( component instanceof IDiagramModelObject ) { IDiagramModel diagram = ((IDiagramModelObject)component).getDiagramModel(); modelId = diagram.getId(); DBMetadata dbMetadata = DBMetadata.getDBMetadata(diagram); - modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); + //modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); modelDatabaseVersion = dbMetadata.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModelConnection ) { - request = "SELECT id, name, version, checksum, created_on, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + request = "SELECT id, name, version, checksum, created_on, created_by, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + " FROM "+this.schemaPrefix+"views_connections" + " LEFT JOIN "+this.schemaPrefix+"views_connections_in_view ON connection_id = id AND connection_version = version" + " WHERE id = ?" @@ -255,7 +265,7 @@ else if ( component instanceof IDiagramModelConnection ) { IDiagramModel diagram = ((IDiagramModelConnection)component).getDiagramModel(); modelId = diagram.getId(); DBMetadata dbMetadata = DBMetadata.getDBMetadata(diagram); - modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); + //modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); modelDatabaseVersion = dbMetadata.getDatabaseVersion().getVersion(); } else @@ -271,24 +281,27 @@ else if ( component instanceof IDiagramModelConnection ) { String checksum = null; String containerChecksum = null; Timestamp createdOn = null; + String createdBy = null; while ( result.next() ) { version = result.getInt("version"); checksum = result.getString("checksum"); containerChecksum = (component instanceof IDiagramModel ? result.getString("container_checksum") : null); createdOn = result.getTimestamp("created_on"); + createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version - if ( modelInitialVersion == 0 || result.getInt("model_version") == modelInitialVersion ) { - metadata.getInitialVersion().set(version, containerChecksum, checksum, createdOn); + //if ( modelInitialVersion == 0 || result.getInt("model_version") == modelInitialVersion ) { + if ( DBPlugin.areEqual(checksum, metadata.getCurrentVersion().getChecksum()) ) { + metadata.getInitialVersion().set(version, containerChecksum, checksum, createdOn, createdBy); metadata.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - metadata.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + metadata.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - metadata.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + metadata.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); } } if ( logger.isTraceEnabled() ) { @@ -316,72 +329,66 @@ public void getHashMapVersionFromDatabase(HashMap component String request; String orderByRequest = ""; String modelId; - int modelInitialVersion; int modelDatabaseVersion; - DBMetadata dbMetadata; // we get the "first" (in fact any) component of the hashmap to determine its class IIdentifier component = componentHashMap.entrySet().iterator().next().getValue(); - // unused but to avoid null warning - dbMetadata = DBMetadata.getDBMetadata(component); + // unused at this stage, but to avoid null warning + DBMetadata dbMetadata = DBMetadata.getDBMetadata(component); if ( component instanceof IArchimateElement ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" elements from the database."); - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"elements" + " LEFT JOIN "+this.schemaPrefix+"elements_in_model ON element_id = id AND element_version = version" + " WHERE id in ("; orderByRequest = " ORDER BY id, version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IArchimateElement)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IArchimateRelationship ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" relationships from the database."); - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"relationships" + " LEFT JOIN "+this.schemaPrefix+"relationships_in_model ON relationship_id = id AND relationship_version = version" + " WHERE id in ("; orderByRequest = " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IArchimateRelationship)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IFolder ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" folders from the database."); - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"folders" + " LEFT JOIN "+this.schemaPrefix+"folders_in_model ON folder_id = id AND folder_version = version" + " WHERE id in ("; orderByRequest = " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IFolder)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModel ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" views from the database."); - request = "SELECT id, name, version, checksum, container_checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, container_checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"views" + " LEFT JOIN "+this.schemaPrefix+"views_in_model ON view_id = id AND view_version = version" + " WHERE id in ("; orderByRequest = " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IDiagramModel)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModelObject ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" view objects from the database."); - request = "SELECT id, name, version, checksum, created_on, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + request = "SELECT id, name, version, checksum, created_on, created_by, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + " FROM "+this.schemaPrefix+"views_objects" + " LEFT JOIN "+this.schemaPrefix+"views_objects_in_view ON object_id = id AND object_version = version" + " WHERE id in ("; @@ -389,13 +396,12 @@ else if ( component instanceof IDiagramModelObject ) { IDiagramModel diagram = ((IDiagramModelObject)component).getDiagramModel(); modelId = diagram.getId(); dbMetadata = DBMetadata.getDBMetadata(diagram); - modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); modelDatabaseVersion = dbMetadata.getDatabaseVersion().getVersion(); } else if ( component instanceof IDiagramModelConnection ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" view connections from the database."); - request = "SELECT id, name, version, checksum, created_on, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + request = "SELECT id, name, version, checksum, created_on, created_by, view_id as model_id, view_version as model_version" // for convenience, we rename view_id to model_id and view_version to model_version + " FROM "+this.schemaPrefix+"views_connections" + " LEFT JOIN "+this.schemaPrefix+"views_connections_in_view ON connection_id = id AND connection_version = version" + " WHERE id in ("; @@ -403,20 +409,18 @@ else if ( component instanceof IDiagramModelConnection ) { IDiagramModel diagram = ((IDiagramModelConnection)component).getDiagramModel(); modelId = diagram.getId(); dbMetadata = DBMetadata.getDBMetadata(diagram); - modelInitialVersion = dbMetadata.getInitialVersion().getVersion(); modelDatabaseVersion = dbMetadata.getDatabaseVersion().getVersion(); } else if ( component instanceof IProfile ) { if ( logger.isTraceEnabled() ) logger.trace(" Searching for "+componentHashMap.size()+" specializations from the database."); - request = "SELECT id, name, version, checksum, created_on, model_id, model_version" + request = "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"profiles" + " LEFT JOIN "+this.schemaPrefix+"profiles_in_model ON profile_id = id AND profile_version = version" + " WHERE id in ("; orderByRequest = " ORDER BY version, model_version"; DBArchimateModel model = (DBArchimateModel) ((IProfile)component).getArchimateModel(); modelId = model.getId(); - modelInitialVersion = model.getInitialVersion().getVersion(); modelDatabaseVersion = model.getDatabaseVersion().getVersion(); } else @@ -449,6 +453,7 @@ else if ( component instanceof IProfile ) { String checksum = null; String containerChecksum = null; Timestamp createdOn = null; + String createdBy = null; String oldId = null; String id; @@ -479,19 +484,21 @@ else if ( component instanceof IProfile ) { checksum = result.getString("checksum"); containerChecksum = (component instanceof IDiagramModel ? result.getString("container_checksum") : null); createdOn = result.getTimestamp("created_on"); + createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version - if ( modelInitialVersion == 0 || result.getInt("model_version") == modelInitialVersion ) { - dbMetadata.getInitialVersion().set(version, containerChecksum, checksum, createdOn); + // if ( modelInitialVersion == 0 || result.getInt("model_version") == modelInitialVersion ) { + if ( result.getInt("model_version") == 0 || checksum.equals(dbMetadata.getCurrentVersion().getChecksum()) ) { + dbMetadata.getInitialVersion().set(version, containerChecksum, checksum, createdOn, createdBy); dbMetadata.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - dbMetadata.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + dbMetadata.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - dbMetadata.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + dbMetadata.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); oldId = id; } @@ -565,7 +572,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws dbMetadata.getLatestDatabaseVersion().reset(); } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, model_id, model_version, pos" + "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version, pos" + " FROM "+this.schemaPrefix+"profiles" + " LEFT JOIN "+this.schemaPrefix+"profiles_in_model ON profile_id = id AND profile_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"profiles JOIN "+this.schemaPrefix+"profiles_in_model ON profile_id = id AND profile_version = version WHERE model_id = ? AND model_version = ?)" @@ -581,6 +588,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -612,15 +620,15 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("model_version") == modelInitialVersion || checksum.equals(currentComponent.getCurrentVersion().getChecksum()) ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -676,7 +684,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws // we do not use max(version) in the SQL request as all database brands do not support it // so we get all the version (sorted by the version) and determine the latest version of each element when the ID changes or when we read the latest element try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, model_id, model_version" + "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"elements" + " LEFT JOIN "+this.schemaPrefix+"elements_in_model ON element_id = id AND element_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"elements JOIN "+this.schemaPrefix+"elements_in_model ON element_id = id AND element_version = version WHERE model_id = ? AND model_version = ?)" @@ -695,6 +703,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); // if the current element ID is equals to the previous element ID, it means that we got a newer version of the same element // so we just archive the current component as previous component for future reference @@ -733,15 +742,15 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws // if the component is part of the model, we compare with the model's version //if ( modelInitialVersion == 0 || result.getInt("model_version") == modelInitialVersion ) { if ( result.getInt("model_version") == modelInitialVersion || checksum.equals(currentComponent.getCurrentVersion().getChecksum()) ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); // we copy currentComponent to previous component to be able to retrieve it in next loop previousComponent = currentComponent; @@ -795,7 +804,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, model_id, model_version" + "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"relationships" + " LEFT JOIN "+this.schemaPrefix+"relationships_in_model ON relationship_id = id AND relationship_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"relationships JOIN "+this.schemaPrefix+"relationships_in_model ON relationship_id = id AND relationship_version = version WHERE model_id = ? AND model_version = ?)" @@ -811,6 +820,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -842,15 +852,15 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("model_version") == modelInitialVersion || checksum.equals(currentComponent.getCurrentVersion().getChecksum()) ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -902,7 +912,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws dbMetadata.getLatestDatabaseVersion().reset(); } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, model_id, model_version" + "SELECT id, name, version, checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"folders" + " LEFT JOIN "+this.schemaPrefix+"folders_in_model ON folder_id = id AND folder_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"folders JOIN "+this.schemaPrefix+"folders_in_model ON folder_id = id AND folder_version = version WHERE model_id = ? AND model_version = ?)" @@ -918,6 +928,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -949,15 +960,15 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("model_version") == modelInitialVersion || checksum.equals(currentComponent.getCurrentVersion().getChecksum()) ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -1010,7 +1021,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws dbMetadata.getLatestDatabaseVersion().reset(); } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, container_checksum, created_on, model_id, model_version" + "SELECT id, name, version, checksum, container_checksum, created_on, created_by, model_id, model_version" + " FROM "+this.schemaPrefix+"views" + " LEFT JOIN "+this.schemaPrefix+"views_in_model ON view_id = id AND view_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"views JOIN "+this.schemaPrefix+"views_in_model ON view_id = id AND view_version = version WHERE model_id = ? AND model_version = ?)" @@ -1027,6 +1038,7 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws String checksum = result.getString("checksum"); String containerChecksum = result.getString("container_checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -1058,15 +1070,15 @@ public void getAllVersionFromDatabase(DBArchimateModel model, DBGui gui) throws if ( DBPlugin.areEqual(result.getString("model_id"), modelId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("model_version") == modelInitialVersion || checksum.equals(currentComponent.getCurrentVersion().getChecksum()) ) { - currentComponent.getInitialVersion().set(version, containerChecksum, checksum, createdOn); + currentComponent.getInitialVersion().set(version, containerChecksum, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("model_version") == modelDatabaseVersion ) - currentComponent.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, containerChecksum, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -1213,7 +1225,7 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m } } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, view_id, view_version" + "SELECT id, name, version, checksum, created_on, created_by, view_id, view_version" + " FROM "+this.schemaPrefix+"views_objects" + " LEFT JOIN "+this.schemaPrefix+"views_objects_in_view ON object_id = id AND object_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"views_objects JOIN "+this.schemaPrefix+"views_objects_in_view ON object_id = id AND object_version = version WHERE view_id = ? AND view_version = ?)" @@ -1229,6 +1241,7 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -1260,16 +1273,16 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m if ( DBPlugin.areEqual(result.getString("view_id"), viewId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("view_version") == viewInitialVersion ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("view_version") == viewDatabaseVersion ) { - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -1304,7 +1317,7 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m } } try ( DBSelect result = new DBSelect(this.databaseEntry.getName(), this.connection, - "SELECT id, name, version, checksum, created_on, view_id, view_version" + "SELECT id, name, version, checksum, created_on, created_by, view_id, view_version" + " FROM "+this.schemaPrefix+"views_connections" + " LEFT JOIN "+this.schemaPrefix+"views_connections_in_view ON connection_id = id AND connection_version = version" + " WHERE id IN (SELECT id FROM "+this.schemaPrefix+"views_connections JOIN "+this.schemaPrefix+"views_connections_in_view ON connection_id = id AND connection_version = version WHERE view_id = ? AND view_version = ?)" @@ -1320,6 +1333,7 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m int version = result.getInt("version"); String checksum = result.getString("checksum"); Timestamp createdOn = result.getTimestamp("created_on"); + String createdBy = result.getString("created_by"); if ( DBPlugin.areEqual(currentId, previousId) ) currentComponent = previousComponent; @@ -1351,16 +1365,16 @@ private void getViewObjectsAndConnectionsVersionsFromDatabase(DBArchimateModel m if ( DBPlugin.areEqual(result.getString("view_id"), viewId) ) { // if the component is part of the model, we compare with the model's version if ( result.getInt("view_version") == viewInitialVersion ) { - currentComponent.getInitialVersion().set(version, checksum, createdOn); + currentComponent.getInitialVersion().set(version, checksum, createdOn, createdBy); currentComponent.getCurrentVersion().setVersion(version); } if ( result.getInt("view_version") == viewDatabaseVersion ) { - currentComponent.getDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getDatabaseVersion().set(version, checksum, createdOn, createdBy); } } // components are sorted by version (so also by timestamp) so the latest found is the latest in time - currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn); + currentComponent.getLatestDatabaseVersion().set(version, checksum, createdOn, createdBy); previousComponent = currentComponent; previousId = currentId; @@ -1510,7 +1524,7 @@ private void exportElement(IArchimateElement element) throws Exception { ,element.getDocumentation() ,dbMetadata.getPrimaryProfileID() ,System.getProperty("user.name") - ,((DBArchimateModel)element.getArchimateModel()).getCurrentVersion().getTimestamp() + ,model.getCurrentVersion().getTimestamp() ,nbProperties ,nbFeatures ,dbMetadata.getCurrentVersion().getChecksum() @@ -1626,7 +1640,7 @@ private void exportRelationship(IArchimateRelationship relationship) throws Exce ,dbMetadata.isDirectedAsInteger() ,dbMetadata.getPrimaryProfileID() ,System.getProperty("user.name") - ,((DBArchimateModel)relationship.getArchimateModel()).getCurrentVersion().getTimestamp() + ,model.getCurrentVersion().getTimestamp() ,nbProperties ,nbFeatures ,dbMetadata.getCurrentVersion().getChecksum() @@ -1694,7 +1708,7 @@ private void exportFolder(IFolder folder) throws Exception { ,folder.getName() ,folder.getDocumentation() ,System.getProperty("user.name") - ,dbMetadata.getCurrentVersion().getTimestamp() + ,model.getCurrentVersion().getTimestamp() ,nbProperties ,nbFeatures ,dbMetadata.getCurrentVersion().getChecksum() @@ -1758,7 +1772,7 @@ private void exportView(IDiagramModel view) throws Exception { ,dbMetadata.getCurrentVersion().getVersion() ,view.getClass().getSimpleName() ,System.getProperty("user.name") - ,((DBArchimateModel)view.getArchimateModel()).getCurrentVersion().getTimestamp() + ,model.getCurrentVersion().getTimestamp() ,view.getName() ,view.getConnectionRouterType() ,view.getDocumentation() @@ -1863,7 +1877,7 @@ private void exportViewObject(IDiagramModelComponent viewObject) throws Exceptio ,dbMetadata.getWidth() ,dbMetadata.getHeight() ,System.getProperty("user.name") - ,((DBArchimateModel)viewObject.getDiagramModel().getArchimateModel()).getCurrentVersion().getTimestamp() + ,model.getCurrentVersion().getTimestamp() ,nbProperties ,nbFeatures ,dbMetadata.getCurrentVersion().getChecksum() diff --git a/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java b/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java index 1e4f516d..e1c8b327 100644 --- a/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java +++ b/sources/src/org/archicontribs/database/connection/DBDatabaseImportConnection.java @@ -150,7 +150,8 @@ public DBDatabaseImportConnection(DBDatabaseConnection databaseConnection) { public HashMap getObjectFromDatabase(EObject component, int version) throws Exception { String id = ((IIdentifier)component).getId(); String clazz; - if ( component instanceof IArchimateElement ) clazz = "IArchimateElement"; + if ( component instanceof DBArchimateModel ) clazz = "IArchimateModel"; + else if ( component instanceof IArchimateElement ) clazz = "IArchimateElement"; else if ( component instanceof IArchimateRelationship ) clazz = "IArchimateRelationship"; else if ( component instanceof IFolder ) clazz = "IFolder"; else if ( component instanceof IDiagramModel ) clazz = "IDiagramModel"; @@ -182,15 +183,17 @@ public HashMap getObjectFromDatabase(String id, String clazz, in try { if ( version == 0 ) { // because of PostGreSQL, we need to split the request in two - if ( DBPlugin.areEqual(clazz, "IArchimateElement") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"elements e WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"elements WHERE id = e.id)", id); + if ( DBPlugin.areEqual(clazz, "IArchimateModel") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, 'ArchimateModel' as class, name, note, purpose, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"models m WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"models WHERE id = m.id)", id); + else if ( DBPlugin.areEqual(clazz, "IArchimateElement") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"elements e WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"elements WHERE id = e.id)", id); else if ( DBPlugin.areEqual(clazz, "IArchimateRelationship") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, source_id, target_id, strength, access_type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"relationships r WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"relationships WHERE id = r.id)", id); else if ( DBPlugin.areEqual(clazz, "IFolder") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, 'Folder' as class, type, root_type, name, documentation, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"folders f WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"folders WHERE id = f.id)", id); else if ( DBPlugin.areEqual(clazz, "IDiagramModel") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, created_by, created_on, background, connection_router_type, viewpoint, properties, features, checksum, container_checksum FROM "+this.schemaPrefix+"views v WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"views WHERE id = v.id)", id); else if ( DBPlugin.areEqual(clazz, "IDiagramModelObject") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, container_id, element_id, diagram_ref_id, border_color, border_type, content, documentation, is_locked, image_path, image_position, line_color, line_width, fill_color, alpha, font, font_color, name, notes, text_alignment, text_position, type, x, y, width, height, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"views_objects v WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"views_objects WHERE id = v.id)", id); else if ( DBPlugin.areEqual(clazz, "IDiagramModelConnection") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, container_id, name, documentation, is_locked, line_color, line_width, font, font_color, relationship_id, relationship_version, source_object_id, target_object_id, text_position, type, created_by, created_on, properties, features, bendpoints, checksum FROM "+this.schemaPrefix+"views_connections v WHERE id = ? AND version = (SELECT MAX(version) FROM "+this.schemaPrefix+"views_connections WHERE id = v.id)", id); else throw new Exception("Do not know how to get a "+clazz+" from the database."); - } else { - if ( DBPlugin.areEqual(clazz, "IArchimateElement") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"elements WHERE id = ? AND version = ?", id, version); + } else { + if ( DBPlugin.areEqual(clazz, "IArchimateModel") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, 'ArchimateModel' as class, name, note, purpose, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"models m WHERE id = ? AND version = ?", id, version); + else if ( DBPlugin.areEqual(clazz, "IArchimateElement") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"elements WHERE id = ? AND version = ?", id, version); else if ( DBPlugin.areEqual(clazz, "IArchimateRelationship") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, source_id, target_id, strength, access_type, profile, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"relationships WHERE id = ? AND version = ?", id, version); else if ( DBPlugin.areEqual(clazz, "IFolder") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, 'Folder' as class, type, root_type, name, documentation, created_by, created_on, properties, features, checksum FROM "+this.schemaPrefix+"folders WHERE id = ? AND version = ?", id, version); else if ( DBPlugin.areEqual(clazz, "IDiagramModel") ) result = new DBSelect(this.databaseEntry.getName(), this.connection, "SELECT id, version, class, name, documentation, created_by, created_on, background, connection_router_type, viewpoint, properties, features, checksum, container_checksum FROM "+this.schemaPrefix+"views WHERE id = ? AND version = ?", id, version); diff --git a/sources/src/org/archicontribs/database/data/DBVersion.java b/sources/src/org/archicontribs/database/data/DBVersion.java index fa91093a..2999482f 100644 --- a/sources/src/org/archicontribs/database/data/DBVersion.java +++ b/sources/src/org/archicontribs/database/data/DBVersion.java @@ -37,24 +37,24 @@ public DBVersion(DBVersion versionToCopy) { * Initialize the {@link DBVersion} with another DBVersion that will be copied * @param versionToCopy */ - public DBVersion(int version, String containerChecksum, String checksum, Timestamp timestamp) { - set(version, containerChecksum, checksum, timestamp); + public DBVersion(int version, String containerChecksum, String checksum, Timestamp timestamp, String username) { + set(version, containerChecksum, checksum, timestamp, username); } - public DBVersion(int version, String checksum, Timestamp timestamp) { - set(version, null, checksum, timestamp); + public DBVersion(int version, String checksum, Timestamp timestamp, String username) { + set(version, null, checksum, timestamp, username); } public DBVersion() { - this(0, null, null, null); + this(0, null, null, null, null); } public DBVersion(Timestamp timestamp) { - this(0, null, null, timestamp); + this(0, null, null, timestamp, null); } public DBVersion(int version) { - this(version, null, null, null); + this(version, null, null, null, null); } public void reset() { @@ -62,6 +62,7 @@ public void reset() { setContainerChecksum(null); setChecksum(null); setTimestamp(null); + setUsername(null); } public void set(DBVersion version) { @@ -70,26 +71,30 @@ public void set(DBVersion version) { setContainerChecksum(null); setChecksum(null); setTimestamp(null); + setUsername(null); } else { setVersion(version.getVersion()); setContainerChecksum(version.getContainerChecksum()); setChecksum(version.getChecksum()); setTimestamp(version.getTimestamp()); + setUsername(version.getUsername()); } } - public void set(int version, String checksum, Timestamp timestamp) { + public void set(int version, String checksum, Timestamp timestamp, String username) { setVersion(version); setContainerChecksum(null); setChecksum(checksum); setTimestamp(timestamp); + setUsername(username); } - public void set(int version, String containerChecksum, String checksum, Timestamp timestamp) { + public void set(int version, String containerChecksum, String checksum, Timestamp timestamp, String username) { setVersion(version); setContainerChecksum(containerChecksum); setChecksum(checksum); setTimestamp(timestamp); + setUsername(username); } public void setVersion(int version) { @@ -122,4 +127,15 @@ public void setContainerChecksum(String checksum) { public void setTimestamp(Timestamp timestamp) { this.timestamp = (timestamp==null ? NEVER : timestamp); } + + private String username; + public String getUsername() { + if (this.username == null) + return System.getProperty("user.name"); + return this.username; + } + + public void setUsername(String name) { + this.username = name; + } } diff --git a/sources/src/org/archicontribs/database/menu/DBMenu.java b/sources/src/org/archicontribs/database/menu/DBMenu.java index b19ff526..e5a150e1 100644 --- a/sources/src/org/archicontribs/database/menu/DBMenu.java +++ b/sources/src/org/archicontribs/database/menu/DBMenu.java @@ -46,6 +46,7 @@ import com.archimatetool.model.IFolder; import com.archimatetool.model.INameable; import com.archimatetool.model.ISketchModel; +import com.archimatetool.model.impl.ArchimateModel; /** * This class is used when the user right-click on a graphical object to add entries to the contextual menu @@ -84,9 +85,9 @@ public void createContributionItems(IServiceLocator serviceLocator, IContributio case "DBArchimateModel": additions.addContributionItem(new Separator(), null); if ( showDebugInContextMenu ) { - showConvertIds(); additions.addContributionItem(new Separator(), null); } + showGetHistory((ArchimateModel)obj); showImportComponent(); showExportModel(); break; @@ -461,26 +462,4 @@ private void showDebug() { true); this.fAdditions.addContributionItem(new CommandContributionItem(p), null); } - - private void showConvertIds() { - ImageDescriptor menuIcon = ImageDescriptor.createFromURL(FileLocator.find(Platform.getBundle("com.archimatetool.editor"), new Path("img/app-16.png"), null)); - String label = "Convert old fashion IDs to Archi4 IDs"; - - if ( logger.isDebugEnabled() ) logger.debug("Adding menu label: "+label); - CommandContributionItemParameter p = new CommandContributionItemParameter( - PlatformUI.getWorkbench().getActiveWorkbenchWindow(), // serviceLocator - "org.archicontribs.database.DBMenu", // id - "org.archicontribs.database.convertIdsCommand", // commandId - null, // parameters - menuIcon, // icon - null, // disabledIcon - null, // hoverIcon - label, // label - null, // mnemonic - null, // tooltip - CommandContributionItem.STYLE_PUSH, // style - null, // helpContextId - true); - this.fAdditions.addContributionItem(new CommandContributionItem(p), null); - } } diff --git a/sources/src/org/archicontribs/database/menu/DBMenuConvertIdsHandler.java b/sources/src/org/archicontribs/database/menu/DBMenuConvertIdsHandler.java deleted file mode 100644 index 11c43ba1..00000000 --- a/sources/src/org/archicontribs/database/menu/DBMenuConvertIdsHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This program and the accompanying materials - * are made available under the terms of the License - * which accompanies this distribution in the file LICENSE.txt - */ - -package org.archicontribs.database.menu; - -import org.apache.log4j.Level; -import org.archicontribs.database.DBPlugin; -import org.archicontribs.database.GUI.DBGuiUtils; -import org.archicontribs.database.model.DBArchimateModel; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.ImageLoader; -import org.eclipse.ui.handlers.HandlerUtil; - -import com.archimatetool.editor.diagram.util.DiagramUtils; -import com.archimatetool.model.FolderType; -import com.archimatetool.model.IArchimateElement; -import com.archimatetool.model.IArchimateModelObject; -import com.archimatetool.model.IArchimateRelationship; -import com.archimatetool.model.IDiagramModel; -import com.archimatetool.model.IDiagramModelComponent; -import com.archimatetool.model.IDiagramModelConnection; -import com.archimatetool.model.IFolder; -import com.archimatetool.model.IIdentifier; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Iterator; -import java.util.Map.Entry; - -import javax.imageio.ImageIO; - -/** - * Class that is called by the "replace IDs" context menu. Convert old Archi 3 IDs to Archi 4 IDs - * - * @author Herve Jouin - */ -@SuppressWarnings("unused") -public class DBMenuConvertIdsHandler extends AbstractHandler { - //private static final DBLogger logger = new DBLogger(DBMenu.class); - - /* - * This method doesn't do anything but is used for debugging purpose :-) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - DBArchimateModel model = (DBArchimateModel) ((IStructuredSelection)HandlerUtil.getCurrentSelection(event)).getFirstElement(); - int idsReplaced = 0; - - DBGuiUtils.showPopupMessage("Checking IDs ..."); - - try { - model.countAllObjects(); - - if ( model.getId().length() != 36 ) { - model.setId(DBPlugin.createID(model)); - ++idsReplaced; - } - - for (IFolder folder: model.getAllFolders().values() ) { - if ( folder.getId().length() != 36 ) { - folder.setId(DBPlugin.createID(folder)); - ++idsReplaced; - } - } - - for (IArchimateElement element: model.getAllElements().values() ) { - if ( element.getId().length() != 36 ) { - element.setId(DBPlugin.createID(element)); - ++idsReplaced; - } - } - - for (IArchimateRelationship relationship: model.getAllRelationships().values() ) { - if ( relationship.getId().length() != 36 ) { - relationship.setId(DBPlugin.createID(relationship)); - ++idsReplaced; - } - } - - for (IDiagramModel view: model.getAllViews().values() ) { - if ( view.getId().length() != 36 ) { - view.setId(DBPlugin.createID(view)); - ++idsReplaced; - } - } - - for (IDiagramModelComponent viewObject: model.getAllViewObjects().values() ) { - if ( viewObject.getId().length() != 36 ) { - viewObject.setId(DBPlugin.createID(viewObject)); - ++idsReplaced; - } - } - - for (IDiagramModelConnection viewConnection: model.getAllViewConnections().values() ) { - if ( viewConnection.getId().length() != 36 ) { - viewConnection.setId(DBPlugin.createID(viewConnection)); - ++idsReplaced; - } - } - } catch (Exception e) { - DBGuiUtils.closePopupMessage(); - DBGuiUtils.popup(Level.ERROR, "Could not convert the IDs.\n\n"+idsReplaced+" IDs have been replaced.", e); - return null; - } - - DBGuiUtils.closePopupMessage(); - DBGuiUtils.popup(Level.INFO, idsReplaced+" IDs have been replaced."); - - return null; - } -} diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java index 4152f391..e1ddbe08 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportElementFromIdCommand.java @@ -210,9 +210,9 @@ public void execute() { DBMetadata metadata = this.model.getDBMetadata(this.importedElement); if ( this.mustCreateCopy ) - metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); metadata.setId((String)this.newValues.get("id")); metadata.setName((String)this.newValues.get("name")); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportFolderFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportFolderFromIdCommand.java index b3ddf9a0..64c4aa67 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportFolderFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportFolderFromIdCommand.java @@ -157,9 +157,9 @@ public void execute() { DBMetadata dbMetadata = this.model.getDBMetadata(this.importedFolder); if ( this.mustCreateCopy ) - dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); dbMetadata.setId((String)this.newValues.get("id")); dbMetadata.setName((String)this.newValues.get("name")); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportProfileFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportProfileFromIdCommand.java index af1f280c..377d3f51 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportProfileFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportProfileFromIdCommand.java @@ -126,9 +126,9 @@ public void execute() { DBMetadata dbMetadata = this.model.getDBMetadata(this.importedProfile); if ( this.mustCreateCopy ) - dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); dbMetadata.setId((String)this.newValues.get("id")); dbMetadata.setName((String)this.newValues.get("name")); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java index 105630e4..ad635549 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportRelationshipFromIdCommand.java @@ -179,9 +179,9 @@ public void execute() { DBMetadata dbMetadata = this.model.getDBMetadata(this.importedRelationship); if ( this.mustCreateCopy ) - dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); dbMetadata.setId((String)this.newValues.get("id")); dbMetadata.setName((String)this.newValues.get("name")); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportViewConnectionFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportViewConnectionFromIdCommand.java index 507cf201..63115fa3 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportViewConnectionFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportViewConnectionFromIdCommand.java @@ -206,9 +206,9 @@ public void execute() { DBMetadata metadata = this.model.getDBMetadata(this.importedViewConnection); if ( this.mustCreateCopy ) - metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); metadata.getCurrentVersion().set(metadata.getInitialVersion()); metadata.getDatabaseVersion().set(metadata.getInitialVersion()); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportViewFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportViewFromIdCommand.java index 1263366f..abbe1027 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportViewFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportViewFromIdCommand.java @@ -207,9 +207,9 @@ public void execute() { DBMetadata metadata = this.model.getDBMetadata(this.importedView); if ( this.mustCreateCopy ) - metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + metadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + metadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); metadata.setId((String)this.newValues.get("id")); metadata.setName((String)this.newValues.get("name")); diff --git a/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java b/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java index 8a8813c8..c40a1a73 100644 --- a/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java +++ b/sources/src/org/archicontribs/database/model/commands/DBImportViewObjectFromIdCommand.java @@ -267,9 +267,9 @@ public void execute() { DBMetadata dbMetadata = this.model.getDBMetadata(this.importedViewObject); if ( this.mustCreateCopy ) - dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime())); + dbMetadata.getInitialVersion().set(0, null, new Timestamp(Calendar.getInstance().getTime().getTime()), null); else - dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on")); + dbMetadata.getInitialVersion().set((int)this.newValues.get("version"), (String)this.newValues.get("checksum"), (Timestamp)this.newValues.get("created_on"), (String)this.newValues.get("created_by")); dbMetadata.getCurrentVersion().set(dbMetadata.getInitialVersion()); dbMetadata.getDatabaseVersion().set(dbMetadata.getInitialVersion()); diff --git a/sources/src/org/archicontribs/database/preferences/DBFileFieldEditor.java b/sources/src/org/archicontribs/database/preferences/DBFileFieldEditor.java index 747249d6..d504bf51 100644 --- a/sources/src/org/archicontribs/database/preferences/DBFileFieldEditor.java +++ b/sources/src/org/archicontribs/database/preferences/DBFileFieldEditor.java @@ -21,6 +21,7 @@ public class DBFileFieldEditor extends FileFieldEditor { */ public DBFileFieldEditor() { super(); + setFileExtensions(new String[] {"*.log", "*.txt", "*.*"}); } /** @@ -31,6 +32,7 @@ public DBFileFieldEditor() { */ public DBFileFieldEditor(String name, String labelText, Composite parent) { super(name, labelText, false, parent); + setFileExtensions(new String[] {"*.log", "*.txt", "*.*"}); } /** @@ -42,6 +44,7 @@ public DBFileFieldEditor(String name, String labelText, Composite parent) { */ public DBFileFieldEditor(String name, String labelText, boolean enforceAbsolute, Composite parent) { super(name, labelText, enforceAbsolute, VALIDATE_ON_FOCUS_LOST, parent); + setFileExtensions(new String[] {"*.log", "*.txt", "*.*"}); } /** @@ -54,15 +57,6 @@ public DBFileFieldEditor(String name, String labelText, boolean enforceAbsolute, */ public DBFileFieldEditor(String name, String labelText, boolean enforceAbsolute, int validationStrategy, Composite parent) { super(name, labelText, enforceAbsolute, validationStrategy, parent); - } - - @Override - protected String changePressed() { - return getTextControl().getText(); - } - - @Override - protected boolean checkState() { - return true; - } + setFileExtensions(new String[] {"*.log", "*.txt", "*.*"}); + } }