renaming in personsvc
This commit is contained in:
parent
687e24fa83
commit
f648d8ec2b
|
@ -155,7 +155,7 @@ public class EmpiLink {
|
|||
return this;
|
||||
}
|
||||
|
||||
public EmpiLink setSourceResourcePid(Long theSourceResourcePid) {
|
||||
public EmpiLink setGoldenResourcePid(Long theSourceResourcePid) {
|
||||
setPersonPid(theSourceResourcePid);
|
||||
|
||||
mySourceResourcePid = theSourceResourcePid;
|
||||
|
|
|
@ -91,7 +91,7 @@ public class EmpiLinkDaoSvc {
|
|||
return oExisting.get();
|
||||
} else {
|
||||
EmpiLink newLink = myEmpiLinkFactory.newEmpiLink();
|
||||
newLink.setSourceResourcePid(theSourceResourcePid);
|
||||
newLink.setGoldenResourcePid(theSourceResourcePid);
|
||||
newLink.setPersonPid(theSourceResourcePid);
|
||||
newLink.setTargetPid(theTargetResourcePid);
|
||||
return newLink;
|
||||
|
@ -104,7 +104,7 @@ public class EmpiLinkDaoSvc {
|
|||
}
|
||||
EmpiLink link = myEmpiLinkFactory.newEmpiLink();
|
||||
link.setTargetPid(theTargetResourcePid);
|
||||
link.setSourceResourcePid(theSourceResourcePid);
|
||||
link.setGoldenResourcePid(theSourceResourcePid);
|
||||
Example<EmpiLink> example = Example.of(link);
|
||||
return myEmpiLinkDao.findOne(example);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public class EmpiLinkDaoSvc {
|
|||
*/
|
||||
public Optional<EmpiLink> getEmpiLinksByPersonPidTargetPidAndMatchResult(Long thePersonPid, Long theTargetPid, EmpiMatchResultEnum theMatchResult) {
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink();
|
||||
exampleLink.setSourceResourcePid(thePersonPid);
|
||||
exampleLink.setGoldenResourcePid(thePersonPid);
|
||||
exampleLink.setTargetPid(theTargetPid);
|
||||
exampleLink.setMatchResult(theMatchResult);
|
||||
Example<EmpiLink> example = Example.of(exampleLink);
|
||||
|
@ -210,17 +210,17 @@ public class EmpiLinkDaoSvc {
|
|||
}
|
||||
|
||||
/**
|
||||
* Given a Person, return all links in which they are the source Person of the {@link EmpiLink}
|
||||
* Given a Golden Resource , return all links in which they are the source Person of the {@link EmpiLink}
|
||||
*
|
||||
* @param thePersonResource The {@link IBaseResource} Person who's links you would like to retrieve.
|
||||
* @return A list of all {@link EmpiLink} entities in which thePersonResource is the source Person.
|
||||
* @param theGoldenResource The {@link IBaseResource} Person who's links you would like to retrieve.
|
||||
* @return A list of all {@link EmpiLink} entities in which theGoldenResource is the source Person.
|
||||
*/
|
||||
public List<EmpiLink> findEmpiLinksBySourceResource(IBaseResource thePersonResource) {
|
||||
Long pid = myIdHelperService.getPidOrNull(thePersonResource);
|
||||
public List<EmpiLink> findEmpiLinksByGoldenResource(IBaseResource theGoldenResource) {
|
||||
Long pid = myIdHelperService.getPidOrNull(theGoldenResource);
|
||||
if (pid == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setSourceResourcePid(pid);
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setGoldenResourcePid(pid);
|
||||
Example<EmpiLink> example = Example.of(exampleLink);
|
||||
return myEmpiLinkDao.findAll(example);
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ public class EmpiLinkDaoSvc {
|
|||
if (sourcePid == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setTargetPid(targetPid).setSourceResourcePid(sourcePid);
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setTargetPid(targetPid).setGoldenResourcePid(sourcePid);
|
||||
Example<EmpiLink> example = Example.of(exampleLink);
|
||||
return myEmpiLinkDao.findAll(example);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public class EmpiLinkDaoSvc {
|
|||
if (pid == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setSourceResourcePid(pid);
|
||||
EmpiLink exampleLink = myEmpiLinkFactory.newEmpiLink().setGoldenResourcePid(pid);
|
||||
exampleLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||
Example<EmpiLink> example = Example.of(exampleLink);
|
||||
return myEmpiLinkDao.findAll(example);
|
||||
|
|
|
@ -79,7 +79,7 @@ public class EmpiLinkQuerySvcImpl implements IEmpiLinkQuerySvc {
|
|||
private Example<EmpiLink> exampleLinkFromParameters(IIdType thePersonId, IIdType theTargetId, EmpiMatchResultEnum theMatchResult, EmpiLinkSourceEnum theLinkSource) {
|
||||
EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink();
|
||||
if (thePersonId != null) {
|
||||
empiLink.setSourceResourcePid(myIdHelperService.getPidOrThrowException(thePersonId));
|
||||
empiLink.setGoldenResourcePid(myIdHelperService.getPidOrThrowException(thePersonId));
|
||||
}
|
||||
if (theTargetId != null) {
|
||||
empiLink.setTargetPid(myIdHelperService.getPidOrThrowException(theTargetId));
|
||||
|
|
|
@ -60,19 +60,23 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
|||
public IAnyResource mergeGoldenResources(IAnyResource theFromGoldenResource, IAnyResource theToGoldenResource, MdmTransactionContext theMdmTransactionContext) {
|
||||
Long toGoldenResourcePid = myIdHelperService.getPidOrThrowException(theToGoldenResource);
|
||||
|
||||
myPersonHelper.mergeFields(theFrom, theTo);
|
||||
myPersonHelper.mergeFields(theFromGoldenResource, theToGoldenResource);
|
||||
|
||||
mergeSourceResourceLinks(theFromGoldenResource, theToGoldenResource, toGoldenResourcePid, theMdmTransactionContext);
|
||||
mergeGoldenResourceLinks(theFromGoldenResource, theToGoldenResource, toGoldenResourcePid, theMdmTransactionContext);
|
||||
|
||||
//TODO GGG MDM: Is this just cleanup? In theory, the merge step from before shoulda done this..
|
||||
removeTargetLinks(theFromGoldenResource, theToGoldenResource, theMdmTransactionContext);
|
||||
|
||||
refreshLinksAndUpdatePerson(theToGoldenResource, theMdmTransactionContext);
|
||||
|
||||
myEmpiResourceDaoSvc.upsertSourceResource(theFromGoldenResource, theMdmTransactionContext.getResourceType());
|
||||
|
||||
Long fromGoldenResourcePid = myIdHelperService.getPidOrThrowException(theFromGoldenResource);
|
||||
addMergeLink(toGoldenResourcePid, fromGoldenResourcePid, theMdmTransactionContext.getResourceType());
|
||||
myPersonHelper.deactivateResource(theFromGoldenResource);
|
||||
//myPersonHelper.deactivateResource(theFromGoldenResource);
|
||||
|
||||
refreshLinksAndUpdatePerson(theFromGoldenResource, theMdmTransactionContext);
|
||||
//Remove HAPI-EMPI Managed TAG, add a different Ttag? e.g. HAPI-EMPI-DEPRECATED or something? This would serve the purpose.
|
||||
|
||||
myEmpiResourceDaoSvc.upsertSourceResource(theFromGoldenResource, theMdmTransactionContext.getResourceType());
|
||||
|
||||
log(theMdmTransactionContext, "Merged " + theFromGoldenResource.getIdElement().toVersionless() + " into " + theToGoldenResource.getIdElement().toVersionless());
|
||||
return theToGoldenResource;
|
||||
|
@ -86,9 +90,10 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
|||
* @param theMdmTransactionContext Context to keep track of the deletions
|
||||
*/
|
||||
private void removeTargetLinks(IAnyResource theFrom, IAnyResource theTo, MdmTransactionContext theMdmTransactionContext) {
|
||||
List<EmpiLink> allLinksWithTheFromAsTarget = myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(theFrom);
|
||||
List<EmpiLink> allLinksWithTheFromAsTarget = myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(theFrom);
|
||||
allLinksWithTheFromAsTarget
|
||||
.stream()
|
||||
//TODO GGG NG MDM: Why are we keeping manual links? Haven't we already copied those over in the previous merge step?
|
||||
.filter(EmpiLink::isAuto) // only keep manual links
|
||||
.forEach(l -> {
|
||||
theMdmTransactionContext.addTransactionLogMessage(String.format("Deleting link %s", l));
|
||||
|
@ -107,14 +112,10 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
|||
myEmpiLinkDaoSvc.save(empiLink);
|
||||
}
|
||||
|
||||
private void refreshLinksAndUpdatePerson(IAnyResource theToPerson, MdmTransactionContext theMdmTransactionContext) {
|
||||
// myEmpiLinkSvc.syncEmpiLinksToPersonLinks(theToPerson, theEmpiTransactionContext);
|
||||
myEmpiResourceDaoSvc.upsertSourceResource(theToPerson, theMdmTransactionContext.getResourceType());
|
||||
}
|
||||
|
||||
private void mergeSourceResourceLinks(IAnyResource theFromResource, IAnyResource theToResource, Long theToResourcePid, MdmTransactionContext theMdmTransactionContext) {
|
||||
List<EmpiLink> fromLinks = myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(theFromResource); // fromLinks - links going to theFromResource
|
||||
List<EmpiLink> toLinks = myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(theToResource); // toLinks - links going to theToResource
|
||||
private void mergeGoldenResourceLinks(IAnyResource theFromResource, IAnyResource theToResource, Long theToResourcePid, MdmTransactionContext theMdmTransactionContext) {
|
||||
List<EmpiLink> fromLinks = myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(theFromResource); // fromLinks - links going to theFromResource
|
||||
List<EmpiLink> toLinks = myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(theToResource); // toLinks - links going to theToResource
|
||||
|
||||
// For each incomingLink, either ignore it, move it, or replace the original one
|
||||
for (EmpiLink fromLink : fromLinks) {
|
||||
|
@ -122,7 +123,7 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
|||
if (optionalToLink.isPresent()) {
|
||||
// toLinks.remove(optionalToLink);
|
||||
|
||||
// The original links already contain this target, so move it over to the toPerson
|
||||
// The original links already contain this target, so move it over to the toResource
|
||||
EmpiLink toLink = optionalToLink.get();
|
||||
if (fromLink.isManual()) {
|
||||
switch (toLink.getLinkSource()) {
|
||||
|
@ -141,7 +142,7 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc {
|
|||
}
|
||||
}
|
||||
// The original links didn't contain this target, so move it over to the toPerson
|
||||
fromLink.setSourceResourcePid(theToResourcePid);
|
||||
fromLink.setGoldenResourcePid(theToResourcePid);
|
||||
ourLog.trace("Saving link {}", fromLink);
|
||||
myEmpiLinkDaoSvc.save(fromLink);
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ abstract public class BaseEmpiR4Test extends BaseJpaR4Test {
|
|||
EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink();
|
||||
empiLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
||||
empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||
empiLink.setSourceResourcePid(myIdHelperService.getPidOrNull(sourcePatient));
|
||||
empiLink.setGoldenResourcePid(myIdHelperService.getPidOrNull(sourcePatient));
|
||||
empiLink.setTargetPid(myIdHelperService.getPidOrNull(patient));
|
||||
return empiLink;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class EmpiExpungeTest extends BaseEmpiR4Test {
|
|||
EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink();
|
||||
empiLink.setLinkSource(EmpiLinkSourceEnum.MANUAL);
|
||||
empiLink.setMatchResult(EmpiMatchResultEnum.MATCH);
|
||||
empiLink.setSourceResourcePid(mySourceEntity.getId());
|
||||
empiLink.setGoldenResourcePid(mySourceEntity.getId());
|
||||
empiLink.setTargetPid(myTargetEntity.getId());
|
||||
saveLink(empiLink);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class EmpiProviderQueryLinkR4Test extends BaseLinkR4Test {
|
|||
myPerson2Id = new StringType(sourcePatient2.getIdElement().toVersionless().getValue());
|
||||
Long sourcePatient2Pid = myIdHelperService.getPidOrNull(sourcePatient2);
|
||||
|
||||
EmpiLink possibleDuplicateEmpiLink = myEmpiLinkDaoSvc.newEmpiLink().setSourceResourcePid(sourcePatient1Pid).setTargetPid(sourcePatient2Pid).setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(EmpiLinkSourceEnum.AUTO);
|
||||
EmpiLink possibleDuplicateEmpiLink = myEmpiLinkDaoSvc.newEmpiLink().setGoldenResourcePid(sourcePatient1Pid).setTargetPid(sourcePatient2Pid).setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE).setLinkSource(EmpiLinkSourceEnum.AUTO);
|
||||
saveLink(possibleDuplicateEmpiLink);
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class EmpiLinkSvcTest extends BaseEmpiR4Test {
|
|||
|
||||
private void saveNoMatchLink(Long thePersonPid, Long theTargetPid) {
|
||||
EmpiLink noMatchLink = myEmpiLinkDaoSvc.newEmpiLink()
|
||||
.setSourceResourcePid(thePersonPid)
|
||||
.setGoldenResourcePid(thePersonPid)
|
||||
.setTargetPid(theTargetPid)
|
||||
.setLinkSource(EmpiLinkSourceEnum.MANUAL)
|
||||
.setMatchResult(EmpiMatchResultEnum.NO_MATCH);
|
||||
|
|
|
@ -121,7 +121,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
|||
@Test
|
||||
public void mergeRemovesPossibleDuplicatesLink() {
|
||||
EmpiLink empiLink = myEmpiLinkDaoSvc.newEmpiLink()
|
||||
.setSourceResourcePid(myToGoldenPatientPid)
|
||||
.setGoldenResourcePid(myToGoldenPatientPid)
|
||||
.setTargetPid(myFromGoldenPatientPid)
|
||||
.setEmpiTargetType("Patient")
|
||||
.setMatchResult(EmpiMatchResultEnum.POSSIBLE_DUPLICATE)
|
||||
|
@ -206,7 +206,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
|||
}
|
||||
|
||||
private List<EmpiLink> getNonRedirectLinksByPerson(Patient theGoldenPatient) {
|
||||
return myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(theGoldenPatient).stream()
|
||||
return myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(theGoldenPatient).stream()
|
||||
.filter(link -> !link.isRedirect())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
|||
|
||||
|
||||
private void assertResourceHasLinkCount(IBaseResource theResource, int theCount) {
|
||||
List<EmpiLink> links = myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(theResource);
|
||||
List<EmpiLink> links = myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(theResource);
|
||||
assertEquals(theCount, links.size());
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ public class EmpiPersonMergerSvcTest extends BaseEmpiR4Test {
|
|||
}
|
||||
|
||||
private void assertResourceHasAutoLinkCount(Patient myToGoldenPatient, int theCount) {
|
||||
List<EmpiLink> links = myEmpiLinkDaoSvc.findEmpiLinksBySourceResource(myToGoldenPatient);
|
||||
List<EmpiLink> links = myEmpiLinkDaoSvc.findEmpiLinksByGoldenResource(myToGoldenPatient);
|
||||
assertEquals(theCount, links.stream().filter(EmpiLink::isAuto).count());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue