Exemplo n.º 1
0
  public void readRoom() {

    String csvFile = "Leslokalen.csv";
    BufferedReader br = null;
    String line = "";
    String cvsSplitBy = ";";

    try {
      ApplicationContext appContext = new ClassPathXmlApplicationContext("spring-module.xml");
      Resource resource = appContext.getResource("Leslokalen.csv");
      InputStream is = resource.getInputStream();
      br = new BufferedReader(new InputStreamReader(is));
      br.readLine(); // Read first line with Header

      ArrayList<Room> roomList = new ArrayList<Room>();

      while ((line = br.readLine()) != null) {

        // use comma as separator
        String[] room = line.split(cvsSplitBy);
        Room roomObj = new Room();
        roomObj.setName(room[0]);
        roomObj.setBuilding(room[1]);
        roomObj.setFloor(room[2]);
        roomObj.setCapacity(Integer.valueOf(room[3]));
        roomObj.setPlaces(Integer.valueOf(room[4]));
        roomObj.setProjectorEquipped(room[5].equals(1));
        roomObj.setSmartBoardEquipped(room[6].equals(1));
        roomObj.setRecorderEquipped(room[7].equals(1));

        roomList.add(roomObj);

        if (Globals.DEBUG == 1) {
          System.out.println(roomObj);
        }
      }

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (br != null) {
        try {
          br.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }

    System.out.println("Done");
  }
Exemplo n.º 2
0
 @Test
 public void testSetName() throws Exception {
   Room r1 = new Room("testBefore");
   r1.setName("testAfter");
   assertTrue("testAfter".equals(r1.getName()));
 }
 /**
  * delete a room from the database
  *
  * @param room room to be deleted
  * @return if deleted
  */
 private static Room cursorToRoom(Cursor cursor) {
   Room room = new Room();
   room.set_id(cursor.getLong(0));
   room.setName(cursor.getString(1));
   return room;
 }
Exemplo n.º 4
0
 @Override
 public void setName(String name) {
   simpleRoom.setName(name);
 }