Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto135
1 files changed, 83 insertions, 52 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
index 3e174222e00..8bf467e21b2 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties.generation/transforms/profile2datacontext.qvto
@@ -10,93 +10,114 @@ main() {
profile.rootObjects()[Profile]->map toContext();
}
-mapping Profile::toContext() : c:Context, root:DataContextRoot{
- object c : Context {
- name := self.name;
- dataContexts := root;
- dependencies := uml.rootObjects()[Context];
- };
-
- self.packagedElement->select(e | e.isView())->map toDataContextElement();
-
- object root : DataContextRoot{
- name := self.name;
- label := self.name;
- elements := self.packagedElement->select(e | e.isView())->map toDataContextElement().element
- ->union(self.packagedElement->select(e | e.oclIsKindOf(Package))->map toDataContextPackage());
- modelElementFactory := pRoot.rootObjects()[PropertiesRoot].environments.modelElementFactories
- ->any(e | e.factoryClass = 'org.eclipse.papyrus.uml.properties.modelelement.StereotypeModelElementFactory');
- };
+----- Context -----
+
+mapping Package::toContext() : Context{
+ name := self.name;
+ dataContexts := self.map toDCRoot();
+ dependencies := uml.rootObjects()[Context];
+ self.getClassifiers()->map toDCElement();
}
-query Element::isView() : Boolean {
- return self.oclIsTypeOf(Stereotype) or self.oclIsTypeOf(DataType);
+query Package::getRootPackage() : Package {
+ var package : Package;
+ if self.nestingPackage.oclIsUndefined() then
+ package := self
+ else
+ package := self.nestingPackage.getRootPackage()
+ endif;
+ return package;
}
-abstract mapping Element::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View;
+query Classifier::getRootPackage() : Package {
+ return self.package.getRootPackage();
+}
-abstract mapping PackageableElement::toDataContextPackage() : DataContextPackage {
- name := self.name;
+query Package::getClassifiers() : Collection(Classifier) {
+ return self.packagedElement->select(e | e.isView()).oclAsType(Classifier);
}
-mapping Package::toDataContextPackage() : DataContextPackage inherits PackageableElement::toDataContextPackage{
- elements := self.packagedElement->map toDataContextElement().element->union(
- self.packagedElement->select(e | e.oclIsKindOf(Package))->map toDataContextPackage()
+-------------------
+
+----- DataContextPackage & DataContextRoot -------
+
+mapping Package::toDCPackage() : DataContextPackage disjuncts
+ Package::toDataContextPackage, Package::toDCRoot;
+
+abstract mapping Package::toAbstractDCPackage() : DataContextPackage {
+ name := self.name;
+ elements := self.getClassifiers().map toDCElement().element->union(
+ self.packagedElement->select(e | e.oclIsKindOf(Package)).oclAsType(Package)->map toDataContextPackage()
);
}
-abstract mapping Classifier::toDCElement() : element : DataContextElement, viewSingle : View, viewMultiple : View {
+mapping Package::toDataContextPackage() : DataContextPackage inherits Package::toAbstractDCPackage when {
+ not self.nestingPackage.oclIsUndefined()
+}{
+ if not self.nestingPackage.oclIsUndefined() then
+ package := self.nestingPackage.map toDataContextPackage()
+ endif;
+}
+
+mapping Package::toDCRoot() : DataContextRoot disjuncts Model::toDataContextRoot, Profile::toDatacontextRoot when {
+ self.nestingPackage.oclIsUndefined();
+};
+
+mapping Model::toDataContextRoot() : DataContextRoot inherits Package::toAbstractDCPackage {
+ modelElementFactory := findFactory('org.eclipse.papyrus.uml.properties.modelelement.UMLModelElementFactory');
+}
+
+mapping Profile::toDatacontextRoot() : DataContextRoot inherits Package::toAbstractDCPackage{
+ modelElementFactory := findFactory('org.eclipse.papyrus.uml.properties.modelelement.StereotypeModelElementFactory');
+}
+
+query findFactory(className : String) : ModelElementFactoryDescriptor {
+ return pRoot.rootObjects()[PropertiesRoot].environments.modelElementFactories
+ ->any(e | e.factoryClass = className);
+}
+
+--------------------------------------------------
+
+----- DataContextElement & View -------
+
+mapping Classifier::toDCElement() : element : DataContextElement, viewSingle : View, viewMultiple : View
+ disjuncts Stereotype::toDataContextElement, DataType::toDataContextElement;
+
+abstract mapping Classifier::toAbstractDCElement() : element : DataContextElement, viewSingle : View, viewMultiple : View{
element.name := self.name;
+ element.package := self.package.map toDCPackage();
viewSingle.name := 'Single '+self.name;
viewSingle.automaticContext := true;
viewSingle.datacontexts := element;
viewSingle.elementMultiplicity := 1;
viewSingle.constraints := self.map toConstraint(viewSingle);
- viewSingle.context := self.getContext();
+ viewSingle.context := self.getRootPackage().map toContext();
viewMultiple.name := 'Multiple '+self.name;
viewMultiple.automaticContext := true;
viewMultiple.datacontexts := element;
viewMultiple.elementMultiplicity := -1;
viewMultiple.constraints := self.map toConstraint(viewMultiple);
- viewMultiple.context := self.getContext();
+ viewMultiple.context := self.getRootPackage().map toContext();
}
-mapping Stereotype::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits Classifier::toDCElement{
+mapping Stereotype::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits Classifier::toAbstractDCElement{
element.properties := self.attribute->select(e | e.isAttribute(self))->map toProperty();
- element.supertypes := self.generalization.target->map toDataContextElement().element->union(
+ element.supertypes := self.generalization.target->select(e | e.isView()).oclAsType(Classifier)->map toDCElement().element->union(
self.ownedAttribute->select(e | not e.isAttribute(self)).getDataContextElement()->asSet()
);
}
-mapping DataType::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits Classifier::toDCElement when {
+mapping DataType::toDataContextElement() : element : DataContextElement, viewSingle : View, viewMultiple : View inherits Classifier::toAbstractDCElement when {
self.oclIsTypeOf(DataType) -- Exclude primitive types from generation
}{
element.properties := self.attribute->map toProperty();
- element.supertypes := self.generalization.target->map toDataContextElement().element->union(
+ element.supertypes := self.generalization.target->select(e | e.isView()).oclAsType(Classifier)->map toDCElement().element->union(
self.ownedAttribute->getDataContextElement()->asSet()
);
}
-query Package::getRootPackage() : Package {
- var package : Package;
- if self.nestingPackage.oclIsUndefined() then
- package := self
- else
- package := self.nestingPackage.getRootPackage()
- endif;
- return package;
-}
-
-query Classifier::getRootProfile() : Profile {
- return self.package.getRootPackage().oclAsType(Profile);
-}
-
-query Classifier::getContext() : PropertyContext::Context {
- return self.getRootProfile().map toContext().c;
-}
-
mapping Classifier::toConstraint(view : View) : SimpleConstraint{
name := "is" + view.name.replace(' ', '');
display := view;
@@ -108,6 +129,10 @@ mapping Classifier::toConstraint(view : View) : SimpleConstraint{
properties := stereotypeName;
}
+query Element::isView() : Boolean {
+ return self.oclIsTypeOf(Stereotype) or self.oclIsTypeOf(DataType);
+}
+
query Property::getDataContextElement() : DataContextElement {
var extension := self.association.memberEnd->any(e | not self.association.ownedEnd->includes(e));
var metaclassName := extension.type.name;
@@ -118,12 +143,18 @@ query UML::Property::isAttribute(stereo : Stereotype) : Boolean{
return not self.name.startsWith('base_');
}
+---------------------------------------
+
mapping UML::Property::toProperty() : PropertyContext::Property {
name := self.name;
- type := self.type.toType();
+ type := self.type.getType();
+
+ if self.type.isView() then
+ self.type.oclAsType(Classifier).map toDCElement()
+ endif;
}
-query UML::Type::toType() : PropertyEnvironment::Type {
+query UML::Type::getType() : PropertyEnvironment::Type {
-- Unknown cases are handled as Strings
var type : PropertyEnvironment::Type := PropertyEnvironment::Type::String;
switch {

Back to the top