|
Re: Model referencing existing emf classes [message #431487 is a reply to message #431477] |
Mon, 13 July 2009 13:17 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Marcin,
Comments below.
Marcin Cylke wrote:
> Hello
>
> I'm creating an emf model, that uses some other model's elements. I
> import a model - let's assume it is UML model.
> I create my own model - Diagram, and give it a EReference pointing to
> Class object from UML model. Class is an interface.
>
> When I generate code for such a model, and try to test it with the
> generated editor, I'm unable to create a proper instances of Class
> objects. I'm getting NullPointerExceptions from Properties framework.
> It looks to me as if the object is not created, only its EReference.
>
> I end up with my model file having created objects written into it,
> but uri's are like this:
>
> uRI="#null" aliasURI="#null"
>
> Do i have to instruct EMF which class implementing Class interface I
> want to instantiate? This seems obvious, but how should I do this?
It seems to me that if you extend the UML model, you need to generate
the code using UML's extended/specialized GenModel. It's best to ask
on the UML2 newsgroup how to go about extending UML2...
>
> Marcin Cylke
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Re: Model referencing existing emf classes [message #431517 is a reply to message #431507] |
Tue, 14 July 2009 22:06 |
Marcin Cylke Messages: 61 Registered: July 2009 |
Member |
|
|
Ed Merks wrote:
Hello
The sample code from the previous post had "some" errors, but it was
written down, from what I've remembered.
Original code look like this:
/**
* @model
*/
public interface XsdSimpleModel {
/**
* @model
*/
public abstract String getTypeName();
/**
* @model
*/
public abstract String getNamespace();
/**
* @model
*/
public abstract String getServiceStatus();
/**
* @model type="Object" containment="true"
*/
public abstract EList<XSDSchemaContent> getTypes();
}
>> * @model type="Object" containment="true"
> type="Object" isn't helpful. In fact, it's less than helpful because
> the signature says it's List<Object> not Object...
Well, you're right, but this does not pose a problem either. Such
definition creates a collection of EReferences and then I change this
collection's type to XSDSchemaContent.
> This comes from the the XSD model. How does that relate?
The steps I've done are:
1. Generate ecore model from interface above.
2. import xsd ecore model - with "Load Resources" dialog, choosing
"platform:/plugin/org.eclipse.xsd/model/XSD.ecore"
3. change return type of getTypes to collection of XSDSchemaContent.
4. generate all - on genmodel, which generates edit code + editor code +
model
> I'm totally confused by how you went from the @model stuff to an XSD
> dependency...
So, I've summed up what I did. And when creating a child of that
XsdSimpleModel object - which should belong to that collection of
XSDSchemaContent, I keep getting quoted before exception.
Marcin
|
|
|
Re: Model referencing existing emf classes [message #431535 is a reply to message #431517] |
Wed, 15 July 2009 13:41 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Marcin,
Comments below.
Marcin Cylke wrote:
> Ed Merks wrote:
>
> Hello
>
> The sample code from the previous post had "some" errors, but it was
> written down, from what I've remembered.
> Original code look like this:
> /**
> * @model
> */
> public interface XsdSimpleModel {
>
> /**
> * @model
> */
> public abstract String getTypeName();
>
> /**
> * @model
> */
> public abstract String getNamespace();
>
> /**
> * @model
> */
> public abstract String getServiceStatus();
>
> /**
> * @model type="Object" containment="true"
> */
> public abstract EList<XSDSchemaContent> getTypes();
> }
Schema objects expect to be contained by an XSDSchema, so I can't
imagine this working well... No doubt that's the source of the errors.
It seems to me you'd be better to use an annotated schema than to create
something like a schema...
>
>
>>> * @model type="Object" containment="true"
>> type="Object" isn't helpful. In fact, it's less than helpful because
>> the signature says it's List<Object> not Object...
>
> Well, you're right, but this does not pose a problem either. Such
> definition creates a collection of EReferences and then I change this
> collection's type to XSDSchemaContent.
>
>> This comes from the the XSD model. How does that relate?
>
> The steps I've done are:
> 1. Generate ecore model from interface above.
> 2. import xsd ecore model - with "Load Resources" dialog, choosing
> "platform:/plugin/org.eclipse.xsd/model/XSD.ecore"
> 3. change return type of getTypes to collection of XSDSchemaContent.
> 4. generate all - on genmodel, which generates edit code + editor code
> + model
>
>> I'm totally confused by how you went from the @model stuff to an XSD
>> dependency...
>
> So, I've summed up what I did. And when creating a child of that
> XsdSimpleModel object - which should belong to that collection of
> XSDSchemaContent, I keep getting quoted before exception.
>
> Marcin
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03737 seconds