Programming the Reader Configuration

When the reader is launched from rules or Java code, you can set options to tweak the reader's behavior.

Reading only a specific Project

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();
    }
}

Programmatic Properties

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:

Related reference
Reading Integrity data