📄 rdbmuserlayoutstore.java
字号:
} return new Integer(id); } } finally { RDBMServices.closeResultSet(rs); RDBMServices.closeStatement(stmt); RDBMServices.releaseConnection(con); } return null; } /** * Obtain a list of structure stylesheet descriptions that have stylesheets for a given * mime type. * @param mimeType * @return a mapping from stylesheet names to structure stylesheet description objects */ public Hashtable getStructureStylesheetList (String mimeType) throws Exception { Connection con = RDBMServices.getConnection(); Hashtable list = new Hashtable(); try { Statement stmt = con.createStatement(); try { String sQuery = "SELECT A.SS_ID FROM UP_SS_STRUCT A, UP_SS_THEME B WHERE B.MIME_TYPE='" + mimeType + "' AND B.STRUCT_SS_ID=A.SS_ID"; log.debug("RDBMUserLayoutStore::getStructureStylesheetList() : " + sQuery); ResultSet rs = stmt.executeQuery(sQuery); try { while (rs.next()) { StructureStylesheetDescription ssd = getStructureStylesheetDescription(rs.getInt("SS_ID")); if (ssd != null) list.put(new Integer(ssd.getId()), ssd); } } finally { rs.close(); } } finally { stmt.close(); } } finally { RDBMServices.releaseConnection(con); } return list; } /** * Obtain a list of strcture stylesheet descriptions registered on the system * @return a <code>Hashtable</code> mapping stylesheet id (<code>Integer</code> objects) to {@link StructureStylesheetDescription} objects * @exception Exception */ public Hashtable getStructureStylesheetList() throws Exception { Connection con = RDBMServices.getConnection(); Hashtable list = new Hashtable(); try { Statement stmt = con.createStatement(); try { String sQuery = "SELECT SS_ID FROM UP_SS_STRUCT"; log.debug("RDBMUserLayoutStore::getStructureStylesheetList() : " + sQuery); ResultSet rs = stmt.executeQuery(sQuery); try { while (rs.next()) { StructureStylesheetDescription ssd = getStructureStylesheetDescription(rs.getInt("SS_ID")); if (ssd != null) list.put(new Integer(ssd.getId()), ssd); } } finally { rs.close(); } } finally { stmt.close(); } } finally { RDBMServices.releaseConnection(con); } return list; } public StructureStylesheetUserPreferences getStructureStylesheetUserPreferences (IPerson person, int profileId, int stylesheetId) throws Exception { int userId = person.getID(); StructureStylesheetUserPreferences ssup; Connection con = RDBMServices.getConnection(); try { Statement stmt = con.createStatement(); try { ResultSet rs = null; // get stylesheet description StructureStylesheetDescription ssd = getStructureStylesheetDescription(stylesheetId); // get user defined defaults int layoutId = this.getLayoutID(userId, profileId); if (layoutId == 0) { // First time, grab the default layout for this user String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=" + userId; log.debug("RDBMUserLayoutStore::getStructureStylesheetUserPreferences(): " + sQuery); rs = stmt.executeQuery(sQuery); try { rs.next(); userId = rs.getInt(1); } finally { rs.close(); } } String sQuery = "SELECT PARAM_NAME, PARAM_VAL FROM UP_SS_USER_PARM WHERE USER_ID=" + userId + " AND PROFILE_ID=" + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=1"; log.debug("RDBMUserLayoutStore::getStructureStylesheetUserPreferences(): " + sQuery); rs = stmt.executeQuery(sQuery); try { while (rs.next()) { // stylesheet param ssd.setStylesheetParameterDefaultValue(rs.getString(1), rs.getString(2)); } } finally { rs.close(); } ssup = new StructureStylesheetUserPreferences(); ssup.setStylesheetId(stylesheetId); // fill stylesheet description with defaults for (Enumeration e = ssd.getStylesheetParameterNames(); e.hasMoreElements();) { String pName = (String)e.nextElement(); ssup.putParameterValue(pName, ssd.getStylesheetParameterDefaultValue(pName)); } for (Enumeration e = ssd.getChannelAttributeNames(); e.hasMoreElements();) { String pName = (String)e.nextElement(); ssup.addChannelAttribute(pName, ssd.getChannelAttributeDefaultValue(pName)); } for (Enumeration e = ssd.getFolderAttributeNames(); e.hasMoreElements();) { String pName = (String)e.nextElement(); ssup.addFolderAttribute(pName, ssd.getFolderAttributeDefaultValue(pName)); } // get user preferences sQuery = "SELECT PARAM_NAME, PARAM_VAL, PARAM_TYPE, ULS.STRUCT_ID, CHAN_ID FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT ULS WHERE UUSA.USER_ID=" + userId + " AND PROFILE_ID=" + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=1 AND UUSA.STRUCT_ID = ULS.STRUCT_ID AND UUSA.USER_ID = ULS.USER_ID"; log.debug("RDBMUserLayoutStore::getStructureStylesheetUserPreferences(): " + sQuery); rs = stmt.executeQuery(sQuery); try { while (rs.next()) { String temp1=rs.getString(1); // Access columns left to right String temp2=rs.getString(2); int param_type = rs.getInt(3); int structId = rs.getInt(4); if (rs.wasNull()) { structId = 0; } int chanId = rs.getInt(5); if (rs.wasNull()) { chanId = 0; } if (param_type == 1) { // stylesheet param log.error( "RDBMUserLayoutStore::getStructureStylesheetUserPreferences() : stylesheet global params should be specified in the user defaults table ! UP_SS_USER_ATTS is corrupt. (userId=" + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId) + ", param_name=\"" + temp1 + "\", param_type=" + Integer.toString(param_type)); } else if (param_type == 2) { // folder attribute ssup.setFolderAttributeValue(getStructId(structId,chanId), temp1, temp2); } else if (param_type == 3) { // channel attribute ssup.setChannelAttributeValue(getStructId(structId,chanId), temp1, temp2); } else { // unknown param type log.error( "RDBMUserLayoutStore::getStructureStylesheetUserPreferences() : unknown param type encountered! DB corrupt. (userId=" + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId) + ", param_name=\"" + temp1 + "\", param_type=" + Integer.toString(param_type)); } } } finally { rs.close(); } } finally { stmt.close(); } } finally { RDBMServices.releaseConnection(con); } return ssup; } /** * 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.supportsOuterJoins) { sQuery += ",TYPE,PARAM_NAME,PARAM_DEFAULT_VAL,PARAM_DESCRIPT FROM " + RDBMServices.joinQuery.getQuery("ss_theme"); dbOffset = 11; } else { sQuery += " FROM UP_SS_THEME UTS WHERE"; } sQuery += " UTS.SS_ID=" + stylesheetId; 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.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; log.debug("RDBMUserLayoutStore::getThemeStylesheetDescription(): " + sQuery); rs = stmt.executeQuery(sQuery); } while (true) { if (!RDBMServices.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 + ")."); } else { log.error( "RDBMUserLayoutStore::getThemeStylesheetDescription() : encountered param of unknown type! (stylesheetId=" + stylesheetId + " param_name=\"" + rs.getString(dbOffset + 2) + "\" type=" + type + ")."); } if (RDBMServices.supportsOuterJoins && !rs.next()) { break; } } } finally { try { rs.close(); } catch (Exception e) {} try { stmt.close(); } catch (Exception e) {} } } finally { RDBMServices.releaseConnection(con); } return tsd; } /** * Obtain ID for known theme stylesheet name * @param tsName name of the theme stylesheet * @return id or null if no theme matches the name given. */ public Integer getThemeStylesheetId (String tsName) throws Exception { Integer id = null; Connection con = null; Statement stmt = null; ResultSet rs = null; try { con = RDBMServices.getConnection(); stmt = con.createStatement(); String sQuery = "SELECT SS_ID FROM UP_SS_THEME WHERE SS_NAME='" + tsName + "'"; rs = stmt.executeQuery(sQuery); if (rs.next()) { id = new Integer(rs.getInt("SS_ID")); } } finally { RDBMServices.closeResultSet(rs); RDBMServices.closeStatement(stmt); RDBMServices.releaseConnection(con); } return id; } /** * Obtain a list of theme stylesheet descriptions for a given structure stylesheet * @param structureStylesheetId * @return a map of stylesheet names to theme stylesheet description objects * @exception Exception */ public Hashtable getThemeStylesheetList (int structureStylesheetId) throws Exception { Connection con = RDBMServices.getConnection(); Hashtable list = new Hashtable(); try { Statement stmt = con.createStatement();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -