Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Problem/question using the createFromString and createToString functions
Problem/question using the createFromString and createToString functions [message #718904] Thu, 25 August 2011 15:30 Go to next message
Sharon Snyder is currently offline Sharon SnyderFriend
Messages: 56
Registered: September 2010
Member

Hi,

Sorry if this is a basic question, but I'm trying to create my first EMF project here at work, and I've gotten pretty far along. I am trying to pass a class I create in my model into a command handler as a parameter and would like to use the built in function createToString and then put it back into the object using the built in createFromString function.

The problem I'm having is that I don't know how to find the EDataType of my object.

I tried creating an EDataType object that references my implementation of the object. I found I needed to use the extended metadata and set the baseType to the object in the model. After reloading the genmodel, I verify it looks good...and then go to generate the code - and it hangs when generating the model code only. Is this because I'm referring to the object that is being generated in the model file? Why is there no error generated - it just hangs there - doesn't seem to use up much CPU either, so it's not spinning out of control.

So, can someone tell me how to find the EDataType of my object so I can pass that into the built in functions to serialize/deserialize this class?

Also, how do I report this bug on the model generation?

Thanks,
Sharon
Re: Problem/question using the createFromString and createToString functions [message #718964 is a reply to message #718904] Thu, 25 August 2011 16:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Sharon,

Comments below.

On 25/08/2011 8:30 AM, Sharon Snyder wrote:
> Hi,
>
> Sorry if this is a basic question, but I'm trying to create my first
> EMF project here at work, and I've gotten pretty far along. I am
> trying to pass a class I create in my model into a command handler as
> a parameter and would like to use the built in function createToString
> and then put it back into the object using the built in
> createFromString function.
By class you mean and
> The problem I'm having is that I don't know how to find the EDataType
> of my object.
> I tried creating an EDataType object that references my implementation
> of the object. I found I needed to use the extended metadata and set
> the baseType to the object in the model.
Why?
> After reloading the genmodel, I verify it looks good...and then go to
> generate the code - and it hangs when generating the model code only.
> Is this because I'm referring to the object that is being generated in
> the model file?
It's hard to understand what you just said. I have no idea why you need
to set the baseType.
> Why is there no error generated - it just hangs there - doesn't seem
> to use up much CPU either, so it's not spinning out of control.
>
> So, can someone tell me how to find the EDataType of my object so I
> can pass that into the built in functions to serialize/deserialize
> this class?
It sounds like you're trying to do this for some instance of an EClass.
That's not appropriate. It's not even clear why you need to pass a
String rather than the actual instance.
>
> Also, how do I report this bug on the model generation?
It sounds likely that you've set up something completely bogus, perhaps
a baseType that refers to an EClass rather than to another EDataType...
>
> Thanks,
> Sharon


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem/question using the createFromString and createToString functions [message #718991 is a reply to message #718964] Thu, 25 August 2011 17:59 Go to previous messageGo to next message
Sharon Snyder is currently offline Sharon SnyderFriend
Messages: 56
Registered: September 2010
Member

No Message Body
Re: Problem/question using the createFromString and createToString functions [message #718995 is a reply to message #718991] Thu, 25 August 2011 18:12 Go to previous messageGo to next message
Sharon Snyder is currently offline Sharon SnyderFriend
Messages: 56
Registered: September 2010
Member

I apologize for not being more clear.....

I've created an object in my EMF diagram, generated it - it's an object that contains a number of fields. Let's call it Node...and it is an EClass object, containing a number of attributes (fieldA, fieldB, and fieldC - all of type EString).

I would like to utilize the built in functions of the factory implementation convertToString(EDataType, Object) and the createFromString(EDataType, String) methods. What I'm trying to figure out is how to use these functions. I have an instance of "Node" but cannot figure out how to get the EDataType for it.

I was explaining that I had tried to create an EDataType in the ecore diagram, and generate it. I was able to create the datatype that way, and then when I ran the convertToString function I debugged into it and found that it was looking for the base Type to be filled in....I found that field in the extended metadata. When I tried to generate the model again, the generate function just hangs there and never ends.

I cannot seem to figure out how to send an instance of Node through as the parameter for my command. Which is why I started going this route. If you know of a good example or tutorial I would be grateful!

I hope this is more clear.

Sharon
Re: Problem/question using the createFromString and createToString functions [message #719096 is a reply to message #718995] Fri, 26 August 2011 03:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Sharon,

Comments below.

On 25/08/2011 11:12 AM, Sharon Snyder wrote:
> I apologize for not being more clear.....
>
> I've created an object in my EMF diagram, generated it - it's an
> object that contains a number of fields. Let's call it Node...and it
> is an EClass object, containing a number of attributes (fieldA,
> fieldB, and fieldC - all of type EString).
>
> I would like to utilize the built in functions of the factory
> implementation convertToString(EDataType, Object) and the
> createFromString(EDataType, String) methods.T
Those don't apply for EClasses.
> What I'm trying to figure out is how to use these functions. I have
> an instance of "Node" but cannot figure out how to get the EDataType
> for it.
I don't think you should be trying to do that.
> I was explaining that I had tried to create an EDataType in the ecore
> diagram, and generate it. I was able to create the datatype that way,
> and then when I ran the convertToString function I debugged into it
> and found that it was looking for the base Type to be filled in....I
> found that field in the extended metadata. When I tried to generate
> the model again, the generate function just hangs there and never ends.
This is going down the wrong path.
>
> I cannot seem to figure out how to send an instance of Node through as
> the parameter for my command.
Why are you trying to do it as a String? The only way to serialize
instances of EClasses, i.e., EObjects, is by putting them in a resource
and serializing that resource.
> Which is why I started going this route. If you know of a good
> example or tutorial I would be grateful!
Perhaps it's best you explain why you need a String first, i.e., why
wouldn't you just use the EObject directly?
>
> I hope this is more clear.
>
> Sharon


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Problem/question using the createFromString and createToString functions [message #719214 is a reply to message #719096] Fri, 26 August 2011 12:37 Go to previous messageGo to next message
Sharon Snyder is currently offline Sharon SnyderFriend
Messages: 56
Registered: September 2010
Member

Ed,

I'd love to just send the object, but I cannot seem to figure that out....I'm missing something in the info I've found online. If you have a pointer or good example that would be great. I'm also putting a query out on a hopefully more appropriate forum for the answer to that.

I figured I was going down the rabbit hole, but also wanted to point out the bug I found....that the generate model function will hang and never finish if you do something just that stupid.

Sharon
Re: Problem/question using the createFromString and createToString functions [message #719307 is a reply to message #719214] Fri, 26 August 2011 16:12 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Sharon,

Comments below.

On 26/08/2011 5:37 AM, Sharon Snyder wrote:
> Ed,
>
> I'd love to just send the object, but I cannot seem to figure that out....
You've talked about a command handler, but I don't really understand
what the problem with passing something to it might be. Often commands
are based on an ISelection and it's certainly possible to use a
StructuredSelection to pass in arbitrary Java objects...
> I'm missing something in the info I've found online. If you have a
> pointer or good example that would be great. I'm also putting a query
> out on a hopefully more appropriate forum for the answer to that.
The problem is related to
https://bugs.eclipse.org/bugs/show_bug.cgi?id=143478. I.e., it would be
nice to validate that all the extended metadata is well formed, but
that's quite a sizable task...
>
> I figured I was going down the rabbit hole, but also wanted to point
> out the bug I found....that the generate model function will hang and
> never finish if you do something just that stupid.
You've not really outlined the problem you're trying to solve but rather
a problem with a solution you're trying to use so it's hard to suggest a
more appropriate solution.

> Sharon


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Texo] Questions on Data Generator Feature
Next Topic:[TEXO] Allowed chars in EPackage name
Goto Forum:
  


Current Time: Fri Apr 19 15:11:42 GMT 2024

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

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

Back to the top