Skip to content

Commit

Permalink
#131 #136 Repair bug in builder_app in operation ExtractClass (missin…
Browse files Browse the repository at this point in the history
…g proprety attribute); ORM od MoveProperty is finished (not tested);
  • Loading branch information
Petr Tarant committed Apr 19, 2013
1 parent 0af4aa8 commit c365a2c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions migdb.mm.app/models/mm-app.ecore
Expand Up @@ -35,7 +35,7 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="inheritanceType" lowerBound="1"
eType="#//app/InheritanceType"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="properties" upperBound="-1"
eType="#//app/MultipliableProperty" containment="true" eOpposite="#//app/MultipliableProperty/owningGeneralClass"/>
eType="#//app/MultipliableProperty" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="idProperty" unique="false"
eType="#//app/PrimitiveProperty" resolveProxies="false"/>
</eClassifiers>
Expand Down Expand Up @@ -65,7 +65,7 @@
<eClassifiers xsi:type="ecore:EClass" name="MultipliableProperty" abstract="true"
eSuperTypes="#//app/Property">
<eStructuralFeatures xsi:type="ecore:EReference" name="owningGeneralClass" lowerBound="1"
eType="#//app/StandardClass" changeable="false" derived="true" eOpposite="#//app/StandardClass/properties"/>
eType="#//app/StandardClass" changeable="false" derived="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="upperBound" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="1"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lowerBound" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
Expand Down
5 changes: 3 additions & 2 deletions migdb.qvto/transforms/main/builder_app.qvto
Expand Up @@ -160,10 +160,11 @@ helper _moveProperty(_sourceClassName : String, _name : String, _targetClassName
}
}

helper _extractClass(_sourceClassName : String, _extractClassName : String) : APP::ops::ExtractClass {
helper _extractClass(_sourceClassName : String, _associationPropertyName : String, _extractClassName : String) : APP::ops::ExtractClass {
return object APP::ops::ExtractClass {
sourceClassName := _sourceClassName;
extractClassName := _extractClassName;
associationPropertyName := _associationPropertyName;
}
}

Expand Down Expand Up @@ -308,8 +309,8 @@ helper _class(_name : String, _idProperty : PrimitiveProperty, _properties : Ord
assert(_idProperty <> null);
var cls : StandardClass := object StandardClass {
name := _name;
properties := _properties->append(_idProperty);
idProperty := _idProperty;
properties := _properties;
isAbstract := _isAbstract;
inheritanceType := _parent.inheritanceType;
};
Expand Down
2 changes: 2 additions & 0 deletions migdb.qvto/transforms/main/evolution_app.qvto
Expand Up @@ -258,6 +258,7 @@ query APP::ops::AddParent::isValid(structure : APP::Structure, inout errorLog :
helper APP::ops::AddParent::apply(inout structure : APP::Structure) {
var childClass : APP::StandardClass := structure.findClass(self.className);
childClass.parent := structure.findClass(self.parentClassName);
childClass.properties := childClass.properties->reject(pr | pr = childClass.idProperty);
childClass.idProperty := null;
return;
}
Expand All @@ -282,6 +283,7 @@ helper APP::ops::RemoveParent::apply(inout structure : APP::Structure) {
var idProperty : APP::PrimitiveProperty := _idProperty(getIdName(self.className), structure.findDefaultIdType());
childClass.parent := null;
childClass.idProperty := idProperty;
childClass.properties += idProperty;
return;
}

Expand Down
6 changes: 5 additions & 1 deletion migdb.qvto/transforms/main/orm.qvto
Expand Up @@ -444,9 +444,13 @@ helper APP::ops::MoveProperty::toRdb(appStructure : APP::Structure) : OrderedSet
operations += _insertRow(getDefaultSchemaName(), targetClassName, cl.translateIdName(), cl.name);
};
}endif;
// now update instances in the new column
operations += _updateRow(getDefaultSchemaName(), sourceClassName, movedPropertyName, targetClassName, movedPropertyName, mergeTypeFromAppToRdb(self.tolerance), WHERE_CONDITION);
} else {

// add new column to target class
operations += _addColumn(getDefaultSchemaName(), targetClassName, movedPropertyName, type);
// now update instances in the new column
operations += _updateRow(getDefaultSchemaName(), sourceClassName, movedPropertyName, targetClassName, movedPropertyName, mergeTypeFromAppToRdb(self.tolerance), WHERE_CONDITION);
} endif;
return operations;
}
Expand Down
2 changes: 1 addition & 1 deletion migdb.qvto/transforms/tests/code_generation/secondAPP.qvto
Expand Up @@ -11,7 +11,7 @@ main() {

var root : APP::Operations = outModel.rootObjects()![APP::Operations];

root.operations += _extractClass("Party", "Address");
root.operations += _extractClass("Party", "address", "Address");
//TODO move of property City, Street, Zip and Country
root.operations += _renameProperty("Party", "address", "residentialAddress");
root.operations += _addProperty("Party", "contactAddress", "Country");
Expand Down
Expand Up @@ -7,8 +7,10 @@ transformation extractClass_str(out inoutModel : APP);
main(){
var int : PrimitiveClass := _primitiveClass(getAppDefaultIdTypeName(), app::PrimitiveType::int);
var string : PrimitiveClass := _primitiveClass("string", app::PrimitiveType::char);
var second : StandardClass := _class("Second",_idProperty("idSecond", int) ,OrderedSet{_primitiveProperty("address", string)});
var second : StandardClass := _class("Second",_idProperty("idSecond", int) ,OrderedSet{});
var first : StandardClass := _class("First", _idProperty("idFirst", int), OrderedSet{_associationProperty("asoc",second,1,1)});

var secProp : PrimitiveProperty := _primitiveProperty("address", string);
second.properties += secProp;
_appStructure(OrderedSet{int, string, first, second});
}
Expand Up @@ -7,5 +7,5 @@ transformation extractClass_ops(out inoutModel : APP);
main(){
log("op: EXTRACTCLASS");

_appOperations(OrderedSet{_extractClass("First", "Second")});
_appOperations(OrderedSet{_extractClass("First", "second", "Second")});
}

0 comments on commit c365a2c

Please sign in to comment.