private void getAndPopulatePersonal(String roomID) { // Get and populate operatinginfo Statement stmnt; try { stmnt = conn.createStatement(); String strQuery = "select personal_id, Roll, namn, streckkod, p.optillfalle_id, opsal_id from NarDa.dbo.v_OrbitNardaPersonal p, NarDa.dbo.v_OrbitNardaOperationsinfo op WHERE op.opsal_id = " + roomID + " AND op.optillfalle_id = p.optillfalle_id"; ResultSet res = stmnt.executeQuery(strQuery); Room r = OrbitStamps.operatingRooms.get(roomID); while (res.next()) { String optillfalle_id = res.getString("optillfalle_id"); Operation op = r.operations.get(optillfalle_id); if (op != null) { String namn = (res.getString("namn") != null) ? res.getString("namn") : "Inget namn angivet"; String roll = (res.getString("Roll") != null) ? res.getString("Roll") : "Okänd roll"; String personal_id = (res.getString("personal_id") != null) ? res.getString("personal_id") : "Inget ID angivet"; Person p = new Person(namn, new Role(roll), personal_id); p.devices.add(new PagerReciever("1234")); op.addPerson(p); } } } catch (SQLException e) { e.printStackTrace(); } }
private void getAndPopulateRoomWithOperation(String roomID) { // Get and populate operatinginfo DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Statement stmnt; try { stmnt = conn.createStatement(); String strQuery = "select optillfalle_id, opkort_id, iva, start_tidpunkt, slut_tidpunkt, beskrivning, tid_forberedelse, tid_operation from " + Config.DATABASE_OPERATION_VIEW + " WHERE opsal_id = " + roomID + " ORDER BY start_tidpunkt ASC"; ResultSet res = stmnt.executeQuery(strQuery); Room r = OrbitStamps.operatingRooms.get(roomID); while (res.next()) { String op_id = res.getString("optillfalle_id"); if (!r.operations.containsKey(op_id)) { String opkort_id = res.getString("opkort_id"); String op_desc = (res.getString("beskrivning") != null) ? res.getString("beskrivning") : "Saknar beskrivning"; java.util.Date op_start; java.util.Date op_end; try { op_start = df.parse(res.getString("start_tidpunkt")); op_end = df.parse(res.getString("slut_tidpunkt")); } catch (Exception e) { op_start = new Date(Calendar.getInstance().getTimeInMillis()); op_end = new Date(Calendar.getInstance().getTimeInMillis()); // TODO Auto-generated catch block e.printStackTrace(); } Operation operation = new Operation(op_id, opkort_id, op_start, op_end, op_desc); r.operations.put(op_id, operation); operation.debugPrint(); } } } catch (SQLException e) { e.printStackTrace(); } }