ECL - Profesores

The Embedded Constraint
Language (ECL)
Rubby Casallas
Grupo de Construcción de Software
Uniandes
References
„
Yuehua Lin, Jeff Gray, and Jing Zhang. “The
Embedded Constraint Language: A
Transformation Language for Visual Models”.
http://www.cis.uab.edu/gray/Pubs/ecl.pdf
1
Aspect oriented-approach
„
„
Describe the location and behavior of the
transformation to be performed on the model.
The result of model weaving is a new model
that contains adaptations that are spread
across the model hierarchy.
2
From: http://www.cis.uab.edu/gray/Research/C-SAW/
Basics
„
„
„
ECL is a textual language for describing
transformations on visual models.
Supports a procedural style of specification
It has a model transformation engine: C-SAW
3
Transformation procedures: Strategies
„
A strategy is used to define a specific
transformation procedure.
„
An aspect is a serves as the entry point of a
transformation (location)
Basic Control (Scheduling)
For all models which type is component,
Find all the data atoms,
For each data atom,
add a log atom and proper connection
4
Constructs in ECL (cont..)
The “Start” aspect defines a collection of component models whose
names end with “Impl.”
The “AddConcurrency” strategy is then performed on the collection
of models meeting the Start criteria.
aspect Start() {
GeneratePersonModel (self.name()+"PersonModel");
}
strategy GeneratePersonModel (personsModelName : String) {
declare rootPersonModel;
declare this: model;
declare father : atomList;
this := self;
rootPersonModel := rootFolder().addModel("Root",
personsModelName);
father := this.atoms()->select (m|m.kindOf()=="Father");
father->createMan(rootPersonModel);
...
}
calling another strategy
5
Type Systems
„
Data types in ECL include:
‰
Primitive data types:
„
‰
Model object types:
„
‰
boolean, integer, real and string
atom, model, object and connection
declare concurrencyAtom1,concurrencyAtom2 : atom;
Collection types:
„
atomList, modelList, objectList and connectionList.
Model Collection
„
Collection types are bags
„
The operators on collections
„
Operators on collections are denoted using arrows(->).
‰
‰
‰
„
modelList, atomList, objectList, connectionList
size, forAll, exists, others.
Different at model object types (denoted as a period)
e.g. selects all the atoms, whose kind is “Data,” and determines
whether the number of such atoms is equal to or greater than 1
atoms()->select(a | a.kindOf() == "Data") ->size() >= 1
6
Model Selection and Aggregation
„
ECL supports model queries to select a collection of objects
‰
‰
select. For specifying a selection from the original collection
models(exp). To select all the submodels that satisfy the
constraint specified by the expression.
„
‰
‰
atoms(exp),connections(exp),attributes(exp).
findAtom and findModel. To find a single atom or model
source() and destination(). To return the source object and the
destination object in a connection.
Transformation Operations
„
Basic transformation operations include adding,
removing and changing model elements.
‰
‰
‰
To add new elements to a model: addModel, addAtom and
addConnection.
To remove a model, atom or connection: removeModel,
removeAtom and removeConnection.
To change the value of any attribute of a model element:
setAttribute.
7
Strategy and Context
„
An ECL specification may consist of one or more
strategies
„
A strategy can be called by other strategies.
„
A transformation is applied by traversing a model
and matching elements of the model that satisfy a
predicate.
„
Elements that satisfy a predicate are transformed
according to the transformation rules in the strategy.
Strategy and Context (cont..)
„
Each strategy should be performed in a userspecified context
Given the strategy
if “updateTimeLimit(newTimeLimit : int)”
‰
‰
the context is the a collection of models:
models()->updateTimeLimit(1000);
the context is the current model:
self().updateTimeLimit(1000)
8
Implementation of ECL
„
It is fully implemented into a model
transformation engine: the ConstraintSpecification Aspect Weaver (C-SAW).
„
C-SAW is a GME plug-in component
„
Specifications are interpreted by the C-SAW
to weave changes into source models and
generate the target models.
Other features
„
ECL is not fully imperative. e.g., it takes advantage of
model navigation features from OCL to provide declarative
constructs for automatic selection of model elements.
„
It doesn’t support pattern based
transformations and users need to program their own
model matching and transformation patterns.
„
It can only be used to transform models that
are defined by the same metamodel.
9