Example #1
0
  private com.relteq.sirius.jaxb.DemandProfile restoreDemandProfile(DemandProfiles db_dp)
      throws TorqueException {
    com.relteq.sirius.jaxb.DemandProfile dp = factory.createDemandProfile();
    dp.setKnob(db_dp.getKnob());
    dp.setStartTime(db_dp.getStartTime());
    dp.setDt(db_dp.getDt());
    dp.setLinkIdOrigin(id2str(db_dp.getOriginLinkId()));
    if (null != db_dp.getDestinationLinkId())
      dp.setDestinationLinkId(id2str(db_dp.getDestinationLinkId()));
    dp.setStdDevAdd(db_dp.getStdDeviationAdditive());
    dp.setStdDevMult(db_dp.getStdDeviationMultiplicative());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(DemandsPeer.NUMBER);
    crit.addAscendingOrderByColumn(DemandsPeer.VEHICLE_TYPE_ID);
    @SuppressWarnings("unchecked")
    List<Demands> db_demand_l = db_dp.getDemandss(crit);
    StringBuilder sb = null;
    Integer number = null;
    for (Demands db_demand : db_demand_l) {
      if (null == sb) sb = new StringBuilder();
      else sb.append(db_demand.getNumber().equals(number) ? ':' : ',');
      number = db_demand.getNumber();
      sb.append(db_demand.getDemand().toPlainString());
    }
    if (null != sb) dp.setContent(sb.toString());
    return dp;
  }
Example #2
0
 private com.relteq.sirius.jaxb.NetworkConnections restoreNetworkConnections(
     NetworkConnectionSets db_ncs) throws TorqueException {
   if (null == db_ncs) return null;
   com.relteq.sirius.jaxb.NetworkConnections nc = factory.createNetworkConnections();
   nc.setId(id2str(db_ncs.getId()));
   nc.setName(db_ncs.getName());
   nc.setDescription(db_ncs.getDescription());
   Criteria crit = new Criteria();
   crit.addAscendingOrderByColumn(NetworkConnectionsPeer.FROM_NETWORK_ID);
   crit.addAscendingOrderByColumn(NetworkConnectionsPeer.TO_NETWORK_ID);
   @SuppressWarnings("unchecked")
   List<NetworkConnections> db_nc_l = db_ncs.getNetworkConnectionss(crit);
   com.relteq.sirius.jaxb.Networkpair np = null;
   for (NetworkConnections db_nc : db_nc_l) {
     if (null != np
         && (!np.getNetworkA().equals(id2str(db_nc.getFromNetworkId()))
             || !np.getNetworkB().equals(id2str(db_nc.getToNetworkId())))) {
       nc.getNetworkpair().add(np);
       np = null;
     }
     if (null == np) {
       np = factory.createNetworkpair();
       np.setNetworkA(id2str(db_nc.getFromNetworkId()));
       np.setNetworkB(id2str(db_nc.getToNetworkId()));
     }
     com.relteq.sirius.jaxb.Linkpair lp = factory.createLinkpair();
     lp.setLinkA(id2str(db_nc.getFromLinkId()));
     lp.setLinkB(id2str(db_nc.getToLinkId()));
     np.getLinkpair().add(lp);
   }
   if (null != np) nc.getNetworkpair().add(np);
   return nc;
 }
Example #3
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;
  }
