-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependent rules with paths that must not exist may evaluate on outdated rmObject #602
Conversation
… from evaluated root so that followup rules take that into account
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #602 +/- ##
============================================
- Coverage 71.80% 71.80% -0.01%
- Complexity 6956 6976 +20
============================================
Files 663 663
Lines 22691 22757 +66
Branches 3676 3682 +6
============================================
+ Hits 16294 16341 +47
- Misses 4664 4686 +22
+ Partials 1733 1730 -3 ☔ View full report in Codecov by Sentry. |
public void fixPathsThatMustNotExist(AssertionResult assertionResult) { | ||
assertionResult.getPathsThatMustNotExist().forEach(this::removePathThatMustNotExist); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should first collect all the objects that need to be removed, before actually removing them. Otherwise it won't work when multiple things need to be removed from the same list. E.g. multiple 'id10's in your test archetype.
See for example the processAssertionResults
method in our internal healthcare-ehr-components
library.
if (match instanceof Pathable) { | ||
Pathable item = (Pathable) match; | ||
Pathable parent = item.getParent(); | ||
if (parent instanceof ItemStructure) ((ItemStructure) parent).getItems().remove(item); | ||
else if (parent instanceof Cluster) ((Cluster) parent).getItems().remove(item); | ||
else if (parent instanceof Composition) ((Composition) parent).getContent().remove(item); | ||
else if (parent instanceof Section) ((Section) parent).getItems().remove(item); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should use reflections / ModelInfoLookup to make this work for all classes and attributes. We can discuss that offline.
tools/build.gradle
Outdated
testImplementation project(':openehr-rm') | ||
api project(':openehr-rm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use reflections (see other comment), this should not be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, this dependency not being here is by design, so we can switch to other RM implementations. So, reflection, or some kind of plugin in the model info lookup is the way to go, instead of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main code looks good. @MattijsK Can you take a look at the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clear test, seems all good to me!
Create
PathsThatMustNotExistFixer
with similar purpose as forAssertionFixer
that removespathsThatMustNotExist
from the root asserted during rule evaluation so that next evaluated rules take non-existence into account.Fix applies only for paths that must not exist referring to object instance of
Pathable
with parent being any instance ofItemStructure
,Cluster
,Composition
orSection
. This limited set is the result of needing to know the actual type of the parent in order to call relevant methods to either delete the child from a list or set a value to null. If the desire is there to support all types, almost for all existing RMObject types, a check and cast would be needed.To be able to import the objects from project
openehr-rm
,testImplementation
needed to be changed toapi
inbuild.gradle
oftools
.