Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » "getPackage() : EObject" returns for cross referenced model
"getPackage() : EObject" returns for cross referenced model [message #431554] Thu, 16 July 2009 14:28 Go to next message
Robert Walter is currently offline Robert WalterFriend
Messages: 11
Registered: July 2009
Junior Member
Hi,

I have implemented an oAW workflow component that generates Java model
code for an ecore model (via genmodel). So far so good.

When I pass an ecore model, however, which references a second ecore
model, a NullPointerException happens:

-- Error Stack

java.lang.NullPointerException
at
org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.h asExtendedMetaData(GenPackageImpl.java:3984)
at
org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.i nitialize(GenPackageImpl.java:2473)
at
org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.ini tialize(GenModelImpl.java:1927)
at
com.seitenbau.mdsd.oaw.wfc.EMFGenerator.invokeInternal(EMFGe nerator.java:162)
at
org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invok e(AbstractWorkflowComponent.java:118)
at
org.eclipse.emf.mwe.core.container.CompositeComponent.intern alInvoke(CompositeComponent.java:97)
at
org.eclipse.emf.mwe.core.container.CompositeComponent.invoke (CompositeComponent.java:86)
at
org.eclipse.emf.mwe.core.WorkflowRunner.executeWorkflow(Work flowRunner.java:298)
at org.eclipse.emf.mwe.core.WorkflowRunner.run(WorkflowRunner.j ava:223)
at org.eclipse.emf.mwe.core.WorkflowRunner.main(WorkflowRunner. java:172)
-- End Error Stack

As far as I debugged it, the problem occurs because in the for-loop at the
end of the static method "hasExtendedMetaData" the call of "getEPackage"
in the line

4004: ePackages.add(((EClassifier)eCrossReference).getEPackage());

returns null. By this, null is added to the "ePackages" collection which
results in the mentioned "NullPointerException" when further trying to
iterate through the "ePackages"-contents. So, I'm pretty sure that this is
no bug in EMF, since the built-in eclipse version (creating genmodel via
context menu and then generate the model code, also via context menu item)
works. But maybe one of you could help me with my oAW component. Here is
how I do the java generation (I apologies for possible formating issues!):

############################################################
private void createEPackageList(Object obj)
throws IllegalArgumentException, ClassCastException {
if (obj instanceof EPackage) {
this.packages.add((EPackage) obj);
}
else if (obj instanceof List) {

if (!this.firstElementOnly) {
for (Object ePackage : (List<Object>) obj) {
this.createEPackageList(ePackage);
}
}
else if (!((List) obj).isEmpty()) {
Object o = ((List<Object>) obj).get(0);
if (o instanceof EPackage)
this.packages.add((EPackage) o);
}
}
else {
throw new IllegalArgumentException(
"The specified ecore model contains root elements which are not of
type EPackage. Your ecore model seems to be invalid!");
}
}

private void setEPackagePrefixes(List<GenPackage> genPackageList,
List<EPackage> ePackageList, int index)
throws IndexOutOfBoundsException {
try {
if (!this.firstElementOnly) {
for (GenPackage genPackage : genPackageList) {
genPackage.setPrefix(ePackageList.get(index).getName());
setEPackagePrefixes(genPackage.getSubGenPackages(),
ePackageList.get(index++).getESubpackages(),
0);
}
}
else if (!ePackageList.isEmpty() && !genPackageList.isEmpty()) {
genPackageList.get(0).setPrefix(ePackageList.get(0).getName( ));

// Necessary, since this option is only "valid" for the top
// level packages. The recursive call for the top package's
// subpackages must consider all subpackages!
this.firstElementOnly = false;

setEPackagePrefixes(genPackageList.get(0).getSubGenPackages( ),
ePackageList.get(index++).getESubpackages(), 0);
}
} catch (IndexOutOfBoundsException ioobEX) {
throw ioobEX;
}
}


@Override
public void invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext ctx,

org.eclipse.emf.mwe.core.monitor.ProgressMonitor monitor,
org.eclipse.emf.mwe.core.issues.Issues issues) {
try {
this.createEPackageList(ctx.get(this.ecoreSlot));
} catch (Exception ex) {
throw new WorkflowInterruptedException( "Workflow interrupted because
of: ", ex);
}

if (this.packages.isEmpty()) {
System.out.println("The ecore model is empty. Abort generation of
model classes.");
return;
}

GenModel genModel =
GenModelPackage.eINSTANCE.getGenModelFactory().createGenMode l();
genModel.initialize(packages);
genModel.setModelDirectory(this.javaPath);

genModel.setValidateModel(true);
genModel.setForceOverwrite(true);
genModel.setCanGenerate(true);
genModel.setFacadeHelperClass(null);
genModel.setBundleManifest(false);
genModel.setComplianceLevel(GenJDKLevel.JDK50_LITERAL);
genModel.setRootExtendsClass("org.eclipse.emf.ecore.impl.EObjectImpl ");

try {
this.setEPackagePrefixes(genModel.getGenPackages(), this.packages, 0);
} catch (IndexOutOfBoundsException ioobEX) {
throw new WorkflowInterruptedException("Workflow interrupted because
of: ", ioobEX);
}

genModel.reconcile();

Generator generator = new Generator();
generator.getAdapterFactoryDescriptorRegistry().addDescripto r(
GenModelPackage.eNS_URI, new GeneratorAdapterFactory.Descriptor() {
public GeneratorAdapterFactory createAdapterFactory() {
return new GenModelGeneratorAdapterFactory() {

@Override
public Adapter createGenEnumAdapter() {
return new GenEnumGeneratorAdapter(this) {
@Override
protected OutputStream createOutputStream(URI workspacePath)
throws Exception {
return getURIConverter().createOutputStream(workspacePath);
}

@Override
protected URI toURI(String pathName) {
return URI.createFileURI(javaPath);
}
};
}

@Override
public Adapter createGenClassAdapter() {
return new GenClassGeneratorAdapter(this) {
@Override
protected OutputStream createOutputStream(URI workspacePath)
throws Exception {
return getURIConverter().createOutputStream(workspacePath);
}

@Override
protected URI toURI(String pathName) {
return URI.createFileURI(javaPath);
}
};
}

@Override
public Adapter createGenPackageAdapter() {
return new GenPackageGeneratorAdapter(this) {
@Override
protected URI toURI(String pathName) {
return URI.createFileURI(javaPath);
}
@Override
protected OutputStream createOutputStream(URI workspacePath)
throws Exception {
System.out.println(workspacePath);
return getURIConverter().createOutputStream(workspacePath);
}
};
}
};
}
});

generator.setInput(genModel);
Diagnostic d = generator.generate(genModel,
GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE,
new BasicMonitor.Printing(System.out));

if (d.getSeverity() != Diagnostic.OK) {
System.err.println(d);
}
}
############################################################

Somehow I need to populate the second meta model, but I don't know how!

Thanks in advance ->
Bob
Re: "getPackage() : EObject" returns for cross referenced model [message #431561 is a reply to message #431554] Thu, 16 July 2009 16:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Robert,

Comments below.

Robert Walter wrote:
> Hi,
>
> I have implemented an oAW workflow component that generates Java model
> code for an ecore model (via genmodel). So far so good.
I assume those run standalone.
>
> When I pass an ecore model, however, which references a second ecore
> model, a NullPointerException happens:
>
> -- Error Stack
>
> java.lang.NullPointerException
> at
> org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.h asExtendedMetaData(GenPackageImpl.java:3984)
>
> at
> org.eclipse.emf.codegen.ecore.genmodel.impl.GenPackageImpl.i nitialize(GenPackageImpl.java:2473)
>
> at
> org.eclipse.emf.codegen.ecore.genmodel.impl.GenModelImpl.ini tialize(GenModelImpl.java:1927)
>
> at
> com.seitenbau.mdsd.oaw.wfc.EMFGenerator.invokeInternal(EMFGe nerator.java:162)
>
> at
> org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invok e(AbstractWorkflowComponent.java:118)
>
> at
> org.eclipse.emf.mwe.core.container.CompositeComponent.intern alInvoke(CompositeComponent.java:97)
>
> at
> org.eclipse.emf.mwe.core.container.CompositeComponent.invoke (CompositeComponent.java:86)
>
> at
> org.eclipse.emf.mwe.core.WorkflowRunner.executeWorkflow(Work flowRunner.java:298)
>
> at
> org.eclipse.emf.mwe.core.WorkflowRunner.run(WorkflowRunner.j ava:223)
> at
> org.eclipse.emf.mwe.core.WorkflowRunner.main(WorkflowRunner. java:172)
> -- End Error Stack
>
> As far as I debugged it, the problem occurs because in the for-loop at
> the end of the static method "hasExtendedMetaData" the call of
> "getEPackage" in the line
> 4004: ePackages.add(((EClassifier)eCrossReference).getEPackage());
It sounds like an unresolved proxy. It would be good to look at the
value of the eProxyURI() of this EClass... Why is it not resolving is
the question...
>
> returns null. By this, null is added to the "ePackages" collection
> which results in the mentioned "NullPointerException" when further
> trying to iterate through the "ePackages"-contents. So, I'm pretty
> sure that this is no bug in EMF, since the built-in eclipse version
> (creating genmodel via context menu and then generate the model code,
> also via context menu item) works. But maybe one of you could help me
> with my oAW component. Here is how I do the java generation (I
> apologies for possible formating issues!):
>
> ############################################################
> private void createEPackageList(Object obj)
> throws IllegalArgumentException, ClassCastException {
> if (obj instanceof EPackage) {
> this.packages.add((EPackage) obj);
> } else if (obj instanceof List) {
>
> if (!this.firstElementOnly) {
> for (Object ePackage : (List<Object>) obj) {
> this.createEPackageList(ePackage);
> }
> } else if (!((List) obj).isEmpty()) {
> Object o = ((List<Object>) obj).get(0);
> if (o instanceof EPackage)
> this.packages.add((EPackage) o);
> }
> } else {
> throw new IllegalArgumentException(
> "The specified ecore model contains root elements which are not
> of type EPackage. Your ecore model seems to be invalid!");
> }
> }
>
> private void setEPackagePrefixes(List<GenPackage> genPackageList,
> List<EPackage> ePackageList, int index)
> throws IndexOutOfBoundsException {
> try {
> if (!this.firstElementOnly) {
> for (GenPackage genPackage : genPackageList) {
> genPackage.setPrefix(ePackageList.get(index).getName());
> setEPackagePrefixes(genPackage.getSubGenPackages(),
>
> ePackageList.get(index++).getESubpackages(), 0);
> }
> }
> else if (!ePackageList.isEmpty() && !genPackageList.isEmpty()) {
> genPackageList.get(0).setPrefix(ePackageList.get(0).getName( ));
> // Necessary, since this option is only "valid" for the top
> // level packages. The recursive call for the top package's
> // subpackages must consider all subpackages!
> this.firstElementOnly = false;
> setEPackagePrefixes(genPackageList.get(0).getSubGenPackages( ),
> ePackageList.get(index++).getESubpackages(), 0);
> }
> } catch (IndexOutOfBoundsException ioobEX) {
> throw ioobEX;
> }
> }
>
>
> @Override
> public void invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext ctx,
>
> org.eclipse.emf.mwe.core.monitor.ProgressMonitor monitor,
> org.eclipse.emf.mwe.core.issues.Issues
> issues) {
> try {
> this.createEPackageList(ctx.get(this.ecoreSlot));
> } catch (Exception ex) {
> throw new WorkflowInterruptedException( "Workflow interrupted
> because of: ", ex);
> }
>
> if (this.packages.isEmpty()) {
> System.out.println("The ecore model is empty. Abort generation of
> model classes.");
> return;
> }
>
> GenModel genModel =
> GenModelPackage.eINSTANCE.getGenModelFactory().createGenMode l();
> genModel.initialize(packages);
> genModel.setModelDirectory(this.javaPath);
>
> genModel.setValidateModel(true);
> genModel.setForceOverwrite(true);
> genModel.setCanGenerate(true);
> genModel.setFacadeHelperClass(null);
> genModel.setBundleManifest(false);
> genModel.setComplianceLevel(GenJDKLevel.JDK50_LITERAL);
> genModel.setRootExtendsClass("org.eclipse.emf.ecore.impl.EObjectImpl ");
>
> try {
> this.setEPackagePrefixes(genModel.getGenPackages(), this.packages, 0);
> } catch (IndexOutOfBoundsException ioobEX) {
> throw new WorkflowInterruptedException("Workflow interrupted
> because of: ", ioobEX);
> }
>
> genModel.reconcile();
>
> Generator generator = new Generator();
> generator.getAdapterFactoryDescriptorRegistry().addDescripto r(
> GenModelPackage.eNS_URI, new GeneratorAdapterFactory.Descriptor() {
> public GeneratorAdapterFactory createAdapterFactory() {
> return new GenModelGeneratorAdapterFactory() {
> @Override
> public Adapter createGenEnumAdapter() {
> return new GenEnumGeneratorAdapter(this) {
> @Override
> protected OutputStream createOutputStream(URI
> workspacePath) throws Exception {
> return getURIConverter().createOutputStream(workspacePath);
> }
>
> @Override
> protected URI toURI(String pathName) {
> return URI.createFileURI(javaPath);
> }
> };
> }
>
> @Override
> public Adapter createGenClassAdapter() {
> return new GenClassGeneratorAdapter(this) {
> @Override
> protected OutputStream createOutputStream(URI
> workspacePath) throws Exception {
> return
> getURIConverter().createOutputStream(workspacePath);
> }
>
> @Override
> protected URI toURI(String pathName) {
> return URI.createFileURI(javaPath);
> } };
> }
>
> @Override
> public Adapter createGenPackageAdapter() {
> return new GenPackageGeneratorAdapter(this) {
> @Override
> protected URI toURI(String pathName) {
> return URI.createFileURI(javaPath);
> }
> @Override
> protected OutputStream createOutputStream(URI
> workspacePath) throws Exception {
> System.out.println(workspacePath);
> return
> getURIConverter().createOutputStream(workspacePath);
> }
> };
> }
> };
> }
> });
>
> generator.setInput(genModel);
> Diagnostic d = generator.generate(genModel,
> GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE,
> new BasicMonitor.Printing(System.out));
>
> if (d.getSeverity() != Diagnostic.OK) {
> System.err.println(d); }
> }
> ############################################################
>
> Somehow I need to populate the second meta model, but I don't know how!
That's a lot of code to look at... I'm not sure what to say...
>
> Thanks in advance -> Bob
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: "getPackage() : EObject" returns for cross referenced model [message #431571 is a reply to message #431561] Fri, 17 July 2009 08:11 Go to previous messageGo to next message
Robert Walter is currently offline Robert WalterFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

thanks for your replay.

> It sounds like an unresolved proxy. It would be good to look at the
> value of the eProxyURI() of this EClass... Why is it not resolving is
> the question...

The "eProxyURI" property has the value
" platform:/resource/sql-metamodel/src/main/resources/metamode l/RDBBase.ecore#//SchemaFactory ",
as I stated it in the ecore file. Perhaps this is the somewhat wrong.
Inside the project of the referencing model both the ecore file and the
corresponding Java model of "RDBBase.ecore" reside as project dependency
in the classpath. I tried copying both in the project directly --
receiving the same result (the NullPointerException), while the
"eProxyURI" now has the value "RDBBase.ecore#//SchemaFactory".

> That's a lot of code to look at... I'm not sure what to say...

It's actually too much code to look at, sorry! I just wanted to make sure
not to forget anything ^^"

But since the eProxyURI-property seems to be set correctly, my code might
not be the problem.

I just debugged my generator again with a "working" ecore model, meaning
that the model does not reference another one. In this case, the
"getPackage()" method inside "hasExtendedMetaData" returns the correct
EPackage, although the "eProxyURI" property is null...?

Best wishes,
Robert
Re: "getPackage() : EObject" returns for cross referenced model [message #431584 is a reply to message #431571] Fri, 17 July 2009 15:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Robert,

Comments below.

Robert Walter wrote:
> Hi Ed,
>
> thanks for your replay.
>
>> It sounds like an unresolved proxy. It would be good to look at the
>> value of the eProxyURI() of this EClass... Why is it not resolving
>> is the question...
>
> The "eProxyURI" property has the value
> " platform:/resource/sql-metamodel/src/main/resources/metamode l/RDBBase.ecore#//SchemaFactory ",
> as I stated it in the ecore file. Perhaps this is the somewhat wrong.
It will expect to find a project named sql-metamodel in the workspace.
> Inside the project of the referencing model both the ecore file and
> the corresponding Java model of "RDBBase.ecore" reside as project
> dependency in the classpath.
That sounds problematic. Tricks like this would help redirect to an
installed bundle


editingDomain.getResourceSet().getURIConverter().getURIMap() .putAll(EcorePlugin.computePlatformURIMap());

but it relies on the plugin ID matching the name of the project.
> I tried copying both in the project directly -- receiving the same
> result (the NullPointerException), while the "eProxyURI" now has the
> value "RDBBase.ecore#//SchemaFactory".
It really should be an absolute URI. Not sure how you arrived at this.
>
>
>> That's a lot of code to look at... I'm not sure what to say...
>
> It's actually too much code to look at, sorry! I just wanted to make
> sure not to forget anything ^^"
>
> But since the eProxyURI-property seems to be set correctly, my code
> might not be the problem.
Correctly is a relative term is this case. It looks problematic at best.
>
> I just debugged my generator again with a "working" ecore model,
> meaning that the model does not reference another one. In this case,
> the "getPackage()" method inside "hasExtendedMetaData" returns the
> correct EPackage, although the "eProxyURI" property is null...?
Yes, it's properly resolved. Any time you see a non-null eProxyURI you
know there was trouble finding the resource or the object within it...
>
> Best wishes,
> Robert
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: "getPackage() : EObject" returns for cross referenced model [message #431643 is a reply to message #431584] Mon, 20 July 2009 07:44 Go to previous messageGo to next message
Robert Walter is currently offline Robert WalterFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

thanks for your replay,

>>> It sounds like an unresolved proxy. It would be good to look at the
>>> value of the eProxyURI() of this EClass... Why is it not resolving
>>> is the question...
>>
>> The "eProxyURI" property has the value
>>
" platform:/resource/sql-metamodel/src/main/resources/metamode l/RDBBase.ecore#//SchemaFactory ",
>> as I stated it in the ecore file. Perhaps this is the somewhat wrong.
> It will expect to find a project named sql-metamodel in the workspace.

The project sql-metamodel actually is in the workspace.

>> Inside the project of the referencing model both the ecore file and
>> the corresponding Java model of "RDBBase.ecore" reside as project
>> dependency in the classpath.
> That sounds problematic. Tricks like this would help redirect to an
> installed bundle

Hmm...okay, so, how would you suppose to extend an existing ecore model?
For example, if I would like to provide a (meta)model (I know you don't
like the term "meta"), describing "platform independent" SQL in a way that
you can define an Oracle (meta)model, reusing parts of the general SQL
model? I would really appreciate if there is a "best practice" to do sth
like this :)

>
editingDomain.getResourceSet().getURIConverter().getURIMap() .putAll(EcorePlugin.computePlatformURIMap());

> but it relies on the plugin ID matching the name of the project.
Okay, I will give it try...

>> I tried copying both in the project directly -- receiving the same
>> result (the NullPointerException), while the "eProxyURI" now has the
>> value "RDBBase.ecore#//SchemaFactory".
> It really should be an absolute URI. Not sure how you arrived at this.
I know, this is probarly a stupid question, but I'm not sure what you mean
with "absoulte URI".

Consider a small, basic ecore model which has the following properties:
name="Base"
nsURI="http://www.base.com/mdsd/Base"
nsPrefix="Base"

And a EClass named "BaseClass", which is declared as "abstract". How can I
reference "BaseClass" in another model as a super type of "SubClass"? I
tried it that way, but I get an "PackageNotFoundException, thrown by the
sample reflective editor:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:base="http://www.base.com/mdsd/Base"
name="Sub"
nsURI="http://www.base.com/mdsd/Sub" nsPrefix="Sub">
<eClassifiers xsi:type="ecore:EClass" name="SubClass"
eSuperTypes="base:Base http://www.base.com/mdsd/Base#//Base"/>
</ecore:EPackage>

Where can I find the ecore reference?

Best wishes,
Bob
Re: "getPackage() : EObject" returns for cross referenced model [message #431649 is a reply to message #431643] Mon, 20 July 2009 18:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Robert,

Comments below.

Robert Walter wrote:
> Hi Ed,
>
> thanks for your replay,
>
>>>> It sounds like an unresolved proxy. It would be good to look at
>>>> the value of the eProxyURI() of this EClass... Why is it not
>>>> resolving is the question...
>>>
>>> The "eProxyURI" property has the value
> " platform:/resource/sql-metamodel/src/main/resources/metamode l/RDBBase.ecore#//SchemaFactory ",
>
>>> as I stated it in the ecore file. Perhaps this is the somewhat wrong.
>> It will expect to find a project named sql-metamodel in the workspace.
>
> The project sql-metamodel actually is in the workspace.
>
>>> Inside the project of the referencing model both the ecore file and
>>> the corresponding Java model of "RDBBase.ecore" reside as project
>>> dependency in the classpath.
>> That sounds problematic. Tricks like this would help redirect to an
>> installed bundle
>
> Hmm...okay, so, how would you suppose to extend an existing ecore
> model? For example, if I would like to provide a (meta)model (I know
> you don't like the term "meta"), describing "platform independent" SQL
> in a way that you can define an Oracle (meta)model, reusing parts of
> the general SQL model? I would really appreciate if there is a "best
> practice" to do sth like this :)
If it's always in the workspace during development, that will work fine.
>
>>
> editingDomain.getResourceSet().getURIConverter().getURIMap() .putAll(EcorePlugin.computePlatformURIMap());
>
>
>> but it relies on the plugin ID matching the name of the project.
> Okay, I will give it try...
>
>>> I tried copying both in the project directly -- receiving the same
>>> result (the NullPointerException), while the "eProxyURI" now has the
>>> value "RDBBase.ecore#//SchemaFactory".
>> It really should be an absolute URI. Not sure how you arrived at this.
> I know, this is probarly a stupid question, but I'm not sure what you
> mean with "absoulte URI".
A URI with a scheme, i.e., file:, http:...
>
> Consider a small, basic ecore model which has the following properties:
> name="Base"
> nsURI="http://www.base.com/mdsd/Base" nsPrefix="Base"
>
> And a EClass named "BaseClass", which is declared as "abstract". How
> can I reference "BaseClass" in another model as a super type of
> "SubClass"? I tried it that way, but I get an
> "PackageNotFoundException, thrown by the sample reflective editor:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:base="http://www.base.com/mdsd/Base"
> name="Sub"
> nsURI="http://www.base.com/mdsd/Sub" nsPrefix="Sub">
> <eClassifiers xsi:type="ecore:EClass" name="SubClass"
> eSuperTypes="base:Base http://www.base.com/mdsd/Base#//Base"/>
This is using the nsURI. Typically you'd be using the URI of the
physical location. Aren't you using Sample Ecore Editor to do this?
> </ecore:EPackage>
>
> Where can I find the ecore reference?
Not sure what you mean...
>
> Best wishes,
> Bob
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: "getPackage() : EObject" returns for cross referenced model [message #431659 is a reply to message #431649] Tue, 21 July 2009 07:47 Go to previous messageGo to next message
Robert Walter is currently offline Robert WalterFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,

thank you again for the comments, also for your patience!

>> Hmm...okay, so, how would you suppose to extend an existing ecore
>> model? For example, if I would like to provide a (meta)model (I know
>> you don't like the term "meta"), describing "platform independent" SQL
>> in a way that you can define an Oracle (meta)model, reusing parts of
>> the general SQL model? I would really appreciate if there is a "best
>> practice" to do sth like this :)
> If it's always in the workspace during development, that will work fine.

Okay, obviously some language barriers here... I'm no native English
speaker (as you probably have noticed ;)) I would like to know *how* you
would extend an existing ecore model technically (meaning in XMI). So, you
said you would use an absolut URI, with a schema like http:? In my example
below, you said that I use the nsURI. So, I'm totally confused now...
Where do I get this "physical location URI" of a existing model?

>> Consider a small, basic ecore model which has the following properties:
>> name="Base"
>> nsURI="http://www.base.com/mdsd/Base" nsPrefix="Base"
>>
>> And a EClass named "BaseClass", which is declared as "abstract". How
>> can I reference "BaseClass" in another model as a super type of
>> "SubClass"? I tried it that way, but I get an
>> "PackageNotFoundException, thrown by the sample reflective editor:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <ecore:EPackage xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:base="http://www.base.com/mdsd/Base"
>> name="Sub"
>> nsURI="http://www.base.com/mdsd/Sub" nsPrefix="Sub">
>> <eClassifiers xsi:type="ecore:EClass" name="SubClass"
>> eSuperTypes="base:Base http://www.base.com/mdsd/Base#//Base"/>
>> </ecore:EPackage>
> This is using the nsURI. Typically you'd be using the URI of the
> physical location. Aren't you using Sample Ecore Editor to do this?

I am using the Sample Ecore Editor. Can you please explain how I am
supposed to use this tool to refer to an EClass of an existing model? Or
perhaps you can point me to an explanation. Consider clicking in the
property view's "ESuper Types" line of an EClass "Sub" to add "Base" as a
super type. If "Base" resides in another ecore file, the "ESuper
Types-dialog" does not offer "Base" as an option. So, currently I'm adding
such a super type using the text editor.

>>
>> Where can I find the ecore reference?
> Not sure what you mean...
A reference where the ecore Ecore model is explained. Where, for example,
it is described how to refer to elements of other models :) This wouldn't
by a big document I think...
I understand that there is no magic using this stuff, but on the other
hand it is really annoying for me to always gather information from forums
and newsgroups. I wouldn't say I'm new to EMF, MDSD and stuff, but in many
ways it is still not really transparent or comprehensible all by itself.

Best wishes,
Bob
Re: "getPackage() : EObject" returns for cross referenced model [message #431681 is a reply to message #431659] Tue, 21 July 2009 14:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Robert,

Comments below.


Robert Walter wrote:
> Hi Ed,
>
> thank you again for the comments, also for your patience!
Me, patient? Hehehe...
>
>>> Hmm...okay, so, how would you suppose to extend an existing ecore
>>> model? For example, if I would like to provide a (meta)model (I know
>>> you don't like the term "meta"), describing "platform independent"
>>> SQL in a way that you can define an Oracle (meta)model, reusing
>>> parts of the general SQL model? I would really appreciate if there
>>> is a "best practice" to do sth like this :)
>> If it's always in the workspace during development, that will work fine.
>
> Okay, obviously some language barriers here... I'm no native English
> speaker (as you probably have noticed ;)) I would like to know *how*
> you would extend an existing ecore model technically (meaning in XMI).
> So, you said you would use an absolut URI, with a schema like http:?
> In my example below, you said that I use the nsURI. So, I'm totally
> confused now... Where do I get this "physical location URI" of a
> existing model?
If you create a new Ecore model and use the Sample Ecore Editor, you can
use Load Resource... to load another Ecore model in your workspace.
Once you do that, you can define and EClass, and modify the super types
to reference an EClass from that other loaded Ecore model. If you save
after doing this, you'll see how the reference to the base model is
represented.
>
>>> Consider a small, basic ecore model which has the following properties:
>>> name="Base"
>>> nsURI="http://www.base.com/mdsd/Base" nsPrefix="Base"
>>>
>>> And a EClass named "BaseClass", which is declared as "abstract". How
>>> can I reference "BaseClass" in another model as a super type of
>>> "SubClass"? I tried it that way, but I get an
>>> "PackageNotFoundException, thrown by the sample reflective editor:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <ecore:EPackage xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:base="http://www.base.com/mdsd/Base"
>>> name="Sub"
>>> nsURI="http://www.base.com/mdsd/Sub" nsPrefix="Sub">
>>> <eClassifiers xsi:type="ecore:EClass" name="SubClass"
>>> eSuperTypes="base:Base http://www.base.com/mdsd/Base#//Base"/>
>>> </ecore:EPackage>
>> This is using the nsURI. Typically you'd be using the URI of the
>> physical location. Aren't you using Sample Ecore Editor to do this?
>
> I am using the Sample Ecore Editor. Can you please explain how I am
> supposed to use this tool to refer to an EClass of an existing model?
Load Resource...
> Or perhaps you can point me to an explanation. Consider clicking in
> the property view's "ESuper Types" line of an EClass "Sub" to add
> "Base" as a super type. If "Base" resides in another ecore file, the
> "ESuper Types-dialog" does not offer "Base" as an option. So,
> currently I'm adding such a super type using the text editor.
It will after you load the other resource into the editor.
>
>>>
>>> Where can I find the ecore reference?
>> Not sure what you mean...
> A reference where the ecore Ecore model is explained. Where, for
> example, it is described how to refer to elements of other models :)
> This wouldn't by a big document I think...
> I understand that there is no magic using this stuff, but on the other
> hand it is really annoying for me to always gather information from
> forums and newsgroups. I wouldn't say I'm new to EMF, MDSD and stuff,
> but in many ways it is still not really transparent or comprehensible
> all by itself.
Did you consider buying the EMF book? It's got a wealth of
information... But you're right that the organization of information on
the website could be improved. There just aren't enough people to do
everything and as developers, we prefer to spend time developing above
all other things...
>
> Best wishes,
> Bob
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: "getPackage() : EObject" returns for cross referenced model [message #431711 is a reply to message #431681] Wed, 22 July 2009 14:02 Go to previous message
Robert Walter is currently offline Robert WalterFriend
Messages: 11
Registered: July 2009
Junior Member
Hi Ed,


> If you create a new Ecore model and use the Sample Ecore Editor, you can
> use Load Resource... to load another Ecore model in your workspace.
> Once you do that, you can define and EClass, and modify the super types
> to reference an EClass from that other loaded Ecore model. If you save
> after doing this, you'll see how the reference to the base model is
> represented.
Okay, I actually was not aware of the "Load Resource..." feature, thanks!

>> Or perhaps you can point me to an explanation. Consider clicking in
>> the property view's "ESuper Types" line of an EClass "Sub" to add
>> "Base" as a super type. If "Base" resides in another ecore file, the
>> "ESuper Types-dialog" does not offer "Base" as an option. So,
>> currently I'm adding such a super type using the text editor.
> It will after you load the other resource into the editor.
Yep, works...

>> A reference where the ecore Ecore model is explained. Where, for
>> example, it is described how to refer to elements of other models :)
>> This wouldn't by a big document I think...
>> I understand that there is no magic using this stuff, but on the other
>> hand it is really annoying for me to always gather information from
>> forums and newsgroups. I wouldn't say I'm new to EMF, MDSD and stuff,
>> but in many ways it is still not really transparent or comprehensible
>> all by itself.
> Did you consider buying the EMF book? It's got a wealth of
> information... But you're right that the organization of information on
> the website could be improved. There just aren't enough people to do
> everything and as developers, we prefer to spend time developing above
> all other things...
Actually, my colleague bought it last week as he just told me! But I'm
also looking forward to get one of my own :)

Best wishes,
Bob
Previous Topic:[Teneo] How do you join across models?
Next Topic:[Validation] Deterioration of performance with Eclipse Galileo due to Tracing
Goto Forum:
  


Current Time: Fri Apr 19 09:58:58 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