Class Cast Exception [message #1787347] |
Wed, 23 May 2018 19:07  |
Eclipse User |
|
|
|
Hi everyone,
So I'm trying to write an ETL transformation using profiles as metamodels.So my source and target models are basically uml class diagrams.
in my target model I have a class that has a property that reference to a class in my source model.
When I try to pass the value or the reference of the class to the property which is of the same type as the class ,I get a Class Cast Exception .
Here's the code of the rule in my transformation in which I'm having the problem
rule mainRule
transform s : Source!Model
to t1 : Target!Model,
t2 : Target!Class,
t3: Target!Info {
t1.applyProfile(Source!Profile.allInstances()->first());
t1.name = "InfoModel";
t2.name = "InfoClass";
t2.package = t1 ;
t3.base_Class = t2;
t3.Id = "test" ; // this one is working
t3.Infox = (Source!Infox).allInstances().first(); // Here I get the Class Cast Exception, even thought the Infox attribute is of type the Infox class in the source.
}
and this the the error :
Internal error: java.lang.ClassCastException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@72a8c135 [name: Infox] [instanceClassName: null] [abstract: false, interface: false]' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@ad4497e [name: Infox] [instanceClassName: null] [abstract: false, interface: false]'
Thank you.
|
|
|
|
|
|
|
|
|
|
|
|
Re: Class Cast Exception [message #1790010 is a reply to message #1789875] |
Sat, 02 June 2018 19:09   |
Eclipse User |
|
|
|
Hi Dimitris, It seems that the only solution for this problem is to launch the transformation as a java standalone application. In this case, the profiles will be loaded once even without registering the profiles through an extension. But still I couldn't get any result from launching the ETL transformation as it is.
Here's the java code if that might be interesting for someone else :
EtlModule module = new EtlModule();
module.parse(new File("path/to/.etl"));
URI inputUri = URI.create(new File("path to input UML Model").toURI().toString());
URI OutputUri= URI.create(new File("Path to the Output Uri").toURI().toString());
createUmlModel(module,"Input",inputUri , true, false);
createUmlModel(module,"Output",OutputUri, false, true);
module.execute();
module.getContext().getModelRepository().dispose();
}
private static UmlModel createUmlModel(EtlModule module,String name, URI model, boolean readOnLoad, boolean storeOnDisposal) throws EolModelLoadingException {
UmlModel umlModel = new UmlModel();
StringProperties properties = new StringProperties();
properties.put(EmfModel.PROPERTY_NAME, name);
properties.put(EmfModel.PROPERTY_FILE_BASED_METAMODEL_URI , new File("Path to the profile").toURI().toString());
if (model != null) properties.put(EmfModel.PROPERTY_MODEL_URI, model.toString());
properties.put(EmfModel.PROPERTY_READONLOAD, readOnLoad + "");
properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, storeOnDisposal + "");
umlModel.load(properties, (IRelativePathResolver) null);
module.getContext().getModelRepository().addModel(umlModel);
return umlModel;
}
Thank you,
Omar
|
|
|
|
Powered by
FUDForum. Page generated in 0.06232 seconds