示例#1
0
  /**
   * Create a new object of type cls from a resultset row starting from a specified offset. This is
   * done so that you can select other rows than just those needed for this object. You may for
   * example want to create two objects from the same row.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static TOption row2Object(Record row, int offset, Class cls) throws TorqueException {
    try {
      TOption obj = (TOption) cls.newInstance();
      TOptionPeer.populateObject(row, offset, obj);
      obj.setModified(false);
      obj.setNew(false);

      return obj;
    } catch (InstantiationException e) {
      throw new TorqueException(e);
    } catch (IllegalAccessException e) {
      throw new TorqueException(e);
    }
  }
示例#2
0
  /**
   * selects a collection of TOption objects pre-filled with their TBLOB objects.
   *
   * <p>This method is protected by default in order to keep the public api reasonable. You can
   * provide public methods for those you actually need in TOptionPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List<TOption> doSelectJoinTBLOB(Criteria criteria, Connection conn)
      throws TorqueException {
    setDbName(criteria);

    TOptionPeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TBLOBPeer.addSelectColumns(criteria);

    criteria.addJoin(TOptionPeer.ICONKEY, TBLOBPeer.OBJECTID);

    correctBooleans(criteria);

    List<Record> rows;
    if (conn == null) {
      rows = BasePeer.doSelect(criteria);
    } else {
      rows = BasePeer.doSelect(criteria, conn);
    }

    List<TOption> results = new ArrayList<TOption>();

    for (int i = 0; i < rows.size(); i++) {
      Record row = rows.get(i);

      Class omClass = TOptionPeer.getOMClass();
      TOption obj1 = (TOption) TOptionPeer.row2Object(row, 1, omClass);
      omClass = TBLOBPeer.getOMClass();
      TBLOB obj2 = (TBLOB) TBLOBPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        TOption temp_obj1 = results.get(j);
        TBLOB temp_obj2 = (TBLOB) temp_obj1.getTBLOB();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addTOption(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initTOptions();
        obj2.addTOption(obj1);
      }
      results.add(obj1);
    }
    return results;
  }
示例#3
0
 /** Build a Criteria object from the data object for this peer, skipping all binary columns */
 public static Criteria buildSelectCriteria(TOption obj) {
   Criteria criteria = new Criteria(DATABASE_NAME);
   if (!obj.isNew()) {
     criteria.add(OBJECTID, obj.getObjectID());
   }
   criteria.add(LIST, obj.getList());
   criteria.add(LABEL, obj.getLabel());
   criteria.add(TOOLTIP, obj.getTooltip());
   criteria.add(PARENTOPTION, obj.getParentOption());
   criteria.add(SORTORDER, obj.getSortOrder());
   criteria.add(ISDEFAULT, obj.getIsDefault());
   criteria.add(DELETED, obj.getDeleted());
   criteria.add(SYMBOL, obj.getSymbol());
   criteria.add(ICONKEY, obj.getIconKey());
   criteria.add(ICONCHANGED, obj.getIconChanged());
   criteria.add(CSSSTYLE, obj.getCSSStyle());
   criteria.add(TPUUID, obj.getUuid());
   return criteria;
 }
示例#4
0
 /**
  * Method to do update. This method is to be used during a transaction, otherwise use the
  * doUpdate(TOption) method. It will take care of the connection details internally.
  *
  * @param obj the data object to update in the database.
  * @param con the connection to use
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void doUpdate(TOption obj, Connection con) throws TorqueException {
   doUpdate(buildCriteria(obj), con);
   obj.setModified(false);
 }
示例#5
0
 /**
  * Method to do inserts. This method is to be used during a transaction, otherwise use the
  * doInsert(TOption) method. It will take care of the connection details internally.
  *
  * @param obj the data object to insert into the database.
  * @param con the connection to use
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void doInsert(TOption obj, Connection con) throws TorqueException {
   obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
   obj.setNew(false);
   obj.setModified(false);
 }
示例#6
0
 /**
  * Populates an object from a resultset row starting from a specified offset. This is done so that
  * you can select other rows than just those needed for this object. You may for example want to
  * create two objects from the same row.
  *
  * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
  *     TorqueException.
  */
 public static void populateObject(Record row, int offset, TOption obj) throws TorqueException {
   try {
     obj.setObjectID(row.getValue(offset + 0).asIntegerObj());
     obj.setList(row.getValue(offset + 1).asIntegerObj());
     obj.setLabel(row.getValue(offset + 2).asString());
     obj.setTooltip(row.getValue(offset + 3).asString());
     obj.setParentOption(row.getValue(offset + 4).asIntegerObj());
     obj.setSortOrder(row.getValue(offset + 5).asIntegerObj());
     obj.setIsDefault(row.getValue(offset + 6).asString());
     obj.setDeleted(row.getValue(offset + 7).asString());
     obj.setSymbol(row.getValue(offset + 8).asString());
     obj.setIconKey(row.getValue(offset + 9).asIntegerObj());
     obj.setIconChanged(row.getValue(offset + 10).asString());
     obj.setCSSStyle(row.getValue(offset + 11).asString());
     obj.setUuid(row.getValue(offset + 12).asString());
   } catch (DataSetException e) {
     throw new TorqueException(e);
   }
 }