public class Operations extends Object
This class is not intended to be subclassed by clients.
Modifier and Type | Method and Description |
---|---|
static Function<Model> |
createModel(EPackage ePackage,
OperationContext context)
Returns a function that creates an empty model for the specified package.
|
static Logger |
createModelLogger(OperationStatus status)
Creates a logger instance that redirects log entries as children of the specified status.
|
static ProgressMonitor |
createModelMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
Creates an MDWorkbench progress monitor that wraps the specified Equinox progress monitor.
|
static Function<Model> |
createModelReader(EPackage ePackage,
String readerName,
String uri,
Map<String,?> options,
OperationContext context)
Returns a function that creates a model and executes a model reader.
|
static Function<Model> |
createModelReader(EPackage ePackage,
String readerName,
String uri,
OperationContext context)
Returns a function that creates a model and executes a model reader.
|
static Operation |
createModelReader(Model model,
String readerName,
String uri)
Returns an operation that executes a model reader on the specified model.
|
static Operation |
createModelReader(Model model,
String readerName,
String uri,
Map<String,?> options)
Returns an operation that executes a model reader on the specified model.
|
static Operation |
createModelWriter(Model model,
String writerName,
String uri)
Returns an operation that executes a model writer on the specified model.
|
static Operation |
createModelWriter(Model model,
String writerName,
String uri,
Map<String,?> options)
Returns an operation that executes a model writer on the specified model.
|
static Operation |
createTextTemplate(String templateName,
List<?> arguments,
ClassLoader classLoader,
OperationContext context)
Returns an operation that evaluates the specified text template and write on disk the generated contents.
|
public static Function<Model> createModel(EPackage ePackage, OperationContext context)
ePackage
- an EPackage
that corresponds to a metamodel for which a model is desired.context
- the context in which the function is running.public static Function<Model> createModelReader(EPackage ePackage, String readerName, String uri, OperationContext context)
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
The function is configured to provide a logger and progress monitor to the underlying model reader.
ePackage
- an EPackage
that corresponds to a metamodel for which a model is desired.readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)context
- the context in which the function is running.Model.read(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Function<Model> createModelReader(EPackage ePackage, String readerName, String uri, Map<String,?> options, OperationContext context)
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
The function is configured to provide a logger and progress monitor to the underlying model reader. Client does not need to configure those on its own in the given options.
ePackage
- an EPackage
that corresponds to a metamodel for which a model is desired.readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)options
- properties to configure the model reader.context
- the context in which the function is running.Model.read(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Operation createModelReader(Model model, String readerName, String uri)
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
The operation is configured to provide a logger and progress monitor to the underlying model reader.
model
- the model on which a reading must occur.readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)Model.read(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Operation createModelReader(Model model, String readerName, String uri, Map<String,?> options)
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
The operation is configured to provide a logger and progress monitor to the underlying model reader. Client does not need to configure those on its own in the given options.
model
- the model on which a reading must occur.readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)options
- properties to configure the model reader.Model.read(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Operation createModelWriter(Model model, String writerName, String uri)
The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should
write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource
locator, including null
when the connector does not expect any uri.
The operation is configured to provide a logger and progress monitor to the underlying model writer.
model
- the model on which a reading must occur.writerName
- the connector name to be used.uri
- an additional resource locator used by the connector to write the model (can be null
)Model.write(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Operation createModelWriter(Model model, String writerName, String uri, Map<String,?> options)
The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should
write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource
locator, including null
when the connector does not expect any uri.
The operation is configured to provide a logger and progress monitor to the underlying model writer. Client does not need to configure those on its own in the given options.
model
- the model on which a reading must occur.writerName
- the connector name to be used.uri
- an additional resource locator used by the connector to write the model (can be null
)options
- properties to configure the model writer.Model.write(String, String, Map)
,
createModelLogger(OperationStatus)
,
createModelMonitor(IProgressMonitor)
public static Logger createModelLogger(OperationStatus status)
It is worth noting that error
log entries are redirected as WARNING
status instances, as model reading and writing
log errors should not abort the whole operation execution. Only exceptions raised by a model reading an writing shall abort the process.
status
- the parent status on which children shall be attached.createModelReader(Model, String, String, Map)
,
createModelWriter(Model, String, String, Map)
public static ProgressMonitor createModelMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
monitor
- an Equinox progress monitorcreateModelReader(EPackage, String, String, Map, OperationContext)
,
createModelWriter(Model, String, String, Map)
public static Operation createTextTemplate(String templateName, List<?> arguments, ClassLoader classLoader, OperationContext context)
The template name must be a fully qualified name (e.g. "com.sodius.myproject.MyTemplate"
). The template is located by querying the
template path on the specified class loader, using the ClassLoader.getResource()
method).
The number and type of arguments must match the parameters of the template. If the template does not declare parameters, the arguments can be
an empty list or null
.
The template is evaluated and the generated contents is written out, as specified by the file property of the text template. The specified class loader is used to load classes referenced by the text template. The text template must not use any ruleset, script or other text template.
templateName
- the qualified name of the template.arguments
- the template arguments (can be null
if no arguments expected).classLoader
- the class loader used to load the text template and classes it may reference. The caller usually obtain the class loader with
this.getClass().getClassLoader()
.context
- the context in which the operation is running.