Exemplo n.º 1
0
 /**
  * Gets a handle to a connection object in the given application. This version opens the
  * connection by name If param is null or "" get the first connection available
  *
  * @param lAppID the appid of the application to get the connection for
  * @param sConnectionName the name of the connection
  * @return the JDBC connection object
  * @throws an Exception if there was a problem getting the connection
  */
 public Connection getDataConnection(long lAppID, String sConnectionName) throws Exception {
   TornadoServerInstance tsi = TornadoServer.getInstance();
   TornadoApplication ta = tsi.getTornadoApplication(lAppID);
   Connection cx = ta.getDataConnection(sConnectionName);
   m_htConnections.put(cx, cx);
   return cx;
 }
Exemplo n.º 2
0
 /** Used in webdesign.pma */
 public void releaseDataConnection(long lAppID, Connection cx) {
   TornadoServerInstance tsi = TornadoServer.getInstance();
   TornadoApplication ta = tsi.getTornadoApplication(lAppID);
   if (ta.releaseDataConnection(cx)) {
     m_htConnections.remove(cx);
     m_iDataConnReleaseCount++;
     return;
   }
 }
Exemplo n.º 3
0
  /** Finds an entry in the String table for i18n */
  public String getStringTableEntry(String sStringTableKey, String sVariables[]) {
    Locale loc = getLocale();

    TornadoServerInstance tsi = TornadoServer.getInstance(m_SysCtx);
    TornadoApplication ta = tsi.getTornadoApplication(this.getRequestPath().getPathToApplication());
    String sMessage = ta.getStringTableEntry(sStringTableKey, loc);

    return pmaLog.parseMessage(sMessage, sVariables);
  }
Exemplo n.º 4
0
  /**
   * Unlocks a database connection.
   *
   * @param cx the connection object to put back into the database pool
   */
  public void releaseDataConnection(Connection cx) {
    TornadoServerInstance tsi = TornadoServer.getInstance();
    TornadoApplication ta = tsi.getTornadoApplication(m_rPath.getPathToApplication());
    if (ta.releaseDataConnection(cx)) {
      m_htConnections.remove(cx);
      m_iDataConnReleaseCount++;
      return;
    }

    // Release by appid
    Hashtable htApp = tsi.getAllLoadedApplications();
    Iterator it = htApp.values().iterator();
    while (it.hasNext()) {
      ta = (TornadoApplication) it.next();
      if (ta.releaseDataConnection(cx)) return;
    }

    return;
  }
