bean.setConn(conn); // use same transaction...
langsBean.setConn(conn); // use same transaction...
ETLProcessVO processVO = (ETLProcessVO)gridParams.getOtherGridParams().get(ApplicationConsts.FILTER_VO);
// read from SYS24 table...
Response res = bean.loadETLProcessFields(processVO.getProgressiveSYS23(),username);
if (!res.isError()) {
java.util.List vos = ( (VOListResponse) res).getRows();
HashMap map = new HashMap();
ETLProcessFieldVO vo = null;
for (int i = 0; i < vos.size(); i++) {
vo = (ETLProcessFieldVO) vos.get(i);
map.put(new FieldEntry(vo.getLanguageCodeSYS24(),vo.getFieldNameSYS24()), vo);
}
ArrayList rows = new ArrayList();
SelectableFieldVO selVO = null;
ImportDescriptorVO impVO = (ImportDescriptorVO) Class.forName(processVO.getClassNameSYS23()).newInstance();
FieldEntry pk = null;
for (int i = 0; i < impVO.getFields().length; i++) {
pk = new FieldEntry(ApplicationConsts.JOLLY, impVO.getFields()[i]);
if (map.containsKey(pk)) {
vo = (ETLProcessFieldVO) map.get(pk);
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(true);
selVO.setLabel(p.getProperty(impVO.getLabels()[i]));
selVO.setRequired(impVO.getRequiredFields().contains(impVO.getFields()[i]));
rows.add(selVO);
}
else {
vo = new ETLProcessFieldVO();
vo.setFieldNameSYS24(impVO.getFields()[i]);
vo.setLanguageCodeSYS24(ApplicationConsts.JOLLY);
vo.setProgressiveSys23SYS24(processVO.getProgressiveSYS23());
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(false);
selVO.setLabel(p.getProperty(impVO.getLabels()[i]));
selVO.setRequired(impVO.getRequiredFields().contains(impVO.
getFields()[i]));
rows.add(selVO);
}
} // end for
// retrieve supported languages...
res = langsBean.loadLanguages( serverLanguageId,username);
if (res.isError())
throw new Exception(res.getErrorMessage());
java.util.List langsVO = ( (VOListResponse) res).getRows();
// for each progressive SYS10 x language...
Iterator it = impVO.getProgressiveSys10Fields().keySet().iterator();
String field = null;
LanguageVO langVO = null;
while(it.hasNext()) {
field = it.next().toString();
for(int i=0;i<langsVO.size();i++) {
langVO = (LanguageVO)langsVO.get(i);
pk = new FieldEntry(langVO.getLanguageCodeSYS09(),field);
if (map.containsKey(pk)) {
vo = (ETLProcessFieldVO)map.get(new FieldEntry(langVO.getLanguageCodeSYS09(),field));
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(true);
selVO.setLabel(
p.getProperty((String)impVO.getProgressiveSys10Fields().get(field))+
" "+
langVO.getDescriptionSYS09()
);
selVO.setRequired(impVO.getRequiredFields().contains(field));
rows.add(selVO);
}
else {
vo = new ETLProcessFieldVO();
vo.setFieldNameSYS24(field);
vo.setLanguageCodeSYS24(langVO.getLanguageCodeSYS09());
vo.setProgressiveSys23SYS24(processVO.getProgressiveSYS23());
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(false);
selVO.setLabel(
p.getProperty((String)impVO.getProgressiveSys10Fields().get(field))+
" "+
langVO.getDescriptionSYS09()
);
selVO.setRequired(impVO.getRequiredFields().contains(field));
rows.add(selVO);
}
}
} // end while on descriptions...
// if a hierarchy level has been defined, create an object for each supported language...
if (processVO.getProgressiveHIE02()!=null) {
field = impVO.getHierarchyField();
for(int i=0;i<langsVO.size();i++) {
langVO = (LanguageVO)langsVO.get(i);
pk = new FieldEntry(langVO.getLanguageCodeSYS09(),field);
if (map.containsKey(pk)) {
vo = (ETLProcessFieldVO)map.get(pk);
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(true);
selVO.setLabel(
p.getProperty("hierarchy") +
" " +
langVO.getDescriptionSYS09()
);
selVO.setRequired(impVO.getRequiredFields().contains(field));
rows.add(selVO);
}
else {
vo = new ETLProcessFieldVO();
vo.setFieldNameSYS24(field);
vo.setLanguageCodeSYS24(langVO.getLanguageCodeSYS09());
vo.setProgressiveSys23SYS24(processVO.getProgressiveSYS23());
selVO = new SelectableFieldVO();
selVO.setField(vo);
selVO.setSelected(false);
selVO.setLabel(
p.getProperty("hierarchy")+
" "+
langVO.getDescriptionSYS09()
);
selVO.setRequired(impVO.getRequiredFields().contains(field));
rows.add(selVO);
}
}
}
return new VOListResponse(rows,false,rows.size());
}
else
throw new Exception(res.getErrorMessage());
}
catch (Throwable ex) {
Logger.error(username,this.getClass().getName(),"executeCommand","Error while fetching ETL process fields",ex);
throw new Exception(ex.getMessage());
}