/** * Copy one ValueObject to another * * @param valueObjectDest to be updated * @param valueObjectSrc to copy values from */ public static ims.ocs_if.vo.IfOcsOrderShortVo copy( ims.ocs_if.vo.IfOcsOrderShortVo valueObjectDest, ims.ocs_if.vo.IfOcsOrderShortVo valueObjectSrc) { if (null == valueObjectSrc) { return valueObjectSrc; } valueObjectDest.setID_OcsOrderSession(valueObjectSrc.getID_OcsOrderSession()); valueObjectDest.setIsRIE(valueObjectSrc.getIsRIE()); // Patient valueObjectDest.setPatient(valueObjectSrc.getPatient()); // OrderedBy valueObjectDest.setOrderedBy(valueObjectSrc.getOrderedBy()); // ResponsibleClinician valueObjectDest.setResponsibleClinician(valueObjectSrc.getResponsibleClinician()); // ResponsibleGp valueObjectDest.setResponsibleGp(valueObjectSrc.getResponsibleGp()); // PatientLocation valueObjectDest.setPatientLocation(valueObjectSrc.getPatientLocation()); // PatientClinic valueObjectDest.setPatientClinic(valueObjectSrc.getPatientClinic()); // AdditClinNotes valueObjectDest.setAdditClinNotes(valueObjectSrc.getAdditClinNotes()); // SendNumber valueObjectDest.setSendNumber(valueObjectSrc.getSendNumber()); return valueObjectDest; }
public static ims.ocrr.orderingresults.domain.objects.OcsOrderSession extractOcsOrderSession( ims.domain.ILightweightDomainFactory domainFactory, ims.ocs_if.vo.IfOcsOrderShortVo valueObject, HashMap domMap) { if (null == valueObject) { return null; } Integer id = valueObject.getID_OcsOrderSession(); ims.ocrr.orderingresults.domain.objects.OcsOrderSession domainObject = null; if (null == id) { if (domMap.get(valueObject) != null) { return (ims.ocrr.orderingresults.domain.objects.OcsOrderSession) domMap.get(valueObject); } // ims.ocs_if.vo.IfOcsOrderShortVo ID_OcsOrderSession field is unknown domainObject = new ims.ocrr.orderingresults.domain.objects.OcsOrderSession(); domMap.put(valueObject, domainObject); } else { String key = (valueObject.getClass().getName() + "__" + valueObject.getID_OcsOrderSession()); if (domMap.get(key) != null) { return (ims.ocrr.orderingresults.domain.objects.OcsOrderSession) domMap.get(key); } domainObject = (ims.ocrr.orderingresults.domain.objects.OcsOrderSession) domainFactory.getDomainObject( ims.ocrr.orderingresults.domain.objects.OcsOrderSession.class, id); // TODO: Not sure how this should be handled. Effectively it must be a staleobject exception, // but maybe should be handled as that further up. if (domainObject == null) return null; domMap.put(key, domainObject); } domainObject.setVersion(valueObject.getVersion_OcsOrderSession()); ims.core.patient.domain.objects.Patient value1 = null; if (null != valueObject.getPatient()) { if (valueObject.getPatient().getBoId() == null) { if (domMap.get(valueObject.getPatient()) != null) { value1 = (ims.core.patient.domain.objects.Patient) domMap.get(valueObject.getPatient()); } } else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the // BO field { value1 = domainObject.getPatient(); } else { value1 = (ims.core.patient.domain.objects.Patient) domainFactory.getDomainObject( ims.core.patient.domain.objects.Patient.class, valueObject.getPatient().getBoId()); } } domainObject.setPatient(value1); // SaveAsRefVO - treated as a refVo in extract methods ims.core.resource.people.domain.objects.MemberOfStaff value2 = null; if (null != valueObject.getOrderedBy()) { if (valueObject.getOrderedBy().getBoId() == null) { if (domMap.get(valueObject.getOrderedBy()) != null) { value2 = (ims.core.resource.people.domain.objects.MemberOfStaff) domMap.get(valueObject.getOrderedBy()); } } else { value2 = (ims.core.resource.people.domain.objects.MemberOfStaff) domainFactory.getDomainObject( ims.core.resource.people.domain.objects.MemberOfStaff.class, valueObject.getOrderedBy().getBoId()); } } domainObject.setOrderedBy(value2); // SaveAsRefVO - treated as a refVo in extract methods ims.core.resource.people.domain.objects.Hcp value3 = null; if (null != valueObject.getResponsibleClinician()) { if (valueObject.getResponsibleClinician().getBoId() == null) { if (domMap.get(valueObject.getResponsibleClinician()) != null) { value3 = (ims.core.resource.people.domain.objects.Hcp) domMap.get(valueObject.getResponsibleClinician()); } } else { value3 = (ims.core.resource.people.domain.objects.Hcp) domainFactory.getDomainObject( ims.core.resource.people.domain.objects.Hcp.class, valueObject.getResponsibleClinician().getBoId()); } } domainObject.setResponsibleClinician(value3); // SaveAsRefVO - treated as a refVo in extract methods ims.core.resource.people.domain.objects.Gp value4 = null; if (null != valueObject.getResponsibleGp()) { if (valueObject.getResponsibleGp().getBoId() == null) { if (domMap.get(valueObject.getResponsibleGp()) != null) { value4 = (ims.core.resource.people.domain.objects.Gp) domMap.get(valueObject.getResponsibleGp()); } } else { value4 = (ims.core.resource.people.domain.objects.Gp) domainFactory.getDomainObject( ims.core.resource.people.domain.objects.Gp.class, valueObject.getResponsibleGp().getBoId()); } } domainObject.setResponsibleGp(value4); ims.core.resource.place.domain.objects.Location value5 = null; if (null != valueObject.getPatientLocation()) { if (valueObject.getPatientLocation().getBoId() == null) { if (domMap.get(valueObject.getPatientLocation()) != null) { value5 = (ims.core.resource.place.domain.objects.Location) domMap.get(valueObject.getPatientLocation()); } } else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the // BO field { value5 = domainObject.getPatientLocation(); } else { value5 = (ims.core.resource.place.domain.objects.Location) domainFactory.getDomainObject( ims.core.resource.place.domain.objects.Location.class, valueObject.getPatientLocation().getBoId()); } } domainObject.setPatientLocation(value5); ims.core.resource.place.domain.objects.Clinic value6 = null; if (null != valueObject.getPatientClinic()) { if (valueObject.getPatientClinic().getBoId() == null) { if (domMap.get(valueObject.getPatientClinic()) != null) { value6 = (ims.core.resource.place.domain.objects.Clinic) domMap.get(valueObject.getPatientClinic()); } } else if (valueObject.getBoVersion() == -1) // RefVo was not modified since obtained from the Assembler, no need to update the // BO field { value6 = domainObject.getPatientClinic(); } else { value6 = (ims.core.resource.place.domain.objects.Clinic) domainFactory.getDomainObject( ims.core.resource.place.domain.objects.Clinic.class, valueObject.getPatientClinic().getBoId()); } } domainObject.setPatientClinic(value6); // This is to overcome a bug in both Sybase and Oracle which prevents them from storing an empty // string correctly // Sybase stores it as a single space, Oracle stores it as NULL. This fix will make them // consistent at least. if (valueObject.getAdditClinNotes() != null && valueObject.getAdditClinNotes().equals("")) { valueObject.setAdditClinNotes(null); } domainObject.setAdditClinNotes(valueObject.getAdditClinNotes()); domainObject.setSendNumber(valueObject.getSendNumber()); return domainObject; }
/** * Update the ValueObject with the Domain Object. * * @param map DomainObjectMap of DomainObjects to already created ValueObjects. * @param valueObject to be updated * @param domainObject ims.ocrr.orderingresults.domain.objects.OcsOrderSession */ public static ims.ocs_if.vo.IfOcsOrderShortVo insert( DomainObjectMap map, ims.ocs_if.vo.IfOcsOrderShortVo valueObject, ims.ocrr.orderingresults.domain.objects.OcsOrderSession domainObject) { if (null == domainObject) { return valueObject; } if (null == map) { map = new DomainObjectMap(); } valueObject.setID_OcsOrderSession(domainObject.getId()); valueObject.setIsRIE(domainObject.getIsRIE()); // If this is a recordedInError record, and the domainObject // value isIncludeRecord has not been set, then we return null and // not the value object if (valueObject.getIsRIE() != null && valueObject.getIsRIE().booleanValue() == true && !domainObject.isIncludeRecord()) return null; // If this is not a recordedInError record, and the domainObject // value isIncludeRecord has been set, then we return null and // not the value object if ((valueObject.getIsRIE() == null || valueObject.getIsRIE().booleanValue() == false) && domainObject.isIncludeRecord()) return null; // Patient if (domainObject.getPatient() != null) { if (domainObject.getPatient() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the // id already. { HibernateProxy p = (HibernateProxy) domainObject.getPatient(); int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString()); valueObject.setPatient(new ims.core.patient.vo.PatientRefVo(id, -1)); } else { valueObject.setPatient( new ims.core.patient.vo.PatientRefVo( domainObject.getPatient().getId(), domainObject.getPatient().getVersion())); } } // OrderedBy valueObject.setOrderedBy( ims.core.vo.domain.MemberOfStaffLiteVoAssembler.create(map, domainObject.getOrderedBy())); // ResponsibleClinician valueObject.setResponsibleClinician( ims.core.vo.domain.HcpLiteVoAssembler.create(map, domainObject.getResponsibleClinician())); // ResponsibleGp valueObject.setResponsibleGp( ims.core.vo.domain.GpLiteVoAssembler.create(map, domainObject.getResponsibleGp())); // PatientLocation if (domainObject.getPatientLocation() != null) { if (domainObject.getPatientLocation() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the // id already. { HibernateProxy p = (HibernateProxy) domainObject.getPatientLocation(); int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString()); valueObject.setPatientLocation(new ims.core.resource.place.vo.LocationRefVo(id, -1)); } else { valueObject.setPatientLocation( new ims.core.resource.place.vo.LocationRefVo( domainObject.getPatientLocation().getId(), domainObject.getPatientLocation().getVersion())); } } // PatientClinic if (domainObject.getPatientClinic() != null) { if (domainObject.getPatientClinic() instanceof HibernateProxy) // If the proxy is set, there is no need to lazy load, the proxy knows the // id already. { HibernateProxy p = (HibernateProxy) domainObject.getPatientClinic(); int id = Integer.parseInt(p.getHibernateLazyInitializer().getIdentifier().toString()); valueObject.setPatientClinic(new ims.core.resource.place.vo.ClinicRefVo(id, -1)); } else { valueObject.setPatientClinic( new ims.core.resource.place.vo.ClinicRefVo( domainObject.getPatientClinic().getId(), domainObject.getPatientClinic().getVersion())); } } // AdditClinNotes valueObject.setAdditClinNotes(domainObject.getAdditClinNotes()); // SendNumber valueObject.setSendNumber(domainObject.isSendNumber()); return valueObject; }