Package org.jasig.portal

Examples of org.jasig.portal.StructureStylesheetUserPreferences


    return  tsup;
  }

  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 {
        // get stylesheet description
        StructureStylesheetDescription ssd = getStructureStylesheetDescription(stylesheetId);
        // get user defined defaults
        String subSelectString = "SELECT LAYOUT_ID FROM UP_USER_PROFILE WHERE USER_ID=" + userId + " AND PROFILE_ID=" +
            profileId;
        if (log.isDebugEnabled())
            log.debug("RDBMUserLayoutStore::getStructureStylesheetUserPreferences(): " + subSelectString);
        int layoutId = 0;
        ResultSet rs = stmt.executeQuery(subSelectString);
        try {
          if (rs.next()) {
              layoutId = rs.getInt(1);
          }
        } finally {
          rs.close();
        }
       
        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;
          if (log.isDebugEnabled())
              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";
        if (log.isDebugEnabled())
            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.NODE_ID, CHAN_ID FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT_AGGR ULS WHERE UUSA.USER_ID=" + userId + " AND PROFILE_ID="
            + profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=1 AND UUSA.STRUCT_ID = ULS.NODE_ID AND UUSA.USER_ID = ULS.USER_ID";
        if (log.isDebugEnabled())
            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( "AggregatedUserLayoutStore::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( "AggregatedUserLayoutStore::getStructureStylesheetUserPreferences() : unknown param type encountered! DB corrupt. (userId="
                  + Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
View Full Code Here


            Element folder = (Element) nodes.item(i);
            String name = folder.getAttribute("name");
            if (name.equals("Sticky Tab"))
            {
                String id = folder.getAttribute(Constants.ATT_ID);
                StructureStylesheetUserPreferences ssup
                    = prefs.getStructureStylesheetUserPreferences();
                ssup.putParameterValue("activeTab", id);
                ssup.putParameterValue("tabID", id);
            }
        }
    }
View Full Code Here

    return activeTab;
  }

  private final void setActiveTab(String activeTab) throws Exception
  {
    StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
    ssup.putParameterValue("activeTab", activeTab);

    // Persist structure stylesheet user preferences
    int profileId = editedUserProfile.getProfileId();
    ulStore.setStructureStylesheetUserPreferences(staticData.getPerson(), profileId, ssup);
  }
View Full Code Here

      }
  }

  private final void changeColumnWidths(HashMap columnWidths) throws Exception
  {
    StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
    java.util.Set sColWidths = columnWidths.keySet();
    java.util.Iterator iterator = sColWidths.iterator();
    while(iterator.hasNext())
    {
      String folderId = (String)iterator.next();
      String newWidth = (String)columnWidths.get(folderId);

      // Only accept widths that are either percentages or integers (fixed widths)
      boolean widthIsValid = true;
      try
      {
        Integer.parseInt(newWidth.endsWith("%") ? newWidth.substring(0, newWidth.indexOf("%")) : newWidth);
      }
      catch (java.lang.NumberFormatException nfe)
      {
        widthIsValid = false;
      }

      if (widthIsValid)
        ssup.setFolderAttributeValue(folderId, "width", newWidth);
      else
        if (log.isDebugEnabled())
            log.debug("User id " + staticData.getPerson().getID() + " entered invalid column width: " + newWidth);

    }
View Full Code Here

    // Simply divide the number of columns by 100 and produce an evenly numbered column widths
    int columns = list.getLength();
    int columnSize = 100 / columns;
    int remainder = 100 % columns;
    // Traverse through the columns and reset with the new caculated value
    StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
    for (int i=0; i < list.getLength(); i++){
        Element c = (Element) list.item(i);
        String nId = c.getAttribute("ID");
        ssup.setFolderAttributeValue(nId, "width", (i == (list.getLength() - 1) ? columnSize+remainder+"%" : columnSize+"%"));
    }
  }
