Package models.transit

Examples of models.transit.Agency


       
        if(agencySelect != null || agencySelect.size() > 0) {

            for(Long agencyId : agencySelect) {
               
                Agency a = Agency.findById(agencyId);
                if(a != null)
                        agencyObjects.add(a);
           
            }
        }
View Full Code Here


         
        for (org.onebusaway.gtfs.model.Agency gtfsAgency : reader.getAgencies()) {
         
          if(!agencyIdMap.containsKey(gtfsAgency.getId()))
          {
            Agency agency = new Agency(gtfsAgency);
            agency.save();
           
            agencyIdMap.put(agency.gtfsAgencyId, BigInteger.valueOf(agency.id));
           
            primaryAgencyId = BigInteger.valueOf(agency.id);
           
            agencyCount++;     
          }
          else
            primaryAgencyId = agencyIdMap.get(gtfsAgency.getId());
         
        }
       
        Agency primaryAgency = Agency.findById(primaryAgencyId.longValue());
       
        agencyTask.completeTask("Imported " + agencyCount + " agencies.", GtfsSnapshotMergeTaskStatus.SUCCESS);
       
        Logger.info("Agencies loaded: " + agencyCount.toString());
        Logger.info("GtfsImporter: importing routes...");
       
        GtfsSnapshotMergeTask routeTask = new GtfsSnapshotMergeTask(snapshotMerge);
        routeTask.startTask();
       
          for (org.onebusaway.gtfs.model.Route gtfsRoute : store.getAllRoutes()) {
         
            BigInteger agencyId = agencyIdMap.get(gtfsRoute.getAgency().getId());
            BigInteger routeId = Route.nativeInsert(snapshotMerge.em(), gtfsRoute, agencyId);
             
              routeIdMap.put(gtfsRoute.getId().toString(), routeId );
                        
            routeCount++;
          }
         
          if(agencyCount > 1)
          primaryAgencyId = null;
         
          routeTask.completeTask("Imported " + routeCount + " routes.", GtfsSnapshotMergeTaskStatus.SUCCESS);
         
          Logger.info("Routes loaded:" + routeCount.toString());
          Logger.info("GtfsImporter: importing stops...");
       
        GtfsSnapshotMergeTask stopTask = new GtfsSnapshotMergeTask(snapshotMerge);
        stopTask.startTask();
       
          for (org.onebusaway.gtfs.model.Stop gtfsStop : store.getAllStops()) {      
            
            BigInteger stopId = Stop.nativeInsert(snapshotMerge.em(), gtfsStop, primaryAgencyId);
              stopIdMap.put(gtfsStop.getId().toString(), stopId );
                        
            stopCount++;
          }
         
          stopTask.completeTask("Imported " + stopCount + " stops.", GtfsSnapshotMergeTaskStatus.SUCCESS);
         
          Logger.info("Stops loaded: " + stopCount);
          Logger.info("GtfsImporter: importing Shapes...");
         
          Logger.info("Calculating agency centroid for stops...");
         
        Point centroid = Stop.findCentroid(primaryAgencyId);
        Logger.info("Center: " + centroid.getCoordinate().y + ", " + centroid.getCoordinate().x);
         
        primaryAgency.defaultLat = centroid.getCoordinate().y;
        primaryAgency.defaultLon = centroid.getCoordinate().x;
       
        primaryAgency.save();
       
          GtfsSnapshotMergeTask tripShapeTask = new GtfsSnapshotMergeTask(snapshotMerge);
          tripShapeTask.startTask();
         
          // import points
View Full Code Here

    // **** agency controllers ****

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

        }

    }

    public static void createAgency() {
        Agency agency;

        try {
            agency = mapper.readValue(params.get("body"), Agency.class);
            agency.save();

            // check if gtfsAgencyId is specified, if not create from DB id
            if(agency.gtfsAgencyId == null) {
                agency.gtfsAgencyId = "AGENCY_" + agency.id.toString();
                agency.save();
            }

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

        }
    }


    public static void updateAgency() {
        Agency agency;

        try {
            agency = mapper.readValue(params.get("body"), Agency.class);

            if(agency.id == null || Agency.findById(agency.id) == null)
                badRequest();
           
            // check if gtfsAgencyId is specified, if not create from DB id
            if(agency.gtfsAgencyId == null)
              agency.gtfsAgencyId = "AGENCY_" + agency.id.toString();

            Agency updatedAgency = Agency.em().merge(agency);
            updatedAgency.save();

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

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

        Agency agency = Agency.findById(id);

        if(agency == null)
            badRequest();

        agency.delete();

        ok();
    }
View Full Code Here

                else
                    notFound();
            }
            else {
                if(agencyId != null) {
                    Agency agency = Agency.findById(agencyId);
                    renderJSON(Api.toJson(Route.find("agency = ? order by routeShortName", agency).fetch(), false));
                }
                else
                    renderJSON(Api.toJson(Route.find("order by routeShortName").fetch(), false));  
                   
View Full Code Here

    }

    // **** stop controllers ****
    public static void getStop(Long id, Double lat, Double lon, Boolean majorStops, Long agencyId) {

      Agency agency = null;
      if(agencyId != null)
        agency = Agency.findById(agencyId);
     
        try {
            if(id != null) {
View Full Code Here

                    notFound();
            }
            else {
                if(agencyId != null) {

                    Agency agency = Agency.findById(agencyId);
                    renderJSON(Api.toJson(ServiceCalendar.find("agency = ?", agency).fetch(), false));
                }
                else
                    renderJSON(Api.toJson(ServiceCalendar.all().fetch(), false));
            }
View Full Code Here

                    notFound();
            }
            else {

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

TOP

Related Classes of models.transit.Agency

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.