Beispiel #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;
  }
Beispiel #2
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;
  }
Beispiel #3
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;
  }
Beispiel #4
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;
  }
Beispiel #5
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;
  }
Beispiel #6
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;
  }