/** * Create the ValueObject collection to hold the list of DomainObjects. * * @param map - maps DomainObjects to created ValueObjects * @param domainObjectList - List of ims.icps.configuration.domain.objects.ICPPhase objects. */ public static ims.icp.vo.ICPPhaseListVoCollection createICPPhaseListVoCollectionFromICPPhase( DomainObjectMap map, java.util.List domainObjectList) { ims.icp.vo.ICPPhaseListVoCollection voList = new ims.icp.vo.ICPPhaseListVoCollection(); if (null == domainObjectList) { return voList; } int rieCount = 0; int activeCount = 0; for (int i = 0; i < domainObjectList.size(); i++) { ims.icps.configuration.domain.objects.ICPPhase domainObject = (ims.icps.configuration.domain.objects.ICPPhase) domainObjectList.get(i); ims.icp.vo.ICPPhaseListVo 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 set of DomainObjects. * * @param map - maps DomainObjects to created ValueObjects * @param domainObjectSet - Set of ims.icps.configuration.domain.objects.ICPPhase objects. */ public static ims.icp.vo.ICPPhaseListVoCollection createICPPhaseListVoCollectionFromICPPhase( DomainObjectMap map, java.util.Set domainObjectSet) { ims.icp.vo.ICPPhaseListVoCollection voList = new ims.icp.vo.ICPPhaseListVoCollection(); if (null == domainObjectSet) { return voList; } int rieCount = 0; int activeCount = 0; java.util.Iterator iterator = domainObjectSet.iterator(); while (iterator.hasNext()) { ims.icps.configuration.domain.objects.ICPPhase domainObject = (ims.icps.configuration.domain.objects.ICPPhase) iterator.next(); ims.icp.vo.ICPPhaseListVo 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.icps.configuration.domain.objects.ICPPhase extractICPPhase( ims.domain.ILightweightDomainFactory domainFactory, ims.icp.vo.ICPPhaseListVo valueObject, HashMap domMap) { if (null == valueObject) { return null; } Integer id = valueObject.getID_ICPPhase(); ims.icps.configuration.domain.objects.ICPPhase domainObject = null; if (null == id) { if (domMap.get(valueObject) != null) { return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(valueObject); } // ims.icp.vo.ICPPhaseListVo ID_ICPPhase field is unknown domainObject = new ims.icps.configuration.domain.objects.ICPPhase(); domMap.put(valueObject, domainObject); } else { String key = (valueObject.getClass().getName() + "__" + valueObject.getID_ICPPhase()); if (domMap.get(key) != null) { return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(key); } domainObject = (ims.icps.configuration.domain.objects.ICPPhase) domainFactory.getDomainObject( ims.icps.configuration.domain.objects.ICPPhase.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_ICPPhase()); // 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.getName() != null && valueObject.getName().equals("")) { valueObject.setName(null); } domainObject.setName(valueObject.getName()); // 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.getDescription() != null && valueObject.getDescription().equals("")) { valueObject.setDescription(null); } domainObject.setDescription(valueObject.getDescription()); // create LookupInstance from vo LookupType ims.domain.lookups.LookupInstance value3 = null; if (null != valueObject.getStatus()) { value3 = domainFactory.getLookupInstance(valueObject.getStatus().getID()); } domainObject.setStatus(value3); return domainObject; }
/** * Create the ValueObject from the ims.icps.configuration.domain.objects.ICPPhase object. * * @param map DomainObjectMap of DomainObjects to already created ValueObjects. * @param domainObject */ public static ims.icp.vo.ICPPhaseVo create( DomainObjectMap map, ims.icps.configuration.domain.objects.ICPPhase domainObject) { if (null == domainObject) { return null; } // check if the domainObject already has a valueObject created for it ims.icp.vo.ICPPhaseVo valueObject = (ims.icp.vo.ICPPhaseVo) map.getValueObject(domainObject, ims.icp.vo.ICPPhaseVo.class); if (null == valueObject) { valueObject = new ims.icp.vo.ICPPhaseVo(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.icps.configuration.domain.objects.ICPPhase */ public static ims.icp.vo.ICPPhaseListVo insert( DomainObjectMap map, ims.icp.vo.ICPPhaseListVo valueObject, ims.icps.configuration.domain.objects.ICPPhase domainObject) { if (null == domainObject) { return valueObject; } if (null == map) { map = new DomainObjectMap(); } valueObject.setID_ICPPhase(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; // Name valueObject.setName(domainObject.getName()); // Description valueObject.setDescription(domainObject.getDescription()); // Status ims.domain.lookups.LookupInstance instance3 = domainObject.getStatus(); if (null != instance3) { ims.framework.utils.ImagePath img = null; ims.framework.utils.Color color = null; img = null; if (instance3.getImage() != null) { img = new ims.framework.utils.ImagePath( instance3.getImage().getImageId(), instance3.getImage().getImagePath()); } color = instance3.getColor(); if (color != null) color.getValue(); ims.core.vo.lookups.PreActiveActiveInactiveStatus voLookup3 = new ims.core.vo.lookups.PreActiveActiveInactiveStatus( instance3.getId(), instance3.getText(), instance3.isActive(), null, img, color); ims.core.vo.lookups.PreActiveActiveInactiveStatus parentVoLookup3 = voLookup3; ims.domain.lookups.LookupInstance parent3 = instance3.getParent(); while (parent3 != null) { if (parent3.getImage() != null) { img = new ims.framework.utils.ImagePath( parent3.getImage().getImageId(), parent3.getImage().getImagePath()); } else { img = null; } color = parent3.getColor(); if (color != null) color.getValue(); parentVoLookup3.setParent( new ims.core.vo.lookups.PreActiveActiveInactiveStatus( parent3.getId(), parent3.getText(), parent3.isActive(), null, img, color)); parentVoLookup3 = parentVoLookup3.getParent(); parent3 = parent3.getParent(); } valueObject.setStatus(voLookup3); } return valueObject; }
public static ims.icps.configuration.domain.objects.ICPPhase extractICPPhase( ims.domain.ILightweightDomainFactory domainFactory, ims.icp.vo.ICPPhaseVo valueObject, HashMap domMap) { if (null == valueObject) { return null; } Integer id = valueObject.getID_ICPPhase(); ims.icps.configuration.domain.objects.ICPPhase domainObject = null; if (null == id) { if (domMap.get(valueObject) != null) { return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(valueObject); } // ims.icp.vo.ICPPhaseVo ID_ICPPhase field is unknown domainObject = new ims.icps.configuration.domain.objects.ICPPhase(); domMap.put(valueObject, domainObject); } else { String key = (valueObject.getClass().getName() + "__" + valueObject.getID_ICPPhase()); if (domMap.get(key) != null) { return (ims.icps.configuration.domain.objects.ICPPhase) domMap.get(key); } domainObject = (ims.icps.configuration.domain.objects.ICPPhase) domainFactory.getDomainObject( ims.icps.configuration.domain.objects.ICPPhase.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_ICPPhase()); domainObject.setRules( ims.admin.vo.domain.BusinessRuleVoAssembler.extractBusinessRuleSet( domainFactory, valueObject.getRules(), domainObject.getRules(), domMap)); // 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.getDescription() != null && valueObject.getDescription().equals("")) { valueObject.setDescription(null); } domainObject.setDescription(valueObject.getDescription()); domainObject.setIsActivatedOnInitiation(valueObject.getIsActivatedOnInitiation()); // SaveAsRefVO treated as RefValueObject ims.icps.configuration.vo.ICPActionRefVoCollection refCollection4 = new ims.icps.configuration.vo.ICPActionRefVoCollection(); if (valueObject.getActions() != null) { for (int i4 = 0; i4 < valueObject.getActions().size(); i4++) { ims.icps.configuration.vo.ICPActionRefVo ref4 = (ims.icps.configuration.vo.ICPActionRefVo) valueObject.getActions().get(i4); refCollection4.add(ref4); } } int size4 = (null == refCollection4) ? 0 : refCollection4.size(); java.util.Set domainActions4 = domainObject.getActions(); if (domainActions4 == null) { domainActions4 = new java.util.HashSet(); } java.util.Set newSet4 = new java.util.HashSet(); for (int i = 0; i < size4; i++) { ims.icps.configuration.vo.ICPActionRefVo vo = refCollection4.get(i); ims.icps.configuration.domain.objects.ICPAction dom = null; if (null != vo) { if (vo.getBoId() == null) { if (domMap.get(vo) != null) { dom = (ims.icps.configuration.domain.objects.ICPAction) domMap.get(vo); } } else { dom = (ims.icps.configuration.domain.objects.ICPAction) domainFactory.getDomainObject( ims.icps.configuration.domain.objects.ICPAction.class, vo.getBoId()); } } // Trying to avoid the hibernate collection being marked as dirty via its public interface // methods. (like add) if (!domainActions4.contains(dom)) { domainActions4.add(dom); } newSet4.add(dom); } java.util.Set removedSet4 = new java.util.HashSet(); java.util.Iterator iter4 = domainActions4.iterator(); // Find out which objects need to be removed while (iter4.hasNext()) { ims.domain.DomainObject o = (ims.domain.DomainObject) iter4.next(); if ((o == null || o.getIsRIE() == null || !o.getIsRIE().booleanValue()) && !newSet4.contains(o)) { removedSet4.add(o); } } iter4 = removedSet4.iterator(); // Remove the unwanted objects while (iter4.hasNext()) { domainActions4.remove(iter4.next()); } domainObject.setActions(domainActions4); // 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.getName() != null && valueObject.getName().equals("")) { valueObject.setName(null); } domainObject.setName(valueObject.getName()); domainObject.setGoals( ims.icp.vo.domain.IcpPhaseGoalVoAssembler.extractICPPhaseGoalSet( domainFactory, valueObject.getGoals(), domainObject.getGoals(), domMap)); // 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.getHelpURL() != null && valueObject.getHelpURL().equals("")) { valueObject.setHelpURL(null); } domainObject.setHelpURL(valueObject.getHelpURL()); domainObject.setSequence(valueObject.getSequence()); // create LookupInstance from vo LookupType ims.domain.lookups.LookupInstance value9 = null; if (null != valueObject.getStatus()) { value9 = domainFactory.getLookupInstance(valueObject.getStatus().getID()); } domainObject.setStatus(value9); 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.icps.configuration.domain.objects.ICPPhase */ public static ims.icp.vo.ICPPhaseVo insert( DomainObjectMap map, ims.icp.vo.ICPPhaseVo valueObject, ims.icps.configuration.domain.objects.ICPPhase domainObject) { if (null == domainObject) { return valueObject; } if (null == map) { map = new DomainObjectMap(); } valueObject.setID_ICPPhase(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; // Rules valueObject.setRules( ims.admin.vo.domain.BusinessRuleVoAssembler.createBusinessRuleVoCollectionFromBusinessRule( map, domainObject.getRules())); // Description valueObject.setDescription(domainObject.getDescription()); // isActivatedOnInitiation valueObject.setIsActivatedOnInitiation(domainObject.isIsActivatedOnInitiation()); // Actions valueObject.setActions( ims.icp.vo.domain.ICPActionLiteVoAssembler.createICPActionLiteVoCollectionFromICPAction( map, domainObject.getActions())); // Name valueObject.setName(domainObject.getName()); // Goals valueObject.setGoals( ims.icp.vo.domain.IcpPhaseGoalVoAssembler.createIcpPhaseGoalVoCollectionFromICPPhaseGoal( map, domainObject.getGoals())); // HelpURL valueObject.setHelpURL(domainObject.getHelpURL()); // Sequence valueObject.setSequence(domainObject.getSequence()); // Status ims.domain.lookups.LookupInstance instance9 = domainObject.getStatus(); if (null != instance9) { ims.framework.utils.ImagePath img = null; ims.framework.utils.Color color = null; img = null; if (instance9.getImage() != null) { img = new ims.framework.utils.ImagePath( instance9.getImage().getImageId(), instance9.getImage().getImagePath()); } color = instance9.getColor(); if (color != null) color.getValue(); ims.core.vo.lookups.PreActiveActiveInactiveStatus voLookup9 = new ims.core.vo.lookups.PreActiveActiveInactiveStatus( instance9.getId(), instance9.getText(), instance9.isActive(), null, img, color); ims.core.vo.lookups.PreActiveActiveInactiveStatus parentVoLookup9 = voLookup9; ims.domain.lookups.LookupInstance parent9 = instance9.getParent(); while (parent9 != null) { if (parent9.getImage() != null) { img = new ims.framework.utils.ImagePath( parent9.getImage().getImageId(), parent9.getImage().getImagePath()); } else { img = null; } color = parent9.getColor(); if (color != null) color.getValue(); parentVoLookup9.setParent( new ims.core.vo.lookups.PreActiveActiveInactiveStatus( parent9.getId(), parent9.getText(), parent9.isActive(), null, img, color)); parentVoLookup9 = parentVoLookup9.getParent(); parent9 = parent9.getParent(); } valueObject.setStatus(voLookup9); } return valueObject; }