Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Stereotype not applied to the xmi output file !(applyStereotype() does not really apply/add stereotype to the output xmi file even getAppliedStereotypes() return correct result)
Stereotype not applied to the xmi output file ! [message #1238193] Fri, 31 January 2014 11:14 Go to next message
Naif Mokhayesh is currently offline Naif Mokhayesh
Messages: 29
Registered: November 2011
Junior Member
Hi,

in a In-Place transformation I follow same steps in

http://www.eclipse.org/forums/index.php/t/530322/

and I got strange execution behaviour due to the following bug

https://bugs.eclipse.org/bugs/show_bug.cgi?id=410511

However, after installing recent update (25 Jan, 2014) it was successfully applying Stereotype using applyStereotype() and I verify it using getAppliedStereotypes() during transformation execution.

The problem is that after finishing transformation nothing added to the output xmi file.!! I mean the applied stereotype during execution and it was verified by getAppliedStereotypes() is not shown in output xmi file

I do not why I get applied stereotype during execution but not actually added to the output xmi file.

any advice please...

Thanks
Re: Stereotype not applied to the xmi output file ! [message #1245582 is a reply to message #1238193] Thu, 13 February 2014 20:50 Go to previous message
Naif Mokhayesh is currently offline Naif Mokhayesh
Messages: 29
Registered: November 2011
Junior Member
Hi ,

since around two weeks no one suggest a solution or confirm a bug ! maybe my question was not clear !

However, the following is testing code. I hope it makes my question more clear and get feedback and really I appreciate that

thanks a lot Smile



modeltype UML uses 'http://www.eclipse.org/uml2/2.1.0/UML';

transformation ApplyingStereotype(inout src : UML , in stereotypedModel : UML);
/**
This transformation will take two input models. 
First one (src) is the model that we need to refactor it. 
The second model has stereotyped states that we need just 
copy it with its applied stereotypes to the scr model (refactored model - inout model)
**/

main() {
	
	src.rootObjects()[Model]->toModel();
	

	// according to  http://www.eclipse.org/forums/index.php/t/530322/
	// apply stereotypes after adding new state from stereotypedModel
	src.objectsOfType(State)->copyStereotypes();
	
	
	//after adding new state we list all applied stereotypes for the recent added state
	src.objectsOfType(State)[name = "TestState"]->listAllAppliedStereoyes();
	
	/**
	It seems running since we will get the correct results, 
	but when we check the output xmi file there is no stereotype applied 
	to that state ! but the  stereotype it self is added but not linked/referenced to the 
	corresponding state (the state copied from the second input model)
	
	You can execute ListAllAppliedStereotype.qvto for verification
	**/
}

mapping inout Model::toModel(){
	-- note that the profile is already applied	!
	// for nesting models
	src.objectsOfType(Model)->toModel();
	
	src.objectsOfType(StateMachine)->toStateMachine();
}

mapping inout StateMachine::toStateMachine(){
	src.objectsOfType(Region)->toRegion();
}

mapping inout Region::toRegion(){
		
	// add new state to src model (refactored model --inout)
	self.subvertex += stereotypedModel.objectsOfType(State)->selectOne(S : State | S.name = "TestState");
	
	
}

// in the context of src model
mapping inout State::copyStereotypes() when {self.name = "TestState"}
{	
	// select matching stereotyped state from stereotypedModel
	var stereotypedState : State;
	stereotypedState := stereotypedModel.objectsOfType(State)->selectOne(S : State | S.name = self.name);
	
	var stereotypSet : Set(Stereotype);
	stereotypSet := stereotypedState.getAppliedStereotypes();
	
	// applyStereotype to the recent added state in the src model.
	stereotypSet->forEach(stereotyp){
		self.applyStereotype(stereotyp);
	}

}

query State::listAllAppliedStereoyes() : Void{
	var value : String ;
	
	self.getAppliedStereotypes()->forEach(appliedStereoType){
		log("New added State Name is : " + self.name);
		log("Applied Stereotype is : " + appliedStereoType.name);
		
		appliedStereoType.attribute->forEach(attr){
			
			value := self.getValue(appliedStereoType, attr.name).toString();
			log("attribute name is : " + attr.name + " and value is : " + value); 
		}
	}
}

Previous Topic:apply stereotype on element Problem!
Next Topic:Failed to save model to platform:/resource
Goto Forum:
  


Current Time: Sat Aug 02 02:45:10 EDT 2014

Powered by FUDForum. Page generated in 0.01600 seconds