-
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: Move converters into the bundle package [DHIS2-18093] #18807
Conversation
9069b97
to
114cacb
Compare
...ices/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/domain/Enrollment.java
Dismissed
Show dismissed
Hide dismissed
...s/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/domain/TrackedEntity.java
Dismissed
Show dismissed
Hide dismissed
460ea37
to
13fc56d
Compare
13fc56d
to
7f59931
Compare
Date occurredDate = DateUtils.fromInstant(enrollment.getOccurredAt()); | ||
|
||
dbEnrollment.setEnrollmentDate(enrollmentDate); | ||
dbEnrollment.setOccurredDate(occurredDate != null ? occurredDate : enrollmentDate); |
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.
what's the difference between this one and enrollmentDate
? and why do we set it to enrollmentDate
if occurredDate
is null?
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.
Now the there is less code and it is easier to understand this logic I created https://dhis2.atlassian.net/browse/DHIS2-18224 to reason about this kind of stuff.
I am not sure what is the logic here
} | ||
|
||
@Override | ||
protected org.hisp.dhis.relationship.Relationship convert( | ||
TrackerBundle bundle, Relationship trackerDto) { | ||
return relationshipConverter.from(bundle.getPreheat(), trackerDto, bundle.getUser()); | ||
if (bundle.getStrategy(trackerDto) == TrackerImportStrategy.UPDATE) { | ||
return null; |
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.
why do we not map the object in case of UPDATE?
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.
Relationships cannot be updated.
If this is the case, we are ignoring the object in the payload and send a warning.
Ivo created a bug https://dhis2.atlassian.net/browse/DHIS2-18110 where we should improve the way we set the ignored objects to always provide an error/warning. Here it is happening but it is not enforced by the code.
dbEnrollment.setCompletedDate(now); | ||
dbEnrollment.setCompletedBy(user.getUsername()); | ||
} | ||
case CANCELLED -> { |
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.
unrelated to this PR, but I've seen that when the enrollment is CANCELLED
, the related event(s) are not modified, so it could happen that an event is ACTIVE
while the parent enrollment is CANCELLED
, does that make sense?
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.
Same as before, I just didn't change the logic, but in https://dhis2.atlassian.net/browse/DHIS2-18224 we should try to understand if it makes sense or not.
Why is a default needed in both places? |
Yeah, I don't think it is. |
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.
Is the TrackerObjectsMapper
only used by the persisters? if so move it their and make package private
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/TrackerObjectsMapper.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java
Outdated
Show resolved
Hide resolved
...r/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java
Show resolved
Hide resolved
...racker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/EnrollmentPersister.java
Show resolved
Hide resolved
Unfortunately it is used in here Line 63 in 7f59931
I would like to remove it at some point but it is out of the scope of this PR. |
It is actually needed in both places. |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
This PR moves the converters inside the bundle package and merge them in one single static mapper.
While at it, a few small fixes were performed:
setDeleted(false)
was removed from the mapper.EnrollmentStatus
default isACTIVE
. Added default value in tracker model and removed it from the mapper.deleted
was removed as it was never used.