Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problems creating a dynamic instance
Problems creating a dynamic instance [message #427885] Wed, 04 March 2009 01:35 Go to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000108070805020503000301
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Why cannot the ecore editor create a dynamic instance of a concrete
eclass when its abstract parent eclass implements an interface?

For example, in the attached extlibrary.ecore file; I modified
Addressable to implement an interface. However, when I try to create a
dynamic instance of Person; I get an error saying that it cannot
create/find Person.xmi

Thanks in advance!

--------------000108070805020503000301
Content-Type: text/xml; x-mac-type="0"; x-mac-creator="0";
name="extlibrary.ecore"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="extlibrary.ecore"

<?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" name="extlibrary"
nsURI=" http:///org/eclipse/emf/examples/library/extlibrary.ecore/1. 0.0" nsPrefix="extlib">
<eClassifiers xsi:type="ecore:EClass" name="Book" eSuperTypes="#//CirculatingItem">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="pages" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"
defaultValueLiteral="100"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="category" eType="#//BookCategory"
unsettable="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="author" lowerBound="1"
eType="#//Writer" eOpposite="#//Writer/books"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Library" eSuperTypes="#//Addressable">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="writers" upperBound="-1"
eType="#//Writer" volatile="true" transient="true" derived="true" containment="true"
resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="group" value="#people"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1"
eType="#//Employee" volatile="true" transient="true" derived="true" containment="true"
resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="group" value="#people"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="borrowers" upperBound="-1"
eType="#//Borrower" volatile="true" transient="true" derived="true" containment="true"
resolveProxies="false">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="group" value="#people"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="stock" ordered="false"
upperBound="-1" eType="#//Item" containment="true" resolveProxies="false"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="books" ordered="false"
upperBound="-1" eType="#//Book" transient="true" derived="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="branches" upperBound="-1"
eType="#//Library" containment="true" eOpposite="#//Library/parentBranch"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parentBranch" eType="#//Library"
eOpposite="#//Library/branches"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="people" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="group"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Writer" eSuperTypes="#//Person">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
volatile="true" transient="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="books" upperBound="-1"
eType="#//Book" eOpposite="#//Book/author"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="BookCategory">
<eLiterals name="Mystery"/>
<eLiterals name="ScienceFiction" value="1"/>
<eLiterals name="Biography" value="2"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Item" abstract="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="publicationDate" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Lendable" abstract="true" interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="copies" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="borrowers" ordered="false"
upperBound="-1" eType="#//Borrower" eOpposite="#//Borrower/borrowed"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="CirculatingItem" abstract="true" eSuperTypes="#//Item #//Lendable"/>
<eClassifiers xsi:type="ecore:EClass" name="Periodical" abstract="true" eSuperTypes="#//Item">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="issuesPerYear" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AudioVisualItem" abstract="true" eSuperTypes="#//CirculatingItem">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="minutesLength" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="damaged" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BookOnTape" eSuperTypes="#//AudioVisualItem">
<eStructuralFeatures xsi:type="ecore:EReference" name="reader" eType="#//Person"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="author" eType="#//Writer"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="VideoCassette" eSuperTypes="#//AudioVisualItem">
<eStructuralFeatures xsi:type="ecore:EReference" name="cast" upperBound="-1" eType="#//Person"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Borrower" eSuperTypes="#//Person">
<eStructuralFeatures xsi:type="ecore:EReference" name="borrowed" upperBound="-1"
eType="#//Lendable" eOpposite="#//Lendable/borrowers"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Person" eSuperTypes="#//Addressable">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="firstName" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lastName" lowerBound="1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Employee" eSuperTypes="#//Person">
<eStructuralFeatures xsi:type="ecore:EReference" name="manager" eType="#//Employee"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Addressable" abstract="true" interface="true">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="address" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eGenericSuperTypes eClassifier="#//IComparable">
<eTypeArguments eClassifier="#//Addressable"/>
</eGenericSuperTypes>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IComparable" instanceClassName="java.lang.Comparable"
abstract="true" interface="true">
<eTypeParameters name="T"/>
</eClassifiers>
</ecore:EPackage>

--------------000108070805020503000301--
Re: Problems creating a dynamic instance [message #427896 is a reply to message #427885] Wed, 04 March 2009 12:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030805010309000109060307
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Alfredo,

The action should really be disabled as it is for Addressable directly.
We should fix that enablement test. The log shows this underlying cause
for why book.xmi wasn't created.

java.lang.IllegalArgumentException: The class 'IComparable' is not a
valid classifier
at
org.eclipse.emf.ecore.impl.EFactoryImpl.create(EFactoryImpl. java:235)
at
org.eclipse.emf.ecore.impl.EFactoryImpl.create(EFactoryImpl. java:243)
at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3 244)

The problem is that it's impossible to create a dynamic instance that
implements IComparable or any other existing interface for that matter.
After all, DynamicEObjectImpl won't implement that interface.


AJ wrote:
> Hi,
>
> Why cannot the ecore editor create a dynamic instance of a concrete
> eclass when its abstract parent eclass implements an interface?
>
> For example, in the attached extlibrary.ecore file; I modified
> Addressable to implement an interface. However, when I try to create a
> dynamic instance of Person; I get an error saying that it cannot
> create/find Person.xmi
>
> Thanks in advance!

--------------030805010309000109060307
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alfredo,<br>
<br>
The action should really be disabled as it is for Addressable
directly.&nbsp; We should fix that enablement test.&nbsp; The log shows this
underlying cause for why book.xmi wasn't created.<br>
<blockquote>java.lang.IllegalArgumentException: The class 'IComparable'
is not a valid classifier<br>
&nbsp;&nbsp;&nbsp; at
org.eclipse.emf.ecore.impl.EFactoryImpl.create(EFactoryImpl. java:235) <br>
&nbsp;&nbsp;&nbsp; at
org.eclipse.emf.ecore.impl.EFactoryImpl.create(EFactoryImpl. java:243) <br>
&nbsp;&nbsp;&nbsp; at org.eclipse.emf.ecore.util.EcoreUtil.create(EcoreUtil.java:3 244) <br>
</blockquote>
The problem is that it's impossible to create a dynamic instance that
implements IComparable or any other existing interface for that
matter.&nbsp; After all, DynamicEObjectImpl won't implement that interface.<br>
<br>
<br>
AJ wrote:
<blockquote cite="mid:gokm0a$vom$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
Why cannot the ecore editor create a dynamic instance of a concrete
eclass when its abstract parent eclass implements an interface?
<br>
<br>
For example, in the attached extlibrary.ecore file; I modified
Addressable to implement an interface. However, when I try to create a
dynamic instance of Person; I get an error saying that it cannot
create/find Person.xmi
<br>
<br>
Thanks in advance!
<br>
</blockquote>
</body>
</html>

--------------030805010309000109060307--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:CDO as an enterprise persistence solution???
Next Topic:EMF Transaction
Goto Forum:
  


Current Time: Fri Apr 26 03:55:42 GMT 2024

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

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

Back to the top