Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Problems using the "resolve/resolveone" command - tracking objects(rersolve does not work as expected, properbly due to a problem with a not completly loaded element)
icon5.gif  [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #533178] Wed, 12 May 2010 13:50 Go to next message
C. Kopf is currently offline C. KopfFriend
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:

Quote:

Found DEPrototype named dep2_char1_2 getting name of primitiveType, if any!
PrimitiveType found! Type was: CharType new type will be PrimitiveType with name Char.
name of primitiveType is: Char
RESOLVE:
Trying to resolve DataType: representation: arsep3x.swcomponent.datatype.datatypes.impl.CharTypeImpl@b92e21 (eProxyURI: ar:/#/ARRoot/SubpackLevel1_two/charType1?type=CharType) in: arsep3x.swcomponent.portinterface.impl.DEPrototypeImpl@7e73c (checksum: <unset>, timestamp: <unset>) (shortName: dep2_char1_2, category: <unset>) (isQueued: <unset>)
TYPE Transform:
Transforming PrimitiveType to DataType: charType1 representation is: arsep3x.swcomponent.datatype.datatypes.impl.CharTypeImpl@61fdb8 (checksum: <unset>, timestamp: <unset>) (shortName: charType1, category: <unset>) (encoding: <unset>)



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 Go to previous messageGo to next message
Josef Freundorfer is currently offline Josef FreundorferFriend
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 #534180 is a reply to message #533219] Tue, 18 May 2010 10:08 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Hi Josef,

I expect this answer is placed in the wrong topic, isn't it?

I will place it in the topic you created (about the ProxyURI).

If I am wrong, and this is placed in this topic correctly, I do not understand the context of the message. So if this is the case, can you please add some explanations. Thanks a lot!


Cheers,

Christian



Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534252 is a reply to message #534180] Tue, 18 May 2010 13:28 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Sorry josef,

I got your idea, it just toke some time. Embarrassed

I will test it immediatly!

Thanks for your help anyway!

Cheers,


Christian
Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534266 is a reply to message #534252] Tue, 18 May 2010 14:28 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
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:

Quote:

org.eclipse.emf.ecore.impl.DynamicEObjectImpl@eb4ce6 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@59fe5 (name: Invalid_Class) (instanceClassName: null) (abstract: false, interface: false)) org.eclipse.emf.ecore.impl.DynamicEObjectImpl@eb4ce6 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@59fe5 (name: Invalid_Class) (instanceClassName: null) (abstract: false, interface: false))




Properply I understood your solution wrong?

Thanks very much at all!

[Updated on: Tue, 18 May 2010 14:29]

Report message to a moderator

Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534490 is a reply to message #534266] Wed, 19 May 2010 10:57 Go to previous messageGo to next message
Josef Freundorfer is currently offline Josef FreundorferFriend
Messages: 10
Registered: May 2010
Location: Germany
Junior Member
If you call target.dump(). Do you see the correct name?

Is the referenced object included in the output of:

tn3.objects()[TN3::PrimitiveType]->forEach(a){a.dump();};
Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534540 is a reply to message #534490] Wed, 19 May 2010 13:19 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Hi Josef

here is what I found out since yesterday:

The usage of the code you suggested:

tn3.objects()[TN3::PrimitiveType]->forEach(a){a.dump();};

did verify my expectations. Primitivetypes generated before the call of the resolve() or your code existed and the others did not. Changing the sequence of the mappings (which will later on lead to other problems) lead to the wished results: now your select command works pretty fine. Thanks again!

At all this somehow still is a critical problem. How can I use the late command in your procedure correctly - I did not get it to work yet.


Anyway, does anybody know why it is impossible to use the resolve-method as it is intended for such issues? To me it seems some problem of the tool implementation, so is there any bug report yet? I did not found any, should I open one?

Thanks again!

Cheers,
Chris
Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534578 is a reply to message #533178] Wed, 19 May 2010 15:14 Go to previous messageGo to next message
Josef Freundorfer is currently offline Josef FreundorferFriend
Messages: 10
Registered: May 2010
Location: Germany
Junior Member
I also didn't get the late keyword running in my code.

I handle it this way:

- mapping which creates ABC wherein somewhere a reference to XYZ is needed
- tons of work
- mapping which creates XYZ
- helperMethod which resolves ABC and puts the association to XYZ into it

It's not the best way, but it works fine for me.
icon14.gif  Re: [QVTo] Problems using the "resolve/resolveone" command - tracking objects [message #534586 is a reply to message #534578] Wed, 19 May 2010 15:35 Go to previous message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Alright Josef,

good to know that I am not the only one! Smile

I did it the same way as you. It works so far. Anyway I think a bugreport is needed here I will create one during the next days.

Did the resolve-method work in any other loc for you?

Due to the fact that it worked in several small example-project (e.g. using UML metamodels ...) but does not in the projects code, I expect this problem has some relation to the metamodel I use, as far as I see you also use an AutoSar metamodel?!

Hmm, well then the bugreport may look somehow strange, because I am not allowed to send the metamodel anyway. (as far as I know).

So it would be very kind if you can tell me whether it (the resolve-statements) did not work in your autosar-tranformation-project as well and if you have experienced similar problems in other (non-autosar) projects.

Thanks again, you helped me a lot. Smile
Hope I can return some help some day. Embarrassed
Previous Topic:[ATL] Problem when referencing a created target element within a rule
Next Topic:[ATL]
Goto Forum:
  


Current Time: Sun Nov 23 21:34:41 GMT 2014

Powered by FUDForum. Page generated in 0.02191 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software