Example #1
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 #2
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;
  }