01: /**
02: * Jedes Selectstatement erhaelt eine eigene Klasse
03: */package com.teamkonzept.field.db.queries;
04:
05: import com.teamkonzept.db.*;
06: import com.teamkonzept.lib.*;
07:
08: import java.sql.*;
09:
10: public class TKDBContentTreeDir extends TKPrepQuery {
11:
12: public final static boolean isPrepared = true;
13:
14: public final static String[] paramOrder = {};
15:
16: public final static Object[][] paramTypes = null;
17:
18: public final static boolean[] setRelevants = { true };
19:
20: public final static String sqlString = "SELECT * "
21: + "FROM CONTENT_TREE " + "ORDER BY LEFT_NR";
22:
23: public void initQuery(Connection con) {
24: super .initQuery(con, isPrepared, paramOrder, paramTypes,
25: setRelevants, sqlString);
26: }
27:
28: /************************************************************************
29: /**
30: * Erzeugt eine Hashtabelle mit Pfadnamen im Contenttree ...
31: *
32: * @param
33: */
34: public static TKHashtable getContentPathes() throws Throwable {
35: TKQuery q = TKDBManager.newQuery(TKDBContentTreeDir.class);
36: q.execute();
37: ResultSet rs = q.fetchResultSet();
38:
39: TKHashtable pathes = new TKHashtable();
40:
41: while (rs.next()) {
42:
43: int leftNr = rs.getInt("LEFT_NR");
44: int rightNr = rs.getInt("RIGHT_NR");
45:
46: int contentNodeId = rs.getInt("CONTENT_NODE_ID");
47: int contentNodeParent = rs.getInt("CONTENT_NODE_PARENT");
48: int formId = rs.getInt("CONTENT_FORM");
49: int nodeType = rs.getInt("CONTENT_NODE_TYPE");
50:
51: String nodeName = rs.getString("CONTENT_NODE_NAME");
52: String nodeShortName = rs
53: .getString("CONTENT_NODE_SHORTNAME");
54:
55: if (nodeShortName == null) {
56:
57: continue;
58: }
59:
60: if (contentNodeParent <= 0) {
61: pathes.put(new Integer(contentNodeId), nodeShortName);
62: } else {
63:
64: String pstr = (String) pathes.get(new Integer(
65: contentNodeParent));
66: if (pstr == null) {
67: continue;
68: }
69:
70: pathes.put(new Integer(contentNodeId), pstr + "/"
71: + nodeShortName);
72: }
73: }
74:
75: return pathes;
76: }
77: }
|