Package org.onebusaway.gtfs.model

Examples of org.onebusaway.gtfs.model.Agency


    // GTFS.
    return new AgencyAndId(operatorId, operatorId + "-" + routeId);
  }

  private Agency getAgencyForId(String id) {
    Agency agency = _dao.getAgencyForId(id);
    if (agency == null) {
      agency = new Agency();
      agency.setId(id);
      agency.setTimezone(_agencyTimezone);
      agency.setLang(_agencyLang);

      OperatorElement operator = _operatorsById.get(id);
      if (operator != null) {
        if (!isEmpty(operator.getShortFormName())) {
          agency.setName(operator.getShortFormName());
        }
        if (!isEmpty(operator.getEnquiryPhone())) {
          agency.setPhone(operator.getEnquiryPhone());
        }
      }
      NationalExpressOperatorElement nxOperator = _nxOperatorsById.get(id);
      if (nxOperator != null) {
        if (!isEmpty(nxOperator.getMarketingName())) {
          agency.setName(nxOperator.getMarketingName());
        }
        if (!isEmpty(nxOperator.getUrl())) {
          agency.setUrl(nxOperator.getUrl());
        }
      }

      if (isEmpty(agency.getName())) {
        agency.setName(_agencyName);
      }
      if (isEmpty(agency.getPhone())) {
        agency.setPhone(_agencyPhone);
      }
      if (isEmpty(agency.getUrl())) {
        agency.setUrl(_agencyUrl);
      }
      _dao.saveEntity(agency);
    }
    return agency;
  }
View Full Code Here


    private void addTripFields(Leg leg, State[] states) {
        Trip trip = states[states.length - 1].getBackTrip();

        if (trip != null) {
            Route route = trip.getRoute();
            Agency agency = route.getAgency();
            ServiceDay serviceDay = states[states.length - 1].getServiceDay();

            leg.agencyId = agency.getId();
            leg.agencyName = agency.getName();
            leg.agencyUrl = agency.getUrl();
            leg.headsign = states[states.length - 1].getBackDirection();
            leg.route = states[states.length - 1].getBackEdge().getName();
            leg.routeColor = route.getColor();
            leg.routeId = route.getId().getId();
            leg.routeLongName = route.getLongName();
View Full Code Here

    @Override
    public Agency unmarshal(AgencyType arg) throws Exception {
        if (arg == null) {
            return null;
        }
        Agency a = new Agency();
        a.setId(arg.id);
        a.setName(arg.name);
        a.setUrl(arg.url);
        a.setTimezone(arg.timezone);
        a.setLang(arg.lang);
        a.setPhone(arg.phone);
        a.setFareUrl(arg.fareUrl);
        return new Agency(a);
    }
View Full Code Here

        secondStops.add(trainStopArrive);
        thirdStops.add(ferryStopDepart);
        thirdStops.add(ferryStopArrive);

        // Agencies for legs 1, 2 and 4, plus initialization
        Agency trainAgency = new Agency();
        Agency ferryAgency = new Agency();

        trainAgency.setId("Train");
        trainAgency.setName("John Train");
        trainAgency.setUrl("http://www.train.org/");
        ferryAgency.setId("Ferry");
        ferryAgency.setName("Brian Ferry");
        ferryAgency.setUrl("http://www.ferry.org/");

        // Routes for legs 1, 2 and 4, plus initialization
        Route firstRoute = new Route();
        Route secondRoute = new Route();
        Route thirdRoute = new Route();
View Full Code Here

                assertEquals(index_vertex, vertex);
            }
        }

        /* Agencies */
        Agency agency;
        agency = graph.index.agencyForId.get("azerty");
        assertNull(agency);
        agency = graph.index.agencyForId.get("agency");
        assertEquals(agency.getId(), "agency");
        assertEquals(agency.getName(), "Fake Agency");

        /* Stops */
        graph.index.stopForId.get(new AgencyAndId("X", "Y"));

        /* Trips */
 
View Full Code Here

    public void setId(String id) {
        this.id = id;
    }

    public void apply(Graph graph) {
        Agency agency = this.agency != null ? graph.index.agencyForId.get(this.agency) : null;
        Route route = this.route != null ? graph.index.routeForId.get(this.route) : null;
        Stop stop = this.stop != null ? graph.index.stopForId.get(this.stop) : null;
        Trip trip = this.trip != null ? graph.index.tripForId.get(this.trip) : null;

        if (route != null || trip != null || agency != null) {
View Full Code Here

            }
        }
    }

    public void remove(Graph graph) {
        Agency agency = this.agency != null ? graph.index.agencyForId.get(this.agency) : null;
        Route route = this.route != null ? graph.index.routeForId.get(this.route) : null;
        Stop stop = this.stop != null ? graph.index.stopForId.get(this.stop) : null;
        Trip trip = this.trip != null ? graph.index.tripForId.get(this.trip) : null;

        if (route != null || trip != null || agency != null) {
View Full Code Here

  }

  @Test
  public void testGenerateAgencyNarratives() {

    Agency agency = new Agency();
    agency.setId("1");
    agency.setLang("en");
    agency.setName("Agency");
    agency.setPhone("555-1234");
    agency.setTimezone("America/New_York");
    agency.setUrl("http://agency.gov/");

    Mockito.when(_gtfsDao.getAllAgencies()).thenReturn(Arrays.asList(agency));

    Modification mod = new Modification();
    mod.setType(AgencyNarrative.class);
    mod.setId("1");
    mod.setProperty("disclaimer");
    mod.setValue("Use at your own risk.");

    _modifications.setModifications(Arrays.asList(mod));

    _task.generateAgencyNarratives(_provider);

    AgencyNarrative narrative = _provider.getNarrativeForAgencyId("1");
    assertEquals(mod.getValue(), narrative.getDisclaimer());
    assertEquals(agency.getLang(), narrative.getLang());
    assertEquals(agency.getName(), narrative.getName());
    assertEquals(agency.getPhone(), narrative.getPhone());
    assertEquals(agency.getTimezone(), narrative.getTimezone());
    assertEquals(agency.getUrl(), narrative.getUrl());
  }
View Full Code Here

  @Test
  public void test() {

    GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class);

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");
    // gtfsDao.saveEntity(agency);

    Route route = new Route();
    route.setId(new AgencyAndId("1", "routeA"));
    route.setAgency(agency);
View Full Code Here

    stopC.setId(aid("stopC"));
    graph.putStopEntry(stop("stopC", 47.66847942216854, -122.37545336180114));

    graph.refreshStopMapping();

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");

    Route route = new Route();
    route.setAgency(agency);

    Trip trip = new Trip();
View Full Code Here

TOP

Related Classes of org.onebusaway.gtfs.model.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.