public class GraphTransformer extends ChangeRequest
ChangeRequest
, so its execution can be deferred. When
it is executed, it generates a bunch of MoMLChangeRequest
s and
immediately executes those requests. Those requests adjusts the model with the
given match of the pattern.Modifier and Type | Class and Description |
---|---|
static class |
GraphTransformer.ReplacementObjectAttribute
A temporary attribute to record the corresponding object in the replacement
for any object in the pattern.
|
Constructor and Description |
---|
GraphTransformer(TransformationRule transformationRule,
java.util.List<MatchResult> matchResults)
Construct a transformer with the given transformation rule (including a
pattern and a replacement), and a list of match results.
|
GraphTransformer(TransformationRule transformationRule,
MatchResult matchResult)
Construct a transformer with the given transformation rule (including a
pattern and a replacement), and a single match result.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_addConnections()
Add new connections.
|
protected void |
_addObjects()
Add new NamedObjs.
|
protected void |
_execute()
Execute the change request and perform the transformation on the match
result(s) given to the constructor.
|
protected void |
_hideRelations()
Hide all the relations in the host model that can be hidden, such as the
ones that are visible but are not multi-way.
|
protected void |
_init()
Initialize model transformation and construct the maps between objects
in the pattern, those in the replacement, and those in the host model.
|
protected void |
_performOperations()
Perform all the operations associated with the objects in the
replacement.
|
protected void |
_recordMoML()
Record the MoML for the objects in the host model that are matched and
need to be preserved in the result.
|
protected void |
_removeLinks()
Remove the links in the host model that are matched but need to be
deleted.
|
protected void |
_removeObjects()
Remove the NamedObjs in the host model that are matched but need to be
deleted.
|
protected void |
_restoreParameterValues()
Restore the values of the ValueIterators in the host model, so that they
have the values that were used to obtain the match result.
|
protected void |
_wrapup()
Finish up transformation and remove the helper attributes in the
replacement and the host model created in the transformation.
|
void |
addTransformationListener(TransformationListener listener)
Add a TransformationListener to listen to the transformation.
|
MatchResult |
getMatchResult()
Get the current match result used for the transformation.
|
Pattern |
getPattern()
Get the pattern of the transformation rule being used.
|
Replacement |
getReplacement()
Get the replacement of the transformation rule being used.
|
void |
removeTransformationListener(TransformationListener listener)
Remove a previously added TransformationListener.
|
static void |
startUndoableTransformation(boolean mergeWithPrevious)
Make all the transformers to execute undoable MoMLChangeRequests.
|
static void |
stopUndoableTransformation()
Stop executing undoable MoMLChangeRequests in all transformers, so that
future requests cannot be undone.
|
static void |
transform(TransformationRule transformationRule,
java.util.List<MatchResult> matchResults)
Transform a list of match results with a transformation rule.
|
static void |
transform(TransformationRule transformationRule,
java.util.List<MatchResult> matchResults,
TransformationListener listener)
Transform a list of match results with a transformation rule.
|
static void |
transform(TransformationRule transformationRule,
MatchResult matchResult)
Transform a match result with a transformation rule.
|
static void |
transform(TransformationRule transformationRule,
MatchResult matchResult,
TransformationListener listener)
Transform a match result with a transformation rule.
|
addChangeListener, execute, getDescription, getLocality, getSource, isErrorReported, isPersistent, isStructuralChange, removeChangeListener, setDescription, setErrorReported, setListeners, setPersistent, waitForCompletion
public GraphTransformer(TransformationRule transformationRule, java.util.List<MatchResult> matchResults)
transformationRule
- The transformation rule.matchResults
- The list of match results.public GraphTransformer(TransformationRule transformationRule, MatchResult matchResult)
transformationRule
- The transformation rule.matchResult
- The match result.public void addTransformationListener(TransformationListener listener)
listener
- The TransformationListener.removeTransformationListener(TransformationListener)
public MatchResult getMatchResult()
public Pattern getPattern()
public Replacement getReplacement()
public void removeTransformationListener(TransformationListener listener)
listener
- The TransformationListener.addTransformationListener(TransformationListener)
public static void startUndoableTransformation(boolean mergeWithPrevious)
mergeWithPrevious
- Whether the undo entries should be merged with
previous undo entries.public static void stopUndoableTransformation()
public static void transform(TransformationRule transformationRule, java.util.List<MatchResult> matchResults) throws TransformationException
transformationRule
- The transformation rule.matchResults
- The list of match results.TransformationException
- If the pattern is not matched to any
host model in the match results.public static void transform(TransformationRule transformationRule, java.util.List<MatchResult> matchResults, TransformationListener listener) throws TransformationException
transformationRule
- The transformation rule.matchResults
- The list of match results.listener
- The TransformationListener to listen to the
transformation.TransformationException
- If the pattern is not matched to any
host model in the match results.public static void transform(TransformationRule transformationRule, MatchResult matchResult) throws TransformationException
transformationRule
- The transformation rule.matchResult
- The match result.TransformationException
- If the pattern is not matched to any
host model in the match result.public static void transform(TransformationRule transformationRule, MatchResult matchResult, TransformationListener listener) throws TransformationException
transformationRule
- The transformation rule.matchResult
- The match result.listener
- The TransformationListener to listen to the
transformation.TransformationException
- If the pattern is not matched to any
host model in the match result.protected void _addConnections() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _addObjects() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _execute() throws TransformationException
_execute
in class ChangeRequest
TransformationException
- If transformation is unsuccessful.protected void _hideRelations()
protected void _init() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _performOperations() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _recordMoML() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _removeLinks()
protected void _removeObjects() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _restoreParameterValues() throws TransformationException
TransformationException
- If transformation is unsuccessful.protected void _wrapup() throws TransformationException
TransformationException
- If transformation is unsuccessful.