Exemplo n.º 5
0
  /**
   * Stores a new xsl resource based on the column names and design name
   *
   * @param sDesignName
   * @param sColumnNames
   * @return
   */
  private boolean saveXSLDesignElement(String sDesignName, String sColumnNames[]) {

    if (sDesignName == null
        || sDesignName.length() == 0
        || sColumnNames == null
        || sColumnNames.length == 0) {
      m_SysCtx.doError("HTTPSessionContext.NoXML", new String[] {sDesignName}, this);
      return false;
    }
    boolean bOK = true;
    Connection cx = null;
    PreparedStatement prepStmt = null;
    String sQuery;
    StringBuilder sbXSL = new StringBuilder(4096);

    sbXSL.append("<?xml version=\"1.0\"?>\r\n");
    sbXSL.append(
        "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\r\n\r\n");

    sbXSL.append("<xsl:output method=\"html\" indent=\"yes\"/>\r\n");

    sbXSL.append("<xsl:template match=\"/\">\r\n");
    sbXSL.append("\t<xsl:apply-templates/>\r\n");
    sbXSL.append("</xsl:template>\r\n\r\n");

    sbXSL.append("<xsl:template match=\"data\">\r\n");
    sbXSL.append("<table class=\"listTable\">\r\n");
    sbXSL.append("<thead>\r\n");
    sbXSL.append("<tr>\r\n");
    sbXSL.append("\t<th>&#160;</th>\r\n");
    // for each column, show the header
    for (int i = 0; i < sColumnNames.length; i++) {
      sbXSL.append("\t<th>");
      sbXSL.append(sColumnNames[i]);
      sbXSL.append("</th>\r\n");
    }
    sbXSL.append("</tr>\r\n");
    sbXSL.append("</thead>\r\n\r\n");

    sbXSL.append("<tbody>\r\n");
    sbXSL.append("<xsl:for-each select=\"row\">\r\n");
    sbXSL.append("<tr>\r\n");

    sbXSL.append(
        "\r\n\t<!-- Decimals: <xsl:value-of select=\"format-number(item[@name='numbercolumn']/value, '###,###.00')\" /> -->\r\n");
    sbXSL.append(
        "\t<!-- Totals: <xsl:value-of select=\"format-number(sum(/data/row/item[@name='numbercolumn']/value), '###,###.00')\" /> -->\r\n");
    sbXSL.append(
        "\t<!-- Dates: <xsl:value-of select=\"item[@name='datecolumn']/value/year\" /> (year,month,day,hour,minute,second) -->\r\n\r\n");

    // show an example of a delete column
    sbXSL.append("\t<td>\r\n");
    sbXSL.append(
        "\t\t<a><xsl:attribute name=\"href\">JavaScript:deleteRecord('<xsl:value-of select=\"item[@name='columnid']/value\"/>');</xsl:attribute>\r\n");
    sbXSL.append(
        "\t\t<img border=\"0\" alt=\"Delete this record\"><xsl:attribute name=\"src\"><xsl:value-of select=\"/data/@path\"/>/recyclebin.gif?OpenResource</xsl:attribute></img>\r\n");
    sbXSL.append("\t\t</a>\r\n");
    sbXSL.append("\t</td>\r\n");

    // for each column
    for (int i = 0; i < sColumnNames.length; i++) {
      sbXSL.append("\t<td>\r\n");
      if (i == 0)
        sbXSL.append(
            "\t\t<a><xsl:attribute name=\"href\"><xsl:value-of select=\"/data/@path\"/><xsl:text>/EditPageName?OpenPage&amp;id=</xsl:text><xsl:value-of select=\"item[@name='idcolumn']/value\"/></xsl:attribute>\r\n");
      sbXSL.append(
          "\t\t<xsl:value-of select=\"item[@name='"
              + sColumnNames[i].toLowerCase()
              + "']/value\"/>\r\n");
      if (i == 0) sbXSL.append("\t\t</a>\r\n");
      sbXSL.append("\t</td>\r\n");
    }

    sbXSL.append("</tr>\r\n");
    sbXSL.append("</xsl:for-each>\r\n");
    sbXSL.append("</tbody>\r\n\r\n");
    sbXSL.append("<!-- sum a column or count all the rows\r\n");
    sbXSL.append("<tr>\r\n");
    sbXSL.append(
        "\t<td>$<xsl:value-of select=\"format-number(sum(/data/row/item[@name='numbercolumn']/value), '###,###.00')\"/></td>\r\n");
    sbXSL.append("\t<td><xsl:value-of select=\"count(/data/row)\"/></td>\r\n");
    sbXSL.append("</tr>\r\n");
    sbXSL.append("-->\r\n\r\n");

    sbXSL.append("</table>\r\n");
    sbXSL.append("</xsl:template>\r\n");
    sbXSL.append("</xsl:stylesheet>\r\n");

    TornadoServerInstance tsi = TornadoServer.getInstance(m_SysCtx);
    try {
      cx = m_SysCtx.getSystemConnection();
      sQuery =
          "INSERT INTO DESIGNBUCKET(AppID,Name,DesignType,ContentType,Updated,UpdatedBy,Comment,Options,InheritFrom,DesignData) VALUES(?,?,?,?,?,?,?,?,?,?)";
      prepStmt = cx.prepareStatement(sQuery);
      long lAppID =
          tsi.getApplicationID(
              m_rPath.Group,
              m_rPath.Application); // HTTPServer.getAppID(m_SysCtx, m_rPath.Application,
      // m_rPath.Group);
      if (lAppID > 0) {
        prepStmt.setLong(1, lAppID);
        prepStmt.setString(2, sDesignName);
        prepStmt.setInt(3, DesignElement.DESIGN_TYPE_RESOURCE); // designtype

        // if(docDesign.getItemValue("Type").equals(String.valueOf(DesignElement.DESIGN_TYPE_PAGE)))
        // szMimeType = "text/html";
        prepStmt.setString(4, "text/xml"); // contenttype
        prepStmt.setTimestamp(5, new Timestamp((new java.util.Date()).getTime())); // updated
        prepStmt.setString(6, pmaSystem.SYSTEM_ACCOUNT); // updatedby
        prepStmt.setString(7, ""); // comment
        prepStmt.setString(8, "");
        prepStmt.setString(9, ""); // inherit

        prepStmt.setBinaryStream(
            10,
            new ByteArrayInputStream(sbXSL.toString().getBytes()),
            (int) sbXSL.length()); // designdata

        prepStmt.execute();
      } else bOK = false;

    } catch (Exception sqle) {
      m_SysCtx.doError(sqle.getMessage(), m_SessCtx);
    } finally {
      Util.closeJDBC(prepStmt);
      m_SysCtx.releaseSystemConnection(cx);
    }

    return bOK;
  }
