From 1e41621eca369ceb8e3a116db4002d1b334cc33f Mon Sep 17 00:00:00 2001 From: Nick Goupinets Date: Thu, 19 Aug 2021 16:43:51 -0400 Subject: [PATCH] Rolled back changes --- .../ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java | 9 -------- .../fhir/jpa/dao/mdm/MdmLinkExpandSvc.java | 22 +++---------------- .../fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java | 9 -------- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java index be0a6289a4e..16834facbe2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IMdmLinkDao.java @@ -67,13 +67,4 @@ public interface IMdmLinkDao extends JpaRepository { "AND ml.myMatchResult=:matchResult") List expandPidsBySourcePidAndMatchResult(@Param("sourcePid") Long theSourcePid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum); - @Query("SELECT DISTINCT ml.myGoldenResourcePid as goldenPid, ml.mySourcePid as sourcePid " + - "FROM MdmLink ml " + - "INNER JOIN MdmLink ml2 " + - "ON ml.myGoldenResourcePid = ml2.myGoldenResourcePid " + - "WHERE (ml2.mySourcePid = :sourceOrGoldenPid OR ml2.myGoldenResourcePid = :sourceOrGoldenPid) " + - "AND ml2.myMatchResult=:matchResult " + - "AND ml.myMatchResult=:matchResult") - List expandPidsBySourceOrGoldenResourcePidAndMatchResult(@Param("sourceOrGoldenPid") Long theSourceOrGoldenPid, @Param("matchResult") MdmMatchResultEnum theMdmMatchResultEnum); - } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkExpandSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkExpandSvc.java index b03e22d04b8..66af7f5a706 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkExpandSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkExpandSvc.java @@ -72,19 +72,6 @@ public class MdmLinkExpandSvc { return expandMdmBySourceResourcePid(pidOrThrowException); } - /** - * Given a resource ID of a source resource or golden resource, perform MDM expansion and return all the resource - * IDs of all resources that are MDM-Matched to this resource. - * - * @param theId The Resource ID of the resource to MDM-Expand - * @return A set of strings representing the FHIR ids of the expanded resources. - */ - public Set expandMdmBySourceOrGoldenResourceId(IIdType theId) { - ourLog.debug("About to expand source resource with resource id {}", theId); - Long pidOrThrowException = myIdHelperService.getPidOrThrowException(theId); - return flatten(myMdmLinkDao.expandPidsBySourceOrGoldenResourcePidAndMatchResult(pidOrThrowException, MdmMatchResultEnum.MATCH)); - } - /** * Given a PID of a source resource, perform MDM expansion and return all the resource IDs of all resources that are * MDM-Matched to this resource. @@ -94,17 +81,14 @@ public class MdmLinkExpandSvc { */ public Set expandMdmBySourceResourcePid(Long theSourceResourcePid) { ourLog.debug("About to expand source resource with PID {}", theSourceResourcePid); - return flatten(myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourceResourcePid, MdmMatchResultEnum.MATCH)); - } - - protected Set flatten(List thePidTuples) { + List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourceResourcePid, MdmMatchResultEnum.MATCH); Set flattenedPids = new HashSet<>(); - thePidTuples.forEach(tuple -> { + goldenPidSourcePidTuples.forEach(tuple -> { flattenedPids.add(tuple.getSourcePid()); flattenedPids.add(tuple.getGoldenPid()); }); Set resourceIds = myIdHelperService.translatePidsToFhirResourceIds(flattenedPids); - ourLog.debug("Expanded pids are [{}]", String.join(",", resourceIds)); + ourLog.debug("Pid {} has been expanded to [{}]", theSourceResourcePid, String.join(",", resourceIds)); return resourceIds; } diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java index b5deb25f0c6..ae034af6fa7 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java @@ -83,15 +83,6 @@ public class MdmLinkDaoSvcTest extends BaseMdmR4Test { assertThat(lists, hasSize(10)); - lists.stream() - .forEach(tuple -> { - assertThat(tuple.getGoldenPid(), is(equalTo(golden.getIdElement().getIdPartAsLong()))); - assertThat(tuple.getSourcePid(), is(in(expectedExpandedPids))); - }); - - lists = myMdmLinkDao.expandPidsBySourceOrGoldenResourcePidAndMatchResult(mdmLinks.get(0).getGoldenResourcePid(), MdmMatchResultEnum.MATCH); - assertThat(lists, hasSize(10)); - lists.stream() .forEach(tuple -> { assertThat(tuple.getGoldenPid(), is(equalTo(golden.getIdElement().getIdPartAsLong())));