Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » EDate and XPand
EDate and XPand [message #627424] Thu, 23 September 2010 00:22 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Hi,

I'm having trouble using an ecore EDate in my template. When I do:

«mydate»

I get a formatted date:

Mon Sep 20 00:00:00 PDT 2010

Unfortunately, my output (of course) needs to be a different format, i.e.:

Sep 20 2010 00:00:00 GMT-0600

Now, in my XPand editor I can do:

mydate.toGMTString()

with auto-completion signifying that I've actually got an EDate. But when I try to runt the workflow, I get:

959 ERROR WorkflowRunner - Workflow interrupted. Reason: Couldn't find operation 'toGMTString()' for Object.

Perhaps I've got something in my workflow mis-configured? I've tried explicitly registering Ecore, i.e.

<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
<platformUri value=".."/>
...
<registerGeneratedEPackage value="org.eclipse.emf.ecore.EcorePackage"/>
</bean>

Re: EDate and XPand [message #627972 is a reply to message #627424] Thu, 23 September 2010 08:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hello Miles,

adding org.eclipse.xtend.type.impl.java.JavaBeansMetaModel and using java::util::Date as Type should help.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EDate and XPand [message #628690 is a reply to message #627972] Thu, 23 September 2010 17:07 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Christian Dietrich wrote on Thu, 23 September 2010 04:10

adding org.eclipse.xtend.type.impl.java.JavaBeansMetaModel and using java::util::Date as Type should help.



Thanks Christian. I'm still not getting why this would show up as a function in the editor. I don't have Java Beans activated in my XPand preferences. I must admit that the relationship between what is defined in the workflow vs. workspace settings has always been a bit opaque to me. Anyway, in the meantime I implemented my own, which I include here for those looking for the same thing..

//Output for Occurred: Sat Sep 18 00:00:00 PDT 2010
//Input for JSON: 2010-09-18
cached toJSONDate(String dateString) :
	dateString.splitDate().last() + "-" + dateString.splitDate().get(1).convertMonthOne() + "-" + dateString.splitDate().get(2);
	            
cached splitDate(String dateString) :
	dateString.split(" ");
                        
cached convertMonthOne(String dateString) :
	switch (dateString) {
		case "Jan" : "01"
		case "Feb" : "02"
		case "Mar" : "03"
		case "Apr" : "04"
		case "May" : "05"
		case "Jun" : "06"
		case "Jul" : "07"
		case "Aug" : "08"
		case "Sep" : "09"
		case "Oct" : "10"
		case "Nov" : "11"
		case "Dec" : "12"
		default : "##"
	};


Re: EDate and XPand [message #629607 is a reply to message #627972] Tue, 28 September 2010 21:29 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Christian Dietrich wrote on Thu, 23 September 2010 04:10
Hello Miles,

adding org.eclipse.xtend.type.impl.java.JavaBeansMetaModel and using java::util::Date as Type should help.

~Christian


Christian, forgive me for a dumb question, where should I add that given that I am using EMF metamodel packages for my model?

-Miles
Re: EDate and XPand [message #629609 is a reply to message #629607] Tue, 28 September 2010 21:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi miles,

just add it to the workflow component that invoken the extension (In Your case the Generator component) and the Xtend/Xpand Section of your projects properties.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EDate and XPand [message #629615 is a reply to message #629609] Tue, 28 September 2010 22:56 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Christian Dietrich wrote on Tue, 28 September 2010 17:37

just add it to the workflow component that invoken the extension (In Your case the Generator component) and the Xtend/Xpand Section of your projects properties.



Hi Christian, that's the part I'm feeling stupid about.

I'm not sure how to register using org.eclipse.xpand2.Generator:

	<bean id="emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
..

	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="emf"/>


And I have:

metamodelContributor=org.eclipse.xtend.typesystem.emf.ui.EmfMetamodelContributor,org.eclipse.xtend.shared.ui.core.metamodel.jdt.javabean.JavaBeanMetamodelContributor


But java::util::* isn't availble in my ext.

-Miles
Re: EDate and XPand [message #629712 is a reply to message #629615] Wed, 29 September 2010 11:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi

the workflow should look like

<bean id="emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
<bean id="java" class="org.eclipse.xtend.type.impl.java.JavaBeansMetaModel"/>
..

	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="emf"/>
                <metaModel idRef="java"/>



metamodelContributor=org.eclipse.xtend.typesystem.emf.ui.Emf MetamodelContributor,org.eclipse.xtend.shared.ui.core.metamo del.jdt.javabean.JavaBeanMetamodelContributor

works fine for mewith this extension:

String toSpecialDate(java::util::Date d) :
	"xxx" + d.toString();


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EDate and XPand [message #629848 is a reply to message #629712] Wed, 29 September 2010 18:02 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Christian Dietrich wrote on Wed, 29 September 2010 07:00

<bean id="emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
<bean id="java" class="org.eclipse.xtend.type.impl.java.JavaBeansMetaModel"/>
..

	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="emf"/>
                <metaModel idRef="java"/>



metamodelContributor=org.eclipse.xtend.typesystem.emf.ui.Emf MetamodelContributor,org.eclipse.xtend.shared.ui.core.metamo del.jdt.javabean.JavaBeanMetamodelContributor
~Christian


Thanks Christian. I wasn't aware that you could have multiple metaModel idRefs. It would be helpful I think to have reference docs on this somewhere as otherwise we end up digging through the API docs to try to uncover this information.

I did setup the settings the way you describe above but while the generator works fine the parser still complains. I'm actually having this issue with my own meta-models as well, so that may just be something messed up in my runtime.

cheers and thanks again,

Miles
Previous Topic:[Acceleo] Meta-model URI resolution query
Next Topic:XPAND Simple query
Goto Forum:
  


Current Time: Thu Mar 28 18:45:08 GMT 2024

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

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

Back to the top