[QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #533178] |
Wed, 12 May 2010 13:50 |
C. Kopf Messages: 37 Registered: November 2009 |
Member |
|
|
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 15:10 |
Josef Freundorfer Messages: 10 Registered: May 2010 Location: Germany |
Junior Member |
|
|
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...
|
|
|
|
|
Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534266 is a reply to message #534252] |
Tue, 18 May 2010 14:28 |
C. Kopf Messages: 37 Registered: November 2009 |
Member |
|
|
Alright, I tested it and it does not help. Same problem as before.
My logs make me think that the select-clause does not found anything to fit the condition.
I used it as follows, so if I did not get it right, please correct me:
most of your code fit perfectly (just changing some element-'identifiers'
query getPrimitiveType(eProxyURI : String) : TN3::PrimitiveType{
var target = getEProxyFromRepresentation(eProxyURI);
return tn3.objects()[TN3::PrimitiveType]->selectOne(dt|
dt.name = target.name);
}
and called it like this:
mapping DataElementPrototype::dataElementProtoType2messageAndStreamComSpec() : MessageAndStreamComSpec
{
var foundtype:TN3::PrimitiveType := getPrimitiveType(self.type.repr());
types := foundtype;
}
Results still are same as with the code in my first message, log shows that your function creates the EProxyURI Element as wished but that getPrimitiveType returns something like this:
Properply I understood your solution wrong?
Thanks very much at all!
[Updated on: Tue, 18 May 2010 14:29] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03316 seconds