@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);
    }
  }
 @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);
 }
 @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);
     }
   }
 }