Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to put Integer default value to null(How to put Integer default value to null)
How to put Integer default value to null [message #1779895] Mon, 15 January 2018 13:52 Go to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

I'm creating a papyrus profile and i want to put the default value of an attribute of type Integer or EInt to null, but I can't find how to do it with papyrus interface.
In case I use undefined default value, I got 0, same thing happens using LiteralNull .

May someone explain me how to do this please?

Thanks!
Re: How to put Integer default value to null [message #1779920 is a reply to message #1779895] Mon, 15 January 2018 19:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

EInt cannot be null; it is a java.lang.int. You must use EIntegerObject. EMF does not support nullable primitives, even though UML and OCL does.

Integer should be able to set to null. Please provide a repro if you meant what you wrote.

Regards

Ed Willink
Re: How to put Integer default value to null [message #1779967 is a reply to message #1779920] Tue, 16 January 2018 09:22 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

thanks for your quick answer

My bad for Eint you right.

It seems the integer value does not accept null value.

I've a meta-model with stereotype using an integer attribute. My model uses that meta-model but retrieve a 0 value instead of null even I've defined literalNullValue or undefined in its properties.

I'm certain the issue comes from the model's attribute. The model is based on the meta-model, my attribute is defined with a null value in the meta, but the attribute using this definition in the model (Properties->Profile->Applied stereotypes) looks like :

- myStereotype (form myMetamodel)
--myAttribute: Integer[0..1] = 0

My need it to set it such, but can't, I got this warning "the actual entry is not an integer" :
--myAttribute: Integer[0..1] = null

Regards
Re: How to put Integer default value to null [message #1779978 is a reply to message #1779967] Tue, 16 January 2018 09:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

As I wrote before: "Please provide a repro if you meant what you wrote." There is no way that I am even going to attempt to follow your hints to reconstruct your problem.

Regards

Ed Willink
Re: How to put Integer default value to null [message #1779985 is a reply to message #1779978] Tue, 16 January 2018 11:19 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

I'm sorry, I'm not really sure of what you mean when you says repro, tell me if you need something else.
So here is what i have in profile.uml files:

My meta-model :

<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_LqxlAPqkEeeKLLjLjITMPg" name="myMetaModel" metaclassReference="_qBMw4PqkEeeKLLjLjITMPg">
  <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d3UN8fqkEeeKLLjLjITMPg" source="http://www.eclipse.org/uml2/2.0.0/UML">
    <contents xmi:type="ecore:EPackage" xmi:id="_NRsDAfqlEeeKLLjLjITMPg" name="myMetaModel" nsURI="http:///schemas/myMetaModel/_NRsDAPqlEeeKLLjLjITMPg/2" nsPrefix="myMetaModel">
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NRsDCfqlEeeKLLjLjITMPg" source="PapyrusVersion">
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NRsDCvqlEeeKLLjLjITMPg" key="Version" value="0.0.3"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NRsDC_qlEeeKLLjLjITMPg" key="Comment" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NRsDDPqlEeeKLLjLjITMPg" key="Copyright" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NRsDDfqlEeeKLLjLjITMPg" key="Date" value="2018-01-16"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_NRsDDvqlEeeKLLjLjITMPg" key="Author" value=""/>
      </eAnnotations>
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_NRsDAvqlEeeKLLjLjITMPg" name="Attribute">
        <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_NRsDA_qlEeeKLLjLjITMPg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_PBZikPqkEeeKLLjLjITMPg"/>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_NRsDBPqlEeeKLLjLjITMPg" name="length" ordered="false">
          <eType xmi:type="ecore:EDataType" href="http://www.eclipse.org/uml2/5.0.0/Types#//Integer"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_NRsDBvqlEeeKLLjLjITMPg" name="base_Property" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Property"/>
        </eStructuralFeatures>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_ulbKAPqkEeeKLLjLjITMPg" name="myMetaModel" nsURI="http:///schemas/myMetaModel/_ulai8PqkEeeKLLjLjITMPg/1" nsPrefix="myMetaModel">
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ulbKCPqkEeeKLLjLjITMPg" source="PapyrusVersion">
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ulbKCfqkEeeKLLjLjITMPg" key="Version" value="0.0.2"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ulbKCvqkEeeKLLjLjITMPg" key="Comment" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ulbKC_qkEeeKLLjLjITMPg" key="Copyright" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ulbKDPqkEeeKLLjLjITMPg" key="Date" value="2018-01-16"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_ulbKDfqkEeeKLLjLjITMPg" key="Author" value=""/>
      </eAnnotations>
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_ulbKAfqkEeeKLLjLjITMPg" name="Attribute">
        <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_ulbKAvqkEeeKLLjLjITMPg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_PBZikPqkEeeKLLjLjITMPg"/>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_ulbKA_qkEeeKLLjLjITMPg" name="length" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EDataType" href="http://www.eclipse.org/uml2/5.0.0/Types#//Integer"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_ulbKBfqkEeeKLLjLjITMPg" name="base_Property" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/5.0.0/UML#//Property"/>
        </eStructuralFeatures>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_d3UN8vqkEeeKLLjLjITMPg" name="myMetaModel" nsURI="http:///schemas/myMetaModel/_d3UN8PqkEeeKLLjLjITMPg/0" nsPrefix="myMetaModel">
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d3U1APqkEeeKLLjLjITMPg" source="PapyrusVersion">
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d3U1AfqkEeeKLLjLjITMPg" key="Version" value="0.0.1"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d3U1AvqkEeeKLLjLjITMPg" key="Comment" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d3U1A_qkEeeKLLjLjITMPg" key="Copyright" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d3U1BPqkEeeKLLjLjITMPg" key="Date" value="2018-01-16"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_d3U1BfqkEeeKLLjLjITMPg" key="Author" value=""/>
      </eAnnotations>
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_d3UN8_qkEeeKLLjLjITMPg" name="Attribute">
        <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_d3UN9PqkEeeKLLjLjITMPg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_PBZikPqkEeeKLLjLjITMPg"/>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_d3UN9fqkEeeKLLjLjITMPg" name="length" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EDataType" href="http://www.eclipse.org/uml2/5.0.0/Types#//Integer"/>
        </eStructuralFeatures>
      </eClassifiers>
    </contents>
  </eAnnotations>
  <elementImport xmi:type="uml:ElementImport" xmi:id="_qBMw4PqkEeeKLLjLjITMPg" alias="Property">
    <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Property"/>
  </elementImport>
  <packagedElement xmi:type="uml:Stereotype" xmi:id="_PBZikPqkEeeKLLjLjITMPg" name="Attribute">
    <ownedAttribute xmi:type="uml:Property" xmi:id="_QCa6sPqkEeeKLLjLjITMPg" name="length">
      <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
      <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_MZa-QPqlEeeKLLjLjITMPg"/>
      <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_MZhE4PqlEeeKLLjLjITMPg" value="1"/>
    </ownedAttribute>
    <ownedAttribute xmi:type="uml:Property" xmi:id="_tuxO0PqkEeeKLLjLjITMPg" name="base_Property" association="_tuuLgPqkEeeKLLjLjITMPg">
      <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Property"/>
    </ownedAttribute>
  </packagedElement>
  <packagedElement xmi:type="uml:Extension" xmi:id="_tuuLgPqkEeeKLLjLjITMPg" name="E_Attribute_Property1" memberEnd="_tuwnwPqkEeeKLLjLjITMPg _tuxO0PqkEeeKLLjLjITMPg">
    <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_tuwnwPqkEeeKLLjLjITMPg" name="extension_Attribute" type="_PBZikPqkEeeKLLjLjITMPg" aggregation="composite" association="_tuuLgPqkEeeKLLjLjITMPg"/>
  </packagedElement>
</uml:Profile>


and my model :

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:myMetaModel="http:///schemas/myMetaModel/_NRsDAPqlEeeKLLjLjITMPg/2" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http:///schemas/myMetaModel/_NRsDAPqlEeeKLLjLjITMPg/2 /TestGeneUml/myMetaModel.profile.uml#_NRsDAfqlEeeKLLjLjITMPg">
  <uml:Model xmi:id="_jJrfcPqkEeeKLLjLjITMPg" name="MyModel">
    <packagedElement xmi:type="uml:Class" xmi:id="_lT0bwPqkEeeKLLjLjITMPg" name="Example">
      <ownedAttribute xmi:type="uml:Property" xmi:id="_wul18PqkEeeKLLjLjITMPg" name="myAttribute">
        <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer"/>
        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="_IYjw4PqlEeeKLLjLjITMPg" value="1"/>
        <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="_IYvXEPqlEeeKLLjLjITMPg" value="1"/>
      </ownedAttribute>
    </packagedElement>
    <profileApplication xmi:type="uml:ProfileApplication" xmi:id="_jOo38PqkEeeKLLjLjITMPg">
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_Rhlx8fqlEeeKLLjLjITMPg" source="PapyrusVersion">
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Rhlx8vqlEeeKLLjLjITMPg" key="Version" value="0.0.3"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Rhlx8_qlEeeKLLjLjITMPg" key="Comment" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Rhlx9PqlEeeKLLjLjITMPg" key="Copyright" value=""/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Rhlx9fqlEeeKLLjLjITMPg" key="Date" value="2018-01-16"/>
        <details xmi:type="ecore:EStringToStringMapEntry" xmi:id="_Rhlx9vqlEeeKLLjLjITMPg" key="Author" value=""/>
      </eAnnotations>
      <eAnnotations xmi:type="ecore:EAnnotation" xmi:id="_jOpfAPqkEeeKLLjLjITMPg" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="/TestGeneUml/myMetaModel.profile.uml#_NRsDAfqlEeeKLLjLjITMPg"/>
      </eAnnotations>
      <appliedProfile xmi:type="uml:Profile" href="/TestGeneUml/myMetaModel.profile.uml#_LqxlAPqkEeeKLLjLjITMPg"/>
    </profileApplication>
  </uml:Model>
  <myMetaModel:Attribute xmi:id="_BrwhsPqlEeeKLLjLjITMPg" base_Property="_wul18PqkEeeKLLjLjITMPg"/>
</xmi:XMI>


I can't put screen yet, because I've got to few message on this forum.
  • Attachment: screen1.png
    (Size: 8.80KB, Downloaded 149 times)
  • Attachment: screen2.png
    (Size: 54.61KB, Downloaded 148 times)
  • Attachment: screen3.png
    (Size: 5.23KB, Downloaded 143 times)
  • Attachment: screen4.png
    (Size: 34.65KB, Downloaded 144 times)
Re: How to put Integer default value to null [message #1779986 is a reply to message #1779985] Tue, 16 January 2018 11:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Attached models, preferably as a zipped project, are much easier to handle, since they don't need cutting and pasting to reconstruct what you already had.

I can't see your problem.

Obviously your attribute[1..1] cannot be set to null.

I don't see any use of your Stereotype so that presumably isn't the problem.

In UML, null is the absence of an Object. In a textual language such as Java or OCL this absence is hard to handle textually and so the "null" keyword is available.

Regards

Ed Willink

Re: How to put Integer default value to null [message #1780010 is a reply to message #1779986] Tue, 16 January 2018 14:13 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

Here is the zipped project.

My meta-model attribute "length" in my "Attribute" Stereotype is set to [0..1] (screen 1)

In my model, the attribute in my class use the "Attribute" stereotype (screen 3).
But, in the Profile view in Properties view (screen 4), i can't (or i don't know how to do it) set the value of "length" in Applied stereotypes -> Attribute to null.

Regards
Re: How to put Integer default value to null [message #1780018 is a reply to message #1780010] Tue, 16 January 2018 15:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your repro has problems with bad references to /TestGeneUml/myMetaModel.profile.uml, which once fixed give a double ProfileApplication.

I have the latest EMF in my workspace and so have had to raise new Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=529884

Your Attribute.length does not have a <<EAttribute>> stereotype so you have a default value for isUnsettable which is I suspect false, however after a bit of fighting to get past Bug 529884, I can set it to true and it seems to make no difference. It appears that the UML Model Editor does not allow a blank default for an unsettable Integer. However given the amount of fighting I had to do to get past earlier bugs, I cannot be confident in this.

Regards

Ed Willink
Re: How to put Integer default value to null [message #1780034 is a reply to message #1780018] Tue, 16 January 2018 16:19 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

Sorry, I've cleaned the wrong reference in my project

Thanks so much for all your replies!

Regards
Re: How to put Integer default value to null [message #1780173 is a reply to message #1780018] Thu, 18 January 2018 11:24 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
Hello,

I have papyrus Oxygen version 3.0.0

I have another issue related to this one :

When in my metaModel my "length" attribute is a String.
In my model, in the Profile view of "myAttribute", the default value is null .
If I set the value and then delete it, "length" is an empty String not null.
I don't know how to set it back to null.

[Updated on: Thu, 18 January 2018 13:39]

Report message to a moderator

Re: How to put Integer default value to null [message #1780174 is a reply to message #1780173] Thu, 18 January 2018 11:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The icons at the top right of the Properties View include a reset-to-default. Hover over them to find out which.

Regards

Ed Willink
Re: How to put Integer default value to null [message #1780199 is a reply to message #1780174] Thu, 18 January 2018 14:50 Go to previous messageGo to next message
muriel cadiot is currently offline muriel cadiotFriend
Messages: 10
Registered: January 2018
Junior Member
hello,

Here is what i have in my Profile view:

index.php/fa/31849/0/

Shouldn't i have a "Property values" line with button on top of the value input?

Can I ask you which version of Eclipse/papyrus are you using?

Regards
  • Attachment: screen4.png
    (Size: 34.65KB, Downloaded 1589 times)
Re: How to put Integer default value to null [message #1780201 is a reply to message #1780199] Thu, 18 January 2018 15:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry I was referring to the UML Model Editor. Just possibly selecting the "UML" or "Advanced" sheet might help. Otherwise raise a Papyrus Bugzilla. Perhaps deleting the specialization resets to default.

It was a long time before I discovered 'reset-to-default' so for many years I resorted to XMI text editing.

Regards

Ed Willink
Re: How to put Integer default value to null [message #1819705 is a reply to message #1779895] Tue, 21 January 2020 17:30 Go to previous message
pere joseph rodríguez is currently offline pere joseph rodríguezFriend
Messages: 51
Registered: October 2014
Member
Good evening,
I have trying to understand the related bug, but still don't know if this issue is solved or not. Could anyone help please?

Is possible to have [0..1] Integer attributes in a stereotype and able to get null values instead of a 0?

Thanks in advance.
Regards,
Pere Joseph
Previous Topic:Papyrus Project
Next Topic:Adding a block as <<part>> in an IBD
Goto Forum:
  


Current Time: Thu Apr 25 14:14:43 GMT 2024

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

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

Back to the top