Accessing the Model Manager API
You access the Model Manager API using the utility class DatabaseApiUtil and its static method api. This method returns a DatabaseApi instance that is used, for example, to list all databases configured in the COMSOL Desktop, connect to a configured database, or to directly obtain the model version corresponding to the model opened in the COMSOL Desktop.
The Model Manager API is defined in the com.comsol.api.database package and its subpackages. You will find the complete Javadoc for all types and methods in these packages on the COMSOL API for use with Java®>Java Documentation pages on the COMSOL documentation website https://doc.comsol.com.
Examples
Get the model version that the model opened in the COMSOL Desktop was loaded from. The opened model is identified by its model tag string, which should not be confused with a tag item in a Model Manager database.
String tag = model.tag();
DatabaseApi api = DatabaseApiUtil.api();
ModelItemVersion version = api.modelVersionByModelTag(tag);
A model version contains, for example, methods for reading basic Model Settings.
Get the model version corresponding to a model location URI string. Such a string can be obtained, for example, by selecting Copy Location () in the context menu for a model version in the Model Manager workspace.
DatabaseApi api = DatabaseApiUtil.api();
 
// The dots represent further characters specific to the selected
// model version.
String location = "dbmodel:///?..."
ModelItemVersion v = api.modelVersionByLocationUri(location);
Get the file version corresponding to a file location URI string. Such a string can be obtained, for example, by selecting Copy Location () in the context menu for a file version in the Model Manager workspace. You can also obtain it by selecting Copy Location () in the Location menu() for a model tree node with a Filename field in the Model Builder or Application Builder workspaces.
DatabaseApi api = DatabaseApiUtil.api();
 
// The dots represent further characters specific to the selected
// file version.
String location = "dbfile:///my_interpolation_function.txt?...";
FileItemVersion version = api.fileVersionByLocationUri(location);
A file version contains, for example, methods for reading basic File Settings, including listing all its file resources.
Write the label of all configured databases to the Debug Log window in the Application Builder workspace using the debugLog method from the Method Editor’s built-in method library.
DatabaseApi api = DatabaseApiUtil.api();
 
QueryDatabaseConfigurationResultStream configurations = api
  .queryDatabaseConfigurations();
 
for (QueryDatabaseConfigurationResult config : configurations) {
  debugLog(config.label());
}
Configurations for both local databases and server databases accessed via a Model Manager server are included in the for-loop.
Creating and Running Methods in Models in the COMSOL Multiphysics Reference Manual
Save a new version of the model opened in the COMSOL Desktop using its model tag identifier and without providing a commit comment.
String tag = model.tag();
DatabaseApi api = DatabaseApiUtil.api();
ModelItemVersion version = api.saveRegularModel(tag, null);