-
Notifications
You must be signed in to change notification settings - Fork 354
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
fix: use tracker importer in EnrollmentSmsSubmission DHIS2-17729 #18595
Conversation
...dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/imports/FooTest.java
Fixed
Show fixed
Hide fixed
051a422
to
01938b6
Compare
3b1e707
to
ffba672
Compare
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.
🎉
} | ||
|
||
@Nonnull | ||
private static Event mapToEvent( |
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 can see there are different map
and some mapTo
. Is it on purpose or we should just stick with one naming standard?
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 return type is not part of the method signature. That is why there are cases where I had to use a different name. I did try to use map
for the package private methods that turn an sms submission into tracker objects. Other private helpers then got other names.
@@ -546,7 +552,7 @@ private void mapRelationshipItems( | |||
} | |||
|
|||
private void mapRelationshipItems(TrackedEntity trackedEntity, boolean includeDeleted) | |||
throws ForbiddenException, NotFoundException { | |||
throws NotFoundException { |
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.
Was the forbidden exception just not thrown?
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.
yes, that was a linting error that I fixed.
LGTM, the only thing I'm concerned about is regarding this statement |
LGTM! The only concern I have is regarding this statement: "The previous listener deleted any attribute value that existed on a TE/EN if not present in the SMS. We kept this logic." Where are we deleting the attribute values from? |
ffba672
to
05c997c
Compare
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
As a reference this is the
EnrollmentSmsSubmission
processing logic before we made our changes to sms processing. You can see that users were able to create and update a tracked entity, enroll it and create and update events.This is how the EnrollmentSmsSubmission sms is encoded. If you navigate further down you can find out which fields are mandatory. Mandatory are (meaning you'll get an NPE if you don't provide them): ids and enrollmentStatus.
EnrollmentSMSListener
.SmsImportMapper
with pure functions that translate asmscompression/models
to aTrackerObjects
that can be passed to the tracker importer.SmsImportMapper
unit tests and a couple integration tests.equals
implementation of theTrackedEntityAttribute
see bug below. I was not able to retrieve the attributes even though my test user had read access to the them. They were filtered out inDefaultTrackedEntityService
due to them not beingequal
.Mapping of attributes
An
EnrollmentSmsSubmission
can contain tracked entity attributes. The previous listener deleted any attribute value that existed on a TE/EN if not present in the SMS. We kept this logic.Tracked entity attributes can be
TETA
)PA
)Users can send TEA 3. on the tracked entity and/or the enrollment. This is what the Capture app does as the UI guarantees that a program will always have its tracked entity types' attributes. This is not guaranteed when directly working with the API. The tracker importer validates that attributes are correctly placed. Since 1. and 2. are valid and could be sent to us via SMS we have to handle them well.
This is how each of the above types of attribute values are mapped onto tracker importer objects:
The assumption is that if an attribute is in the programs attributes that it can be put onto the enrollment. It might very well also be a tracked entity type attribute but that does not matter. The tracker importer will reject the import if an attribute is neither a TETA or PA.
The program with its attributes is fetched from the DB. An attribute in this set is either of type 2. or 3. The tracked entity is fetched from the DB with its attributes which includes all types mentioned above!
Next
These are the tracker related compression based SMS we need to adapt so they use the importer:
SubmissionType
=>Listener
class processing these types of SMSDELETE
=>DeleteEventListener
✅ (fix: processing sms and test tracker event deletion DHIS2-17729 #18473)ENROLLMENT
=>EnrollmentSMSListener
✅ (this PR)RELATIONSHIP
=>RelationshipSMSListener
✅ (fix: use tracker importer in RelationshipSMSListener DHIS2-17729 #18509)SIMPLE_EVENT
=>SimpleEventSMSListener
TRACKER_EVENT
=>TrackerEventSMSListener
✅ (fix: use tracker importer in TrackerEventSMSListener DHIS2-17729 #18522)The above can be used used by Android when users are offline.
Then there are command based SMS listeners we need to adapt so they use the importer:
TRACKED_ENTITY_REGISTRATION_PARSER
=>TrackedEntityRegistrationSMSListener
PROGRAM_STAGE_DATAENTRY_PARSER
=>ProgramStageDataEntrySMSListener
EVENT_REGISTRATION_PARSER
=>SingleEventListener
Bug?