Package org.onebusaway.transit_data_federation.impl.transit_graph

Examples of org.onebusaway.transit_data_federation.impl.transit_graph.AgencyEntryImpl


  /****
   * Entity Factory Methods
   ****/

  public static AgencyEntryImpl agency(String id) {
    AgencyEntryImpl agency = new AgencyEntryImpl();
    agency.setId(id);
    return agency;
  }
View Full Code Here


    StopEntriesFactory factory = new StopEntriesFactory();
    factory.setGtfsDao(dao);

    TransitGraphImpl graph = new TransitGraphImpl();

    AgencyEntryImpl agency = new AgencyEntryImpl();
    agency.setId("1");
    graph.putAgencyEntry(agency);
    graph.refreshAgencyMapping();

    factory.processStops(graph);

    StopEntryImpl stopEntryA = graph.getStopEntryForId(stopA.getId());

    assertEquals(stopA.getId(), stopEntryA.getId());
    assertEquals(stopA.getLat(), stopEntryA.getStopLat(), 0);
    assertEquals(stopA.getLon(), stopEntryA.getStopLon(), 0);

    StopEntryImpl stopEntryB = graph.getStopEntryForId(stopB.getId());

    assertEquals(stopB.getId(), stopEntryB.getId());
    assertEquals(stopB.getLat(), stopEntryB.getStopLat(), 0);
    assertEquals(stopB.getLon(), stopEntryB.getStopLon(), 0);

    List<StopEntry> stops = graph.getAllStops();
    assertEquals(2, stops.size());
    assertTrue(stops.contains(stopEntryA));
    assertTrue(stops.contains(stopEntryB));

    stops = agency.getStops();
    assertTrue(stops.contains(stopEntryA));
    assertTrue(stops.contains(stopEntryB));
  }
View Full Code Here

  @Test
  public void testProcessRouteCollections() {

    TransitGraphImpl graph = new TransitGraphImpl();

    AgencyEntryImpl agency = new AgencyEntryImpl();
    agency.setId("A");
    graph.putAgencyEntry(agency);
    graph.refreshAgencyMapping();

    RouteEntryImpl routeA = new RouteEntryImpl();
    routeA.setId(new AgencyAndId("A", "routeA"));
    graph.putRouteEntry(routeA);

    RouteEntryImpl routeB = new RouteEntryImpl();
    routeB.setId(new AgencyAndId("A", "routeB"));
    graph.putRouteEntry(routeB);

    RouteCollectionEntriesFactory factory = new RouteCollectionEntriesFactory();
    GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class);
    factory.setGtfsDao(gtfsDao);
    factory.setUniqueService(new UniqueServiceImpl());
    factory.processRouteCollections(graph);

    RouteCollectionEntry routeEntryA = graph.getRouteCollectionForId(routeA.getId());
    assertEquals(routeA.getId(), routeEntryA.getId());
    List<RouteEntry> routes = routeEntryA.getChildren();
    assertEquals(1, routes.size());
    assertTrue(routes.contains(routeA));

    RouteCollectionEntry routeEntryB = graph.getRouteCollectionForId(routeB.getId());
    assertEquals(routeB.getId(), routeEntryB.getId());
    routes = routeEntryB.getChildren();
    assertEquals(1, routes.size());
    assertTrue(routes.contains(routeB));

    List<RouteCollectionEntry> routeCollections = graph.getAllRouteCollections();
    assertEquals(2, routeCollections.size());
    assertTrue(routeCollections.contains(routeEntryA));
    assertTrue(routeCollections.contains(routeEntryB));

    routeCollections = agency.getRouteCollections();
    assertEquals(2, routeCollections.size());
    assertTrue(routeCollections.contains(routeEntryA));
    assertTrue(routeCollections.contains(routeEntryB));
  }
View Full Code Here

  @Test
  public void testGroupRoutesByShortName() {

    TransitGraphImpl graph = new TransitGraphImpl();

    AgencyEntryImpl agency = new AgencyEntryImpl();
    agency.setId("A");
    graph.putAgencyEntry(agency);
    graph.refreshAgencyMapping();

    RouteEntryImpl routeA = new RouteEntryImpl();
    routeA.setId(new AgencyAndId("A", "routeA"));
    graph.putRouteEntry(routeA);

    RouteEntryImpl routeB = new RouteEntryImpl();
    routeB.setId(new AgencyAndId("A", "routeB"));
    graph.putRouteEntry(routeB);

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

    Route rA = new Route();
    rA.setId(routeA.getId());
    rA.setShortName("10");
    Mockito.when(gtfsDao.getRouteForId(routeA.getId())).thenReturn(rA);

    Route rB = new Route();
    rB.setId(routeB.getId());
    rB.setShortName("10");
    Mockito.when(gtfsDao.getRouteForId(routeB.getId())).thenReturn(rB);

    RouteCollectionEntriesFactory factory = new RouteCollectionEntriesFactory();
    factory.setGroupRoutesByShortName(true);

    factory.setGtfsDao(gtfsDao);
    factory.setUniqueService(new UniqueServiceImpl());
    factory.processRouteCollections(graph);

    AgencyAndId id = new AgencyAndId("A", "10");
    RouteCollectionEntry routeCollectionEntry = graph.getRouteCollectionForId(id);
    assertEquals(id, routeCollectionEntry.getId());
    List<RouteEntry> routes = routeCollectionEntry.getChildren();
    assertEquals(2, routes.size());
    assertTrue(routes.contains(routeA));
    assertTrue(routes.contains(routeB));

    List<RouteCollectionEntry> routeCollections = graph.getAllRouteCollections();
    assertEquals(1, routeCollections.size());
    assertTrue(routeCollections.contains(routeCollectionEntry));

    routeCollections = agency.getRouteCollections();
    assertEquals(1, routeCollections.size());
    assertTrue(routeCollections.contains(routeCollectionEntry));
  }
View Full Code Here

    for (Map.Entry<String, ArrayList<StopEntry>> entry : stopEntriesByAgencyId.entrySet()) {
      String agencyId = entry.getKey();
      ArrayList<StopEntry> stopEntries = entry.getValue();
      stopEntries.trimToSize();
      AgencyEntryImpl agency = graph.getAgencyForId(agencyId);
      agency.setStops(stopEntries);
    }

    graph.refreshStopMapping();
  }
View Full Code Here

    for (Map.Entry<String, ArrayList<RouteCollectionEntry>> entry : entriesByAgencyId.entrySet()) {
      String agencyId = entry.getKey();
      ArrayList<RouteCollectionEntry> routeCollections = entry.getValue();
      routeCollections.trimToSize();
      AgencyEntryImpl agencyEntry = graph.getAgencyForId(agencyId);
      agencyEntry.setRouteCollections(routeCollections);
    }
  }
View Full Code Here

  public void processAgencies(TransitGraphImpl graph) {

    Collection<Agency> agencies = _gtfsDao.getAllAgencies();

    for (Agency agency : agencies) {
      AgencyEntryImpl agencyEntry = new AgencyEntryImpl();
      agencyEntry.setId(_uniqueService.unique(agency.getId()));
      graph.putAgencyEntry(agencyEntry);
    }

    graph.refreshAgencyMapping();
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.transit_data_federation.impl.transit_graph.AgencyEntryImpl

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.