Example #4
0
  private com.relteq.sirius.jaxb.Event restoreEvent(Events db_event) throws TorqueException {
    com.relteq.sirius.jaxb.Event event = factory.createEvent();
    event.setId(id2str(db_event.getId()));
    event.setTstamp(db_event.getTstamp());
    event.setEnabled(db_event.getEnabled());
    event.setType(db_event.getType());
    event.setJavaClass(db_event.getJavaClass());
    event.setDescription(db_event.getDescription());
    event.setDisplayPosition(restorePosition(db_event.getDisplayGeometry()));
    event.setTargetElements(restoreTargetElements(db_event));
    event.setParameters(restoreParameters(db_event));

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(EventSplitRatiosPeer.IN_LINK_ID);
    crit.addAscendingOrderByColumn(EventSplitRatiosPeer.OUT_LINK_ID);
    crit.addAscendingOrderByColumn(EventSplitRatiosPeer.VEHICLE_TYPE_ID);
    @SuppressWarnings("unchecked")
    List<EventSplitRatios> db_esr_l = db_event.getEventSplitRatioss(crit);
    if (!db_esr_l.isEmpty()) {
      com.relteq.sirius.jaxb.SplitratioEvent srevent = factory.createSplitratioEvent();
      com.relteq.sirius.jaxb.Splitratio sr = null;
      StringBuilder sb = new StringBuilder();
      for (EventSplitRatios db_esr : db_esr_l) {
        if (null != sr
            && !(sr.getLinkIn().equals(id2str(db_esr.getInLinkId()))
                && sr.getLinkOut().equals(id2str(db_esr.getOutLinkId())))) {
          sr.setContent(sb.toString());
          sb.setLength(0);
          srevent.getSplitratio().add(sr);
          sr = null;
        }
        if (null == sr) {
          sr = factory.createSplitratio();
          sr.setLinkIn(id2str(db_esr.getInLinkId()));
          sr.setLinkOut(id2str(db_esr.getOutLinkId()));
        } else sb.append(':');
        // TODO revise: check if there are missing vehicle types
        sb.append(db_esr.getSplitRatio().toPlainString());
      }
      if (null != sr) {
        sr.setContent(sb.toString());
        srevent.getSplitratio().add(sr);
      }
      event.setSplitratioEvent(srevent);
    }

    return event;
  }
Example #5
0
 /**
  * Get the root categories
  *
  * @param repository
  * @param projectID
  * @param personID filter by only if set
  * @return
  */
 @Override
 public List<TReportCategoryBean> loadRootCategories(
     Integer repository, Integer projectID, Integer personID) {
   List<TReportCategory> categories = null;
   Criteria criteria = new Criteria();
   criteria.add(REPOSITORY, repository);
   criteria.add(PARENTID, (Object) null, Criteria.ISNULL);
   if (projectID == null) {
     criteria.add(PROJECT, (Object) null, Criteria.ISNULL);
   } else {
     criteria.add(PROJECT, projectID);
   }
   if (personID != null) {
     criteria.add(CREATEDBY, personID);
   }
   criteria.addAscendingOrderByColumn(LABEL);
   try {
     categories = doSelect(criteria);
   } catch (Exception e) {
     LOGGER.error(
         "Getting root report categories by repository "
             + repository
             + " project "
             + projectID
             + " person "
             + personID
             + " failed with "
             + e.getMessage(),
         e);
   }
   return convertTorqueListToBeanList(categories);
 }
Example #6
0
 /**
  * Loads filterCategoryBeans by repository
  *
  * @param repository
  * @param personID
  * @return
  */
 @Override
 public List<TReportCategoryBean> loadByRepositoryPersonProjects(
     Integer repository, Integer personID, List<Integer> projects) {
   List<TReportCategory> categories = new ArrayList<TReportCategory>();
   Criteria criteria = new Criteria();
   criteria.add(REPOSITORY, repository);
   if (personID != null) {
     criteria.add(CREATEDBY, personID);
   }
   if (projects != null && !projects.isEmpty()) {
     criteria.addIn(PROJECT, projects);
   }
   criteria.addAscendingOrderByColumn(LABEL);
   try {
     categories.addAll(doSelect(criteria));
   } catch (Exception e) {
     LOGGER.error(
         "Getting filter categories by repository "
             + repository
             + " personID "
             + personID
             + " projects "
             + projects
             + " failed with "
             + e.getMessage(),
         e);
   }
   return convertTorqueListToBeanList(categories);
 }
Example #7
0
 /**
  * Loads a filterCategoryBeans by parentIDs
  *
  * @param parentIDs
  * @return
  */
 @Override
 public List<TReportCategoryBean> loadByParents(List<Integer> parentIDs) {
   List<TReportCategory> categories = new ArrayList<TReportCategory>();
   if (parentIDs == null || parentIDs.isEmpty()) {
     return new ArrayList<TReportCategoryBean>();
   }
   List<int[]> parentIDChunksList = GeneralUtils.getListOfChunks(parentIDs);
   if (parentIDChunksList != null && !parentIDChunksList.isEmpty()) {
     Iterator<int[]> iterator = parentIDChunksList.iterator();
     while (iterator.hasNext()) {
       int[] parentIDsChunk = iterator.next();
       Criteria criteria = new Criteria();
       criteria.addIn(PARENTID, parentIDsChunk);
       criteria.addAscendingOrderByColumn(LABEL);
       try {
         categories.addAll(doSelect(criteria));
       } catch (Exception e) {
         LOGGER.error(
             "Getting the report categories by parents "
                 + parentIDsChunk.length
                 + " failed with "
                 + e.getMessage(),
             e);
       }
     }
   }
   return convertTorqueListToBeanList(categories);
 }
