[QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #533178] |
Wed, 12 May 2010 09:50  |
Eclipse User |
|
|
|
Hi everybody,
I again have some trouble using the resolve-methodes:
I am using the following code:
mapping DEPrototype::dEProtoType2ComSpec() : ComSpec
{
log("Found DEPrototype named "+self.shortName);
var testString:String := getNameOfPrimitiveType(self.type);
log("name of primitive type is: "+testString);
log("RESOLVE: ");
log("Trying to resolve DataType: "+self.type.shortName+ " representation: "+self.type.repr()+" in: "+self.repr());
types := self.type.late resolveone(DataType);
-- one may also use resolve instead of resolveone -> same problem
}
FYI:
query getNameOfPrimitiveType(in type:Datatype) : String {
var resultString:String;
var className:String := type.metaClassName();
switch {
case (type.oclIsTypeOf(OpaqueType)) resultString := "Bitstring";
case (type.oclIsTypeOf(BooleanType)) resultString := "Boolean";
case (type.oclIsTypeOf(IntegerType)) resultString := "Integer";
case (type.oclIsTypeOf(RealType)) resultString := "Float";
case (type.oclIsTypeOf(StringType)) resultString := "Charstring";
case (type.oclIsTypeOf(CharType)) resultString := "Char";
else resultString := "not found";
};
log ("PrimitiveType found! Type was: "+type.metaClassName()+" new type will be PrimitiveType with name "+resultString+".");
return resultString;
}
The resolve now doers not work as wished. The "types" relation of a generated ComSpec element stays empty, no DataType element is linked there. Actually, the needed DataType elements do exist.
Log looks like the following:
Somehow it seems like the Datatype get different id (repr()) so properbly this is the problem, actually I do not have a clue how to overcome this issue, does anyone have an idea or does anyone know what is wrong in my code, ...?
FYI here is the code used to generate the CharType (I know it is somehow messy, I will do a refactroing shortly after resolving this issue here):
mapping ARSEPDatatypes::PrimitiveType::primitiveType2primitiveType() : TN3::PrimitiveType
disjuncts
OpaqueType::opaqueType2primitiveType,
CharType::charType2primitiveType,
BooleanType::booleanType2primitiveType,
IntegerType::integerType2primitiveType,
RealType::realType2primitiveType,
StringType::stringType2primitiveType
{
}
// mapping inherited by all mappings for primitive Datatypes
mapping ARSEPDatatypes::PrimitiveType::primitiveTypeMappings() : TN3::PrimitiveType
{
name:= self.shortName;
log("TYPE Transform: ");
log("Tranforming PrimitiveType to DataType: "+self.shortName+" representation is: "+self.repr());
}
// mapping of CharType:
mapping CharType::charType2primitiveType() : TN3::PrimitiveType
inherits ARSEPDatatypes::PrimitiveType::primitiveTypeMappings{
}
Thanks again for any help!
Chris
|
|
|
Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #533219 is a reply to message #533178] |
Wed, 12 May 2010 11:10   |
Eclipse User |
|
|
|
intermediate class EProxyURI extends autosar3x::ARObject {
type : String;
name : String;
parentPackage : String;
};
query EProxyURI::dump() : OclVoid {
log("EProxyURI (type: " + self.type.quotify("\"") + ", name: " + self.name.quotify("\"") + ", parentPackage: " + self.parentPackage.quotify("\"") + ")");
return null;
}
query getEProxyFromRepresentation(eProxyURI : String) : EProxyURI {
var lastSlash := eProxyURI.rfind("/");
var lastQuestionmark := eProxyURI.rfind("?");
var tmp : String;
var ret := object EProxyURI{};
ret.name := eProxyURI.substring(lastSlash+1,lastQuestionmark-1);
ret.type := eProxyURI.substring(lastQuestionmark+6,eProxyURI.length()-1);
tmp := eProxyURI.substring(1,(lastSlash-1));
lastSlash := tmp.rfind("/");
ret.parentPackage := tmp.substring(lastSlash+1,tmp.length());
return ret;
}
call getEProxyFromRepresentation with the repr(), and you'll get the ShortName of the Object, which can't be resolved as object.name
With this information you can search for it with something like:
query getXYZ(eProxyURI : String) : NS::XYZ{
var target = getEProxyFromRepresentation(eProxyURI);
return i.objects()[NS::XYZ]->selectOne(
shortName = target.name and
metaClassName() = target.type);
}
Hope it helps.
P.S: Yes, the getEProxyFromRepresentation, have to be enhanced...
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.25475 seconds