EBoolean [message #902804] |
Mon, 20 August 2012 14:02 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Hi all,
At transformation, I need to assign a boolean variable to true.
isLoaded is EBoolean EAttribute.
at transformation i defined,
isLoaded<-true,
but this vale (true) cannot be find within the object.
I am just wondering, if this is a right way to assign a boolean attribute?
This is my rule:
rule rule_getDevice{
from
a: source!DeviceItem
to
p:target!Device
do{
p.name <- a.Name;
p.s7DeviceReference<-a.DeviceReference;
p.isSelectedWithinStep7<- a.IsSelected;
p.isLoaded<-false;
if (a.IsSelected = 'true'){
p.isLoaded<-true;
p.HeadModule<-a.ModuleList.ModuleItem->select(mi|mi.getSlotValue()='0')->collect(e|thisModule.rule_getHeadModule(e))->first();
p.Slot<-a.ModuleList.ModuleItem->select(mi|mi.getSlotValue()<>'0')->sortedBy(mi|mi.getSlotValue().toInteger())->collect(e|thisModule.rule_getSlot(e));
}
}
}
Thanks in advance!
Kosala
[Updated on: Mon, 20 August 2012 14:39] Report message to a moderator
|
|
|
|
Re: EBoolean [message #902911 is a reply to message #902826] |
Tue, 21 August 2012 06:34 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
Hi Fernanda,
Thanks for your response. I do not get any error, but "isLoaded" attribute at transformation output object does not contain true. It is always false.
In this case "isLoaded" is set with transient property true (at the ecore model), since i do not need it to be persisted.
I do not understand why this transient field is not set from the atl transformation? How to slove this issue?
Really appriciate any advice.
Kosala
[Updated on: Tue, 21 August 2012 08:42] Report message to a moderator
|
|
|
|
Re: EBoolean [message #902972 is a reply to message #902938] |
Tue, 21 August 2012 13:20 |
Kosala Yapa Messages: 159 Registered: September 2010 |
Senior Member |
|
|
I found the issue.
The transformation is working, but the problem is transient variable does not support serialization.
I can find the right value of isLoaded field in outModel, but not in the return object.
here is my code:
protected IModel inModel;
protected IModel outModel;
public void loadModels(String inputModelPath) throws ATLCoreException {
EMFModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IReferenceModel sourceMetamodel = factory.newReferenceModel();
injector.inject(sourceMetamodel, this.getSourceMetamodelPath());
IReferenceModel targetMetamodel = factory.newReferenceModel();
injector.inject(targetMetamodel, getPackage_eNS_URI());
this.inModel = factory.newModel(sourceMetamodel);
injector.inject(inModel, inputModelPath);
this.outModel = factory.newModel(targetMetamodel);
}
public EObject getModelObjects() throws ATLCoreException, IOException {
getPackage_eINSTANCE().getClass();
final PipedOutputStream outputStream = new PipedOutputStream();
PipedInputStream inputStream = new PipedInputStream(outputStream);
//read from outputStream
new Thread(new Runnable() {
public void run() {
try {
(new EMFExtractor()).extract(outModel, outputStream, null);
} catch (ATLCoreException e) {
e.printStackTrace();
}
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
//load EObject from inputStream
XMIResourceImpl resource = new XMIResourceImpl();
resource.load(inputStream, new HashMap<Object,Object>());
EObject obj = resource.getContents().get(0);
// return EObject
return obj;
}
any advice is appriciated.
Thanks
Kosala
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03595 seconds