Example #8
0
  private com.relteq.sirius.jaxb.SplitratioProfile restoreSplitRatioProfile(
      SplitRatioProfiles db_srp) throws TorqueException {
    com.relteq.sirius.jaxb.SplitratioProfile srp = factory.createSplitratioProfile();
    srp.setNodeId(id2str(db_srp.getNodeId()));
    srp.setDt(db_srp.getDt());
    srp.setStartTime(db_srp.getStartTime());
    if (null != db_srp.getDestinationLinkId())
      srp.setLinkIdDestination(id2str(db_srp.getDestinationLinkId()));

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(SplitRatiosPeer.IN_LINK_ID);
    crit.addAscendingOrderByColumn(SplitRatiosPeer.OUT_LINK_ID);
    crit.addAscendingOrderByColumn(SplitRatiosPeer.ORDINAL);
    crit.addAscendingOrderByColumn(SplitRatiosPeer.VEHICLE_TYPE_ID);
    @SuppressWarnings("unchecked")
    List<SplitRatios> db_sr_l = db_srp.getSplitRatioss(crit);
    com.relteq.sirius.jaxb.Splitratio sr = null;
    Integer ordinal = null;
    StringBuilder sb = new StringBuilder();
    for (SplitRatios db_sr : db_sr_l) {
      if (null != sr
          && !(sr.getLinkIn().equals(id2str(db_sr.getInLinkId()))
              && sr.getLinkOut().equals(id2str(db_sr.getOutLinkId())))) {
        sr.setContent(sb.toString());
        srp.getSplitratio().add(sr);
        sr = null;
      }
      if (null == sr) { // new split ratio
        sr = factory.createSplitratio();
        sr.setLinkIn(id2str(db_sr.getInLinkId()));
        sr.setLinkOut(id2str(db_sr.getOutLinkId()));
        sb.setLength(0);
      } else { // same split ratio, different time stamp (',') or vehicle type (':')
        sb.append(db_sr.getOrdinal().equals(ordinal) ? ':' : ',');
      }
      ordinal = db_sr.getOrdinal();
      sb.append(db_sr.getSplitRatio().toPlainString());
    }
    if (null != sr) {
      sr.setContent(sb.toString());
      srp.getSplitratio().add(sr);
    }
    return srp;
  }
 private Criteria ordenacion(Criteria c, String CampoOrdenacion, String OrdenOrdenacion) {
   if ((OrdenOrdenacion != null) && (OrdenOrdenacion.compareTo("ASC") == 0))
     if ((CampoOrdenacion != null)) {
       c.addAscendingOrderByColumn(CampoOrdenacion.toString());
     }
   if ((OrdenOrdenacion != null) && (OrdenOrdenacion.compareTo("DESC") == 0))
     if ((CampoOrdenacion != null)) {
       c.addDescendingOrderByColumn(CampoOrdenacion.toString());
     }
   return c;
 }
