metanorma / mn-samples-plateau

Project PLATEAU by MLIT: Japanese Ministry of Land, Infrastructure, Transport and Tourism (国土交通省)
https://www.mlit.go.jp/plateau/
1 stars 0 forks source link

Modeling the "gray box" indicating that an inherited attribute is not to be used #199

Open ronaldtse opened 1 week ago

ronaldtse commented 1 week ago

In Enterprise Architect 16, I've created a usage attribute in Building that overrides the usage attribute in _AbstractBuilding.

It looks like this:

image

You have to manually set its "Multiplicity" to "0..0" in the EA Properties pane.

Screenshot 2024-10-11 at 7 02 01 PM

Then the result in XMI as you will see below, says <bounds lower="0" upper="0"/>:

<attributes>
    <attribute xmi:idref="EAID_B0A1A78F_F75A_4b39_BCFF_8E2579D1C17D" name="usage" scope="Private">
        <initial/>
        <documentation/>
        <model ea_localid="2167" ea_guid="{B0A1A78F-F75A-4b39-BCFF-8E2579D1C17D}"/>
        <properties type="gml::CodeType" collection="false" static="0" duplicates="0" changeability="changeable"/>
        <coords ordered="0"/>
        <containment containment="Not Specified" position="0"/>
        <stereotype/>
        <bounds lower="0" upper="0"/>
        <options/>
        <style/>
        <styleex value="volatile=0;"/>
        <tags/>
        <xrefs/>
    </attribute>
</attributes>

This way we are able to detect which attributes are meant to be disabled, and the reason of why that attribute is disabled can also be entered in the Notes.

ronaldtse commented 1 week ago

FYI @ReesePlews @Chika96

ronaldtse commented 1 week ago

Note that when creating this attribute, you will need to choose the same data type, and can use "Select Type" if the type is a defined element in the package.

Screenshot 2024-10-11 at 7 04 14 PM
ReesePlews commented 1 week ago

hello @ronaldtse thank you very much for researching this option. i am still grappling with UML, so i am wondering what happens if we change the structure of Building by adding this new attribute? i have been told that the specific order of attributes, and other constructs matters.

if i understand your idea correctly: (based on the snippet image from doc01v4, shown below)

image

do we create identical attributes for "boundedBy", "relativeToTerrain", "relativeToWater", etc in the bldg class and set their multiplicity to [0..0]?

does this same method also work for the inherited roles?

thank you again for researching this.

ronaldtse commented 1 week ago

Yes you're right we have to do it for all greyed out attributes.

I actually haven't tried the role override. Will report back.

ronaldtse commented 6 days ago

For overriding a role/association/relationship, it's more complicated. Nonetheless it is possible, but you have to create a (throw-away) diagram.

After setting the relationships, you can just delete the diagram. The relationships are stored in the model, not the diagram.

Steps:

  1. Create a diagram (could be anywhere)
  2. Add the Building class to the diagram (e.g. through drag and drop) (the class you want to override a role)
  3. Add the data type or class you want to override the role for. For example, in the Building class you want to override lod2MultiSurface. The target data type is called gml:MultiSurface.
  4. Create an "Association" between them (e.g. through dragging the arrow icon from the source to the target)
  5. Edit the Association's property (e.g. double click the association line) through the Properties popup. Go to the "Role(s)" tab. In the "SOURCE Building" pane, enter lod2MultiSurface. In the "TARGET MultiSurface" pane, enter lod2MultiSurface, then set "Multiplicity" to "0".
  6. Click on the "Building" class in the diagram, and see that the "Relationships" pane shows a new association with the desired "Target cardinality" of 0.

To test:

  1. Save the diagram and changes. Right-click the image tab in the navigation, click "Save All".
  2. Go to "Publish" in the navigation Ribbon, click on "Publish As...". Export as UML 2.5.1 XMI.

Notice this line in the XML: <type multiplicity="0".

<connector xmi:idref="EAID_2D561F37_F66C_48ae_99E1_973940394BE9">
  <source xmi:idref="EAID_B2D484B5_202B_4034_9046_90FCCEC07F56">
    <model ea_localid="612" type="Class" name="Building"/>
    <role visibility="Public" targetScope="instance"/>
    <type aggregation="none" containment="Unspecified"/>
    <constraints/>
    <modifiers isOrdered="false" changeable="none" isNavigable="false"/>
    <style value="Union=0;Derived=0;AllowDuplicates=0;Owned=0;Navigable=Unspecified;"/>
    <documentation/>
    <xrefs/>
    <tags/>
  </source>
  <target xmi:idref="EAID_9CD87EC7_BBC1_4503_B284_14860C27C0BF">
    <model ea_localid="22" type="Class" name="MultiSurface"/>
    <role name="lod2MultiSurface" visibility="Public" targetScope="instance"/>
    <type multiplicity="0" aggregation="none" containment="Unspecified"/>
    <constraints/>
    <modifiers isOrdered="false" changeable="none" isNavigable="false"/>
    <style value="Union=0;Derived=0;AllowDuplicates=0;Owned=0;Navigable=Unspecified;"/>
    <documentation/>
    <xrefs/>
    <tags/>
  </target>
  <model ea_localid="961"/>
  <properties ea_type="Association" direction="Source -&gt; Destination"/>
  <modifiers isRoot="false" isLeaf="false"/>
  <parameterSubstitutions/>
  <documentation/>
  <appearance linemode="3" linecolor="-1" linewidth="0" seqno="0" headStyle="0" lineStyle="0"/>
  <labels rb="0" rt="+lod2MultiSurface"/>
  <extendedProperties virtualInheritance="0"/>
  <style/>
  <xrefs/>
  <tags/>
</connector>

Create a diagram and add those classes

Use the "Add Element > Insert > Any Element" dialog.

Screenshot 2024-10-12 at 4 39 39 PM

Use the Quick Link association linker to connect the two classes

Screenshot 2024-10-12 at 4 40 33 PM

Double-click or right-click/properties to open the association's property window

And fill in the details.

Screenshot 2024-10-12 at 4 36 41 PM

Notice the Relationships pane at the bottom will show the relationship

Screenshot 2024-10-12 at 4 41 39 PM

Remember to save the diagram and all changes

Screenshot 2024-10-12 at 4 42 07 PM

Export package to XMI

Screenshot 2024-10-12 at 4 42 29 PM
ronaldtse commented 6 days ago

EA's website said there's an easier way to create Relationships, but I can't seem to get it working. The "Link Type" does not provide a selection of what can a relationship be built with.

ReesePlews commented 6 days ago

thank you @ronaldtse that is quite a set of steps. i am really going to have to study how that works. thank you for figuring this out and for documenting it so carefully. i am sure the Plateau Team and @Chika96 will be interested in checking this. thank you!