Skip to content

Commit

Permalink
chore: Clean up tracker domain objects [DHIS2-18222] (#18857)
Browse files Browse the repository at this point in the history
* chore: Clean up tracker domain objects [DHIS2-18222]

* Fix test
  • Loading branch information
enricocolasante authored Oct 21, 2024
1 parent 64ffcba commit 24b1656
Show file tree
Hide file tree
Showing 27 changed files with 54 additions and 386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ private void collectTrackedEntities(
addIdentifier(identifiers, TrackedEntityType.class, trackedEntity.getTrackedEntityType());
addIdentifier(identifiers, OrganisationUnit.class, trackedEntity.getOrgUnit());

collectEnrollments(identifiers, trackedEntity.getEnrollments());

trackedEntity
.getAttributes()
.forEach(
Expand All @@ -123,7 +121,6 @@ private void collectEnrollments(
addIdentifier(identifiers, OrganisationUnit.class, enrollment.getOrgUnit());

collectNotes(identifiers, enrollment.getNotes());
collectEvents(identifiers, enrollment.getEvents());
enrollment
.getAttributes()
.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
package org.hisp.dhis.tracker.imports.bundle;

import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
import static org.hisp.dhis.program.EnrollmentStatus.COMPLETED;
import static org.hisp.dhis.relationship.RelationshipEntity.PROGRAM_INSTANCE;
import static org.hisp.dhis.relationship.RelationshipEntity.PROGRAM_STAGE_INSTANCE;
import static org.hisp.dhis.relationship.RelationshipEntity.TRACKED_ENTITY_INSTANCE;

import java.util.Date;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.time.Instant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hisp.dhis.common.ValueType;

/**
* @author Morten Olav Hansen <[email protected]>
Expand All @@ -43,21 +41,10 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class Attribute implements Serializable {
@JsonProperty private MetadataIdentifier attribute;

@JsonProperty private String code; // remove

@JsonProperty private String displayName; // remove

@JsonProperty private Instant createdAt; // remove

@JsonProperty private Instant updatedAt; // remove

@JsonProperty private String storedBy;

@JsonProperty private ValueType valueType; // remove

@JsonProperty private String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
// TODO(DHIS2-18223) Remove unused fields when fixing data values logic
public class DataValue implements Serializable {
@JsonProperty private Instant createdAt; // remove

Expand All @@ -55,8 +55,4 @@ public class DataValue implements Serializable {
@JsonProperty private MetadataIdentifier dataElement;

@JsonProperty private String value;

@JsonProperty private User createdBy; // remove

@JsonProperty private User updatedBy; // remove
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class Enrollment implements TrackerDto, Serializable {
@JsonProperty private String enrollment;

@JsonProperty private Instant createdAt; // remove

@JsonProperty private Instant createdAtClient;

@JsonProperty private Instant updatedAt; // remove

@JsonProperty private Instant updatedAtClient;

@JsonProperty private String trackedEntity;
Expand All @@ -73,25 +68,10 @@ public class Enrollment implements TrackerDto, Serializable {

@JsonProperty private boolean followUp;

@JsonProperty private String completedBy; // remove

@JsonProperty private Instant completedAt; // remove

@JsonProperty private boolean deleted; // remove

@JsonProperty private String storedBy;

@JsonProperty private User createdBy; // remove

@JsonProperty private User updatedBy; // remove

@JsonProperty private Geometry geometry;

@JsonProperty @Builder.Default private List<Event> events = new ArrayList<>(); // remove

@JsonProperty @Builder.Default
private List<Relationship> relationships = new ArrayList<>(); // remove

@JsonProperty @Builder.Default private List<Attribute> attributes = new ArrayList<>();

@JsonProperty @Builder.Default private List<Note> notes = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class Event implements TrackerDto, Serializable {
@JsonProperty private String event;

Expand All @@ -64,23 +63,14 @@ public class Event implements TrackerDto, Serializable {

@JsonProperty private MetadataIdentifier orgUnit;

@JsonProperty @Builder.Default
private List<Relationship> relationships = new ArrayList<>(); // remove

@JsonProperty private Instant occurredAt;

@JsonProperty private Instant scheduledAt;

@JsonProperty private String storedBy;

@JsonProperty private boolean deleted; // remove

@JsonProperty private Instant createdAt; // remove

@JsonProperty private Instant createdAtClient;

@JsonProperty private Instant updatedAt; // remove

@JsonProperty private Instant updatedAtClient;

@JsonProperty private MetadataIdentifier attributeOptionCombo;
Expand All @@ -96,10 +86,6 @@ public class Event implements TrackerDto, Serializable {

@JsonProperty private User assignedUser;

@JsonProperty private User createdBy; // remove

@JsonProperty private User updatedBy; // remove

@JsonProperty @Builder.Default private Set<DataValue> dataValues = new HashSet<>();

@JsonProperty @Builder.Default private List<Note> notes = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.time.Instant;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -45,15 +44,10 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class Note implements Serializable {
@JsonProperty private String note;

@JsonProperty private Instant storedAt; // remove

@JsonProperty private String value;

@JsonProperty private User createdBy; // remove

@JsonProperty private String storedBy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,13 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class Relationship implements TrackerDto, Serializable {
@JsonProperty private String relationship;

@JsonProperty private String relationshipName; // remove

@JsonProperty private MetadataIdentifier relationshipType;

@JsonProperty private Instant createdAt; // remove

@JsonProperty private Instant createdAtClient;

@JsonProperty private Instant updatedAt; // remove

@JsonProperty private boolean bidirectional;

@JsonProperty private RelationshipItem from;

@JsonProperty private RelationshipItem to;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,27 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
// TODO(DHIS2-18222) Remove unused fields
public class TrackedEntity implements TrackerDto, Serializable {
@JsonProperty private String trackedEntity;

@JsonProperty private MetadataIdentifier trackedEntityType;

@JsonProperty private Instant createdAt; // remove

@JsonProperty private Instant createdAtClient;

@JsonProperty private Instant updatedAt; // remove

@JsonProperty private Instant updatedAtClient;

@JsonProperty private MetadataIdentifier orgUnit;

@JsonProperty private boolean inactive;

@JsonProperty private boolean deleted; // remove

@JsonProperty private boolean potentialDuplicate;

@JsonProperty private Geometry geometry;

@JsonProperty private String storedBy;

@JsonProperty private User createdBy; // remove

@JsonProperty private User updatedBy; // remove

@JsonProperty @Builder.Default
private List<Relationship> relationships = new ArrayList<>(); // remove

@JsonProperty @Builder.Default private List<Attribute> attributes = new ArrayList<>();

@JsonProperty @Builder.Default private List<Enrollment> enrollments = new ArrayList<>(); // remove

@Override
public String getUid() {
return this.trackedEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public class User implements Serializable {

@JsonProperty private String username;

@JsonProperty private String firstName;

@JsonProperty private String surname;

public boolean isEmpty() {
return isBlank(uid) && isBlank(username);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ private static TrackedEntity mapTrackedEntity(
.attributes(
mapTrackedEntityTypeAttributes(
submission.getValues(), existingAttributeValues, programAttributes))
.enrollments(
List.of(Enrollment.builder().enrollment(submission.getEnrollment().getUid()).build()))
.build();
}

Expand Down
Loading

0 comments on commit 24b1656

Please sign in to comment.