From 30668a2566c07a6d334a415d5e9a1b51ca3e2b04 Mon Sep 17 00:00:00 2001 From: victor Date: Fri, 5 Jun 2020 16:56:13 +0200 Subject: [PATCH] [ANDROSDK-1163] Do not crash if relationship is not tei-te --- .../internal/RelationshipHandlerImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/src/main/java/org/hisp/dhis/android/core/relationship/internal/RelationshipHandlerImpl.java b/core/src/main/java/org/hisp/dhis/android/core/relationship/internal/RelationshipHandlerImpl.java index 4cd4334ff8..a6011ea238 100644 --- a/core/src/main/java/org/hisp/dhis/android/core/relationship/internal/RelationshipHandlerImpl.java +++ b/core/src/main/java/org/hisp/dhis/android/core/relationship/internal/RelationshipHandlerImpl.java @@ -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; @@ -65,6 +67,20 @@ final class RelationshipHandlerImpl extends IdentifiableHandlerImpl beforeCollectionHandled(Collection relationships) { + Collection 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)) {