public ims.assessment.vo.UserDefinedObjectListVo getCurrentUserDefinedForm() { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer("select id from UserDefinedObject u "); hql.append(" where u.activeStatus = :status"); hql.append(" and u.objectType = :type"); List<?> results = factory.find(hql.toString(), new String[] {"status", "type"}, new Object[] { getDomLookup(PreActiveActiveInactiveStatus.ACTIVE), getDomLookup(UserDefinedObjectType.NEEDSASSESSMENT)}); if(results == null || results.size() != 1 || results.get(0) == null) return null; UserDefinedObject activeRecord = (UserDefinedObject)factory.getDomainObject(UserDefinedObject.class, (Integer)results.get(0)); return UserDefinedObjectListVoAssembler.create(activeRecord); }
public UserDefinedObjectVo getUDF(UserDefinedObjectType udfType, PreActiveActiveInactiveStatus status) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" "); String query = "select u1_1 from UserDefinedObject as u1_1 left join u1_1.components as u2_1 left join u1_1.objectType as l1_1 left join u1_1.activeStatus as l2_1 "; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String andStr = " "; if (udfType != null) { hql.append(andStr + " l1_1.id = :UDFTYPE "); markers.add("UDFTYPE"); values.add(new Integer(udfType.getID())); andStr = " and "; } if (status != null) { hql.append(andStr + " l2_1.id = :STATUS "); markers.add("STATUS"); values.add(new Integer(status.getId())); andStr = " and "; } if (markers.size() > 0) query += " where "; query += hql.toString(); List list = factory.find(query, markers, values); if(list == null || list.size() == 0) return null; //we should have only one active UDF return UserDefinedObjectVoAssembler.create((UserDefinedObject) list.get(0)); }