Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to do a derived attribute?
How to do a derived attribute? [message #430863] Sat, 13 June 2009 15:07 Go to next message
Anthony is currently offline AnthonyFriend
Messages: 10
Registered: July 2009
Junior Member
Hi,
I thought that this question was solved but I haven't found the answer
to this question.

I have three classes: RootClass, Action and Element. Action and
Element are children of RootClass. What I want to do is that the value of
the attribute actionName of the class Element is equal to the value of the
attribute name of the class Action.
I tried to do it but I don't know how to do a derived attribute. I
have to do the derived attribute without writing code (only using the
ecore model).
Below shows my metamodel:

<?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="my"
nsURI="my" nsPrefix="my">
<eClassifiers xsi:type="ecore:EClass" name="RootClass">
<eStructuralFeatures xsi:type="ecore:EReference" name="actions"
upperBound="-1"
eType="#//Action" containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="elements"
upperBound="-1"
eType="#//Element" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Action">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Element">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="actionName"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
changeable="false" volatile="true" transient="true" derived="true">
<eAnnotations source="http://www.eclipse.org/ocl/examples/OCL">
<details key="derive" value="action.name"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="action"
eType="#//Action"/>
</eClassifiers>
</ecore:EPackage>


Thanks for your time.
Re: How to do a derived attribute? [message #430864 is a reply to message #430863] Sat, 13 June 2009 15:20 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010906070708030304010302
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Anthony,

Comments below.

Anthony wrote:
> Hi,
> I thought that this question was solved but I haven't found the
> answer to this question.
>
> I have three classes: RootClass, Action and Element. Action and
> Element are children of RootClass. What I want to do is that the value
> of the attribute actionName of the class Element is equal to the value
> of the attribute name of the class Action.
> I tried to do it but I don't know how to do a derived attribute. I
> have to do the derived attribute without writing code (only using the
> ecore model).
That's just not supported yet.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=216701

You'll have to write code.
>
> Below shows my metamodel:
>
> <?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="my"
> nsURI="my" nsPrefix="my">
> <eClassifiers xsi:type="ecore:EClass" name="RootClass">
> <eStructuralFeatures xsi:type="ecore:EReference" name="actions"
> upperBound="-1"
> eType="#//Action" containment="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="elements"
> upperBound="-1"
> eType="#//Element" containment="true"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Action">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Element">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="actionName"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
> changeable="false" volatile="true" transient="true"
> derived="true">
> <eAnnotations source="http://www.eclipse.org/ocl/examples/OCL">
> <details key="derive" value="action.name"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="action"
> eType="#//Action"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> Thanks for your
> time.
>

--------------010906070708030304010302
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Anthony,<br>
<br>
Comments below.<br>
<br>
Anthony wrote:
<blockquote
cite="mid:9e540aa2cb7fc9c3e95ace1511523da2$1@www.eclipse.org"
type="cite">Hi,
<br>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Code generation for sequence diagram
Next Topic:Teneo: Id and Unique
Goto Forum:
  


Current Time: Tue Apr 23 12:20:32 GMT 2024

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

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

Back to the top