Пример #1
0
  /**
   * Create a new AccessType with data fields.
   *
   * <p>The AccessType class has a sequence key; this method generates the sequence for later
   * insertion into the database.
   *
   * @param accessTypeId primary key attribute
   * @param name the name of the access type
   * @return the new AccessType object
   * @throws DelegateException when there is a problem generating the key or creating the object
   */
  public org.phoenixbioinformatics.api.bs.api.BsAccessType createAccessType(
      java.math.BigInteger accessTypeId, java.lang.String name) throws DelegateException {
    com.poesys.db.pk.SequencePrimaryKey key = null;

    // Generate a new AccessType id if the input key is null.
    if (accessTypeId == null) {
      java.sql.Connection connection = null;
      try {
        connection = getConnection();
        if (connection == null) {
          throw new DelegateException("Could not get database connection to generate sequence");
        }

        if (dbms.equals(DBMS.MYSQL) || dbms.equals(DBMS.JNDI_MYSQL)) {
          key =
              com.poesys.db.pk.PrimaryKeyFactory.createMySqlSequenceKey(
                  connection,
                  "AccessType_SEQ",
                  "accessTypeId",
                  "org.phoenixbioinformatics.api.db.api.AccessType");
        } else if (dbms.equals(DBMS.ORACLE) || dbms.equals(DBMS.JNDI_ORACLE)) {
          // Create key with sequence AccessType_SEQ
          key =
              com.poesys.db.pk.PrimaryKeyFactory.createOracleSequenceKey(
                  connection,
                  "AccessType_SEQ",
                  "accessTypeId",
                  "org.phoenixbioinformatics.api.db.api.AccessType");
        } else {
          throw new DelegateException("com.poesys.bs.delegate.msg.noDbms");
        }
        // Get the sequence number for use as an attribute value.
        accessTypeId = key.getValue();
      } catch (com.poesys.db.InvalidParametersException e) {
        Object[] args = e.getParameters().toArray();
        String message = com.poesys.db.Message.getMessage(e.getMessage(), args);
        throw new DelegateException(message, e);
      } catch (com.poesys.db.NoPrimaryKeyException e) {
        Object[] args = e.getParameters().toArray();
        String message = com.poesys.db.Message.getMessage(e.getMessage(), args);
        throw new DelegateException(message, e);
      } catch (java.sql.SQLException e) {
        throw new DelegateException(e.getMessage(), e);
      } finally {
        // Done with this connection, close it and return it to the pool.
        if (connection != null) {
          try {
            connection.close();
          } catch (java.sql.SQLException e) {
            throw new DelegateException(e.getMessage(), e);
          }
        }
      }
    } else {
      key =
          com.poesys.db.pk.PrimaryKeyFactory.createSequenceKey(
              "accessTypeId", accessTypeId, "org.phoenixbioinformatics.api.db.api.AccessType");
    }

    // Create a data-access DTO proxy (supports lazy loading).
    org.phoenixbioinformatics.api.db.api.IAccessType dto =
        new org.phoenixbioinformatics.api.db.api.AccessTypeProxy(
            new org.phoenixbioinformatics.api.db.api.AccessType(key, accessTypeId, name));

    // Create the business DTO.
    return new org.phoenixbioinformatics.api.bs.api.BsAccessType(dto);
  }
Пример #2
0
  /**
   * Create a new PageView with data fields.
   *
   * <p>The PageView class has a sequence key; this method generates the sequence for later
   * insertion into the database.
   *
   * @param pageViewId primary key attribute
   * @param pageViewDate the date and time of the page view request
   * @param uri the request URI and any query string
   * @param ip the IP address of the requests in the session; all page views in the session have
   *     this IP address
   * @param sessionId a token identifying a collection of page views as defined by the client
   *     processing the page views
   * @param partyId foreign key used by setter to query associated object
   * @return the new PageView object
   * @throws DelegateException when there is a problem generating the key or creating the object
   */
  public org.phoenixbioinformatics.api.bs.api.BsPageView createPageView(
      java.math.BigInteger pageViewId,
      java.sql.Timestamp pageViewDate,
      java.lang.String uri,
      java.lang.String ip,
      java.lang.String sessionId,
      java.math.BigInteger partyId)
      throws DelegateException {
    com.poesys.db.pk.SequencePrimaryKey key = null;

    // Generate a new PageView id if the input key is null.
    if (pageViewId == null) {
      java.sql.Connection connection = null;
      try {
        connection = getConnection();
        if (connection == null) {
          throw new DelegateException("Could not get database connection to generate sequence");
        }

        if (dbms.equals(DBMS.MYSQL) || dbms.equals(DBMS.JNDI_MYSQL)) {
          key =
              com.poesys.db.pk.PrimaryKeyFactory.createMySqlSequenceKey(
                  connection,
                  "PageView_SEQ",
                  "pageViewId",
                  "org.phoenixbioinformatics.api.db.api.PageView");
        } else if (dbms.equals(DBMS.ORACLE) || dbms.equals(DBMS.JNDI_ORACLE)) {
          // Create key with sequence PageView_SEQ
          key =
              com.poesys.db.pk.PrimaryKeyFactory.createOracleSequenceKey(
                  connection,
                  "PageView_SEQ",
                  "pageViewId",
                  "org.phoenixbioinformatics.api.db.api.PageView");
        } else {
          throw new DelegateException("com.poesys.bs.delegate.msg.noDbms");
        }
        // Get the sequence number for use as an attribute value.
        pageViewId = key.getValue();
      } catch (com.poesys.db.InvalidParametersException e) {
        Object[] args = e.getParameters().toArray();
        String message = com.poesys.db.Message.getMessage(e.getMessage(), args);
        throw new DelegateException(message, e);
      } catch (com.poesys.db.NoPrimaryKeyException e) {
        Object[] args = e.getParameters().toArray();
        String message = com.poesys.db.Message.getMessage(e.getMessage(), args);
        throw new DelegateException(message, e);
      } catch (java.sql.SQLException e) {
        throw new DelegateException(e.getMessage(), e);
      } finally {
        // Done with this connection, close it and return it to the pool.
        if (connection != null) {
          try {
            connection.close();
          } catch (java.sql.SQLException e) {
            throw new DelegateException(e.getMessage(), e);
          }
        }
      }
    } else {
      key =
          com.poesys.db.pk.PrimaryKeyFactory.createSequenceKey(
              "pageViewId", pageViewId, "org.phoenixbioinformatics.api.db.api.PageView");
    }

    // Create a data-access DTO for direct access, no proxy required.
    org.phoenixbioinformatics.api.db.api.IPageView dto =
        new org.phoenixbioinformatics.api.db.api.PageView(
            key, pageViewId, pageViewDate, uri, ip, sessionId, partyId);

    // Create the business DTO.
    return new org.phoenixbioinformatics.api.bs.api.BsPageView(dto);
  }