Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Losing atributes after saving and reopening Dynamic Instances(Losing Attributes even after saving)
Losing atributes after saving and reopening Dynamic Instances [message #655407] Sun, 20 February 2011 17:01 Go to next message
Oscar Andres Fajardo F. is currently offline Oscar Andres Fajardo F.Friend
Messages: 10
Registered: February 2011
Location: Colombia
Junior Member
Hi,
I've done a metamodel that apparently works. But when I generate everything, even install the plugins [Edit, Editor, Diagram] and create an instance of my metamodel there are some numeric values that get lost even after saving the instance.
The numeric values [score] that I lose are the ones that are part of the ScoredRelation [Achieves, Possesses]

Why this could be? Is it because of the metamodel? any suggestions? I'll be happy and thankful to receive any comment...

Here's the 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="MAS"
    nsURI="http://MAS/1.0" nsPrefix="MAS">
  <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
    <details key="invocationDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
    <details key="settingDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
    <details key="validationDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
  </eAnnotations>
  <eClassifiers xsi:type="ecore:EClass" name="MASModel">
    <eStructuralFeatures xsi:type="ecore:EReference" name="Elements" upperBound="-1"
        eType="#//MASElement" containment="true" eOpposite="#//MASElement/MAS"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="Relations" upperBound="-1"
        eType="#//MASRelation" containment="true" eOpposite="#//MASRelation/MAS"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="MASRelation" abstract="true">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="source" lowerBound="1"
        eType="#//MASElement"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="target" lowerBound="1"
        eType="#//MASElement"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="MAS" lowerBound="1" eType="#//MASModel"
        changeable="false" eOpposite="#//MASModel/Relations"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="MASElement" abstract="true">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"
        defaultValueLiteral="" iD="true"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="MAS" lowerBound="1" eType="#//MASModel"
        changeable="false" eOpposite="#//MASModel/Elements"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Requires" eSuperTypes="#//MASRelation">
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
      <details key="constraints" value="RequiresDestinationType RequiresSourceType"/>
    </eAnnotations>
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
      <details key="RequiresDestinationType" value="self.target->forAll(a|a.oclIsKindOf(Capabilities))"/>
      <details key="RequiresSourceType" value="self.source->forAll(a|a.oclIsKindOf(Role))"/>
    </eAnnotations>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ScoredRelation" abstract="true" eSuperTypes="#//MASRelation">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="score" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"
        transient="true" defaultValueLiteral="0"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Achieves" eSuperTypes="#//ScoredRelation">
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
      <details key="constraints" value="AchievesDestinationType AchievesSourceType"/>
    </eAnnotations>
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
      <details key="AchievesDestinationType" value="self.target->forAll(a|a.oclIsKindOf(Goal))"/>
      <details key="AchievesSourceType" value="self.source->forAll(a|a.oclIsKindOf(Role))"/>
    </eAnnotations>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Possesses" eSuperTypes="#//ScoredRelation">
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
      <details key="constraints" value="PossessesDestinationType PossessesSourceType"/>
    </eAnnotations>
    <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
      <details key="PossessesDestinationType" value="self.target->forAll(a|a.oclIsKindOf(Capabilities))"/>
      <details key="PossessesSourceType" value="self.source->forAll(a|a.oclIsKindOf(Agent))"/>
    </eAnnotations>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Role" eSuperTypes="#//MASElement"/>
  <eClassifiers xsi:type="ecore:EClass" name="Goal" eSuperTypes="#//MASElement"/>
  <eClassifiers xsi:type="ecore:EClass" name="Agent" eSuperTypes="#//MASElement"/>
  <eClassifiers xsi:type="ecore:EClass" name="Capabilities" eSuperTypes="#//MASElement"/>
</ecore:EPackage>


Here's an instance, as you can see there are no scores anywhere...
<?xml version="1.0" encoding="ASCII"?>
<MAS:MASModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:MAS="http://MAS/1.0" xsi:schemaLocation="http://MAS/1.0 MAS.ecore">
  <Elements xsi:type="MAS:Capabilities" name="c1"/>
  <Elements xsi:type="MAS:Agent" name="a1"/>
  <Relations xsi:type="MAS:Possesses" name="a1c1" source="a1" target="c1"/>
</MAS:MASModel>
Re: Losing atributes after saving and reopening Dynamic Instances [message #655647 is a reply to message #655407] Tue, 22 February 2011 06:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30543
Registered: July 2009
Senior Member
Oscar,

EMF won't, by default, save a feature's value of eIsSet is false.
You'll see this has been discussed a great many times and there are
options to keep default values...


Oscar Andres Fajardo F. wrote:
> Hi,
> I've done a metamodel that apparently works. But when I generate
> everything, even install the plugins [Edit, Editor, Diagram] and
> create an instance of my metamodel there are some numeric values that
> get lost even after saving the instance.
> The numeric values [score] that I lose are the ones that are part of
> the ScoredRelation [Achieves, Possesses]
>
> Why this could be? Is it because of the metamodel? any suggestions?
> I'll be happy and thankful to receive any comment...
>
> Here's the 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="MAS"
> nsURI="http://MAS/1.0" nsPrefix="MAS">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="invocationDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> <details key="settingDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> <details key="validationDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> </eAnnotations>
> <eClassifiers xsi:type="ecore:EClass" name="MASModel">
> <eStructuralFeatures xsi:type="ecore:EReference" name="Elements"
> upperBound="-1"
> eType="#//MASElement" containment="true"
> eOpposite="#//MASElement/MAS"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="Relations"
> upperBound="-1"
> eType="#//MASRelation" containment="true"
> eOpposite="#//MASRelation/MAS"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="MASRelation"
> abstract="true">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="source"
> lowerBound="1"
> eType="#//MASElement"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="target"
> lowerBound="1"
> eType="#//MASElement"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="MAS"
> lowerBound="1" eType="#//MASModel"
> changeable="false" eOpposite="#//MASModel/Relations"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="MASElement" abstract="true">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"
> defaultValueLiteral="" iD="true"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="MAS"
> lowerBound="1" eType="#//MASModel"
> changeable="false" eOpposite="#//MASModel/Elements"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Requires"
> eSuperTypes="#//MASRelation">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="constraints" value="RequiresDestinationType
> RequiresSourceType"/>
> </eAnnotations>
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
> <details key="RequiresDestinationType"
> value="self.target->forAll(a|a.oclIsKindOf(Capabilities))"/ >
> <details key="RequiresSourceType"
> value="self.source->forAll(a|a.oclIsKindOf(Role))"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="ScoredRelation"
> abstract="true" eSuperTypes="#//MASRelation">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="score"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFloat"
> transient="true" defaultValueLiteral="0"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Achieves"
> eSuperTypes="#//ScoredRelation">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="constraints" value="AchievesDestinationType
> AchievesSourceType"/>
> </eAnnotations>
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
> <details key="AchievesDestinationType"
> value="self.target->forAll(a|a.oclIsKindOf(Goal))"/>
> <details key="AchievesSourceType"
> value="self.source->forAll(a|a.oclIsKindOf(Role))"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Possesses"
> eSuperTypes="#//ScoredRelation">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="constraints" value="PossessesDestinationType
> PossessesSourceType"/>
> </eAnnotations>
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
> <details key="PossessesDestinationType"
> value="self.target->forAll(a|a.oclIsKindOf(Capabilities))"/ >
> <details key="PossessesSourceType"
> value="self.source->forAll(a|a.oclIsKindOf(Agent))"/>
> </eAnnotations>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Role"
> eSuperTypes="#//MASElement"/>
> <eClassifiers xsi:type="ecore:EClass" name="Goal"
> eSuperTypes="#//MASElement"/>
> <eClassifiers xsi:type="ecore:EClass" name="Agent"
> eSuperTypes="#//MASElement"/>
> <eClassifiers xsi:type="ecore:EClass" name="Capabilities"
> eSuperTypes="#//MASElement"/>
> </ecore:EPackage>
>
>
> Here's an instance, as you can see there are no scores anywhere...
>
> <?xml version="1.0" encoding="ASCII"?>
> <MAS:MASModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:MAS="http://MAS/1.0" xsi:schemaLocation="http://MAS/1.0 MAS.ecore">
> <Elements xsi:type="MAS:Capabilities" name="c1"/>
> <Elements xsi:type="MAS:Agent" name="a1"/>
> <Relations xsi:type="MAS:Possesses" name="a1c1" source="a1"
> target="c1"/>
> </MAS:MASModel>
>
Re: Losing atributes after saving and reopening Dynamic Instances [message #655888 is a reply to message #655647] Wed, 23 February 2011 01:55 Go to previous messageGo to next message
Oscar Andres Fajardo F. is currently offline Oscar Andres Fajardo F.Friend
Messages: 10
Registered: February 2011
Location: Colombia
Junior Member
Hi Ed, thanks for your reply.
Even though I searched what you mention I still can't understand what you're saying. I though everything that has to be set is setted from the ecore file.
I switched some values in the ecore file, and tried to keep blank the default value(It seems that the default value is the one that keeps setted) but now I got errors.
Please if you know how to make this thing work and tell it to me, I'll be very thankful
Score:
Changeabel :true
Default Value Literal: 0 (at this point if I unset this m-attribute raises a validation error) ->The default value literal '' must be a valid literal of the attribute's type
Derived: false
EAttribute Type: EDouble[double]
EType: EDouble[double]
ID: false
Lower Bound: 0
Name: score
Ordered: false
Transient: false
Unique false
Unsettable: false
Upper Bound: 1
Volatile: false

I've seen posts about multiple hierarchy, but I understand that what I'm doing is not multiple, because I don't have 2 or more parents... so I don't understand what would be the problem in this case.

Thank you very much for your comments
Re: Losing atributes after saving and reopening Dynamic Instances [message #655889 is a reply to message #655888] Wed, 23 February 2011 02:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30543
Registered: July 2009
Senior Member
Oscar,

Comments below.

Oscar Andres Fajardo F. wrote:
> Hi Ed, thanks for your reply.
> Even though I searched what you mention I still can't understand what
> you're saying. I though everything that has to be set is setted from
> the ecore file.
> I switched some values in the ecore file, and tried to keep blank the
> default value(It seems that the default value is the one that keeps
> setted) but now I got errors.
Keep in mind that the empty string and no value at all (null) aren't the
same. So you need to use the reset button in the properties view to set
it to null as opposed to the empty string.
> Please if you know how to make this thing work and tell it to me, I'll
> be very thankful
> Score:
> Changeabel :true
> Default Value Literal: 0 (at this point if I unset this m-attribute
> raises a validation error) ->The default value literal '' must be a
> valid literal of the attribute's type
> Derived: false
> EAttribute Type: EDouble[double]
Also note that primitives inherently have a default value of zero.
> EType: EDouble[double]
> ID: false
> Lower Bound: 0
> Name: score
> Ordered: false
> Transient: false
> Unique false
> Unsettable: false
> Upper Bound: 1
> Volatile: false
>
> I've seen posts about multiple hierarchy, but I understand that what
> I'm doing is not multiple, because I don't have 2 or more parents...
> so I don't understand what would be the problem in this case.
I don't expect a score of 0.0 for a float to be serialized. This
option can be used to serialize explicit defaults (ones specified in the
Ecore model) but not implicit defaults (all primitives have an implicit
default just like Java).

/**
* Keep default content ( e.g. default attributes). This applies to
saving and converting contents to DOM.
* By default the default content is discarded.
* To save the default content, set this option to
<code>Boolean.TRUE</code>.
*/
String OPTION_KEEP_DEFAULT_CONTENT = "KEEP_DEFAULT_CONTENT";
>
>
> Thank you very much for your comments
Previous Topic:invalid QName for EMF but not for javax.xml.namespace
Next Topic:running validation from an application (or a junit test)
Goto Forum:
  


Current Time: Tue Oct 15 08:23:49 GMT 2019

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

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

Back to the top