/** * ************************************************************************ Lineas de Remesa * * @param whereClause where clause or null (starting with AND) * @return lines */ public MRemesaLine[] getLines(String whereClause, String orderClause) { ArrayList list = new ArrayList(); StringBuffer sql = new StringBuffer("SELECT * FROM C_RemesaLine WHERE C_Remesa_ID=? "); if (whereClause != null) sql.append(whereClause); if (orderClause != null) sql.append(" ").append(orderClause); PreparedStatement pstmt = null; try { pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt.setInt(1, getC_Remesa_ID()); ResultSet rs = pstmt.executeQuery(); while (rs.next()) list.add(new MRemesaLine(getCtx(), rs)); rs.close(); pstmt.close(); pstmt = null; } catch (Exception e) { log.saveError("getLines - " + sql, e); } finally { try { if (pstmt != null) pstmt.close(); } catch (Exception e) { } pstmt = null; } // MRemesaLine[] lines = new MRemesaLine[list.size()]; list.toArray(lines); return lines; } // getLines
/** * Get Restriction Lines * * @param reload reload data * @return array of lines */ public MGoalRestriction[] getRestrictions(boolean reload) { if (m_restrictions != null && !reload) return m_restrictions; ArrayList<MGoalRestriction> list = new ArrayList<MGoalRestriction>(); // String sql = "SELECT * FROM PA_GoalRestriction " + "WHERE PA_Goal_ID=? AND IsActive='Y' " + "ORDER BY Org_ID, C_BPartner_ID, M_Product_ID"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, get_Trx()); pstmt.setInt(1, getPA_Goal_ID()); rs = pstmt.executeQuery(); while (rs.next()) list.add(new MGoalRestriction(getCtx(), rs, get_Trx())); } catch (Exception e) { log.log(Level.SEVERE, sql, e); } finally { DB.closeStatement(pstmt); DB.closeResultSet(rs); } // m_restrictions = new MGoalRestriction[list.size()]; list.toArray(m_restrictions); return m_restrictions; } // getRestrictions
/** * Get Accessible Goals * * @param ctx context * @return array of goals */ public static MGoal[] getGoals(Ctx ctx) { ArrayList<MGoal> list = new ArrayList<MGoal>(); String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' " + "ORDER BY SeqNo"; sql = MRole.getDefault(ctx, false) .addAccessSQL(sql, "PA_Goal", false, true); // RW to restrict Access PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, (Trx) null); rs = pstmt.executeQuery(); while (rs.next()) { MGoal goal = new MGoal(ctx, rs, null); goal.updateGoal(false); list.add(goal); } } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeStatement(pstmt); DB.closeResultSet(rs); } MGoal[] retValue = new MGoal[list.size()]; list.toArray(retValue); return retValue; } // getGoals
public CFBamISOCurrencyBuff[] readAllBuff(CFBamAuthorization Authorization) { final String S_ProcName = "CFBamRamISOCurrency.readAllBuff() "; CFBamISOCurrencyBuff buff; ArrayList<CFBamISOCurrencyBuff> filteredList = new ArrayList<CFBamISOCurrencyBuff>(); CFBamISOCurrencyBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISCY")) { filteredList.add(buff); } } return (filteredList.toArray(new CFBamISOCurrencyBuff[0])); }
public CFAccFeeBuff[] readBuffByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAccRamFee.readBuffByTenantIdx() "; CFAccFeeBuff buff; ArrayList<CFAccFeeBuff> filteredList = new ArrayList<CFAccFeeBuff>(); CFAccFeeBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("FEE")) { filteredList.add((CFAccFeeBuff) buff); } } return (filteredList.toArray(new CFAccFeeBuff[0])); }
public CFSecurityISOLanguageBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFInternetRamISOLanguage.readAllBuff"; CFSecurityISOLanguageBuff buff; ArrayList<CFSecurityISOLanguageBuff> filteredList = new ArrayList<CFSecurityISOLanguageBuff>(); CFSecurityISOLanguageBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISLN")) { filteredList.add(buff); } } return (filteredList.toArray(new CFSecurityISOLanguageBuff[0])); }
public CFSecuritySecSessionBuff[] readBuffByFinishIdx( CFSecurityAuthorization Authorization, UUID SecUserId, Calendar Finish) { final String S_ProcName = "CFSecurityRamSecSession.readBuffByFinishIdx() "; CFSecuritySecSessionBuff buff; ArrayList<CFSecuritySecSessionBuff> filteredList = new ArrayList<CFSecuritySecSessionBuff>(); CFSecuritySecSessionBuff[] buffList = readDerivedByFinishIdx(Authorization, SecUserId, Finish); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SESS")) { filteredList.add((CFSecuritySecSessionBuff) buff); } } return (filteredList.toArray(new CFSecuritySecSessionBuff[0])); }
public CFBamDelSubDep3Buff[] readBuffByTableIdx( CFBamAuthorization Authorization, long RelationTenantId, long RelationId) { final String S_ProcName = "CFBamRamDelDep.readBuffByTableIdx() "; CFBamDelDepBuff buff; ArrayList<CFBamDelSubDep3Buff> filteredList = new ArrayList<CFBamDelSubDep3Buff>(); CFBamDelDepBuff[] buffList = readDerivedByTableIdx(Authorization, RelationTenantId, RelationId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("DELD")) { filteredList.add((CFBamDelSubDep3Buff) buff); } } return (filteredList.toArray(new CFBamDelSubDep3Buff[0])); }
public CFSecuritySecGroupMemberBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFFreeSwitchRamSecGroupMember.readAllBuff"; CFSecuritySecGroupMemberBuff buff; ArrayList<CFSecuritySecGroupMemberBuff> filteredList = new ArrayList<CFSecuritySecGroupMemberBuff>(); CFSecuritySecGroupMemberBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGMB")) { filteredList.add(buff); } } return (filteredList.toArray(new CFSecuritySecGroupMemberBuff[0])); }
public CFBamUuidDefBuff[] readBuffByVAccSecIdx( CFSecurityAuthorization Authorization, ICFBamSchema.AccessSecurityEnum ViewAccessSecurity) { final String S_ProcName = "CFBamRamValue.readBuffByVAccSecIdx() "; CFBamUuidDefBuff buff; ArrayList<CFBamUuidDefBuff> filteredList = new ArrayList<CFBamUuidDefBuff>(); CFBamUuidDefBuff[] buffList = readDerivedByVAccSecIdx(Authorization, ViewAccessSecurity); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("VALU")) { filteredList.add((CFBamUuidDefBuff) buff); } } return (filteredList.toArray(new CFBamUuidDefBuff[0])); }
/** * Return Array of Regions of Country * * @param ctx context * @param C_Country_ID country * @return MRegion Array */ public static MRegion[] getRegions(Ctx ctx, int C_Country_ID) { if (s_regions.isEmpty()) loadAllRegions(ctx); ArrayList<MRegion> list = new ArrayList<MRegion>(); Iterator<MRegion> it = s_regions.values().iterator(); while (it.hasNext()) { MRegion r = it.next(); if (r.getC_Country_ID() == C_Country_ID) list.add(r); } // Sort it MRegion[] retValue = new MRegion[list.size()]; list.toArray(retValue); Arrays.sort(retValue, new MRegion(ctx, 0, null)); return retValue; } // getRegions
public CFDbTestLoaderBehaviourBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFDbTestRamLoaderBehaviour.readAllBuff"; CFDbTestLoaderBehaviourBuff buff; ArrayList<CFDbTestLoaderBehaviourBuff> filteredList = new ArrayList<CFDbTestLoaderBehaviourBuff>(); CFDbTestLoaderBehaviourBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("LDBV")) { filteredList.add(buff); } } return (filteredList.toArray(new CFDbTestLoaderBehaviourBuff[0])); }
public CFSecuritySecFormBuff[] readBuffBySecAppIdx( CFSecurityAuthorization Authorization, long ClusterId, int SecAppId) { final String S_ProcName = "CFInternetRamSecForm.readBuffBySecAppIdx() "; CFSecuritySecFormBuff buff; ArrayList<CFSecuritySecFormBuff> filteredList = new ArrayList<CFSecuritySecFormBuff>(); CFSecuritySecFormBuff[] buffList = readDerivedBySecAppIdx(Authorization, ClusterId, SecAppId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SFRM")) { filteredList.add((CFSecuritySecFormBuff) buff); } } return (filteredList.toArray(new CFSecuritySecFormBuff[0])); }
public CFDbTestNumberDefBuff[] readBuffByNextIdx( CFSecurityAuthorization Authorization, Long NextTenantId, Long NextId) { final String S_ProcName = "CFDbTestRamValue.readBuffByNextIdx() "; CFDbTestNumberDefBuff buff; ArrayList<CFDbTestNumberDefBuff> filteredList = new ArrayList<CFDbTestNumberDefBuff>(); CFDbTestNumberDefBuff[] buffList = readDerivedByNextIdx(Authorization, NextTenantId, NextId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("VALU")) { filteredList.add((CFDbTestNumberDefBuff) buff); } } return (filteredList.toArray(new CFDbTestNumberDefBuff[0])); }
public CFSecurityServiceBuff[] readBuffByTypeIdx( CFSecurityAuthorization Authorization, int ServiceTypeId) { final String S_ProcName = "CFBamRamService.readBuffByTypeIdx() "; CFSecurityServiceBuff buff; ArrayList<CFSecurityServiceBuff> filteredList = new ArrayList<CFSecurityServiceBuff>(); CFSecurityServiceBuff[] buffList = readDerivedByTypeIdx(Authorization, ServiceTypeId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("HSVC")) { filteredList.add((CFSecurityServiceBuff) buff); } } return (filteredList.toArray(new CFSecurityServiceBuff[0])); }
public CFSecurityTSecGroupMemberBuff[] readBuffByUserIdx( CFSecurityAuthorization Authorization, UUID SecUserId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByUserIdx() "; CFSecurityTSecGroupMemberBuff buff; ArrayList<CFSecurityTSecGroupMemberBuff> filteredList = new ArrayList<CFSecurityTSecGroupMemberBuff>(); CFSecurityTSecGroupMemberBuff[] buffList = readDerivedByUserIdx(Authorization, SecUserId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGMB")) { filteredList.add((CFSecurityTSecGroupMemberBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupMemberBuff[0])); }
public CFGenKbISOCountryCurrencyBuff[] readBuffByCountryIdx( CFGenKbAuthorization Authorization, short ISOCountryId) { final String S_ProcName = "CFGenKbRamISOCountryCurrency.readBuffByCountryIdx() "; CFGenKbISOCountryCurrencyBuff buff; ArrayList<CFGenKbISOCountryCurrencyBuff> filteredList = new ArrayList<CFGenKbISOCountryCurrencyBuff>(); CFGenKbISOCountryCurrencyBuff[] buffList = readDerivedByCountryIdx(Authorization, ISOCountryId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ICCY")) { filteredList.add((CFGenKbISOCountryCurrencyBuff) buff); } } return (filteredList.toArray(new CFGenKbISOCountryCurrencyBuff[0])); }
public CFBamUuidDefBuff[] readDerivedByVAccSecIdx( CFSecurityAuthorization Authorization, ICFBamSchema.AccessSecurityEnum ViewAccessSecurity) { final String S_ProcName = "CFBamRamValue.readDerivedByVAccSecIdx"; CFBamValueBuff buffList[] = schema.getTableValue().readDerivedByVAccSecIdx(Authorization, ViewAccessSecurity); if (buffList == null) { return (null); } else { CFBamValueBuff buff; ArrayList<CFBamUuidDefBuff> filteredList = new ArrayList<CFBamUuidDefBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFBamUuidDefBuff)) { filteredList.add((CFBamUuidDefBuff) buff); } } return (filteredList.toArray(new CFBamUuidDefBuff[0])); } }
public CFBamDelSubDep3Buff[] readDerivedByTableIdx( CFBamAuthorization Authorization, long RelationTenantId, long RelationId) { final String S_ProcName = "CFBamRamDelDep.readDerivedByTableIdx() "; CFBamDelDepBuff buffList[] = schema.getTableDelDep().readDerivedByTableIdx(Authorization, RelationTenantId, RelationId); if (buffList == null) { return (null); } else { CFBamDelDepBuff buff; ArrayList<CFBamDelSubDep3Buff> filteredList = new ArrayList<CFBamDelSubDep3Buff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFBamDelSubDep3Buff)) { filteredList.add((CFBamDelSubDep3Buff) buff); } } return (filteredList.toArray(new CFBamDelSubDep3Buff[0])); } }
public CFDbTestNumberDefBuff[] readDerivedByNextIdx( CFSecurityAuthorization Authorization, Long NextTenantId, Long NextId) { final String S_ProcName = "CFDbTestRamValue.readDerivedByNextIdx"; CFDbTestValueBuff buffList[] = schema.getTableValue().readDerivedByNextIdx(Authorization, NextTenantId, NextId); if (buffList == null) { return (null); } else { CFDbTestValueBuff buff; ArrayList<CFDbTestNumberDefBuff> filteredList = new ArrayList<CFDbTestNumberDefBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFDbTestNumberDefBuff)) { filteredList.add((CFDbTestNumberDefBuff) buff); } } return (filteredList.toArray(new CFDbTestNumberDefBuff[0])); } }
/** * Get Goals with Measure * * @param ctx context * @param PA_Measure_ID measure * @return goals */ public static MGoal[] getMeasureGoals(Ctx ctx, int PA_Measure_ID) { ArrayList<MGoal> list = new ArrayList<MGoal>(); String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' AND PA_Measure_ID=? " + "ORDER BY SeqNo"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, (Trx) null); pstmt.setInt(1, PA_Measure_ID); rs = pstmt.executeQuery(); while (rs.next()) list.add(new MGoal(ctx, rs, null)); } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeStatement(pstmt); DB.closeResultSet(rs); } MGoal[] retValue = new MGoal[list.size()]; list.toArray(retValue); return retValue; } // getMeasureGoals
/** * Get User Goals * * @param ctx context * @param AD_User_ID user * @return array of goals */ public static MGoal[] getUserGoals(Ctx ctx) { int AD_Role_ID = ctx.getAD_Role_ID(); MRole role = MRole.get(ctx, AD_Role_ID); int AD_User_ID = ctx.getAD_User_ID(); if (AD_User_ID < 0) return getTestGoals(ctx); ArrayList<MGoal> list = new ArrayList<MGoal>(); String sql = "SELECT * FROM PA_Goal g " + "WHERE IsActive='Y'" + " AND AD_Client_ID=?" // #1 + " AND ("; if (!role.isWebStoreRole()) sql += " (AD_User_ID IS NULL AND AD_Role_ID IS NULL) OR "; sql += " AD_User_ID=?" // #2 + " OR EXISTS (SELECT * FROM AD_User_Roles ur " + "WHERE ?=ur.AD_User_ID AND g.AD_Role_ID=ur.AD_Role_ID AND ur.IsActive='Y')) " + "ORDER BY SeqNo"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, (Trx) null); pstmt.setInt(1, ctx.getAD_Client_ID()); pstmt.setInt(2, AD_User_ID); pstmt.setInt(3, AD_User_ID); rs = pstmt.executeQuery(); while (rs.next()) { MGoal goal = new MGoal(ctx, rs, null); goal.updateGoal(false); list.add(goal); } } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } MGoal[] retValue = new MGoal[list.size()]; list.toArray(retValue); return retValue; } // getUserGoals
/** * gets all Periods in the Range * * @param startPeriod * @param endPeriod * @param calendar_ID * @return MPeriod[] */ public static MPeriod[] getAllPeriodsInRange( MPeriod startPeriod, MPeriod endPeriod, int calendar_ID, Ctx ctx, Trx trx) { if ((startPeriod.getC_Calendar_ID() != calendar_ID) || (endPeriod.getC_Calendar_ID() != calendar_ID)) { log.saveError("Error", "Periods do not belong to the calendar"); return null; } ArrayList<MPeriod> periods = new ArrayList<MPeriod>(); String sql = "SELECT * FROM C_Period WHERE " + "C_Period.IsActive='Y' AND PeriodType='S' " + "AND C_Period.C_Year_ID IN " + "(SELECT C_Year_ID FROM C_Year WHERE C_Year.C_Calendar_ID = ? ) " + // calendar_ID "AND ((C_Period.C_Year_ID * 1000) + C_Period.PeriodNo) BETWEEN" + " (? * 1000 + ?) AND (? * 1000 + ? )" + // start Period year ID, Period Number , End Period Year ID, Period Number " ORDER BY C_Period.C_Year_ID ASC, C_Period.PeriodNo ASC"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, trx); pstmt.setInt(1, calendar_ID); pstmt.setInt(2, startPeriod.getC_Year_ID()); pstmt.setInt(3, startPeriod.getPeriodNo()); pstmt.setInt(4, endPeriod.getC_Year_ID()); pstmt.setInt(5, endPeriod.getPeriodNo()); rs = pstmt.executeQuery(); while (rs.next()) periods.add(new MPeriod(ctx, rs, trx)); } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } MPeriod[] retValue = new MPeriod[periods.size()]; periods.toArray(retValue); return retValue; }
/** * Get Period Control * * @param requery requery * @return period controls */ public MPeriodControl[] getPeriodControls(boolean requery) { if (m_controls != null && !requery) return m_controls; // ArrayList<MPeriodControl> list = new ArrayList<MPeriodControl>(); String sql = "SELECT * FROM C_PeriodControl " + "WHERE C_Period_ID=?"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, get_Trx()); pstmt.setInt(1, getC_Period_ID()); rs = pstmt.executeQuery(); while (rs.next()) list.add(new MPeriodControl(getCtx(), rs, get_Trx())); } catch (Exception e) { log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } m_controls = new MPeriodControl[list.size()]; list.toArray(m_controls); return m_controls; } // getPeriodControls
protected ReportParameterValue[] getParamValuesFromDataSource( ReportParameter param, Map<String, Object> parameters) throws ProviderException { Connection conn = null; PreparedStatement pStmt = null; ResultSet rs = null; try { ReportDataSource dataSource = param.getDataSource(); conn = dataSourceProvider.getConnection(dataSource.getId()); if (parameters == null || parameters.isEmpty()) { pStmt = conn.prepareStatement(param.getData()); } else { } rs = pStmt.executeQuery(); ResultSetMetaData rsMetaData = rs.getMetaData(); boolean multipleColumns = false; if (rsMetaData.getColumnCount() > 1) multipleColumns = true; ArrayList<ReportParameterValue> v = new ArrayList<ReportParameterValue>(); while (rs.next()) { ReportParameterValue value = new ReportParameterValue(); if (param.getClassName().equals("java.lang.String")) { value.setId(rs.getString(1)); } else if (param.getClassName().equals("java.lang.Double")) { value.setId(new Double(rs.getDouble(1))); } else if (param.getClassName().equals("java.lang.Integer")) { value.setId(new Integer(rs.getInt(1))); } else if (param.getClassName().equals("java.lang.Long")) { value.setId(new Long(rs.getLong(1))); } else if (param.getClassName().equals("java.math.BigDecimal")) { value.setId(rs.getBigDecimal(1)); } else if (param.getClassName().equals("java.util.Date")) { value.setId(rs.getDate(1)); } else if (param.getClassName().equals("java.sql.Date")) { value.setId(rs.getDate(1)); } else if (param.getClassName().equals("java.sql.Timestamp")) { value.setId(rs.getTimestamp(1)); } if (multipleColumns) { value.setDescription(rs.getString(2)); } v.add(value); } rs.close(); ReportParameterValue[] values = new ReportParameterValue[v.size()]; v.toArray(values); return values; } catch (Exception e) { throw new ProviderException("Error retreiving param values from database: " + e.getMessage()); } finally { try { if (pStmt != null) pStmt.close(); if (conn != null) conn.close(); } catch (Exception c) { log.error("Error closing"); } } }