예제 #1
0
 @Test
 public void testGetStartStationByBus() {
   BusRoute r = null;
   try {
     r = iBusRouteService.findBusRoute("34路");
     System.out.println(r);
   } catch (BusServiceException e) {
     e.printStackTrace();
   }
   if (r != null) {
     BusStation s = r.getStartStation();
     System.out.println(s);
     System.out.println(s.getRouteEndStations());
   }
 }
예제 #2
0
 @Test
 public void testGetBusListByStation() {
   BusStation s = null;
   try {
     s = iBusStationService.findBusStation("武科大新校区");
   } catch (Exception e) {
     e.printStackTrace();
   }
   if (s != null) {
     Set<BusRoute> set = s.getRouteStartStations();
     for (BusRoute b : set) {
       System.out.println(b);
     }
   }
 }
예제 #3
0
 @Test
 public void testSaveBusRouteFromCollection() {
   long start = System.currentTimeMillis();
   List<BusRoute> list = iCollectInfoService.getBusRouteList();
   for (BusRoute route : list) {
     if (route != null) {
       BusStation s1 = route.getStartStation();
       BusStation s2 = route.getEndStation();
       if (s1 != null && !"".equals(s1.getName())) {
         try {
           s1 = iBusStationService.findBusStation(s1.getName());
         } catch (Exception e) {
           e.printStackTrace();
         }
         route.setStartStation(s1);
       }
       if (s2 != null && !"".equals(s2.getName())) {
         try {
           s2 = iBusStationService.findBusStation(s2.getName());
         } catch (Exception e) {
           e.printStackTrace();
         }
         route.setEndStation(s2);
       }
       System.out.println(route);
       try {
         iBusRouteService.persist(route);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   long end = System.currentTimeMillis();
   System.out.println((end - start) / 1000f);
 }
예제 #4
0
  @Test
  public void testSaveBusStationFromCollection()
      throws IOException, JDOMException, InterruptedException {

    FileOutputStream fos = new FileOutputStream("positions.txt");
    String lineSeparator = System.getProperty("line.separator");

    List<String> list = iCollectInfoService.getStationNameList();
    List<BusStation> existlist = iBusStationService.listAll(BusStation.class);

    for (BusStation b : existlist) {
      list.remove(b.getName());
    }

    System.out.println(list.size());

    for (String s : list) {
      System.out.println(s);
    }
    System.out.println(list.size());

    for (String str : list) {
      BusStation s = new BusStation(str);
      fos.write(
          new String(s.getName() + "," + s.getX() + "," + s.getY() + lineSeparator).getBytes());
      iBusStationService.persist(s);
    }
    for (String s : list) {
      System.out.println(s);
    }
  }