Repository navigation
Conversation
Move the initialization to the post processors instead of inserting the multiplicity on demand. Apply the ST6RI-774 decision to check only usage kind and ownership. Subsettings and redefinitions no longer exclude defaults, and their targets are never inspected during multiplicity preparation. Preserve end defaults, explicit ranges, and the use of Multiplicity rather than MultiplicityRange.
seidewitz
left a comment
There was a problem hiding this comment.
The functional revisions look good. The only place I would like to see some changes is in the unit test class MultiplicityPreparationTest. Rather than list the changes here, I have pushed a commit with a proposed update to this class.
- Removed the call that turned off use of the library index. Not using the index slows the test down considerably, and I don't understand what the benefit is.
- Took more advantage of the functionality available in
SysMLInteractive. This simplifies the test code a bit. I had some ideas for making the test a trueSysMLInteractiveTest, but, in the end, it didn't seem worth the time and effort to get it to work that way. - Made some updates to other files:
- Added
getOwnedMultiplicitiesOftoTypeUtil, and used this method instead of yourownedMultiplicitiesmethod. This is a good utility method for future use. - Added
setResourcetoSysMLInteractive.
- Added
The test results are the same as before the above changes. I have also checked that their are test failures if MultiplicityPreparationTest is run on the commit previous to this PR, which are fixed by the changes in the PR.
Please let me know if you concur.
Also: - Removed turn-off of library index. - Added getOwnedMultiplicitiesOf to TypeUtil. - Added setResource to SysMLInteractive.
That looks good to me. Feel free to merge the PR whenever you're ready. |
This PR revises the implementation of default multiplicities for SysML so that they are not physically inserted into the model during getter operations. It also proactively resolves the following OMG issue, presuming that the adopted resolution to the issue will insert default multiplicities during parsing, not as implied members.
Background
The SysML Language Specification, subclause 7.6.3 Usages, describes three conditions for a SysML usage to have a default multiplicity of 1..1:
In addition, subclause 7.13.2 Connection Definitions and Usages states that
However, as identified in SYSML21-185, there is no formal specification (in normative specification Clause 8) for inserting a default multiplicity based on the above criteria. Nevertheless, a default multiplicity mechanism was implemented, following the criteria, except for a modification to the third ("The usage does not have any explicit owned subsettings or owned redefinitions that have no owning type").
Previously, the default multiplicity mechanism used the adapter
addAdditionalMembersmethod to physically add default multiplicities as necessary during the transformation of the relevant kinds of elements. ButaddAdditionalMemberswas also being called in other places. For example,TypeAdapter.getFeaturesRedefinedByTypecalled it before computing its cache. As a result, callinggetFeatureon a usage with an implicitRedefinitionsometimes caused a mutation of the model as default multiplicities were added.Impact
As a result of the situation described above, code that merely read features could change loaded models, making resolution tests and serialized expected models depend on getter call order.
Changes
The following changes resolve the problem of possibly mutating a model when a
getteris called, consistent with the expected resolution to SYSML21-185.As previously, "adding a default multiplicity" means adding a
Multiplicityelement (not aMultiplicityRange) via anOwningMembership(not aFeatureMembership). The default multiplicity bounds are determined later by adding an implied specialization toBase::exactlyOne. This is not changed by the PR.