Ejemplo n.º 1
0
  private com.relteq.sirius.jaxb.Table restoreTable(Tables db_table) throws TorqueException {
    com.relteq.sirius.jaxb.Table table = factory.createTable();
    table.setName(db_table.getName());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER);
    @SuppressWarnings("unchecked")
    List<TabularDataKeys> db_tdk_l = db_table.getTabularDataKeyss(crit);
    com.relteq.sirius.jaxb.ColumnNames colnames = factory.createColumnNames();
    for (TabularDataKeys db_tdk : db_tdk_l) colnames.getColumnName().add(restoreColumnName(db_tdk));
    table.setColumnNames(colnames);

    crit.clear();
    crit.addJoin(TabularDataPeer.TABLE_ID, TabularDataKeysPeer.TABLE_ID);
    crit.addJoin(TabularDataPeer.COLUMN_NAME, TabularDataKeysPeer.COLUMN_NAME);
    crit.addAscendingOrderByColumn(TabularDataPeer.ROW_NUMBER);
    crit.addAscendingOrderByColumn(TabularDataKeysPeer.COLUMN_NUMBER);
    @SuppressWarnings("unchecked")
    List<TabularData> db_td_l = db_table.getTabularDatas(crit);
    com.relteq.sirius.jaxb.Row row = null;
    Integer rownum = null;
    java.util.Iterator<com.relteq.sirius.jaxb.ColumnName> citer = null;
    for (TabularData db_td : db_td_l) {
      if (null != rownum && !rownum.equals(db_td.getRowNumber())) {
        table.getRow().add(row);
        row = null;
      }
      if (null == row) {
        row = factory.createRow();
        citer = colnames.getColumnName().iterator();
      }
      while (citer.hasNext()) {
        com.relteq.sirius.jaxb.ColumnName colname = citer.next();
        if (colname.getValue().equals(db_td.getColumnName())) {
          row.getColumn().add(db_td.getValue());
          break;
        } else {
          row.getColumn().add(null);
          logger.warn(
              "Column "
                  + colname.getValue()
                  + " skipped (table="
                  + db_td.getId()
                  + ", row="
                  + db_td.getRowNumber()
                  + ")");
        }
      }
    }
    if (null != row) table.getRow().add(row);

    return table;
  }
