When the reader is launched from rules or Java code, you can set options to tweak the reader's behavior.
Depending on the use case, you might be interested to read only the data contained by a specific Project.
Here is a sample code showing how to read only data in the scope of a project:
MDWorkbench workbench = null; Model model = null; try { // configure connection on Integrity server Map<String, Object> options = new HashMap<String, Object>(); options.put(Options.OPTION_IGNORE_CONNECTOR_UI, true); options.put(Options.OPTION_INTEGRATION_POINT_KIND, IntegrationPointKind.SERVER); options.put(Options.OPTION_SERVER, "myserver"); options.put(Options.OPTION_PORT, "7001"); options.put(Options.OPTION_USER, "myUser"); options.put(Options.OPTION_PASSWORD, "myPassword"); // restrict content to one particular project DatabaseConfiguration configuration = new DatabaseConfiguration(); configuration.getProjects().add("/MyProject"); options.put(Options.OPTION_DATABASE_CONFIGURATION, configuration); // read the model model = workbench.getMetamodelManager().getMetamodel(IntegrityPackage.eINSTANCE).createModel(); model.read("Application", "", options); // get the database instance Database database = model.<Database>getInstances(IntegrityPackage.Literals.DATABASE).first(); // access on-demand the content of the database List<Type> types = database.getTypes(); ... } finally { // disposes the model if (model != null) { model.clear(); } if (workbench != null) { workbench.shutdown(); } }
The model reader can be configured using many options, which are defined in the class
Options
.
Here is a list of the most significant options:
Options.OPTION_IGNORE_CONNECTOR_UI
false
Options.OPTION_DATABASE_CONFIGURATION
com.sodius.mdw.metamodel.integrity.io.DatabaseConfiguration
Options.OPTION_DATABASE_PRELOAD
false
Options.OPTION_INTEGRATION_POINT_KIND
Options.OPTION_INTEGRATION_POINT_KIND
- the connection mode: LOCAL
(default) or SERVER
. It's recommended to use SERVER
mode.
Options.OPTION_SERVER
- the server name of the database to connect to
Options.OPTION_PORT
- the port of the database to connect to
Options.OPTION_USER
- the name of the Integrity user to make the connection
Options.OPTION_PASSWORD
- the password of the Integrity user to make the connection
Options.OPTION_IGNORE_CONNECTOR_UI
should also be set true
in such use case.