Problem by cast from AnyTypeImpl to ModelImpl [message #557414] |
Tue, 07 September 2010 10:57 |
Ming Lu Messages: 8 Registered: September 2010 |
Junior Member |
|
|
Hallo,
i am facing a problem after migration of my oaw 4 project to oaw 5 project.
the class SimpleJavaModificationComponent doesn't exist anymore in oaw 5. so i found the thread in http://www.openarchitectureware.org/forum/viewtopic.php?show topic=14146&lastpost=true#15202 and try to created SimpleJavaModificationComponent .
unfortunately i got the cast-exception:
1. my SimpleJavaModificationComponent:
import org.eclipse.emf.mwe.core.WorkflowContext;
import org.eclipse.emf.mwe.core.issues.Issues;
import org.eclipse.emf.mwe.core.lib.WorkflowComponentWithModelSlot;
import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
public abstract class SimpleJavaModificationComponent extends
WorkflowComponentWithModelSlot {
private Object modelObject;
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
Issues issues) {
String strName = getModelSlot();
modelObject = ctx.get(strName);
if (modelObject == null) {
issues.addWarning(this, "content of modelSlot " + getModelSlot()
+ " is null.");
}
doModification(ctx, monitor, issues, modelObject);
}
protected abstract void doModification(WorkflowContext ctx,
ProgressMonitor monitor, Issues issues, Object model);
}
2. my ModelTransformer Class
public class ModelTransformer extends SimpleJavaModificationComponent {
protected void doModification(WorkflowContext ctx, ProgressMonitor monitor,
Issues issues, Object model) {
ModelImpl dm = (ModelImpl) model;// <---caused an exception!!!
}
}
during debug i found out the Object model ist type of AnyTypeImpl. my question is how can i cast the AnyTypeImpl to ModelImpl?
thanks very much for your help.
|
|
|
|
|
|
|
|
|
|
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557489 is a reply to message #557414] |
Tue, 07 September 2010 16:45 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi Ming
AnyType is the basic XMI element that Xtext uses until it can resolve a
proxy, so a CCE on an AnyType justvtells that a proxy resoluation failed
so your models/namespaces are incompatible or unresolvable.
If you search all ResourceSet.resources.errors you may find that
something is trying to tell you something; Xtext fails to explicitly
diagnose deep proxy resolution failures.
Regards
Ed Willink
On 07/09/2010 11:57, Ming Lu wrote:
> Hallo,
>
> i am facing a problem after migration of my oaw 4 project to oaw 5 project.
>
> the class SimpleJavaModificationComponent doesn't exist anymore in oaw
> 5. so i found the thread in
> http://www.openarchitectureware.org/forum/viewtopic.php?show topic=14146&lastpost=true#15202
> and try to created SimpleJavaModificationComponent .
>
> unfortunately i got the cast-exception:
>
> 1. my SimpleJavaModificationComponent:
>
> import org.eclipse.emf.mwe.core.WorkflowContext;
> import org.eclipse.emf.mwe.core.issues.Issues;
> import org.eclipse.emf.mwe.core.lib.WorkflowComponentWithModelSlot;
> import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
>
> public abstract class SimpleJavaModificationComponent extends
> WorkflowComponentWithModelSlot {
>
> private Object modelObject;
>
> @Override
> protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
> Issues issues) {
>
> String strName = getModelSlot();
> modelObject = ctx.get(strName);
>
> if (modelObject == null) {
> issues.addWarning(this, "content of modelSlot " + getModelSlot()
> + " is null.");
> }
>
> doModification(ctx, monitor, issues, modelObject);
> }
>
> protected abstract void doModification(WorkflowContext ctx,
> ProgressMonitor monitor, Issues issues, Object model);
>
> }
>
>
> 2. my ModelTransformer Class
>
> public class ModelTransformer extends SimpleJavaModificationComponent {
>
> protected void doModification(WorkflowContext ctx, ProgressMonitor monitor,
> Issues issues, Object model) {
>
> ModelImpl dm = (ModelImpl) model;// <---caused an exception!!!
> }
> }
>
>
> during debug i found out the Object model ist type of AnyTypeImpl. my
> question is how can i cast the AnyTypeImpl to ModelImpl?
> thanks very much for your help.
|
|
|
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557490 is a reply to message #557489] |
Tue, 07 September 2010 17:06 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi Ming
Sorry wrong newsgroup. Nothing explicitly to do with Xtext, but the
proxy issue may still be relevant.
Regards
Ed Willink
>
> AnyType is the basic XMI element that Xtext uses until it can resolve a
> proxy, so a CCE on an AnyType justvtells that a proxy resoluation failed
> so your models/namespaces are incompatible or unresolvable.
>
> If you search all ResourceSet.resources.errors you may find that
> something is trying to tell you something; Xtext fails to explicitly
> diagnose deep proxy resolution failures.
>
> Regards
>
> Ed Willink
>
>
> On 07/09/2010 11:57, Ming Lu wrote:
>> Hallo,
>>
>> i am facing a problem after migration of my oaw 4 project to oaw 5
>> project.
>>
>> the class SimpleJavaModificationComponent doesn't exist anymore in oaw
>> 5. so i found the thread in
>> http://www.openarchitectureware.org/forum/viewtopic.php?show topic=14146&lastpost=true#15202
>>
>> and try to created SimpleJavaModificationComponent .
>>
>> unfortunately i got the cast-exception:
>>
>> 1. my SimpleJavaModificationComponent:
>>
>> import org.eclipse.emf.mwe.core.WorkflowContext;
>> import org.eclipse.emf.mwe.core.issues.Issues;
>> import org.eclipse.emf.mwe.core.lib.WorkflowComponentWithModelSlot;
>> import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;
>>
>> public abstract class SimpleJavaModificationComponent extends
>> WorkflowComponentWithModelSlot {
>>
>> private Object modelObject;
>>
>> @Override
>> protected void invokeInternal(WorkflowContext ctx, ProgressMonitor
>> monitor,
>> Issues issues) {
>>
>> String strName = getModelSlot();
>> modelObject = ctx.get(strName);
>>
>> if (modelObject == null) {
>> issues.addWarning(this, "content of modelSlot " + getModelSlot()
>> + " is null.");
>> }
>>
>> doModification(ctx, monitor, issues, modelObject);
>> }
>>
>> protected abstract void doModification(WorkflowContext ctx,
>> ProgressMonitor monitor, Issues issues, Object model);
>>
>> }
>>
>>
>> 2. my ModelTransformer Class
>>
>> public class ModelTransformer extends SimpleJavaModificationComponent {
>>
>> protected void doModification(WorkflowContext ctx, ProgressMonitor
>> monitor,
>> Issues issues, Object model) {
>>
>> ModelImpl dm = (ModelImpl) model;// <---caused an exception!!!
>> }
>> }
>>
>>
>> during debug i found out the Object model ist type of AnyTypeImpl. my
>> question is how can i cast the AnyTypeImpl to ModelImpl?
>> thanks very much for your help.
>
|
|
|
|
|
|
|
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557973 is a reply to message #557414] |
Thu, 09 September 2010 16:16 |
|
The problem is the UML model version, which is 2.1.0 declared in the model file. The actual installed UML plugin version I assume is >= 3.0.0 in a normal Helios distro. So this NS URI must be mapped. Unfortunately this is not all for UML 2.1.x models, since the have to use a special Resource implementation (using the extensionMap mapping) and additional mappings for the UML21_2_UML.ecore2xml, which is referred as platform:/plugin URI.
Unfortunately it is not that easy to map this URI to a file unless it is unpacked from the org.eclipse.uml2.uml package and it would be better to map it from the plugin. This cannot be done in the workflow, since the plugin location is not known. But it can be solved by deriving the Mapping class as follows:
package org.eclipse.xtend.typesystem.uml2;
import org.eclipse.xtend.typesystem.emf.EcoreUtil2;
import org.eclipse.xtend.typesystem.emf.Mapping;
public class UML212URIMapping extends Mapping {
public UML212URIMapping() {
setFrom("pltform:/plugin/org.eclipse.uml2.uml/model/UML21_2_UML.ecore2xml"/>
setTo(EcoreUtil2.getURI("model/UML"1_2_UML.ecore2xml"));
}
}
And then this mapping must be used in the UML2 Setup in the workflow:
<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true">
<extensionMap class="org.eclipse.xtend.typesystem.emf.Mapping">
<from value="uml"/>
<to value="org.eclipse.uml2.uml.resource.UML212UMLResource"/>
</extensionMap>
</bean>
Quite tricky, but necessary for that UML dialect. With UML models declaring other NS URIs than UML 2.1 there should be no problem.
I think it is worth adding this special mapping or a specific version property to the Setup class. I will open a bugzilla for that.
Kind regards,
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.06004 seconds