Package org.worldbank.transport.tamt.shared

Examples of org.worldbank.transport.tamt.shared.DefaultFlow


      String dayType) throws Exception
  {
 
    // to generate a traffic flow report, we must have a default
    // flow for this tag
    DefaultFlow query = new DefaultFlow();
    query.setTagDetails(tagDetails);
    DefaultFlow defaultFlow = regionDao.getDefaultFlow(query);
    if( defaultFlow == null)
    {
      /*
       * We used to an error here:
       * throw new Exception("Cannot generate report. There is no default flow \nfor the '"+tagDetails.getName()+"' tag");
       *
       * But, according the jarogers, we should have a default flow of 0 for
       * all values if there is no default flow entity for this tag.
       *
       */
      defaultFlow = new DefaultFlow();
      defaultFlow.setTagDetails(tagDetails);
     
      defaultFlow.setW2Weekday("0");
      defaultFlow.setW2Saturday("0");
      defaultFlow.setW2SundayHoliday("0");
     
      defaultFlow.setW3Weekday("0");
      defaultFlow.setW3Saturday("0");
      defaultFlow.setW3SundayHoliday("0");
     
      defaultFlow.setPcWeekday("0");
      defaultFlow.setPcSaturday("0");
      defaultFlow.setPcSundayHoliday("0");
     
      defaultFlow.setTxWeekday("0");
      defaultFlow.setTxSaturday("0");
      defaultFlow.setTxSundayHoliday("0");
     
      defaultFlow.setLdcWeekday("0");
      defaultFlow.setLdcSaturday("0");
      defaultFlow.setLdcSundayHoliday("0");
     
      defaultFlow.setLdvWeekday("0");
      defaultFlow.setLdvSaturday("0");
      defaultFlow.setLdvSundayHoliday("0");
     
      defaultFlow.setHdcWeekday("0");
      defaultFlow.setHdcSaturday("0");
      defaultFlow.setHdcSundayHoliday("0");
     
      defaultFlow.setMdbWeekday("0");
      defaultFlow.setMdbSaturday("0");
      defaultFlow.setMdbSundayHoliday("0");
     
      defaultFlow.setHdbWeekday("0");
      defaultFlow.setHdbSaturday("0");
      defaultFlow.setHdbSundayHoliday("0");
     
     
    }
   
    ArrayList<ArrayList> rawData = dao.getTrafficFlowReportData(tagDetails, dayType);
   
    // create the hasValuesList from the rawData
    int hour = 0;
    ArrayList<Boolean> hasValuesList = new ArrayList<Boolean>();
    for (Iterator iterator = rawData.iterator(); iterator.hasNext();) {
      ArrayList row = (ArrayList) iterator.next();
      boolean hasValues = hasValues(row);
      hour++;
      hasValuesList.add(hasValues);
    }
   
    ArrayList<String> defaultFlowValues = new ArrayList<String>();
   
    if( dayType.equalsIgnoreCase(TrafficCountRecord.DAYTYPE_WEEKDAY))
    {
      // extract vehicle flow values from default flow for weekday only
      defaultFlowValues.add(defaultFlow.getW2Weekday());
      defaultFlowValues.add(defaultFlow.getW3Weekday());
      defaultFlowValues.add(defaultFlow.getPcWeekday());
      defaultFlowValues.add(defaultFlow.getTxWeekday());
      defaultFlowValues.add(defaultFlow.getLdvWeekday());
      defaultFlowValues.add(defaultFlow.getLdcWeekday());
      defaultFlowValues.add(defaultFlow.getHdcWeekday());
      defaultFlowValues.add(defaultFlow.getMdbWeekday());
      defaultFlowValues.add(defaultFlow.getHdbWeekday());
     
    } else if (dayType.equalsIgnoreCase(TrafficCountRecord.DAYTYPE_SATURDAY)) {
      // extract vehicle flow values from default flow for saturday only
      defaultFlowValues.add(defaultFlow.getW2Saturday());
      defaultFlowValues.add(defaultFlow.getW3Saturday());
      defaultFlowValues.add(defaultFlow.getPcSaturday());
      defaultFlowValues.add(defaultFlow.getTxSaturday());
      defaultFlowValues.add(defaultFlow.getLdvSaturday());
      defaultFlowValues.add(defaultFlow.getLdcSaturday());
      defaultFlowValues.add(defaultFlow.getHdcSaturday());
      defaultFlowValues.add(defaultFlow.getMdbSaturday());
      defaultFlowValues.add(defaultFlow.getHdbSaturday());
     
    } else {
      // extract vehicle flow values from default flow for sunday/holiday only
      defaultFlowValues.add(defaultFlow.getW2SundayHoliday());
      defaultFlowValues.add(defaultFlow.getW3SundayHoliday());
      defaultFlowValues.add(defaultFlow.getPcSundayHoliday());
      defaultFlowValues.add(defaultFlow.getTxSundayHoliday());
      defaultFlowValues.add(defaultFlow.getLdvSundayHoliday());
      defaultFlowValues.add(defaultFlow.getLdcSundayHoliday());
      defaultFlowValues.add(defaultFlow.getHdcSundayHoliday());
      defaultFlowValues.add(defaultFlow.getMdbSundayHoliday());
      defaultFlowValues.add(defaultFlow.getHdbSundayHoliday());
    }
   
    /*
     * Find out where the BEFOREs and AFTERs start
     */
 
View Full Code Here


    selectedTag.setHTML("Selected tag: <b>"+tagDetails.getName()+"</b>");
   
    // we will need tagDetails later, so keep track of it
    currentTagDetails = tagDetails;
   
    DefaultFlow query = new DefaultFlow();
     
    StudyRegion region = new StudyRegion();
    region.setId(currentStudyRegion.getId());
    tagDetails.setRegion(region);
    query.setTagDetails(tagDetails);
   
    regionService.getDefaultFlow(query, new AsyncCallback<DefaultFlow>() {

      @Override
      public void onFailure(Throwable caught) {
View Full Code Here

  }
 
  private void saveDefaultFlow() {
   
    // prep an entity to save
    DefaultFlow defaultFlow = new DefaultFlow();
   
    if( currentDefaultFlow != null)
    {
      defaultFlow.setId( currentDefaultFlow.getId());
    }
   
    TagDetails tagDetails = new TagDetails();
    if( currentTagDetails != null) // should never be null, because we just clicked on a tag to load the config
    {
      tagDetails.setId(currentTagDetails.getId());
    }
    GWT.log("TAG DETAILS just id for saving flow:" + tagDetails);
   
    // get the study region id too (but just the id)
    StudyRegion region = new StudyRegion();
    region.setId(currentStudyRegion.getId());
    tagDetails.setRegion(region);
    defaultFlow.setTagDetails(tagDetails);
   
    defaultFlow.setW2Weekday(weekdayW2.getValue());
    defaultFlow.setW2Saturday(saturdayW2.getValue());
    defaultFlow.setW2SundayHoliday(sundayHolidayW2.getValue());
   
    defaultFlow.setW3Weekday(weekdayW3.getValue());
    defaultFlow.setW3Saturday(saturdayW3.getValue());
    defaultFlow.setW3SundayHoliday(sundayHolidayW3.getValue());
   
    defaultFlow.setPcWeekday(weekdayPC.getValue());
    defaultFlow.setPcSaturday(saturdayPC.getValue());
    defaultFlow.setPcSundayHoliday(sundayHolidayPC.getValue());
   
    defaultFlow.setTxWeekday(weekdayTX.getValue());
    defaultFlow.setTxSaturday(saturdayTX.getValue());
    defaultFlow.setTxSundayHoliday(sundayHolidayTX.getValue());
   
    defaultFlow.setLdvWeekday(weekdayLDV.getValue());
    defaultFlow.setLdvSaturday(saturdayLDV.getValue());
    defaultFlow.setLdvSundayHoliday(sundayHolidayLDV.getValue());
   
    defaultFlow.setLdcWeekday(weekdayLDC.getValue());
    defaultFlow.setLdcSaturday(saturdayLDC.getValue());
    defaultFlow.setLdcSundayHoliday(sundayHolidayLDC.getValue());
   
    defaultFlow.setHdcWeekday(weekdayHDC.getValue());
    defaultFlow.setHdcSaturday(saturdayHDC.getValue());
    defaultFlow.setHdcSundayHoliday(sundayHolidayHDC.getValue());
   
    defaultFlow.setMdbWeekday(weekdayMDB.getValue());
    defaultFlow.setMdbSaturday(saturdayMDB.getValue());
    defaultFlow.setMdbSundayHoliday(sundayHolidayMDB.getValue());
   
    defaultFlow.setHdbWeekday(weekdayHDB.getValue());
    defaultFlow.setHdbSaturday(saturdayHDB.getValue());
    defaultFlow.setHdbSundayHoliday(sundayHolidayHDB.getValue());
   
    GWT.log("Default flow to save:" + defaultFlow);
   
    regionService.saveDefaultFlow(defaultFlow, new AsyncCallback<DefaultFlow>() {
View Full Code Here

    return defaultFlow;
  }

  public DefaultFlow getDefaultFlow(DefaultFlow defaultFlow) throws Exception {

    DefaultFlow fetched = null;
    String tagId = defaultFlow.getTagDetails().getId();
    String regionId = defaultFlow.getTagDetails().getRegion().getId();
    try {
      Connection connection = getConnection();
      Statement s = connection.createStatement();
      String sql = "SELECT id, " +
          "w2wk, w2sa, w2sh, " +
          "w3wk, w3sa, w3sh, " +
          "pcwk, pcsa, pcsh, " +
          "txwk, txsa, txsh, " +
          "ldvwk, ldvsa, ldvsh, " +
          "ldcwk, ldcsa, ldcsh, " +
          "hdcwk, hdcsa, hdcsh, " +
          "mdbwk, mdbsa, mdbsh, " +
          "hdbwk, hdbsa, hdbsh " +
          "FROM defaulttrafficflow " +
          "WHERE regionid = '"+regionId+"' " +
          "AND tagid = '"+tagId+"'";
      logger.debug("getDefaultFlow sql=" + sql);
      ResultSet r = s.executeQuery(sql);
      while( r.next() ) {
       
        fetched = new DefaultFlow();
        fetched.setId(r.getString(1));
        fetched.setTagDetails(defaultFlow.getTagDetails());
       
        fetched.setW2Weekday(r.getString(2));
        fetched.setW2Saturday(r.getString(3));
        fetched.setW2SundayHoliday(r.getString(4));
       
        fetched.setW3Weekday(r.getString(5));
        fetched.setW3Saturday(r.getString(6));
        fetched.setW3SundayHoliday(r.getString(7));
       
        fetched.setPcWeekday(r.getString(8));
        fetched.setPcSaturday(r.getString(9));
        fetched.setPcSundayHoliday(r.getString(10));
       
        fetched.setTxWeekday(r.getString(11));
        fetched.setTxSaturday(r.getString(12));
        fetched.setTxSundayHoliday(r.getString(13));
       
        fetched.setLdvWeekday(r.getString(14));
        fetched.setLdvSaturday(r.getString(15));
        fetched.setLdvSundayHoliday(r.getString(16));
       
        fetched.setLdcWeekday(r.getString(17));
        fetched.setLdcSaturday(r.getString(18));
        fetched.setLdcSundayHoliday(r.getString(19));
       
        fetched.setHdcWeekday(r.getString(20));
        fetched.setHdcSaturday(r.getString(21));
        fetched.setHdcSundayHoliday(r.getString(22));
       
        fetched.setMdbWeekday(r.getString(23));
        fetched.setMdbSaturday(r.getString(24));
        fetched.setMdbSundayHoliday(r.getString(25));
       
        fetched.setHdbWeekday(r.getString(26));
        fetched.setHdbSaturday(r.getString(27));
        fetched.setHdbSundayHoliday(r.getString(28));
       
      }
      connection.close(); // returns connection to the pool

    }
View Full Code Here

TOP

Related Classes of org.worldbank.transport.tamt.shared.DefaultFlow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.