public class DoorsReader extends Object implements ModelReader
Options can be used to configure the model reader, typically to use a DOORS batch client. Options are defined in the Common
class and
are passed using a Map
to the model reader, as illustrated in the snippet below. Also not that option may be set as Java System
properties. For example, for an option named "xyz"
, setting a value as a Java Virtual Machine argument is done this way:
-Dxyz=myValue
Clients should never instantiate this class and never call the read()
method directly. The model reader is to be used as illustrated
in the snippet below:
MDWorkbench workbench = null; Model model = null; try { // configure to use a DOORS batch client Map<String, Object> options = new HashMap<String, Object>(); options.put(Common.OPTION_IGNORE_CONNECTOR_UI, true); options.put(Common.PREFERENCE_DOORS_IS_SILENT, true); options.put(Common.PREFERENCE_DOORS_PATH, "C:\\Program Files (x86)\\IBM\\Rational\\DOORS\\9.6\\bin\\doors.exe"); options.put(Common.PREFERENCE_DOORS_PORTSERVER, "36677@myServer"); options.put(Common.PREFERENCE_DOORS_USER, "myUser"); options.put(Common.PREFERENCE_DOORS_PASSWORD, "myPassword"); // read the model model = workbench.getMetamodelManager().getMetamodel(DoorsPackage.eINSTANCE).createModel(); model.read("Application", "", options); // get the root folder (the database root node) Folder root = model.<Folder>getInstances(DoorsPackage.Literals.FOLDER).first(); // access on-demand the content of the database List<Item> items = root.getOwnedItems(); ... } finally { // disposes the model and shutdown the DOORS batch client used under the hood if (model != null) { model.clear(); } if (workbench != null) { workbench.shutdown(); } }
To instantiate a DoorsApplication
, which determines how to interact with a DOORS client, the model reader will use the options given
to the read()
method, as the ones illustrated in the above snippet. The DOORS application is created by passing those options to
DoorsUtils.createApplication()
.
You might also request the model reader to use an explicit instance of DoorsApplication
. This allows for example to share a DOORS
batch client between a model reader and a DXL command to update DOORS data. Here is a snippet illustrating this option:
DoorsApplication application = ... Map<String, Object> options = new HashMap<String, Object>(); options.put(Common.OPTION_DOORS_APPLICATION, application); model.read("Application", "", options); ... // The DOORS application was instantiated in this code, which is then in charge to dispose it. application.dispose();
Once a model is read, you can access elements going from one element to another, starting on the root folder. For example, starting from a certain
Folder
, contained folders and modules can be obtained simply by calling myFolder.getOwnedItems()
.
A specific folder or module can also be accessed directly by resolving its full path, DOORS URL or DOORS unique ID, like in this snippet below:
Folder root = model.<Folder> getInstances(DoorsPackage.Literals.FOLDER).first(); Resource resource = root.eResource(); String modulePath = "/MyProject/MyModule"; // full path, DOORS URL or DOORS unique ID FormalModule module = (FormalModule) resource.getEObject(modulePath);
This class is not intended to be subclassed nor instantiated by clients .
Constructor and Description |
---|
DoorsReader() |
public void read(String uri, Model model, ConnectorContext context) throws CoreException
read
in interface ModelReader
CoreException