/** * Create the ValueObject collection to hold the set of DomainObjects. * * @param map - maps DomainObjects to created ValueObjects * @param domainObjectSet - Set of ims.clinical.domain.objects.PatientSpecialNeed objects. */ public static ims.clinical.vo.PatientSpecialNeedVoCollection createPatientSpecialNeedVoCollectionFromPatientSpecialNeed( DomainObjectMap map, java.util.Set domainObjectSet) { ims.clinical.vo.PatientSpecialNeedVoCollection voList = new ims.clinical.vo.PatientSpecialNeedVoCollection(); if (null == domainObjectSet) { return voList; } int rieCount = 0; int activeCount = 0; java.util.Iterator iterator = domainObjectSet.iterator(); while (iterator.hasNext()) { ims.clinical.domain.objects.PatientSpecialNeed domainObject = (ims.clinical.domain.objects.PatientSpecialNeed) iterator.next(); ims.clinical.vo.PatientSpecialNeedVo vo = create(map, domainObject); if (vo != null) voList.add(vo); if (domainObject != null) { if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true) rieCount++; else activeCount++; } } voList.setRieCount(rieCount); voList.setActiveCount(activeCount); return voList; }
/** * Create the ValueObject collection to hold the list of DomainObjects. * * @param map - maps DomainObjects to created ValueObjects * @param domainObjectList - List of ims.clinical.domain.objects.PatientSpecialNeed objects. */ public static ims.clinical.vo.PatientSpecialNeedVoCollection createPatientSpecialNeedVoCollectionFromPatientSpecialNeed( DomainObjectMap map, java.util.List domainObjectList) { ims.clinical.vo.PatientSpecialNeedVoCollection voList = new ims.clinical.vo.PatientSpecialNeedVoCollection(); if (null == domainObjectList) { return voList; } int rieCount = 0; int activeCount = 0; for (int i = 0; i < domainObjectList.size(); i++) { ims.clinical.domain.objects.PatientSpecialNeed domainObject = (ims.clinical.domain.objects.PatientSpecialNeed) domainObjectList.get(i); ims.clinical.vo.PatientSpecialNeedVo vo = create(map, domainObject); if (vo != null) voList.add(vo); if (domainObject != null) { if (domainObject.getIsRIE() != null && domainObject.getIsRIE().booleanValue() == true) rieCount++; else activeCount++; } } voList.setRieCount(rieCount); voList.setActiveCount(activeCount); return voList; }
public static ims.clinical.domain.objects.PatientSpecialNeed extractPatientSpecialNeed( ims.domain.ILightweightDomainFactory domainFactory, ims.clinical.vo.PatientSpecialNeedVo valueObject, HashMap domMap) { if (null == valueObject) { return null; } Integer id = valueObject.getID_PatientSpecialNeed(); ims.clinical.domain.objects.PatientSpecialNeed domainObject = null; if (null == id) { if (domMap.get(valueObject) != null) { return (ims.clinical.domain.objects.PatientSpecialNeed) domMap.get(valueObject); } // ims.clinical.vo.PatientSpecialNeedVo ID_PatientSpecialNeed field is unknown domainObject = new ims.clinical.domain.objects.PatientSpecialNeed(); domMap.put(valueObject, domainObject); } else { String key = (valueObject.getClass().getName() + "__" + valueObject.getID_PatientSpecialNeed()); if (domMap.get(key) != null) { return (ims.clinical.domain.objects.PatientSpecialNeed) domMap.get(key); } domainObject = (ims.clinical.domain.objects.PatientSpecialNeed) domainFactory.getDomainObject( ims.clinical.domain.objects.PatientSpecialNeed.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_PatientSpecialNeed()); // create LookupInstance from vo LookupType ims.domain.lookups.LookupInstance value1 = null; if (null != valueObject.getSpecialNeed()) { value1 = domainFactory.getLookupInstance(valueObject.getSpecialNeed().getID()); } domainObject.setSpecialNeed(value1); // 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.getDetails() != null && valueObject.getDetails().equals("")) { valueObject.setDetails(null); } domainObject.setDetails(valueObject.getDetails()); domainObject.setIsActive(valueObject.getIsActive()); return domainObject; }
/** * Create the ValueObject from the ims.clinical.domain.objects.PatientSpecialNeed object. * * @param map DomainObjectMap of DomainObjects to already created ValueObjects. * @param domainObject */ public static ims.clinical.vo.PatientSpecialNeedVo create( DomainObjectMap map, ims.clinical.domain.objects.PatientSpecialNeed domainObject) { if (null == domainObject) { return null; } // check if the domainObject already has a valueObject created for it ims.clinical.vo.PatientSpecialNeedVo valueObject = (ims.clinical.vo.PatientSpecialNeedVo) map.getValueObject(domainObject, ims.clinical.vo.PatientSpecialNeedVo.class); if (null == valueObject) { valueObject = new ims.clinical.vo.PatientSpecialNeedVo(domainObject.getId(), domainObject.getVersion()); map.addValueObject(domainObject, valueObject); valueObject = insert(map, valueObject, domainObject); } return valueObject; }
/** * Update the ValueObject with the Domain Object. * * @param map DomainObjectMap of DomainObjects to already created ValueObjects. * @param valueObject to be updated * @param domainObject ims.clinical.domain.objects.PatientSpecialNeed */ public static ims.clinical.vo.PatientSpecialNeedVo insert( DomainObjectMap map, ims.clinical.vo.PatientSpecialNeedVo valueObject, ims.clinical.domain.objects.PatientSpecialNeed domainObject) { if (null == domainObject) { return valueObject; } if (null == map) { map = new DomainObjectMap(); } valueObject.setID_PatientSpecialNeed(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; // SpecialNeed ims.domain.lookups.LookupInstance instance1 = domainObject.getSpecialNeed(); if (null != instance1) { ims.framework.utils.ImagePath img = null; ims.framework.utils.Color color = null; img = null; if (instance1.getImage() != null) { img = new ims.framework.utils.ImagePath( instance1.getImage().getImageId(), instance1.getImage().getImagePath()); } color = instance1.getColor(); if (color != null) color.getValue(); ims.core.vo.lookups.SpecialNeed voLookup1 = new ims.core.vo.lookups.SpecialNeed( instance1.getId(), instance1.getText(), instance1.isActive(), null, img, color); ims.core.vo.lookups.SpecialNeed parentVoLookup1 = voLookup1; ims.domain.lookups.LookupInstance parent1 = instance1.getParent(); while (parent1 != null) { if (parent1.getImage() != null) { img = new ims.framework.utils.ImagePath( parent1.getImage().getImageId(), parent1.getImage().getImagePath()); } else { img = null; } color = parent1.getColor(); if (color != null) color.getValue(); parentVoLookup1.setParent( new ims.core.vo.lookups.SpecialNeed( parent1.getId(), parent1.getText(), parent1.isActive(), null, img, color)); parentVoLookup1 = parentVoLookup1.getParent(); parent1 = parent1.getParent(); } valueObject.setSpecialNeed(voLookup1); } // Details valueObject.setDetails(domainObject.getDetails()); // isActive valueObject.setIsActive(domainObject.isIsActive()); return valueObject; }