Search in sources :

Example 6 with Device

use of uk.ac.bris.cs.rfideasalreadytaken.lumberjack.database.data.Device in project lumberjack by fn-ctional.

the class WebBackend method getDevicesCSV.

public String getDevicesCSV() throws SQLException {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append("id,");
    stringBuilder.append("scan value,");
    stringBuilder.append("type,");
    stringBuilder.append("available,");
    stringBuilder.append("currently assigned,");
    stringBuilder.append("rule id");
    stringBuilder.append("\n");
    List<Device> devices = getDevices();
    for (Device device : devices) {
        stringBuilder.append(device.getId());
        stringBuilder.append(",");
        stringBuilder.append(device.getScanValue());
        stringBuilder.append(",");
        stringBuilder.append(device.getType());
        stringBuilder.append(",");
        stringBuilder.append(device.isAvailable());
        stringBuilder.append(",");
        stringBuilder.append(device.isCurrentlyAssigned());
        stringBuilder.append(",");
        stringBuilder.append(device.getRuleID());
        stringBuilder.append("\n");
    }
    return stringBuilder.toString();
}
Also used : Device(uk.ac.bris.cs.rfideasalreadytaken.lumberjack.database.data.Device)

Aggregations

Device (uk.ac.bris.cs.rfideasalreadytaken.lumberjack.database.data.Device)6 ArrayList (java.util.ArrayList)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)1 CSVRecord (org.apache.commons.csv.CSVRecord)1 FileDownloadException (uk.ac.bris.cs.rfideasalreadytaken.lumberjack.exceptions.FileDownloadException)1 FileUploadException (uk.ac.bris.cs.rfideasalreadytaken.lumberjack.exceptions.FileUploadException)1