currVO.setCurrentItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setProgressiveITM04(progressiveITM04);
res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
conn,
new UserSessionParameters(username),
currVO,
"ITM04_ALTERNATIVE_ITEMS",
attribute2dbField,
"Y",
"N",
null,
true
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
}
}
else
progressiveITM04 = vo.getProgressiveITM04();
}
else if (progressives.size()==1) {
// add all components to the fetched group (fetched PROGRESSIVE)
progressiveITM04 = (BigDecimal)progressives.get(0);
// insert current item into ITM04...
AltComponentVO currVO = new AltComponentVO();
currVO.setCompanyCodeSys01ITM04(vo.getCompanyCodeSys01ITM04());
currVO.setCurrentItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setProgressiveITM04(progressiveITM04);
res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
conn,
new UserSessionParameters(username),
currVO,
"ITM04_ALTERNATIVE_ITEMS",
attribute2dbField,
"Y",
"N",
null,
true
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
}
else if (progressives.size()>1) {
// join all groups found and add all components to the unique group just created
String progrs = "";
for(int i=0;i<progressives.size();i++)
progrs += progressives.get(i)+",";
progrs = progrs.substring(0,progrs.length()-1);
pstmt = conn.prepareStatement(
"select ITEM_CODE_ITM01 from ITM04_ALTERNATIVE_ITEMS where COMPANY_CODE_SYS01=? and PROGRESSIVE in ("+progrs+")"
);
pstmt.setString(1,vo.getCompanyCodeSys01ITM04());
rset = pstmt.executeQuery();
itms = new HashSet();
while(rset.next())
if (!rset.getString(1).equals(vo.getCurrentItemCodeItm01ITM04()))
itms.add(rset.getString(1));
rset.close();
pstmt.close();
// delete all items of all retrieved groups...
pstmt = conn.prepareStatement(
"delete from ITM04_ALTERNATIVE_ITEMS where COMPANY_CODE_SYS01=? and PROGRESSIVE in ("+progrs+")"
);
pstmt.execute();
// insert all items in a single new group...
progressiveITM04 = CompanyProgressiveUtils.getInternalProgressive(vo.getCompanyCodeSys01ITM04(),"ITM04_ALTERNATIVE_ITEMS", "PROGRESSIVE", conn);
// insert current item into ITM04...
AltComponentVO currVO = new AltComponentVO();
currVO.setCompanyCodeSys01ITM04(vo.getCompanyCodeSys01ITM04());
currVO.setCurrentItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setProgressiveITM04(progressiveITM04);
res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
conn,
new UserSessionParameters(username),
currVO,
"ITM04_ALTERNATIVE_ITEMS",
attribute2dbField,
"Y",
"N",
null,
true
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
Iterator it = itms.iterator();
while(it.hasNext()) {
currVO = new AltComponentVO();
currVO.setCompanyCodeSys01ITM04(vo.getCompanyCodeSys01ITM04());
currVO.setCurrentItemCodeItm01ITM04(vo.getCurrentItemCodeItm01ITM04());
currVO.setItemCodeItm01ITM04(it.next().toString());
currVO.setProgressiveITM04(progressiveITM04);
res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
conn,
new UserSessionParameters(username),
currVO,
"ITM04_ALTERNATIVE_ITEMS",
attribute2dbField,
"Y",
"N",
null,
true
);
if (res.isError()) {
throw new Exception(res.getErrorMessage());
}
}
}
// add alternative components to the calculated progressive...
for(int i=0;i<list.size();i++) {
vo = (AltComponentVO)list.get(i);
vo.setProgressiveITM04(progressiveITM04);
if (progressives.size()!=1 || !itms.contains(vo.getItemCodeItm01ITM04())) {
// insert into ITM04...
res = org.jallinone.commons.server.QueryUtilExtension.insertTable(
conn,
new UserSessionParameters(username),
vo,
"ITM04_ALTERNATIVE_ITEMS",
attribute2dbField,
"Y",
"N",