Example #10
0
  private com.relteq.sirius.jaxb.WeavingFactorSet restoreWeavingFactorSet(
      WeavingFactorSets db_wfset) throws TorqueException {
    if (null == db_wfset) return null;
    com.relteq.sirius.jaxb.WeavingFactorSet wfset = factory.createWeavingFactorSet();
    wfset.setId(id2str(db_wfset.getId()));
    wfset.setName(db_wfset.getName());
    wfset.setDescription(db_wfset.getDescription());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(WeavingFactorsPeer.IN_LINK_ID);
    crit.addAscendingOrderByColumn(WeavingFactorsPeer.OUT_LINK_ID);
    crit.addAscendingOrderByColumn(WeavingFactorsPeer.VEHICLE_TYPE_ID);
    @SuppressWarnings("unchecked")
    List<WeavingFactors> db_wf_l = db_wfset.getWeavingFactorss(crit);
    com.relteq.sirius.jaxb.Weavingfactors wf = null;
    StringBuilder sb = new StringBuilder();
    for (WeavingFactors db_wf : db_wf_l) {
      if (null != wf
          && !(wf.getLinkIn().equals(id2str(db_wf.getInLinkId()))
              && wf.getLinkOut().equals(id2str(db_wf.getOutLinkId())))) {
        wf.setContent(sb.toString());
        wfset.getWeavingfactors().add(wf);
        wf = null;
      }
      if (null == wf) { // new weaving factor
        wf = factory.createWeavingfactors();
        wf.setLinkIn(id2str(db_wf.getInLinkId()));
        wf.setLinkOut(id2str(db_wf.getOutLinkId()));
        sb.setLength(0);
      } else { // same weaving factor, different vehicle type
        // TODO delimiter = ':' or ','?
        sb.append(':');
      }
      sb.append(db_wf.getFactor().toPlainString());
    }
    if (null != wf) {
      wf.setContent(sb.toString());
      wfset.getWeavingfactors().add(wf);
    }
    return wfset;
  }
Example #11
0
  private com.relteq.sirius.jaxb.InitialDensitySet restoreInitialDensitySet(
      InitialDensitySets db_idset) throws TorqueException {
    if (null == db_idset) return null;
    com.relteq.sirius.jaxb.InitialDensitySet idset = factory.createInitialDensitySet();
    idset.setId(id2str(db_idset.getId()));
    idset.setName(db_idset.getName());
    idset.setDescription(db_idset.getDescription());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(InitialDensitiesPeer.LINK_ID);
    crit.addAscendingOrderByColumn(InitialDensitiesPeer.VEHICLE_TYPE_ID);
    @SuppressWarnings("unchecked")
    List<InitialDensities> db_idl = db_idset.getInitialDensitiess(crit);
    com.relteq.sirius.jaxb.Density density = null;
    StringBuilder sb = new StringBuilder();
    for (InitialDensities db_id : db_idl) {
      if (null != density && !density.getLinkId().equals(id2str(db_id.getLinkId()))) {
        density.setContent(sb.toString());
        idset.getDensity().add(density);
        density = null;
      }
      if (null == density) { // new link
        density = factory.createDensity();
        density.setLinkId(id2str(db_id.getLinkId()));
        density.setLinkIdDestination(id2str(db_id.getDestinationLinkId()));
        sb.setLength(0);
      } else { // same link, different vehicle type
        sb.append(":");
      }
      sb.append(db_id.getDensity().toPlainString());
    }
    // last link
    if (null != density) {
      density.setContent(sb.toString());
      idset.getDensity().add(density);
    }
    return idset;
  }
Example #12
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;
 }
Example #13
0
 /**
  * Loads reportCategoryBean by parent
  *
  * @param parentID
  * @return
  */
 @Override
 public List<TReportCategoryBean> loadByParent(Integer parentID) {
   List<TReportCategory> categories = new ArrayList<TReportCategory>();
   Criteria criteria = new Criteria();
   criteria.add(PARENTID, parentID);
   criteria.addAscendingOrderByColumn(LABEL);
   try {
     categories = doSelect(criteria);
   } catch (Exception e) {
     LOGGER.error(
         "Getting the report categories by parent " + parentID + " failed with " + e.getMessage(),
         e);
   }
   return convertTorqueListToBeanList(categories);
 }
Example #14
0
  com.relteq.sirius.jaxb.FundamentalDiagramProfile restoreFundamentalDiagramProfile(
      FundamentalDiagramProfiles db_fdprofile) throws TorqueException {
    com.relteq.sirius.jaxb.FundamentalDiagramProfile fdprofile =
        factory.createFundamentalDiagramProfile();
    fdprofile.setLinkId(id2str(db_fdprofile.getLinkId()));
    fdprofile.setDt(db_fdprofile.getDt());
    fdprofile.setStartTime(db_fdprofile.getStartTime());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(FundamentalDiagramsPeer.NUMBER);
    @SuppressWarnings("unchecked")
    List<FundamentalDiagrams> db_fd_l = db_fdprofile.getFundamentalDiagramss(crit);
    for (FundamentalDiagrams db_fd : db_fd_l)
      fdprofile.getFundamentalDiagram().add(restoreFundamentalDiagram(db_fd));
    return fdprofile;
  }