Exemplo n.º 6
0
 /**
  * Get a list of all the connection names in the current application
  *
  * @return a Vector of Strings
  */
 public Vector getAllDataConnectionNames() {
   TornadoServerInstance tsi = TornadoServer.getInstance();
   TornadoApplication ta = tsi.getTornadoApplication(m_rPath.getPathToApplication());
   return ta.getAllDataConnectionNames();
 }
Exemplo n.º 7
0
 public String getDataConnectionProperty(String sConnectionName, String sPropertyName) {
   TornadoServerInstance tsi = TornadoServer.getInstance();
   TornadoApplication ta = tsi.getTornadoApplication(m_rPath.getPathToApplication());
   return ta.getDataConnectionProperty(sConnectionName, sPropertyName);
 }
Exemplo n.º 8
0
 /**
  * Gets a handle to a connection object. This version opens the connection by name If param is
  * null or "" get the first connection available
  *
  * @param sConnectionName the name of the connection as it appears in the application's design
  * @return a JDBC connection object, null if one could not be opened
  */
 public Connection getDataConnection(String sConnectionName) throws Exception {
   m_iDataConnGetCount++;
   TornadoServerInstance tsi = TornadoServer.getInstance();
   TornadoApplication ta = tsi.getTornadoApplication(m_rPath.getPathToApplication());
   return ta.getDataConnection(sConnectionName);
 }
Exemplo n.º 9
0
 /**
  * Get the named design element from the current application.
  *
  * @param sDesignName
  * @param iDesignType
  * @param sAppGroup
  * @param sAppName
  * @return null if not found or a Design element object
  */
 public DesignElement getDesignObject(
     String sDesignName, int iDesignType, String sAppGroup, String sAppName) {
   TornadoServerInstance tsi = TornadoServer.getInstance(m_SysCtx);
   return tsi.getDesignElement(sAppGroup, sAppName, sDesignName, iDesignType);
 }
Exemplo n.º 10
0
 /**
  * Return a list of all design element names for the specified type. Use -1 to get all design
  * element names regardless of type
  *
  * @param iDesignType Use DesignElement.DESIGN_TYPE_XXXXX eg DesignElement.DESIGN_TYPE_PAGE
  * @return a String array of all the design element names in this application
  */
 public String[] getAllDesignElementNames(int iDesignType) {
   TornadoServerInstance tsi = TornadoServer.getInstance(m_SysCtx);
   return tsi.getAllDesignElementNames(m_rPath.Group, m_rPath.Application, iDesignType);
 }
Exemplo n.º 11
0
 /**
  * Get the named design element from the current application.
  *
  * @param sDesignName The name of the design element as it appears in the design list eg
  *     "HomePage"
  * @param iDesignType Use DesignElement.DESIGN_TYPE_XXXXX eg DesignElement.DESIGN_TYPE_PAGE. the
  *     puakma.addin.http.document.DesignElement object for a list of types
  * @return null if not found
  */
 public DesignElement getDesignObject(String sDesignName, int iDesignType) {
   TornadoServerInstance tsi = TornadoServer.getInstance(m_SysCtx);
   return tsi.getDesignElement(m_rPath.Group, m_rPath.Application, sDesignName, iDesignType);
 }