Ejemplo n.º 2
0
  /**
   * selects a collection of OrdenTrabajo objects pre-filled with their Trabajador 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 OrdenTrabajoPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List doSelectJoinTrabajador(Criteria criteria) throws TorqueException {
    setDbName(criteria);

    OrdenTrabajoPeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TrabajadorPeer.addSelectColumns(criteria);

    criteria.addJoin(OrdenTrabajoPeer.RESPONSABLE_ID, TrabajadorPeer.ID);

    List rows = BasePeer.doSelect(criteria);
    List results = new ArrayList();

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

      Class omClass = OrdenTrabajoPeer.getOMClass();
      OrdenTrabajo obj1 = (OrdenTrabajo) OrdenTrabajoPeer.row2Object(row, 1, omClass);
      omClass = TrabajadorPeer.getOMClass();
      Trabajador obj2 = (Trabajador) TrabajadorPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        OrdenTrabajo temp_obj1 = (OrdenTrabajo) results.get(j);
        Trabajador temp_obj2 = (Trabajador) temp_obj1.getTrabajador();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          break;
        }
      }
      results.add(obj1);
    }
    return results;
  }
Ejemplo n.º 3
0
 public DBOutputWriter(Scenario scenario) {
   super(scenario);
   try {
     db_scenario = ScenariosPeer.retrieveByPK(str2id(scenario.getId()));
   } catch (NoRowsException exc) {
     logger.error("Scenario " + str2id(scenario.getId()) + " was not found in the database");
   } catch (TooManyRowsException exc) {
     logger.error("Data integrity violation", exc);
   } catch (TorqueException exc) {
     logger.error("Could not load scenario " + str2id(scenario.getId()), exc);
   }
   db_vehicle_type = new VehicleTypes[scenario.getNumVehicleTypes()];
   if (null != db_scenario) {
     logger.info("Loading vehicle types");
     Criteria crit = new Criteria();
     crit.addJoin(VehicleTypesPeer.VEHICLE_TYPE_ID, VehicleTypesInSetsPeer.VEHICLE_TYPE_ID);
     crit.add(VehicleTypesInSetsPeer.VEHICLE_TYPE_SET_ID, db_scenario.getVehicleTypeSetId());
     try {
       @SuppressWarnings("unchecked")
       List<VehicleTypes> db_vt_l = VehicleTypesPeer.doSelect(crit);
       for (VehicleTypes db_vt : db_vt_l)
         for (int i = 0; i < scenario.getNumVehicleTypes(); ++i)
           if (db_vt.getName().equals(scenario.getVehicleTypeNames()[i]))
             db_vehicle_type[i] = db_vt;
     } catch (TorqueException exc) {
       logger.error("Failed to load vehicle types for scenario " + db_scenario.getId(), exc);
     }
   }
 }
Ejemplo n.º 4
0
 private com.relteq.sirius.jaxb.VehicleTypes restoreVehicleTypes(VehicleTypeSets db_vtsets)
     throws TorqueException {
   if (null == db_vtsets) return null;
   Criteria crit = new Criteria();
   crit.addJoin(VehicleTypesInSetsPeer.VEHICLE_TYPE_ID, VehicleTypesPeer.VEHICLE_TYPE_ID);
   crit.add(VehicleTypesInSetsPeer.VEHICLE_TYPE_SET_ID, db_vtsets.getId());
   crit.add(VehicleTypesPeer.PROJECT_ID, db_vtsets.getProjectId());
   crit.addAscendingOrderByColumn(VehicleTypesPeer.VEHICLE_TYPE_ID);
   @SuppressWarnings("unchecked")
   List<VehicleTypes> db_vt_l = VehicleTypesPeer.doSelect(crit);
   if (db_vt_l.isEmpty()) return null;
   com.relteq.sirius.jaxb.VehicleTypes vtypes = factory.createVehicleTypes();
   for (VehicleTypes db_vt : db_vt_l) vtypes.getVehicleType().add(restoreVehicleType(db_vt));
   return vtypes;
 }
Ejemplo n.º 5
0
  /**
   * selects a collection of TRoleListType objects pre-filled with their TListType 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 TRoleListTypePeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List<TRoleListType> doSelectJoinTListType(Criteria criteria, Connection conn)
      throws TorqueException {
    setDbName(criteria);

    TRoleListTypePeer.addSelectColumns(criteria);
    int offset = numColumns + 1;
    TListTypePeer.addSelectColumns(criteria);

    criteria.addJoin(TRoleListTypePeer.LISTTYPE, TListTypePeer.PKEY);

    correctBooleans(criteria);

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

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

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

      Class omClass = TRoleListTypePeer.getOMClass();
      TRoleListType obj1 = (TRoleListType) TRoleListTypePeer.row2Object(row, 1, omClass);
      omClass = TListTypePeer.getOMClass();
      TListType obj2 = (TListType) TListTypePeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        TRoleListType temp_obj1 = results.get(j);
        TListType temp_obj2 = (TListType) temp_obj1.getTListType();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addTRoleListType(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initTRoleListTypes();
        obj2.addTRoleListType(obj1);
      }
      results.add(obj1);
    }
    return results;
  }
Ejemplo n.º 6
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;
  }
  /**
   * selects a collection of System_Log objects pre-filled with their User 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 System_LogPeer.
   *
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  protected static List doSelectJoinUser(Criteria c) throws TorqueException {
    // Set the correct dbName if it has not been overridden
    // c.getDbName will return the same object if not set to
    // another value so == check is okay and faster
    if (c.getDbName() == Torque.getDefaultDB()) {
      c.setDbName(DATABASE_NAME);
    }

    System_LogPeer.addSelectColumns(c);
    int offset = numColumns + 1;
    UserPeer.addSelectColumns(c);

    c.addJoin(System_LogPeer.USER_ID, UserPeer.USER_ID);

    List rows = BasePeer.doSelect(c);
    List results = new ArrayList();

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

      Class omClass = System_LogPeer.getOMClass();
      System_Log obj1 = (System_Log) System_LogPeer.row2Object(row, 1, omClass);
      omClass = UserPeer.getOMClass();
      User obj2 = (User) UserPeer.row2Object(row, offset, omClass);

      boolean newObject = true;
      for (int j = 0; j < results.size(); j++) {
        System_Log temp_obj1 = (System_Log) results.get(j);
        User temp_obj2 = (User) temp_obj1.getUser();
        if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) {
          newObject = false;
          temp_obj2.addSystem_Log(obj1);
          break;
        }
      }
      if (newObject) {
        obj2.initSystem_Logs();
        obj2.addSystem_Log(obj1);
      }
      results.add(obj1);
    }
    return results;
  }
Ejemplo n.º 8
0
 /**
  * Gets the custom option attributeValueBeans for a prepared criteria
  *
  * @param preparedCriteria
  * @return
  * @throws TorqueException
  */
 private static List<TAttributeValueBean> getReportCustomOptionAttributeValues(
     Criteria preparedCriteria) throws TorqueException {
   preparedCriteria.addJoin(BaseTWorkItemPeer.WORKITEMKEY, BaseTAttributeValuePeer.WORKITEM);
   preparedCriteria.addJoin(BaseTAttributeValuePeer.CUSTOMOPTIONID, BaseTOptionPeer.OBJECTID);
   return convertTorqueListToBeanList(doSelect(preparedCriteria));
 }
Ejemplo n.º 9
0
 /**
  * Gets the attributeValueBeans for a prepared criteria
  *
  * @param preparedCriteria
  * @return
  * @throws TorqueException
  */
 private static List<TAttributeValueBean> getCustomAttributeValues(Criteria preparedCriteria)
     throws TorqueException {
   preparedCriteria.addJoin(TWorkItemPeer.WORKITEMKEY, TAttributeValuePeer.WORKITEM);
   return convertTorqueListToBeanList(doSelect(preparedCriteria));
 }