Skip to main content



      Home
Home » Modeling » EMF » Copying derived attribute(Derived attribute)
Copying derived attribute [message #1434835] Tue, 30 September 2014 13:19 Go to next message
Eclipse UserFriend
Is it possible to keep the content of derived attributes when one copies instances of a model element from one editor or another? In my case, the metadata attribute is gone in the destination because it's a derived attribute.

Copied source:
<xxegsn:ArgumentPattern identifier="P1">
    <node xsi:type="xxegsn:Goal" identifier="G1" description="Requirement (ID) {id1::int} holds">
      <data xsi:type="xxegsn:PatternBehavior" metadata="hasParam(id1, int)" toBeInstantiated="true"/>
    </node>
 </xxegsn:ArgumentPattern>


Pasted target:
<xxegsn:ArgumentPattern identifier="P1">
    <node xsi:type="xxegsn:Goal" identifier="G1" description="Requirement (ID) {id1::int} holds">
      <data xsi:type="xxegsn:PatternBehavior" toBeInstantiated="true"/>
    </node>
 </xxegsn:ArgumentPattern>

Re: Copying derived attribute [message #1434878 is a reply to message #1434835] Tue, 30 September 2014 14:49 Go to previous messageGo to next message
Eclipse UserFriend
Al,

Comments below.

On 30/09/2014 7:19 PM, Al B wrote:
> Is it possible to keep the content of derived attributes when one
> copies instances of a model element from one editor or another? In my
> case, the metadata attribute is gone in the destination because it's a
> derived attribute.
The copier deliberately omits derived features because they're generally
derived from context. They're typically transient, volatile, and not
changeable as well...
>
> Copied source:
> <xxegsn:ArgumentPattern identifier="P1">
> <node xsi:type="xxegsn:Goal" identifier="G1"
> description="Requirement (ID) {id1::int} holds">
> <data xsi:type="xxegsn:PatternBehavior" metadata="hasParam(id1,
> int)" toBeInstantiated="true"/>
> </node>
> </xxegsn:ArgumentPattern>
>
> Pasted target:
> <xxegsn:ArgumentPattern identifier="P1">
> <node xsi:type="xxegsn:Goal" identifier="G1"
> description="Requirement (ID) {id1::int} holds">
> <data xsi:type="xxegsn:PatternBehavior" toBeInstantiated="true"/>
> </node>
> </xxegsn:ArgumentPattern>
Why is the feature marked derived? From what is it derived? What
wouldn't work if you didn't mark it derived? Is it changeable? What's
the effect if it's set explicitly? I.e., is that value still respected
or is it still derived? Perhaps you're using this more like a computed
default than as a feature that's truly derived, in which case it's value
is *always* determined from the values of other features...
Re: Copying derived attribute [message #1434896 is a reply to message #1434878] Tue, 30 September 2014 15:30 Go to previous messageGo to next message
Eclipse UserFriend
Ed,

It's derived from the content in the description attribute and it cannot be set explicitly or edited because it's read-only.

description="Requirement (ID) {id1::int} holds"

However, you provided me with information I was looking for; which is the copier deliberately omits derived features because they're generally derived from context. Thus, in my case, the metadata attribute was neither transient, volatile, and not changeable so it shouldn't be set as derived. Instead, it should be just read-only.

Thanks!

[Updated on: Tue, 30 September 2014 15:46] by Moderator

Re: Copying derived attribute [message #1435132 is a reply to message #1434896] Wed, 01 October 2014 00:02 Go to previous message
Eclipse UserFriend
Al,

I assume that "it can't be set explicitly" implies its not changeable,
in which case you can't call eSet for that feature, which is how the
copier would copy it. Of course that seems contradictory to the fact
you show it in the serialization because normally the deserializer will
try to set it when its present. Also, you show the description present
in the copy, so certainly the derivation has the value it needs for its
derivation. Perhaps it's more an issue of which point in time you're
computing the derivation? If you look in
org.eclipse.emf.ecore.util.EcoreUtil.Copier.copy(EObject) you can see it
copies the features in the order in which they appear in the model, so
if a containment reference comes before an attribute, that reference's
containment tree will be copied before the attribute...

On 30/09/2014 9:30 PM, Al B wrote:
> Ed,
>
> It's derived from the content in the description attribute and it
> cannot be set explicitly or edited because it's read-only.
>
> description="Requirement (ID) {id1::int} holds"
Previous Topic:[Xcore] overriding value of a superclass attribute
Next Topic:[CDO] on Android
Goto Forum:
  


Current Time: Wed Jul 23 14:10:18 EDT 2025

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

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

Back to the top