// 2. Get all listboxes for this language
// ps =
// con.prepareStatement("SELECT TRIM(ID) AS ID, LISTORDER, TRIM(TEXT) AS TEXT, TRIM(TEXTVALUE) AS TEXTVALUE, SELECTED, VALIDFROM, VALIDTO, LANGUAGEID FROM listboxtextrow WHERE LANGUAGEID= ? ORDER BY ID, LISTORDER");
// ps.setString(1, currentLang);
// rs = ps.executeQuery();
ListOption oneListOption = null;
Calendar fromCal;
Calendar toCal;
java.sql.Date fromDate;
java.sql.Date toDate;
// TODO: read in correct document order
// Get text documents in correct order
Collection<DocumentorderBean> docCol = DocumentorderFinder
.findAllOrderByOrdernumber(con);
// loop all containers in all documents (in right order) will lead
// to
// the ones existing in more than one document
// being overwritten in correct order
for (DocumentorderBean doBean : docCol) {
for (Listboxtextrow lbtr : ListboxtextrowFinder.findByDocument(
con, doBean.getDocument())) {
// while (rs.next()) {
oneListOption = new ListOption();
// oneListOption.setSelectBoxName(rs.getString(1));
// oneListOption.setListOrder(rs.getInt(2));
// oneListOption.setSelected(rs.getInt(5));
// oneListOption.setText(rs.getString(3));
// oneListOption.setValue(rs.getString(4));
oneListOption.setSelectBoxName(lbtr.getId());
oneListOption.setListOrder(lbtr.getListorder());
oneListOption.setSelected(lbtr.getSelected());
// Text t = (Text) TextFinderBase.findByPrimaryKey(
// con, new TextKey(lbtr.getId() + "_"
// + lbtr.getListorder() + "_D", currentLang));
// Collection<TextBean> ct = TextFinder.findByTextid(con,
// lbtr.getTextid());
Collection<TextBean> ct = TextFinder
.findByIdLanguageidDocument(con, lbtr.getTextid(),
currentLang, doBean.getDocument());
Text t = null;
for (Text te : ct) {
t = te;
}
// Text t = TextFinder.findByTextid(con, lbtr.getTextid());
if (null != t) {
oneListOption.setText(t.getText());
} else {
oneListOption.setText("");
// logger.log(Level.WARN,
// "Translation missing for option: "+lbtr.getId() + "_"
// + lbtr.getListorder() + "_D "+ currentLang);
logger.log(
Level.DEBUG,
"Translation missing for option: "
+ lbtr.getTextid() + " langid: "
+ currentLang);
}
// try {
// oneListOption.setText(((Text)
// TextFinderBase.findByPrimaryKey(
// con, new TextKey(lbtr.getId() + "_"
// + lbtr.getListorder() + "_D", currentLang)))
// .getText());
// }catch (Exception e) {
// // TODO: handle exception
// System.out.println(lbtr.getId() + "_"
// + lbtr.getListorder() + "_D "+currentLang);
// }
oneListOption.setValue(lbtr.getTextvalue());
// fromDate = rs.getDate(6);
fromDate = lbtr.getValidfrom();
fromCal = null;
if (fromDate != null) {
fromCal = Converter.sqlDateToGC(fromDate);
fromCal.set(Calendar.HOUR_OF_DAY, 0);
fromCal.set(Calendar.MINUTE, 0);
fromCal.set(Calendar.SECOND, 0);
fromCal.set(Calendar.MILLISECOND, 0);
}
// toDate = rs.getDate(7);
toDate = lbtr.getValidto();
toCal = null;
if (toDate != null) {
toCal = Converter.sqlDateToGC(toDate);
toCal.set(Calendar.HOUR_OF_DAY, 23);
toCal.set(Calendar.MINUTE, 59);
toCal.set(Calendar.SECOND, 59);
toCal.set(Calendar.MILLISECOND, 999);
}
// Startdate and enddate must include the whole day
// Since we only have dates on the database, the time is
// added
// here
oneListOption.setStartDate(fromCal);
oneListOption.setEndDate(toCal);
// oneListOption.setLangId(rs.getString(8));
oneListOption.setLangId(currentLang);
// check if option is an optgroup,an end of an optgroup or a
// standard option
if (oneListOption.getValue() != null
&& oneListOption.getValue().equalsIgnoreCase(
"optgroup")) {
oneListOption.setType(ListOption.OPTGROUPSTART);
} else if (oneListOption.getValue() != null
&& oneListOption.getValue().equalsIgnoreCase(
"/optgroup")) {
oneListOption.setType(ListOption.OPTGROUPEND);
} else {
oneListOption.setType(ListOption.OPTION);
}
// languageListboxes.get(rs.getString(1)).put(rs.getInt(2),
// oneListOption);
languageListboxes.get(lbtr.getId()).put(