Implementing the Main Publisher Operation

Here are the recommended steps to implement the main operation:

  1. Connect to the authoring tool and extract data

    Whenever possible, it is recommended as a first step to extract the necessary data from the authoring tool. You may implement a publisher that retrieves data on-demand from the authoring tool as the publish is being processed, but it is usually simpler to implement and test if the complete set of data is first retrieved locally (e.g. in a temporary XML file).

    It is also recommended to use MDAccess components whenever possible, like MDAccess for XML to parse XML files. This notably eases the implementation of the publisher, as you can have an in-memory mapping between the authoring tool model element and its representation in the Publisher model.

    If data to publish contains diagrams, make sure you have a mean to extract pictures from the diagrams in the authoring tool. If possible, also make sure you have a mean to identify the locations of areas in the diagram representing resources to publish.

    This step is usually realized using a subclass of com.sodius.mdw.clm.client.ReadModelOperation.

  2. Create an empty Publisher model

    This step involves creating an empty Publisher model, using the Operations.createModel() method. If an MDAccess component was used on first step, a com.sodius.mdw.core.operations.Mapping instance is created to pair the source model (holding authoring tool data) and the Publisher model (empty for now, to contain resources to publish).

  3. Create a Design to publish

    This step involves analyzing the authoring tool data loaded in the source model and creating corresponding resources in the Publisher model. This is realized in a dedicated operation (e.g. CreateDesign) and detailed later in this documentation.

    An instance of org.eclipse.emf.ecore.resource.URIConverter is usually registered in the context at this stage. The recommended implementation to use is com.sodius.mdw.clm.common.publish.operations.PublishURIConverter. A URIConverter is in charge of providing access to the binary stream of a logical URI, for example for the publisher to access diagram pictures content.

  4. Save the Publisher model

    Now that resources are created in memory in the Publisher model, this steps involves serializing the Publisher model into a file. This is realized using the com.sodius.mdw.clm.client.SaveModelOperation class. Depending on the choice made by the end user, the SaveModelOperation class will save the Publisher model either in a local file, for a disconnected mode support, or directly sent to the SECollab server for an immediate import.

    Before requesting the serialization, the Options.OPTION_VALIDATE is set to true in the context so that the Publisher model consistency is checked. This validation for example makes sure a title is set for each resource to publish. It avoids sending to SECollab server inconsistent data and lets the developer know the publisher is not correctly implemented as soon as possible.

Related reference
API Reference
Publisher Schema