public VOListResponse loadVariantsPrices(GridParams params,String serverLanguageId,String username) throws Throwable {
Connection conn = null;
try {
if (this.conn==null) conn = getConn(); else conn = this.conn;
VariantsMatrixVO matrixVO = (VariantsMatrixVO)params.getOtherGridParams().get(ApplicationConsts.VARIANTS_MATRIX_VO);
ItemPK itemPK = matrixVO.getItemPK();
String priceListCode = (String)params.getOtherGridParams().get(ApplicationConsts.PRICELIST);
String sql =
"select SAL11_VARIANTS_PRICES.COMPANY_CODE_SYS01,SAL11_VARIANTS_PRICES.PRICELIST_CODE_SAL01,"+
"SAL11_VARIANTS_PRICES.ITEM_CODE_ITM01,SAL11_VARIANTS_PRICES.VALUE,SAL11_VARIANTS_PRICES.START_DATE,SAL11_VARIANTS_PRICES.END_DATE,"+
"A.DESCRIPTION,ITM01_ITEMS.PROGRESSIVE_HIE02,"+
"SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM06,SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM11,"+
"SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM07,SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM12,"+
"SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM08,SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM13,"+
"SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM09,SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM14,"+
"SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM10,SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM15 "+
" from SAL11_VARIANTS_PRICES,SYS10_COMPANY_TRANSLATIONS A,ITM01_ITEMS where "+
"SAL11_VARIANTS_PRICES.COMPANY_CODE_SYS01=ITM01_ITEMS.COMPANY_CODE_SYS01 and "+
"SAL11_VARIANTS_PRICES.ITEM_CODE_ITM01=ITM01_ITEMS.ITEM_CODE and "+
"ITM01_ITEMS.COMPANY_CODE_SYS01=A.COMPANY_CODE_SYS01 and "+
"ITM01_ITEMS.PROGRESSIVE_SYS10=A.PROGRESSIVE and "+
"A.LANGUAGE_CODE=? and SAL11_VARIANTS_PRICES.COMPANY_CODE_SYS01=? and ITM01_ITEMS.ENABLED='Y' and "+
"SAL11_VARIANTS_PRICES.PRICELIST_CODE_SAL01=? and "+
"SAL11_VARIANTS_PRICES.ITEM_CODE_ITM01=?";
Map attribute2dbField = new HashMap();
attribute2dbField.put("companyCodeSys01SAL11","SAL11_VARIANTS_PRICES.COMPANY_CODE_SYS01");
attribute2dbField.put("pricelistCodeSal01SAL11","SAL11_VARIANTS_PRICES.PRICELIST_CODE_SAL01");
attribute2dbField.put("itemCodeItm01SAL11","SAL11_VARIANTS_PRICES.ITEM_CODE_ITM01");
attribute2dbField.put("valueSAL11","SAL11_VARIANTS_PRICES.VALUE");
attribute2dbField.put("startDateSAL11","SAL11_VARIANTS_PRICES.START_DATE");
attribute2dbField.put("endDateSAL11","SAL11_VARIANTS_PRICES.END_DATE");
attribute2dbField.put("itemDescriptionSYS10","A.DESCRIPTION");
attribute2dbField.put("pricelistDescriptionSYS10","B.DESCRIPTION");
attribute2dbField.put("progressiveHie02ITM01","ITM01_ITEMS.PROGRESSIVE_HIE02");
attribute2dbField.put("variantTypeItm06SAL11","SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM06");
attribute2dbField.put("variantCodeItm11SAL11","SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM11");
attribute2dbField.put("variantTypeItm07SAL11","SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM07");
attribute2dbField.put("variantCodeItm12SAL11","SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM12");
attribute2dbField.put("variantTypeItm08SAL11","SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM08");
attribute2dbField.put("variantCodeItm13SAL11","SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM13");
attribute2dbField.put("variantTypeItm09SAL11","SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM09");
attribute2dbField.put("variantCodeItm14SAL11","SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM14");
attribute2dbField.put("variantTypeItm10SAL11","SAL11_VARIANTS_PRICES.VARIANT_TYPE_ITM10");
attribute2dbField.put("variantCodeItm15SAL11","SAL11_VARIANTS_PRICES.VARIANT_CODE_ITM15");
ArrayList values = new ArrayList();
values.add(serverLanguageId);
values.add(itemPK.getCompanyCodeSys01ITM01());
values.add(priceListCode);
values.add(itemPK.getItemCodeITM01());
// read ALL from SAL11 table...
Response res = QueryUtil.getQuery(
conn,
new UserSessionParameters(username),
sql,
values,
attribute2dbField,
VariantsPriceVO.class,
"Y",
"N",
null,
new GridParams(),
true
);
if (res.isError())
throw new Exception(res.getErrorMessage());
java.util.List rows = ((VOListResponse)res).getRows();
// convert the records list in matrix format...
ArrayList matrixRows = new ArrayList();
VariantsPriceVO vo = null;
CustomValueObject customVO = null;
VariantsMatrixRowVO rowVO = null;
VariantsMatrixColumnVO colVO = null;
HashMap indexes = new HashMap();
for(int i=0;i<matrixVO.getRowDescriptors().length;i++) {
rowVO = (VariantsMatrixRowVO)matrixVO.getRowDescriptors()[i];
customVO = new CustomValueObject();
customVO.setAttributeNameS0(rowVO.getRowDescription());
matrixRows.add(customVO);
indexes.put(
VariantsMatrixUtils.getVariantType(matrixVO,rowVO)+" "+VariantsMatrixUtils.getVariantCode(matrixVO,rowVO),
customVO
);
}
VariantNameVO varVO = (VariantNameVO)matrixVO.getManagedVariants()[0];
for(int i=0;i<rows.size();i++) {
vo = (VariantsPriceVO)rows.get(i);
if (varVO.getTableName().equals("ITM11_VARIANTS_1")) {
customVO = (CustomValueObject)indexes.get(vo.getVariantTypeItm06SAL11()+" "+vo.getVariantCodeItm11SAL11());
}
else if (varVO.getTableName().equals("ITM12_VARIANTS_2")) {
customVO = (CustomValueObject)indexes.get(vo.getVariantTypeItm07SAL11()+" "+vo.getVariantCodeItm12SAL11());
}
else if (varVO.getTableName().equals("ITM13_VARIANTS_3")) {
customVO = (CustomValueObject)indexes.get(vo.getVariantTypeItm08SAL11()+" "+vo.getVariantCodeItm13SAL11());
}
else if (varVO.getTableName().equals("ITM14_VARIANTS_4")) {
customVO = (CustomValueObject)indexes.get(vo.getVariantTypeItm09SAL11()+" "+vo.getVariantCodeItm14SAL11());
}
else if (varVO.getTableName().equals("ITM15_VARIANTS_5")) {
customVO = (CustomValueObject)indexes.get(vo.getVariantTypeItm10SAL11()+" "+vo.getVariantCodeItm15SAL11());
}
if (matrixVO.getColumnDescriptors().length==0) {
customVO.setAttributeNameN0(vo.getValueSAL11());
}
else {
for(int j=0;j<matrixVO.getColumnDescriptors().length;j++) {
colVO = (VariantsMatrixColumnVO)matrixVO.getColumnDescriptors()[j];
if ((varVO.getTableName().equals("ITM11_VARIANTS_1")?true:colVO.getVariantCodeITM11().equals(vo.getVariantCodeItm11SAL11())) &&
(varVO.getTableName().equals("ITM12_VARIANTS_2")?true:colVO.getVariantCodeITM12().equals(vo.getVariantCodeItm12SAL11())) &&
(varVO.getTableName().equals("ITM13_VARIANTS_3")?true:colVO.getVariantCodeITM13().equals(vo.getVariantCodeItm13SAL11())) &&
(varVO.getTableName().equals("ITM14_VARIANTS_4")?true:colVO.getVariantCodeITM14().equals(vo.getVariantCodeItm14SAL11())) &&
(varVO.getTableName().equals("ITM15_VARIANTS_5")?true:colVO.getVariantCodeITM15().equals(vo.getVariantCodeItm15SAL11())) &&