Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » migrating from acceleo2 to acceleo 3(problem re-writing the java services for acceleo3)
migrating from acceleo2 to acceleo 3 [message #908559] Wed, 05 September 2012 15:04
ibrahim kara is currently offline ibrahim karaFriend
Messages: 10
Registered: May 2012
Junior Member
I am migrating a code generator plug-in that was written for acceleo2 to acceleo3. I have the following java service that I need to update for acceleo 3. I could not make it work for acceleo 3 by updating the ENode paramaters. Could you help me convert this java service in order to make it usable for acceleo 3? without the imports:
import fr.obeo.acceleo.gen.template.eval.ENode;
import fr.obeo.acceleo.gen.template.eval.ENodeCastException;
import fr.obeo.acceleo.gen.template.eval.ENodeIterator;
import fr.obeo.acceleo.gen.template.eval.ENodeList;

here is the java code:

public LinkedList<Region> sortRegion(ENode eNode)
throws ENodeCastException, ClassCastException {

Set<Region> unpriorizedSet = new LinkedHashSet<Region>();
TreeMap<Integer, Region> tm = new TreeMap<Integer, Region>(
new TransitionComparator());
ENodeList list = null;
UmlServices umlservice = new UmlServices();
LinkedList<Region> sortedList = new LinkedList<Region>();
Set<Entry<Integer, Region>> set = null;

if (eNode.getType().equals("EObject")) {
throw new IllegalArgumentException(
"Argument must be of type ENodeList, not EObject. Owner.filter(\"Region\").sortRegions() or container.filter(\"Region\").sortRegions() is not allowed.");
// sortedList.add((Region)eNode.getEObject());
// return sortedList;
} else if (eNode.getType().equals("ENodeList")) {
list = eNode.getList();
if (list == null) {
throw new NullPointerException(
"Argument (list) must be not null.");
}

} else {
throw new IllegalArgumentException(
"Argument must be of type ENodeList.");
}

for (ENodeIterator iterator = list.iterator(); iterator.hasNext()Wink {
Region region = (Region) iterator.next().getEObject();
Stereotype stereotype = umlservice.getStereotype(region,
"ExecutionOrderPriority");
if (stereotype == null) {
unpriorizedSet.add(region);
} else {
Integer transitionPriority = (Integer) region.getValue(
stereotype, "priority");
if (transitionPriority != null) {
if (!tm.containsKey(transitionPriority)) {
tm.put(transitionPriority, region);
} else {
unpriorizedSet.add(region);
}
} else {
unpriorizedSet.add(region);
}
}

}

set = tm.entrySet();
for (Entry<Integer, Region> entry : set) {
sortedList.add(entry.getValue());
}
for (Region entry : unpriorizedSet) {
sortedList.add(entry);
}
return sortedList;
}

*************************
here is an example template that calls this java service:

<%script type="uml.StateMachine" name="stateMachineBehaviorCode" post="trim()"%>

.............
<%for (ownedElement.filter("Region").sortRegions().filter("Region")){%>
<%setInitalActive(owner.filter("StateMachine").name.replaceSpecChar()+"."+name.replaceSpecChar())%>
<%}%>
.............

Thanks in advance.
Previous Topic:[Acceleo] Capability Question
Next Topic:[Acceleo] Create Standalone application
Goto Forum:
  


Current Time: Tue Dec 23 03:02:26 GMT 2014

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

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