Example #15
0
 private com.relteq.sirius.jaxb.Route restoreRoute(Routes db_route) throws TorqueException {
   com.relteq.sirius.jaxb.Route route = factory.createRoute();
   route.setId(id2str(db_route.getId()));
   route.setName(db_route.getName());
   com.relteq.sirius.jaxb.LinkReferences lrs = factory.createLinkReferences();
   Criteria crit = new Criteria();
   crit.addAscendingOrderByColumn(RouteLinksPeer.ORDINAL);
   @SuppressWarnings("unchecked")
   List<RouteLinks> db_rl_l = db_route.getRouteLinkss(crit);
   for (RouteLinks db_rl : db_rl_l) {
     com.relteq.sirius.jaxb.LinkReference lr = factory.createLinkReference();
     lr.setId(id2str(db_rl.getLinkId()));
     lrs.getLinkReference().add(lr);
   }
   route.setLinkReferences(lrs);
   return route;
 }
Example #16
0
  private com.relteq.sirius.jaxb.CapacityProfile restoreCapacityProfile(
      DownstreamBoundaryCapacityProfiles db_dbcp) throws TorqueException {
    com.relteq.sirius.jaxb.CapacityProfile cprofile = factory.createCapacityProfile();
    cprofile.setLinkId(id2str(db_dbcp.getLinkId()));
    cprofile.setDt(db_dbcp.getDt());
    cprofile.setStartTime(db_dbcp.getStartTime());

    Criteria crit = new Criteria();
    crit.addAscendingOrderByColumn(DownstreamBoundaryCapacitiesPeer.NUMBER);
    @SuppressWarnings("unchecked")
    List<DownstreamBoundaryCapacities> db_dbc_l = db_dbcp.getDownstreamBoundaryCapacitiess(crit);
    StringBuilder sb = null;
    for (DownstreamBoundaryCapacities db_dbc : db_dbc_l) {
      // TODO delimiter = ',' or ':'?
      if (null == sb) sb = new StringBuilder();
      else sb.append(',');
      sb.append(db_dbc.getDownstreamBoundaryCapacity().toPlainString());
    }
    if (null != sb) cprofile.setContent(sb.toString());
    return cprofile;
  }
  public void servicePerfilturnoTurnos(HttpServletRequest request, HttpServletResponse response)
      throws IOException, TorqueException, ServletException {
    String cadena = null;
    Criteria c = new Criteria();
    int claveId = -1;
    claveId = WebUtils.getintParam(request, "turnos.IDTURNO");
    if (claveId != -1) {
      c.add(TurnosPeer.IDTURNO, claveId);
    }
    c.addAscendingOrderByColumn(TurnosPeer.IDTURNO);
    TurnosGroupBean trgb = TurnosManager.getTurnoss(c);

    if (trgb.getTotalSize() != 0) {
      cadena = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
      cadena =
          cadena
              + "<result><perfilturno.IDTURNO>"
              + trgb.getTurnos(0).getULContentTurnosParsed()
              + "</perfilturno.IDTURNO></result>";
    }

    xmlResponseService(response, new StringBuffer(cadena));
  }
  public void servicePerfilturnoElement(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException, TorqueException {
    StringBuffer cadena = null;
    Criteria c = new Criteria();
    int claveId = -1;
    claveId = WebUtils.getintParam(request, "perfilturno.IDTP");
    if (claveId != -1) {
      c.add(PerfilturnoPeer.IDTP, claveId);
    }
    c.addAscendingOrderByColumn(PerfilturnoPeer.IDTP);
    PerfilturnoGroupBean trgb = PerfilturnoManager.getPerfilturnos(c);

    if (trgb.getTotalSize() != 0) {
      String[] parametros = {
        PerfilturnoHelper.IDTP_GET_METHOD_NAME,
        PerfilturnoHelper.IDPERFIL_GET_METHOD_NAME + "PerfilturnoParsed",
        PerfilturnoHelper.IDTURNO_GET_METHOD_NAME + "PerfilturnoParsed",
        PerfilturnoHelper.VALORCOSTE_GET_METHOD_NAME + "PerfilturnoParsed"
      };
      cadena = trgb.buildXml(parametros, null, "ISO-8859-1");
      cadena.insert(cadena.indexOf("</result>"), getPathElementPerfilturno(request, response));
    }
    xmlResponseService(response, cadena);
  }