Package models.transit

Examples of models.transit.ServiceCalendar


    // **** calendar controllers ****

    public static void getCalendar(Long id, Long agencyId) {
        try {
            if(id != null) {
              ServiceCalendar cal = ServiceCalendar.findById(id);
                if(cal != null)
                    renderJSON(Api.toJson(cal, false));
                else
                    notFound();
            }
View Full Code Here


        }

    }

    public static void createCalendar() {
      ServiceCalendar cal;

        try {
            cal = mapper.readValue(params.get("body"), ServiceCalendar.class);

            if(Agency.findById(cal.agency.id) == null)
                badRequest();

            cal.save();

            // check if gtfsServiceId is specified, if not create from DB id
            if(cal.gtfsServiceId == null) {
              cal.gtfsServiceId = "CAL_" + cal.id.toString();
                cal.save();
            }
           

            renderJSON(Api.toJson(cal, false));
        } catch (Exception e) {
View Full Code Here

        }
    }


    public static void updateCalendar() {
      ServiceCalendar cal;

        try {
          cal = mapper.readValue(params.get("body"), ServiceCalendar.class);

            if(cal.id == null || ServiceCalendar.findById(cal.id) == null)
                badRequest();

            // check if gtfsAgencyId is specified, if not create from DB id
            if(cal.gtfsServiceId == null)
              cal.gtfsServiceId = "CAL_" + cal.id.toString();
           
            ServiceCalendar updatedCal = ServiceCalendar.em().merge(cal);
            updatedCal.save();

            renderJSON(Api.toJson(updatedCal, false));
        } catch (Exception e) {
            e.printStackTrace();
            badRequest();
View Full Code Here

    public static void deleteCalendar(Long id) {
        if(id == null)
            badRequest();

        ServiceCalendar cal = ServiceCalendar.findById(id);

        if(cal == null)
            badRequest();

        cal.delete();

        ok();
    }
View Full Code Here

                    renderJSON(Api.toJson(Trip.find("pattern.route.agency = ?", agency).fetch(), false));
                }
               
                else if (patternId != null && calendarId != null) {
                    TripPattern pattern = TripPattern.findById(patternId);
                    ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
                    renderJSON(Api.toJson(Trip.find("byPatternAndServiceCalendar", pattern, calendar).fetch(), false));
                }
               
                else if(patternId != null) {
                    TripPattern pattern = TripPattern.findById(patternId);
View Full Code Here

      response.setHeader("Content-type", "text/csv");
     
      SimpleDateFormat dfTime = new SimpleDateFormat("hh:mm a");
     
      TripPattern pattern = TripPattern.findById(patternId);
      ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
     
      // ensure that the trip pattern sequence isn't broken
      pattern.resequenceTripStops();
     
      List<Trip> trips  = Trip.find("pattern = ? and serviceCalendar = ? ORDER by id", pattern, calendar).fetch();
View Full Code Here

     
    SimpleDateFormat dfTime = new SimpleDateFormat("hh:mm a");
    SimpleDateFormat dfsTime = new SimpleDateFormat("hh:mm:ss a");
    
    TripPattern pattern = TripPattern.findById(patternId);
    ServiceCalendar calendar = ServiceCalendar.findById(calendarId);
   
    List<Trip> trips = Trip.find("pattern = ? and serviceCalendar = ?", pattern, calendar).fetch();

    for(Trip trip : trips) {
     
View Full Code Here

TOP

Related Classes of models.transit.ServiceCalendar

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.