} // getSeqNo /// <summary> /// Compare To /// </summary> /// <param name="o">the Object to be compared.</param> /// <returns>a negative integer, zero, or a positive integer as this object //is less than, equal to, or greater than the specified object.</returns> public int CompareTo(Object o) { if (o == null) { return(0); } MRegistrationValue oo = (MRegistrationValue)o; int compare = GetSeqNo() - oo.GetSeqNo(); return(compare); } // compareTo
} // getValues /// <summary> /// Get All Attribute Values /// </summary> /// <param name="onlySelfService">only Active Self Service</param> /// <returns> sorted Registration Attribute Values</returns> public MRegistrationValue[] GetValues(bool onlySelfService) { CreateMissingValues(); // String sql = "SELECT * FROM A_RegistrationValue rv " + "WHERE A_Registration_ID=@param"; if (onlySelfService) { sql += " AND EXISTS (SELECT * FROM A_RegistrationAttribute ra WHERE rv.A_RegistrationAttribute_ID=ra.A_RegistrationAttribute_ID" + " AND ra.IsActive='Y' AND ra.IsSelfService='Y')"; } // sql += " ORDER BY A_RegistrationAttribute_ID"; List <MRegistrationValue> list = new List <MRegistrationValue>(); SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; try { //pstmt = DataBase.prepareStatement(sql, get_TrxName()); //pstmt.setInt(1, getA_Registration_ID()); param[0] = new SqlParameter("@param", GetA_Registration_ID()); idr = DataBase.DB.ExecuteReader(sql, param, Get_TrxName()); while (idr.Read()) { list.Add(new MRegistrationValue(GetCtx(), idr, Get_TrxName())); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } log.Log(Level.SEVERE, sql, e); } // Convert and Sort MRegistrationValue[] retValue = new MRegistrationValue[list.Count]; retValue = list.ToArray(); //Arrays.sort(retValue); Array.Sort(retValue); return(retValue); } // getValues
} // getValues /// <summary> /// Create Missing Attribute Values /// </summary> private void CreateMissingValues() { String sql = "SELECT ra.A_RegistrationAttribute_ID " + "FROM A_RegistrationAttribute ra" + " LEFT OUTER JOIN A_RegistrationProduct rp ON (rp.A_RegistrationAttribute_ID=ra.A_RegistrationAttribute_ID)" + " LEFT OUTER JOIN A_Registration r ON (r.M_Product_ID=rp.M_Product_ID) " + "WHERE r.A_Registration_ID=@param" // Not in Registration + " AND NOT EXISTS (SELECT A_RegistrationAttribute_ID FROM A_RegistrationValue v " + "WHERE ra.A_RegistrationAttribute_ID=v.A_RegistrationAttribute_ID AND r.A_Registration_ID=v.A_Registration_ID)"; SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; try { //pstmt = DataBase.prepareStatement(sql, get_TrxName()); //pstmt.setInt(1, getA_Registration_ID()); param[0] = new SqlParameter("@param", GetA_Registration_ID()); idr = DataBase.DB.ExecuteReader(sql, param, Get_TrxName()); while (idr.Read()) { MRegistrationValue v = new MRegistrationValue(this, Utility.Util.GetValueOfInt(idr[0]), "?"); v.Save(); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } log.Log(Level.SEVERE, null, e); } }