Manage Legal Notices functionality
[habeas.git] / src / habeas / Utility.java
index 8b27e7e..a1148a2 100644 (file)
@@ -118,7 +118,7 @@ public class Utility {
     static boolean addLegalNotice(String reference_number, 
             String description, java.util.Date entrustment_date, DBItem client) {
         if ("".equals(reference_number) || "".equals(description) ||
-                entrustment_date == null)
+                entrustment_date == null || client == null)
             return false;
         try {
             Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
@@ -138,6 +138,27 @@ public class Utility {
             return false;
         }
         
+    }
+
+    static ArrayList<Object> getNotices() {
+        ArrayList<Object> notices = new ArrayList<>();
+        try {
+            Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+            Statement st = conn.createStatement();
+            ResultSet rs = st.executeQuery("SELECT id, ReferenceNumber, Description "
+                    + "FROM legalnotices;");
+            while (rs.next()) {
+                notices.add(rs.getInt("id"));
+                notices.add(rs.getString("ReferenceNumber"));
+                notices.add(rs.getString("Description"));
+            }
+            conn.close();
+            return notices;
+        } catch (SQLException ex) {
+            Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+            return null;
+        }
+        
     }
     public Utility () {