public class SampleWorkingRelationshipReciprocalConversion
implements ReciprocalEvidenceConversion {
@Inject
private EvidenceTypeDefDAO etDefDAO;
@Inject
private EvidenceTypeVersionDefDAO etVerDefDAO;
public SampleWorkingRelationshipReciprocalConversion() {
}
public Object getReciprocal(
final Object original, final long targetCaseID)
throws AppException, InformationalException {
DynamicEvidenceDataDetails originalDetails = (DynamicEvidenceDataDetails) original;
String workingRelationshipOriginal =
originalDetails.getAttribute("workingRelationship").getValue();
String workingRelationshipRec = "";
if (workingRelationshipOriginal.equals("ISMANAGEROF")) {
workingRelationshipRec = "ISMANAGEDBY";
}
EvidenceTypeKey evdType = new EvidenceTypeKey();
evdType.evidenceType = "WORKINGRELATIONSHIP";
EvidenceTypeDef evdTypeDef =
etDefDAO.readActiveEvidenceTypeDefByTypeCode(evdType.evidenceType);
EvidenceTypeVersionDef evTypeVersion =
etVerDefDAO.getActiveEvidenceTypeVersionAtDate(evdTypeDef, Date.getCurrentDate());
DynamicEvidenceDataDetails reciprocalDetails =
DynamicEvidenceDataDetailsFactory.newInstance(evTypeVersion);
DynamicEvidenceDataAttributeDetails workingRelationshipAttr =
reciprocalDetails.getAttribute("workingRelationship");
DynamicEvidenceTypeConverter.setAttribute(workingRelationshipAttr, workingRelationshipRec);
DynamicEvidenceDataAttributeDetails participantAttr =
reciprocalDetails.getAttribute("participant");
DynamicEvidenceTypeConverter.setAttribute(participantAttr,
originalDetails.getAttribute("relatedParticipant").getValue());
DynamicEvidenceDataAttributeDetails relatedParticipantAttr =
reciprocalDetails.getAttribute("relatedParticipant");
DynamicEvidenceTypeConverter.setAttribute(relatedParticipantAttr,
originalDetails.getAttribute("participant").getValue());
return reciprocalDetails;
}
public Object getUpdatedReciprocal(
final Object original, final Object unmodifiedReciprocal)
throws AppException, InformationalException {
DynamicEvidenceDataDetails originalDetails =
(DynamicEvidenceDataDetails) original;
DynamicEvidenceDataDetails reciprocalDetails =
(DynamicEvidenceDataDetails) unmodifiedReciprocal;
long caseParticipantRoleIDRec = Long.parseLong(
reciprocalDetails.getAttribute("participant").getValue());
long relCaseParticipantRoleIDRec = Long.parseLong(
reciprocalDetails.getAttribute("relatedParticipant").getValue());
String workingRelationshipRec = reciprocalDetails.getAttribute("workingRelationship").getValue();
for (final DynamicEvidenceDataAttributeDetails listDetails: originalDetails.getAttributes()) {
reciprocalDetails.getAttribute(listDetails.getName()).setValue(
listDetails.getValue());
}
DynamicEvidenceDataAttributeDetails workingRelationshipAttr =
reciprocalDetails.getAttribute("workingRelationship");
DynamicEvidenceTypeConverter.setAttribute(workingRelationshipAttr, workingRelationshipRec);
DynamicEvidenceDataAttributeDetails participantAttr =
reciprocalDetails.getAttribute("participant");
DynamicEvidenceTypeConverter.setAttribute(participantAttr,
caseParticipantRoleIDRec);
DynamicEvidenceDataAttributeDetails relatedParticipantAttr =
reciprocalDetails.getAttribute("relatedParticipant");
DynamicEvidenceTypeConverter.setAttribute(relatedParticipantAttr,
relCaseParticipantRoleIDRec);
return reciprocalDetails;
}
public boolean matchEvidenceDetails(
final Object evidenceDetails1, final Object evidenceDetails2)
throws AppException, InformationalException {
DynamicEvidenceDataDetails dynamicEvidenceDataDetails1 =
(DynamicEvidenceDataDetails) evidenceDetails1;
DynamicEvidenceDataDetails dynamicEvidenceDataDetails2 =
(DynamicEvidenceDataDetails) evidenceDetails2;
curam.core.sl.intf.CaseParticipantRole caseParticipantRoleObj =
curam.core.sl.fact.CaseParticipantRoleFactory.newInstance();
CaseParticipantRoleKey caseParticipantRoleKey = new CaseParticipantRoleKey();
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
dynamicEvidenceDataDetails1.getAttribute("participant"));
Long concernRoleID1 =
caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
dynamicEvidenceDataDetails1.getAttribute("relatedParticipant"));
Long relConcernRoleID1 =
caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
dynamicEvidenceDataDetails2.getAttribute("participant"));
Long concernRoleID2 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
dynamicEvidenceDataDetails2.getAttribute("relatedParticipant"));
Long relConcernRoleID2 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
return dynamicEvidenceDataDetails1.getAttribute("workingRelationship").getValue().equals(
dynamicEvidenceDataDetails2.getAttribute("workingRelationship").getValue())
&& (concernRoleID1.longValue() == concernRoleID2.longValue())
&& (relConcernRoleID1.longValue() == relConcernRoleID2.longValue());
}
public boolean matchOriginalAndReciprocal(
final Object originalEvidence, final Object reciprocalEvidence)
throws AppException, InformationalException {
DynamicEvidenceDataDetails originalDetails =
(DynamicEvidenceDataDetails) originalEvidence;
DynamicEvidenceDataDetails reciprocalDetails =
(DynamicEvidenceDataDetails) reciprocalEvidence;
curam.core.sl.intf.CaseParticipantRole caseParticipantRoleObj =
curam.core.sl.fact.CaseParticipantRoleFactory.newInstance();
CaseParticipantRoleKey caseParticipantRoleKey = new CaseParticipantRoleKey();
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
originalDetails.getAttribute("participant"));
Long concernRoleID1 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
originalDetails.getAttribute("relatedParticipant"));
Long relConcernRoleID1 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
reciprocalDetails.getAttribute("participant"));
Long concernRoleID2 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
caseParticipantRoleKey.caseParticipantRoleID = (Long) DynamicEvidenceTypeConverter.convert(
reciprocalDetails.getAttribute("relatedParticipant"));
Long relConcernRoleID2 = caseParticipantRoleObj.readCaseIDandParticipantID(caseParticipantRoleKey).participantRoleID;
String workingRelationshipOriginal =
originalDetails.getAttribute("workingRelationship").getValue();
String workingRelationshipRec = "";
if (workingRelationshipOriginal.equals("ISMANAGEROF")) {
workingRelationshipRec = "ISMANAGEDBY";
}
return reciprocalDetails.getAttribute("workingRelationship").getValue().equals(
workingRelationshipRec)
&& (concernRoleID1.longValue() == relConcernRoleID2.longValue())
&& (relConcernRoleID1.longValue() == concernRoleID2.longValue());
}
public long getPrimaryParticipant(final Object originalEvidence)
throws AppException, InformationalException {
DynamicEvidenceDataDetails originalDetails = (DynamicEvidenceDataDetails) originalEvidence;
long caseParticipantRoleID = Long.parseLong(
originalDetails.getAttribute("participant").getValue());
CaseParticipantRoleKey caseParticipantRoleKey = new CaseParticipantRoleKey();
caseParticipantRoleKey.caseParticipantRoleID = caseParticipantRoleID;
return CaseParticipantRoleFactory.newInstance().read(caseParticipantRoleKey).participantRoleID;
}
public long getRelatedParticipant(final Object originalEvidence)
throws AppException, InformationalException {
DynamicEvidenceDataDetails originalDetails =
(DynamicEvidenceDataDetails) originalEvidence;
long caseParticipantRoleID = Long.parseLong(
originalDetails.getAttribute("relatedParticipant").getValue());
CaseParticipantRoleKey caseParticipantRoleKey = new CaseParticipantRoleKey();
caseParticipantRoleKey.caseParticipantRoleID = caseParticipantRoleID;
return CaseParticipantRoleFactory.newInstance().read(caseParticipantRoleKey).participantRoleID;
}
}