MDWorkbench Services, available in the Services view, allow a user to easily execute a packaged model transformation. An MDWorkbench Service provides a wizard for the user to select transformation options and to launch the service execution.
MDWorkbench Services might be implemented using MDWorkbench Rules. If you have Java skills, services can also be fully implemented in Java, with an Operation Service.
Here are the steps to declare an operation service:
com.sodius.mdw.corecom.sodius.mdw.platform.servicescom.sodius.mdw.metamodel.xxx, for each metamodel your project requires.org.eclipse.jface.wizard.IWizardOperationFactoryThe service extension references a wizard to display when the user executes the service. Though this wizard is optional, it is very commonly needed for the user to enter input information used by the launched transformation.
The wizard must implement the org.eclipse.jface.wizard.IWizard interface and is recommended to extend org.eclipse.jface.wizard.Wizard.
The wizard is free to display as many pages as needed and to group options in such a way that the interface is intuitive for the end user.
The contract is for the IWizard.performFinish() method to store all user entered data, necessary for the service execution,
in the IDialogSettings instance returned by IWizard.getDialogSettings().
All options set in the IDialogSettings instance are then accessible
to the associated OperationFactory
through the OperationContext argument.
The service extension references an OperationFactory
to instantiate the main Operation to execute.
The OperationFactory is given an instance of OperationContext that contains all user entered data set in the wizard.
An Operation is a block of code to execute and has an associated status,
which determines whether warning or errors are encountered during the execution.
The status enables to monitor the execution state of the operation and to query the execution result.
An operation can be decomposed into sub-operations.
An Operation cannot throw an exception.
All exceptions that occur during the execution are to catch and to store into the operation associated status.
The developer is encouraged to regularly check the Operation.isCanceledOrFailed(monitor)
method to determine whether the operation shall continue to execute.
The operation should return as soon as a cancel request is detected or when an error is stored in the status.
The Operations class
provides ready to use operations for common activities, like reading or writing a model.
The MappingFunction class
provides a common base for operations that are targeted to model transformation, where an output model is created from an input model.
The Services view shows available services. User can execute Operation services from here.
When a service execution is completed, a log is displayed in the Report view.
The log shows the flow of executed operations, so that the user can review the various steps of the execution and the associated information.
If MappingFunction instances were used during the execution,
the log also provides information on the input and output models and the traceability links between their model elements.
An Operation can also be executed using a code like the following:
// create the context with input options
OperationContext context = OperationContext.Factory.create(MDWorkbenchFactory.create());
context.setProperty("myVariable", "myValue");
// run the operation
Operation operation = new MyOperationFactory().create(context);
new OperationRunner().run(operation, new NullProgressMonitor());
// write the operation's log
FileOutputStream output = new FileOutputStream(new File("c:\\temp\\log.html"));
StatusWriter.Factory.createHTML(context).write(operation.getStatus(), output);
output.close();
The Operation service author can provide extension points in the transformation so that other plug-in authors can contribute to enhance the transformation.