Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Problem by cast from AnyTypeImpl to ModelImpl(migration OAW 4 to OAW 5(Eclipse galileo))
Problem by cast from AnyTypeImpl to ModelImpl [message #557414] Tue, 07 September 2010 10:57 Go to next message
Ming Lu is currently offline Ming LuFriend
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 #557417 is a reply to message #557414] Tue, 07 September 2010 11:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

are you sure that there is a Model (you should cast to the interface always) in the slot? can you post your complete workflow?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557419 is a reply to message #557417] Tue, 07 September 2010 11:23 Go to previous messageGo to next message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member

thanks a lot for your quickly answer

i am pretty sure that is my model. and here is the snipshot of my workflow:

........
<component class="namespace.ModelTransformer">
  	<modelSlot value="model" />
</component>
.......
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557421 is a reply to message #557419] Tue, 07 September 2010 11:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

your exceptions says there is a org.eclipse.emf.ecore.xml.type.AnyType in the model solt so one more: how to you get the model? can you plase post your complete workflow?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557438 is a reply to message #557421] Tue, 07 September 2010 12:31 Go to previous messageGo to next message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member
Christian Dietrich wrote on Tue, 07 September 2010 07:27
Hi,

your exceptions says there is a org.eclipse.emf.ecore.xml.type.AnyType in the model solt so one more: how to you get the model? can you plase post your complete workflow?

~Christian


Hi Christian,

the model generated from Enterprise Architect.

<?xml version="1.0" encoding="UTF-8"?>
<workflow>
<property file="./workflow.properties" />

<bean class="org.openarchitectureware.uml2.Setup"
	standardUML2Setup="true" />

<bean id="mm_Emf" class="oaw.type.emf.EmfMetaModel"> 
      <metaModelPackage value="org.eclipse.emf.ecore.EcorePackage"/> 
</bean> 

<bean id="mm_uml2"
	class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel" />

<component class="org.eclipse.xtend.typesystem.emf.XmiReader">
	<modelFile value="${model.file}"/>
	<outputSlot value="model"/>
</component>

<component id="dirCleaner"
    class="org.eclipse.emf.mwe.utils.DirectoryCleaner" >
    <directory value="${outlet.src.dir}"/>
</component>

<component class="org.dromdary.jpa.generator.model2model.ModelTransformerJpa">
  	<modelSlot value="model" />
</component>

<component id="generator"
    class="org.openarchitectureware.xpand2.Generator" skipOnErrors="true" fileEncoding="ISO-8859-1">
    
    <metaModel idRef="mm_Emf" />
	<metaModel idRef="mm_uml2" />
	
	<globalVarDef name="list_set_property"
				value="${list.set.property}" />
	<globalVarDef name="type_header_text"
				value="${type.header.text}" />
	<globalVarDef name="type_footer_text"
				value="${type.footer.text}" />
	<globalVarDef name="java_version"
				value="${java.version}" />
	<globalVarDef name="annotation_source_key"
				value="${annotation.source.key}" />
	<globalVarDef name="javabasic_generateSerialVersionUID"
				value="${javabasic.generateSerialVersionUID}" />
	<globalVarDef name="interface_operation_implementation_strategy"
				value="${interface.operation.implementation.strategy}" />
	<globalVarDef name="use_overridden_equals_hashcode_toString" 
				value="${use.overridden.equals.hashcode.toString}" />

	<advice value="org::dromdary::jpa::generator::templates::AopEntry" />
		
    <expand value="org::dromdary::jpa::generator::templates::Root::Root FOR model"/>
    
    <outlet path="${outlet.src.dir}">
				<fileEncoding value="${file.encoding.output}"/>
				<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
	</outlet>   
	
    <outlet name="${outlet.persistenceXML}" overwrite="true">
				<fileEncoding value="${file.encoding.output}"/>
				<postprocessor class="org.fornax.utilities.formatter.xml.XmlFormatter" />
	</outlet> 
	
    <outlet name="outletSrcOnceDir"
				path="${outlet.src.once.dir}" overwrite="false">
				<fileEncoding value="${file.encoding.output}"/>
				<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
	</outlet>
	
</component>
</workflow>
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557440 is a reply to message #557438] Tue, 07 September 2010 12:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

EA does not produce Eclipse UL2 compatible XMI: see http://www.eclipse.org/forums/index.php?t=msg&th=174985

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557448 is a reply to message #557440] Tue, 07 September 2010 13:21 Go to previous messageGo to next message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member
Christian Dietrich wrote on Tue, 07 September 2010 08:41
Hi,

EA does not produce Eclipse UL2 compatible XMI: see http://www.eclipse.org/forums/index.php?t=msg&th=174985

~Christian


Hi,

i have forgot to write. i used components4oaw to make compatible XMI from EA.

~Ming
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557449 is a reply to message #557448] Tue, 07 September 2010 13:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

And is it running now? is this the current workflow - the namespaces in your workflow seem a bit old.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557489 is a reply to message #557414] Tue, 07 September 2010 16:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 #557587 is a reply to message #557490] Wed, 08 September 2010 08:05 Go to previous messageGo to next message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member
Hi Edward,

Thx for your help!

i have a question. i try to debug in eclipse and see the Issues issues in
protected void doModification(WorkflowContext ctx, ProgressMonitor monitor, Issues issues, Object model) {
...
}

doesn't occupied any objects.

is this problem, you mined? if yes, how can i trace whether proxy issue works?

Regards
~Ming
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557598 is a reply to message #557449] Wed, 08 September 2010 09:02 Go to previous messageGo to next message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member
Hi Christian, Edward,

it still doesn't work. here is the link to the branch of source:
https://dromdary.svn.sourceforge.net/svnroot/dromdary/branch es/migrationToEclipse36/

it will very kind of you, if you can check it out!

the same source works with oaw 4.3 + eclipse 3.4. we became the error because we want to migrate the project to oaw 5 (integrated into eclipse EMF )+ eclipse 3.5.

please checkout the souce and open it in the eclipse 3.5 (Eclipse Modeling Tools) edition and run oaw in the project common.generator/src/main/resources/workflow.oaw. you can see the cast-exception in the console.

Thanks a lot for your kindly help!
best Regards
~Ming
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557706 is a reply to message #557598] Wed, 08 September 2010 15:04 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

can you provide a stripped down single project example that i can use out-of-the-box.?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 08 September 2010 19:14]

Report message to a moderator

Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557775 is a reply to message #557706] Wed, 08 September 2010 20:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

using the latest (and mwe compatible ea exporter) from here: http://uml2ea.blogspot.com/ it works with a dummy eap sample file.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #557973 is a reply to message #557414] Thu, 09 September 2010 16:16 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

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
Re: Problem by cast from AnyTypeImpl to ModelImpl [message #558188 is a reply to message #557973] Fri, 10 September 2010 13:16 Go to previous message
Ming Lu is currently offline Ming LuFriend
Messages: 8
Registered: September 2010
Junior Member
Hi, Christian, Karsten, Edward

thanks a lot for your kindly helps!

i resolved the problem with the new component4oaw. it was the problem of uml 2 compilable from the c4oaw 1.6.1. with c4oaw 2.0 rc3 is my project runnable.

thanks again for your helps!

best regards and nice weekend!
~Ming
Previous Topic:[MWE2] [Xtend] mismatched input '<EOF>' expecting RULE_ID
Next Topic:[xpand] name of UMLPrimitiveType not generated (=null)
Goto Forum:
  


Current Time: Thu Mar 28 17:52:11 GMT 2024

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

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

Back to the top