- /**
- * Diese Methode sollte ueberschrieben werden, wenn fuer die abgeleitete Database-Klasse
- * eine SimpleList mit Standard-Popupdaten erzeugt werden koennen soll.
- * @return null
- */
- public SimpleList getPopupData() throws StorageObjectFailure {
- return null;
- }
-
- /**
- * Holt Daten fuer Popups.
- * @param name Name des Feldes.
- * @param hasNullValue Wenn true wird eine leerer Eintrag fuer die Popups erzeugt.
- * @return SimpleList Gibt freemarker.template.SimpleList zurueck.
- */
- public SimpleList getPopupData(String name, boolean hasNullValue)
- throws StorageObjectFailure {
- return getPopupData(name, hasNullValue, null);
- }
-
- /**
- * Holt Daten fuer Popups.
- * @param name Name des Feldes.
- * @param hasNullValue Wenn true wird eine leerer Eintrag fuer die Popups erzeugt.
- * @param where Schraenkt die Selektion der Datensaetze ein.
- * @return SimpleList Gibt freemarker.template.SimpleList zurueck.
- */
- public SimpleList getPopupData(String name, boolean hasNullValue, String where)
- throws StorageObjectFailure {
- return getPopupData(name, hasNullValue, where, null);
- }
-
- /**
- * Holt Daten fuer Popups.
- * @param name Name des Feldes.
- * @param hasNullValue Wenn true wird eine leerer Eintrag fuer die Popups erzeugt.
- * @param where Schraenkt die Selektion der Datensaetze ein.
- * @param order Gibt ein Feld als Sortierkriterium an.
- * @return SimpleList Gibt freemarker.template.SimpleList zurueck.
- */
- public SimpleList getPopupData(String name, boolean hasNullValue,
- String where, String order) throws StorageObjectFailure {
- // caching
- if (hasPopupCache && (popupCache != null)) {
- return popupCache;
- }
-
- SimpleList simpleList = null;
- Connection con = null;
- Statement stmt = null;
-
- // build sql
- StringBuffer sql =
- new StringBuffer("select ").append(thePKeyName).append(",").append(name)
- .append(" from ").append(theTable);
-
- if ((where != null) && !(where.length() == 0)) {
- sql.append(" where ").append(where);
- }
-
- sql.append(" order by ");
-
- if ((order != null) && !(order.length() == 0)) {
- sql.append(order);
- } else {
- sql.append(name);
- }
-
- // execute sql
- try {
- con = getPooledCon();
- } catch (Exception e) {
- throw new StorageObjectFailure(e);
- }
-
- try {
- stmt = con.createStatement();
-
- ResultSet rs = executeSql(stmt, sql.toString());
-
- if (rs != null) {
- if (!evaluatedMetaData) {
- get_meta_data();
- }
-
- simpleList = new SimpleList();
-
- // if popup has null-selector
- if (hasNullValue) {
- simpleList.add(POPUP_EMPTYLINE);
- }
-
- SimpleHash popupDict;
-
- while (rs.next()) {
- popupDict = new SimpleHash();
- popupDict.put("key", getValueAsString(rs, 1, thePKeyType));
- popupDict.put("value", rs.getString(2));
- simpleList.add(popupDict);
- }
-
- rs.close();
- }
- }
- catch (Exception e) {
- logger.error("getPopupData: " + e.getMessage());
- throw new StorageObjectFailure(e);
- } finally {
- freeConnection(con, stmt);
- }
-
- if (hasPopupCache) {
- popupCache = simpleList;
- }
-
- return simpleList;
- }
-
- /**
- * Liefert alle Daten der Tabelle als SimpleHash zurueck. Dies wird verwandt,
- * wenn in den Templates ein Lookup-Table benoetigt wird. Sollte nur bei kleinen
- * Tabellen Verwendung finden.
- * @return SimpleHash mit den Tabellezeilen.
- */
- public SimpleHash getHashData() {
- /** @todo dangerous! this should have a flag to be enabled, otherwise
- * very big Hashes could be returned */
- if (hashCache == null) {
- try {
- hashCache =
- HTMLTemplateProcessor.makeSimpleHash(selectByWhereClause("", -1));
- }
- catch (StorageObjectFailure e) {
- logger.debug(e.getMessage());
- }
- }
-
- return hashCache;
- }
-
- /* invalidates the popupCache
- */
- protected void invalidatePopupCache() {
- /** @todo invalidates toooo much */
- popupCache = null;
- hashCache = null;
- }
-
- /**
- * Diese Methode fuehrt den Sqlstring <i>sql</i> aus und timed im Logfile.
- * @param stmt Statemnt
- * @param sql Sql-String
- * @return ResultSet
- * @exception StorageObjectException
- */