* Obtain theme stylesheet description object for a given theme stylesheet id.
* @param stylesheetId the id of the theme stylesheet
* @return theme stylesheet description
*/
public ThemeStylesheetDescription getThemeStylesheetDescription (int stylesheetId) throws Exception {
ThemeStylesheetDescription tsd = null;
Connection con = null;
try {
con = RDBMServices.getConnection();
Statement stmt = con.createStatement();
int dbOffset = 0;
String sQuery = "SELECT SS_NAME,SS_URI,SS_DESCRIPTION_URI,SS_DESCRIPTION_TEXT,STRUCT_SS_ID,SAMPLE_ICON_URI,SAMPLE_URI,MIME_TYPE,DEVICE_TYPE,SERIALIZER_NAME,UP_MODULE_CLASS";
if (RDBMServices.getDbMetaData().supportsOuterJoins()) {
sQuery += ",TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM " + RDBMServices.getDbMetaData().getJoinQuery().getQuery("ss_theme");
dbOffset = 11;
} else {
sQuery += " FROM UP_SS_THEME UTS WHERE";
}
sQuery += " UTS.SS_ID=" + stylesheetId;
if (log.isDebugEnabled())
log.debug("RDBMUserLayoutStore::getThemeStylesheetDescription(): " + sQuery);
ResultSet rs = stmt.executeQuery(sQuery);
try {
if (rs.next()) {
tsd = new ThemeStylesheetDescription();
tsd.setId(stylesheetId);
tsd.setStylesheetName(rs.getString(1));
tsd.setStylesheetURI(rs.getString(2));
tsd.setStylesheetDescriptionURI(rs.getString(3));
tsd.setStylesheetWordDescription(rs.getString(4));
int ssId = rs.getInt(5);
if (rs.wasNull()) {
ssId = 0;
}
tsd.setStructureStylesheetId(ssId);
tsd.setSampleIconURI(rs.getString(6));
tsd.setSamplePictureURI(rs.getString(7));
tsd.setMimeType(rs.getString(8));
tsd.setDeviceType(rs.getString(9));
tsd.setSerializerName(rs.getString(10));
tsd.setCustomUserPreferencesManagerClass(rs.getString(11));
}
if (!RDBMServices.getDbMetaData().supportsOuterJoins()) {
rs.close();
// retrieve stylesheet params and attributes
sQuery = "SELECT TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM UP_SS_THEME_PARM WHERE SS_ID=" + stylesheetId;
if (log.isDebugEnabled())
log.debug("RDBMUserLayoutStore::getThemeStylesheetDescription(): " + sQuery);
rs = stmt.executeQuery(sQuery);
}
while (true) {
if (!RDBMServices.getDbMetaData().supportsOuterJoins() && !rs.next()) {
break;
}
int type = rs.getInt(dbOffset + 1);
if (rs.wasNull()) {
break;
}
if (type == 1) {
// param
tsd.addStylesheetParameter(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));
}
else if (type == 3) {
// channel attribute
tsd.addChannelAttribute(rs.getString(dbOffset + 2), rs.getString(dbOffset + 3), rs.getString(dbOffset + 4));
}
else if (type == 2) {
// folder attributes are not allowed here
log.error( "RDBMUserLayoutStore::getThemeStylesheetDescription() : encountered a folder attribute specified for a theme stylesheet ! Corrupted DB entry. (stylesheetId="
+ stylesheetId + " param_name=\"" + rs.getString(dbOffset + 2) + "\" type=" + type + ").");