Skip to content

Commit

Permalink
Merge pull request #1286 from dhis2/androsdk-1163
Browse files Browse the repository at this point in the history
fix: [ANDROSDK-1163] Do not crash if relationship is not tei-te
  • Loading branch information
vgarciabnz authored Jun 8, 2020
2 parents 18d180e + 30668a2 commit a1ab410
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.hisp.dhis.android.core.relationship.Relationship;
import org.hisp.dhis.android.core.relationship.RelationshipItem;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.inject.Inject;
Expand Down Expand Up @@ -65,6 +67,20 @@ final class RelationshipHandlerImpl extends IdentifiableHandlerImpl<Relationship
this.versionManager = versionManager;
}

@Override
protected Collection<Relationship> beforeCollectionHandled(Collection<Relationship> relationships) {
Collection<Relationship> supportedRelationships = new ArrayList<>();

for (Relationship relationship : relationships) {
// Only TEI - TEI relationships are supported so far
if (relationship.from().hasTrackedEntityInstance() && relationship.to().hasTrackedEntityInstance()) {
supportedRelationships.add(relationship);
}
}

return supportedRelationships;
}

@Override
protected Relationship beforeObjectHandled(Relationship relationship) {
if (!versionManager.isRelationshipSupported(relationship)) {
Expand Down

0 comments on commit a1ab410

Please sign in to comment.