View Full Code Here

        /*
         * Clean up the DOM for export.
         */
       
        // (1) Add structure & theme attributes...
        StructureStylesheetUserPreferences ssup = up.getStructureStylesheetUserPreferences();
        // The structure transform supports both 'folder' and 'channel' attributes...
        List<String> structFolderAttrNames = Collections.list(ssup.getFolderAttributeNames());
        for (Iterator<org.dom4j.Element> fldrs = (Iterator<org.dom4j.Element>) layoutDoc.selectNodes("//folder").iterator(); fldrs.hasNext();) {
            org.dom4j.Element fld = fldrs.next();
            for (String attr : structFolderAttrNames) {
                String val = ssup.getDefinedFolderAttributeValue(fld.valueOf("@ID"), attr);
                if (val != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Adding structure folder attribute:  name=" + attr + ", value=" + val);
                    }
                    org.dom4j.Element sa = fac.createElement("structure-attribute");
                    org.dom4j.Element n = sa.addElement("name");
                    n.setText(attr);
                    org.dom4j.Element v = sa.addElement("value");
                    v.setText(val);
                    fld.elements().add(0, sa);
                }
            }
        }
        List<String> structChannelAttrNames = Collections.list(ssup.getChannelAttributeNames());
        for (Iterator<org.dom4j.Element> chnls = (Iterator<org.dom4j.Element>) layoutDoc.selectNodes("//channel").iterator(); chnls.hasNext();) {
            org.dom4j.Element chnl = chnls.next();
            for (String attr : structChannelAttrNames) {
                String val = ssup.getDefinedChannelAttributeValue(chnl.valueOf("@ID"), attr);
                if (val != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Adding structure channel attribute:  name=" + attr + ", value=" + val);
                    }
                    org.dom4j.Element sa = fac.createElement("structure-attribute");
View Full Code Here

            up.setThemeStylesheetUserPreferences(this.getDistributedTSUP(person,
                        profile.getProfileId(), profile.getThemeStylesheetId()));
           
            // Structure Attributes.
            boolean saSet = false;
            StructureStylesheetUserPreferences ssup = up.getStructureStylesheetUserPreferences();
            // ssup must be manually cleaned out.
            for (Enumeration<String> names = (Enumeration<String>) ssup.getFolderAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> fIds = (Enumeration<String>) ssup.getFolders(); fIds.hasMoreElements();) {
                    String f = fIds.nextElement();
                    if (ssup.getDefinedFolderAttributeValue(f, n) != null) {
                        ssup.removeFolder(f);
                    }
                }
            }
            for (Enumeration<String> names = (Enumeration<String>) ssup.getChannelAttributeNames(); names.hasMoreElements();) {
                String n = names.nextElement();
                for (Enumeration<String> chds = (Enumeration<String>) ssup.getChannels(); chds.hasMoreElements();) {
                    String c = chds.nextElement();
                    if (ssup.getDefinedChannelAttributeValue(c, n) != null) {
                        ssup.removeChannel(c);
                    }
                }
            }
            for (Iterator<org.dom4j.Element> it = (Iterator<org.dom4j.Element>) layout.selectNodes("//structure-attribute").iterator(); it.hasNext();) {
                org.dom4j.Element sa = (org.dom4j.Element) it.next();
                String idAttr = sa.getParent().valueOf("@ID");
                if (sa.getParent().getName().equals("folder")) {
                    ssup.setFolderAttributeValue(idAttr, sa.valueOf("name"), sa.valueOf("value"));
                    saSet = true;
                } else if (sa.getParent().getName().equals("channel")) {
                    ssup.setChannelAttributeValue(idAttr, sa.valueOf("name"), sa.valueOf("value"));
                    saSet = true;
                } else {
                    String msg = "Unrecognized parent element for user preferences attribute:  " + sa.getParent().getName();
                    throw new RuntimeException(msg);
                }
View Full Code Here

    return activeTab;
  }

  private final void setActiveTab(String activeTab) throws Exception
  {
    StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
    ssup.putParameterValue("activeTab", activeTab);

    // Persist structure stylesheet user preferences
    int profileId = editedUserProfile.getProfileId();
    ulStore.setStructureStylesheetUserPreferences(staticData.getPerson(), profileId, ssup);
  }
View Full Code Here

              tab.setName(tabName);
          }
          ulm.updateNode(tab);

          // Update the externalId...
          StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
          if (tabExternalId != null && tabExternalId.trim().length() != 0) {
              try {
                  ssup.setFolderAttributeValue(tab.getId(), "externalId", tabExternalId);
                  ulStore.setStructureStylesheetUserPreferences(staticData.getPerson(),
                                editedUserProfile.getProfileId(), ssup);
              } catch (Exception e) {
                throw new PortalException("Failed to set the 'externalId' attribute of tab '" +
                            tabId + "' in StructureStylesheetUserPreferences", e);
              }
          } else {
            // tabExternalId is not specified... need to remove it if present...
            if (ssup.getDefinedFolderAttributeValue(tab.getId(), "externalId") != null) {
              // It *is* previously specified, and being removed...
                  try {
                    // Setting to null and saving will remove it from DB.
                      ssup.setFolderAttributeValue(tab.getId(), "externalId", null);
                      ulStore.setStructureStylesheetUserPreferences(staticData.getPerson(),
                                  editedUserProfile.getProfileId(), ssup);
                  } catch (Exception e) {
                    throw new PortalException("Failed to remove the 'externalId' attribute of tab '" +
                                tabId + "' in StructureStylesheetUserPreferences", e);
View Full Code Here

    ulm.addNode(newTab,ulm.getRootFolderId(),siblingId);

    // Update the externalId...
    if (tabExternalId != null) {
        try {
            StructureStylesheetUserPreferences ssup = userPrefs.getStructureStylesheetUserPreferences();
            ssup.setFolderAttributeValue(newTab.getId(), "externalId", tabExternalId);
            int profileId = editedUserProfile.getProfileId();
            ulStore.setStructureStylesheetUserPreferences(staticData.getPerson(), profileId, ssup);
        } catch (Exception e) {
          throw new PortalException("Failed to set the 'externalId' attribute of tab '" +
                newTab.getId() + "' in StructureStylesheetUserPreferences", e);
View Full Code Here

TOP

Related Classes of org.jasig.portal.StructureStylesheetUserPreferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.