database-plugin
database-plugin copied to clipboard
Exporting model to sqlite database using CLI results in empty model
I would like to export an archi model to sqlite for further processing as part of my CI pipeline, unfortunately this doesn't seem to work as expected. Here's what I've tried.
Note that I use the following configuration in ~/.archi/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.archicontribs.database.prefs
:
databases=1
databases_driver_0=sqlite
databases_name_0=export
databases_server_0=/tmp/export.sqlite
databases_views-images-border-width_0=10
databases_views-images-scale-factor_0=100
eclipse.preferences.version=1
loggerLevel=debug
loggerMode=simple
pluginVersion=4.9.7
If /tmp/export.sqlite
does not exist I get a dialog telling me that the database does not exist and I have to confirm this. I can work around this by creating the empty database manually, but that's not really relevant for the problem here, so I click OK to proceed. Here's the resulting output. Notice how we export an empty model instead of the model I try to load using the modelrepository plugin.
Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --abortOnException --modelrepository.loadModel . --export.database export
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.concurrent
2024-05-23 15:59:55 INFO 228:DBPlugin - Logger initialised.
2024-05-23 15:59:55 INFO 229:DBPlugin - Initialising Database import/export plugin v4.9.7 ...
2024-05-23 15:59:55 INFO 231:DBPlugin - ===============================================
2024-05-23 15:59:55 DEBUG 252:DBPlugin - Archi is setup with 16760 MB of memory.
2024-05-23 15:59:55 DEBUG 294:DBPlugin - Plugin's package = org.archicontribs.database
2024-05-23 15:59:55 DEBUG 295:DBPlugin - Plugin's version = 4.9.7
2024-05-23 15:59:55 DEBUG 296:DBPlugin - Archi's version = 5.0.0
2024-05-23 15:59:55 DEBUG 297:DBPlugin - Plugin's folder = /home/alf/.archi/dropins
2024-05-23 15:59:55 DEBUG 298:DBPlugin - Plugin's filename = /home/alf/.archi/dropins/org.archicontribs.database_4.9.7.jar
[LoadModelFromRepositoryProvider] Loading model at .
2024-05-23 15:59:56 DEBUG 32:DBArchimateFactory - Initializing DBArchimateFactory
2024-05-23 15:59:56 DEBUG 71:DBArchimateModel - Creating new ArchimateModel
[LoadModelFromRepositoryProvider] Loaded model: 'Arkitektur Studieadministrasjon'
2024-05-23 15:59:56 DEBUG 228:DBGui - Creating Form GUI.
2024-05-23 15:59:56 DEBUG 115:DBGuiExportModel - Setting up GUI for exporting model "Arkitektur Studieadministrasjon" (plugin version 4.9.7).
2024-05-23 15:59:56 DEBUG 356:DBDatabaseEntry - Getting databases preferences from preference store
2024-05-23 15:59:56 DEBUG 373:DBDatabaseEntry - Getting database entry "export" from the preference store
2024-05-23 15:59:56 INFO 1108:DBGui - Connecting to the database ...
2024-05-23 15:59:56 DEBUG 701:DBGui - Selected database = export (sqlite, /tmp/export.sqlite, 0, ,
2024-05-23 15:59:56 DEBUG 174:DBDatabaseConnection - Opening connection to database export: driver=sqlite, server=/tmp/export.sqlite, port=0, database=, schema=, username=
2024-05-23 15:59:56 DEBUG 177:DBDatabaseConnection - JDBC class = org.sqlite.JDBC
2024-05-23 15:59:56 DEBUG 180:DBDatabaseConnection - JDBC connection string = jdbc:sqlite:/tmp/export.sqlite
2024-05-23 15:59:56 DEBUG 223:DBDatabaseConnection - Connecting with username =
2024-05-23 15:59:57 DEBUG 243:DBDatabaseConnection - Will use default schema
2024-05-23 15:59:57 DEBUG 707:DBGui - We are connected to the database.
2024-05-23 15:59:57 DEBUG 230:DBGuiUtils ┌ Question: We successfully connected to the database but it seems that it has not been initialized.
2024-05-23 15:59:57 DEBUG 230:DBGuiUtils │
2024-05-23 15:59:57 DEBUG 230:DBGuiUtils └ Do you wish to intialize the database ?
2024-05-23 15:59:58 DEBUG 258:DBGuiUtils - Answer: Yes
2024-05-23 15:59:58 INFO 71:DBGuiUtils - Creating necessary database tables ...
2024-05-23 15:59:59 DEBUG 1451:DBDatabaseConnection - Setting database auto commit to false
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table database_version
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table models
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table folders
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table folders_in_model
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table elements
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table elements_in_model
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table relationships
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table relationships_in_model
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views_in_model
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views_objects
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views_objects_in_view
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views_connections
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table views_connections_in_view
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table properties
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table features
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table profiles
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table profiles_in_model
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table bendpoints
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table metadata
2024-05-23 15:59:59 DEBUG 525:DBDatabaseConnection - Creating table images
2024-05-23 15:59:59 DEBUG 1460:DBDatabaseConnection - Committing database transaction.
2024-05-23 15:59:59 DEBUG 1451:DBDatabaseConnection - Setting database auto commit to true
2024-05-23 15:59:59 DEBUG 160:DBGuiUtils - INFO: The database has been successfully initialized.
2024-05-23 16:00:00 DEBUG 1301:DBGuiExportModel - Enabling the "Export" button.
2024-05-23 16:00:00 INFO 1967:DBGuiExportModel - Exporting model:
2024-05-23 16:00:00 INFO 1995:DBGuiExportModel - Calculating model's checksum.
2024-05-23 16:00:00 INFO 988:DBGui - Comparing the model to the database ...
2024-05-23 16:00:00 DEBUG 133:DBDatabaseExportConnection - Getting versions of the model from the database
2024-05-23 16:00:00 DEBUG 157:DBDatabaseExportConnection - The model does not exist in the database
2024-05-23 16:00:00 DEBUG 563:DBDatabaseExportConnection - Getting versions of the profiles from the database
2024-05-23 16:00:00 DEBUG 671:DBDatabaseExportConnection - Getting versions of the elements from the database
2024-05-23 16:00:00 DEBUG 794:DBDatabaseExportConnection - Getting versions of the relationships from the database
2024-05-23 16:00:00 DEBUG 903:DBDatabaseExportConnection - Getting versions of the folders from the database
2024-05-23 16:00:00 DEBUG 1012:DBDatabaseExportConnection - Getting versions of the views from the database
2024-05-23 16:00:00 DEBUG 1122:DBDatabaseExportConnection - Checking missing images from the database
2024-05-23 16:00:00 DEBUG 1195:DBDatabaseExportConnection - Checking if the images exist in the database
2024-05-23 16:00:00 INFO 988:DBGui - Checking if view screenshots are required
2024-05-23 16:00:00 INFO 1108:DBGui - Calculating number of new, updated and deleted components.
2024-05-23 16:00:00 INFO 1955:DBGuiExportModel - The model needs to be exported to the database.
2024-05-23 16:00:00 INFO 1108:DBGui - Checking for conflicts ...
2024-05-23 16:00:00 INFO 1108:DBGui - Removing from the model the components that have been deleted in the database ...
2024-05-23 16:00:00 INFO 2253:DBGuiExportModel - There is no component to import from the database.
2024-05-23 16:00:00 INFO 1108:DBGui - Checking if components have been moved to new folder ...
2024-05-23 16:00:00 INFO 2541:DBGuiExportModel - There is no component to move to a new folder.
2024-05-23 16:00:00 INFO 988:DBGui - Exporting model to the database ...
2024-05-23 16:00:00 DEBUG 1451:DBDatabaseConnection - Setting database auto commit to false
2024-05-23 16:00:00 INFO 2576:DBGuiExportModel - Exporting the model itself ...
2024-05-23 16:00:00 DEBUG 1421:DBDatabaseExportConnection - Exporting model (initial version = 0, exported version = 1, latest database version = 0)
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting specializations ..."
2024-05-23 16:00:00 DEBUG 2109:DBDatabaseExportConnection - Exporting Profile:"Modul"(id-97daed04442e40d1a0077dc1866a365a) (initial version = 0, exported version = 1, database_version = 0, latest_database_version = 0)
2024-05-23 16:00:00 DEBUG 2109:DBDatabaseExportConnection - Exporting Profile:"Schema"(id-a9dfee63c9f64fc7bf954f51ffe899f2) (initial version = 0, exported version = 1, database_version = 0, latest_database_version = 0)
2024-05-23 16:00:00 DEBUG 2109:DBDatabaseExportConnection - Exporting Profile:"Database"(id-2fa74595f41a4b79b583c33ec4f3bcf5) (initial version = 0, exported version = 1, database_version = 0, latest_database_version = 0)
2024-05-23 16:00:00 DEBUG 2109:DBDatabaseExportConnection - Exporting Profile:"Team"(id-028a26da878b4bf9844543b5ffaa9281) (initial version = 0, exported version = 1, database_version = 0, latest_database_version = 0)
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting elements ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting relationships ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting folders ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting views ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting view objects ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting view connections ..."
2024-05-23 16:00:00 INFO 1014:DBGui - Setting progress bar label to "Exporting images ..."
2024-05-23 16:00:00 DEBUG 1460:DBDatabaseConnection - Committing database transaction.
2024-05-23 16:00:01 DEBUG 260:DBDatabaseConnection - Closing the database connection.
2024-05-23 16:00:01 DEBUG 2961:DBGuiExportModel - Copying current version to initial version.
2024-05-23 16:00:01 DEBUG 3234:DBGuiExportModel - Showing result.
2024-05-23 16:00:01 INFO 3243:DBGuiExportModel - <------ In model ------> <----- In database ---->
2024-05-23 16:00:01 INFO 3244:DBGuiExportModel - Total New Updated Deleted New Updated Deleted Conflict
2024-05-23 16:00:01 INFO 3245:DBGuiExportModel - Elements: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3246:DBGuiExportModel - Relationships: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3248:DBGuiExportModel - Folders: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3249:DBGuiExportModel - views: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3250:DBGuiExportModel - Objects: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3251:DBGuiExportModel - Connections: 0 0 0 0 0 0 0 0
2024-05-23 16:00:01 INFO 3252:DBGuiExportModel - images: 0 0 0
2024-05-23 16:00:01 INFO 1108:DBGui - *** Export successful ***
DBPlugin Export CommandLine DBPlugin Export CommandLine: The model "Arkitektur Studieadministrasjon" has been exported to the "export" database.
The problem here is that the model I want to load and export (Arkitektur Studieadministrasjon) contains hundreds of elements, relationships etc. I get the feeling that there is a race condition here where the database export runs before the model I want to export gets loaded. Thus an empty model is created and exported instead. Loading the model using --loadModel
also result in an empty model.
If I try to do another export without first deleting the sqlite file it fails with a different message. That's a different bug I suspect, but here's the output in case it helps:
Archi -application com.archimatetool.commandline.app -consoleLog -nosplash --abortOnException --modelrepository.loadModel . --export.database export
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.concurrent
2024-05-23 16:07:37 INFO 228:DBPlugin - Logger initialised.
2024-05-23 16:07:37 INFO 229:DBPlugin - Initialising Database import/export plugin v4.9.7 ...
2024-05-23 16:07:37 INFO 231:DBPlugin - ===============================================
2024-05-23 16:07:37 DEBUG 252:DBPlugin - Archi is setup with 16760 MB of memory.
2024-05-23 16:07:37 DEBUG 294:DBPlugin - Plugin's package = org.archicontribs.database
2024-05-23 16:07:37 DEBUG 295:DBPlugin - Plugin's version = 4.9.7
2024-05-23 16:07:37 DEBUG 296:DBPlugin - Archi's version = 5.0.0
2024-05-23 16:07:37 DEBUG 297:DBPlugin - Plugin's folder = /home/alf/.archi/dropins
2024-05-23 16:07:37 DEBUG 298:DBPlugin - Plugin's filename = /home/alf/.archi/dropins/org.archicontribs.database_4.9.7.jar
[LoadModelFromRepositoryProvider] Loading model at .
2024-05-23 16:07:37 DEBUG 32:DBArchimateFactory - Initializing DBArchimateFactory
2024-05-23 16:07:37 DEBUG 71:DBArchimateModel - Creating new ArchimateModel
[LoadModelFromRepositoryProvider] Loaded model: 'Arkitektur Studieadministrasjon'
2024-05-23 16:07:38 DEBUG 228:DBGui - Creating Form GUI.
2024-05-23 16:07:38 DEBUG 115:DBGuiExportModel - Setting up GUI for exporting model "Arkitektur Studieadministrasjon" (plugin version 4.9.7).
2024-05-23 16:07:38 DEBUG 356:DBDatabaseEntry - Getting databases preferences from preference store
2024-05-23 16:07:38 DEBUG 373:DBDatabaseEntry - Getting database entry "export" from the preference store
2024-05-23 16:07:38 INFO 1108:DBGui - Connecting to the database ...
2024-05-23 16:07:38 DEBUG 701:DBGui - Selected database = export (sqlite, /tmp/export.sqlite, 0, ,
2024-05-23 16:07:38 DEBUG 174:DBDatabaseConnection - Opening connection to database export: driver=sqlite, server=/tmp/export.sqlite, port=0, database=, schema=, username=
2024-05-23 16:07:38 DEBUG 177:DBDatabaseConnection - JDBC class = org.sqlite.JDBC
2024-05-23 16:07:38 DEBUG 180:DBDatabaseConnection - JDBC connection string = jdbc:sqlite:/tmp/export.sqlite
2024-05-23 16:07:38 DEBUG 223:DBDatabaseConnection - Connecting with username =
2024-05-23 16:07:38 DEBUG 243:DBDatabaseConnection - Will use default schema
2024-05-23 16:07:38 DEBUG 707:DBGui - We are connected to the database.
2024-05-23 16:07:38 DEBUG 1301:DBGuiExportModel - Enabling the "Export" button.
2024-05-23 16:07:38 INFO 1967:DBGuiExportModel - Exporting model:
2024-05-23 16:07:38 INFO 1995:DBGuiExportModel - Calculating model's checksum.
2024-05-23 16:07:38 INFO 988:DBGui - Comparing the model to the database ...
2024-05-23 16:07:38 DEBUG 133:DBDatabaseExportConnection - Getting versions of the model from the database
2024-05-23 16:07:38 DEBUG 153:DBDatabaseExportConnection - The model already exists in the database:
2024-05-23 16:07:38 DEBUG 563:DBDatabaseExportConnection - Getting versions of the profiles from the database
2024-05-23 16:07:38 DEBUG 671:DBDatabaseExportConnection - Getting versions of the elements from the database
2024-05-23 16:07:38 DEBUG 794:DBDatabaseExportConnection - Getting versions of the relationships from the database
2024-05-23 16:07:38 DEBUG 903:DBDatabaseExportConnection - Getting versions of the folders from the database
2024-05-23 16:07:38 DEBUG 1012:DBDatabaseExportConnection - Getting versions of the views from the database
2024-05-23 16:07:38 DEBUG 1122:DBDatabaseExportConnection - Checking missing images from the database
2024-05-23 16:07:38 DEBUG 1195:DBDatabaseExportConnection - Checking if the images exist in the database
2024-05-23 16:07:38 INFO 988:DBGui - Checking if view screenshots are required
2024-05-23 16:07:38 INFO 1108:DBGui - Calculating number of new, updated and deleted components.
2024-05-23 16:07:38 INFO 1955:DBGuiExportModel - The model needs to be exported to the database.
2024-05-23 16:07:38 INFO 1108:DBGui - Checking for conflicts ...
2024-05-23 16:07:38 INFO 1108:DBGui - Removing from the model the components that have been deleted in the database ...
2024-05-23 16:07:38 INFO 2253:DBGuiExportModel - There is no component to import from the database.
2024-05-23 16:07:38 INFO 1108:DBGui - Checking if components have been moved to new folder ...
2024-05-23 16:07:38 INFO 2541:DBGuiExportModel - There is no component to move to a new folder.
2024-05-23 16:07:38 INFO 988:DBGui - Exporting model to the database ...
2024-05-23 16:07:38 DEBUG 1451:DBDatabaseConnection - Setting database auto commit to false
2024-05-23 16:07:38 INFO 2576:DBGuiExportModel - Exporting the model itself ...
2024-05-23 16:07:38 DEBUG 1421:DBDatabaseExportConnection - Exporting model (initial version = 0, exported version = 2, latest database version = 1)
2024-05-23 16:07:38 INFO 1014:DBGui - Setting progress bar label to "Exporting specializations ..."
2024-05-23 16:07:38 DEBUG 2109:DBDatabaseExportConnection - Exporting Profile:"Modul"(id-97daed04442e40d1a0077dc1866a365a) (initial version = 0, exported version = 1, database_version = 0, latest_database_version = 0)
2024-05-23 16:07:38 DEBUG 1476:DBDatabaseConnection - Rollbacking database transaction.
2024-05-23 16:07:38 DEBUG 260:DBDatabaseConnection - Closing the database connection.
2024-05-23 16:07:38 DEBUG 3234:DBGuiExportModel - Showing result.
2024-05-23 16:07:38 ERROR 1106:DBGui ┌ Failed to export the model to the database
2024-05-23 16:07:38 ERROR 1106:DBGui └ [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: profiles.id, profiles.version)
2024-05-23 16:07:38 DEBUG 160:DBGuiUtils ┌ ERROR: Failed to export the model to the database
2024-05-23 16:07:38 DEBUG 160:DBGuiUtils │
2024-05-23 16:07:38 DEBUG 160:DBGuiUtils └ The transaction has been rolled back to leave the database in a coherent state. You may solve the issue and export again your components.
org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: profiles.id, profiles.version)
at org.sqlite.core.DB.newSQLException(DB.java:1135)
at org.sqlite.core.DB.newSQLException(DB.java:1146)
at org.sqlite.core.DB.execute(DB.java:941)
at org.sqlite.core.DB.executeUpdate(DB.java:1010)
at org.sqlite.jdbc3.JDBC3PreparedStatement.lambda$executeLargeUpdate$2(JDBC3PreparedStatement.java:117)
at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout(JDBC3Statement.java:429)
at org.sqlite.jdbc3.JDBC3PreparedStatement.executeLargeUpdate(JDBC3PreparedStatement.java:116)
at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:98)
at org.archicontribs.database.connection.DBStatement.executeUpdate(DBStatement.java:78)
at org.archicontribs.database.connection.DBRequest.<init>(DBRequest.java:23)
at org.archicontribs.database.connection.DBDatabaseConnection.insert(DBDatabaseConnection.java:1357)
at org.archicontribs.database.connection.DBDatabaseExportConnection.exportProfile(DBDatabaseExportConnection.java:2123)
at org.archicontribs.database.connection.DBDatabaseExportConnection.exportEObject(DBDatabaseExportConnection.java:1467)
at org.archicontribs.database.GUI.DBGuiExportModel.export(DBGuiExportModel.java:2597)
at org.archicontribs.database.commandline.DBExportModelProvider.run(DBExportModelProvider.java:69)
at com.archimatetool.commandline.CentralScrutinizer.runProviderOptions(CentralScrutinizer.java:164)
at com.archimatetool.commandline.CentralScrutinizer.start(CentralScrutinizer.java:82)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
at org.eclipse.equinox.launcher.Main.main(Main.java:1440)
DBPlugin Export CommandLine DBPlugin Export CommandLine: Failed to export the model "Arkitektur Studieadministrasjon" to the "export" database.
If I use the export GUI this problem does not exist.