+ }
+ static java.util.Date getValidDate (ResultSet rs, String datefield) throws SQLException {
+ // Since resultset.getDate returns a java.sql.Date, we need a way to get
+ // the date in java.util.Date which is usable in our application. Hence
+ // this helper function. Since we don't want a valid Date object if the
+ // field is null, we are using this if clause
+ if (rs.getDate(datefield) == null)
+ return null;
+ else
+ return (new java.util.Date(rs.getLong(datefield)*1000));
+ }
+
+ static ArrayList<Object> getNoticeDetails(int selid) {
+ ArrayList<Object> notice = new ArrayList<>();
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("SELECT * FROM legalnotices WHERE id=?;");
+ st.setInt(1, selid);
+ ResultSet rs = st.executeQuery();
+ while (rs.next()) {
+ notice.add(rs.getString("ReferenceNumber"));
+ notice.add(rs.getString("Description"));
+ notice.add(getValidDate(rs, "EntrustmentDate"));
+ notice.add (rs.getInt ("ClientId"));
+ notice.add (rs.getBoolean("DraftCreated"));
+ notice.add (rs.getBoolean("DraftApproved"));
+ notice.add (rs.getBoolean("NoticeSent"));
+ notice.add (getValidDate(rs, "SentDate"));
+ notice.add (rs.getString("RPADReference"));
+ notice.add (rs.getBoolean("NoticeDelivered"));
+ notice.add (getValidDate(rs, "DeliveryDate"));
+ notice.add (rs.getString("BillStatus"));
+ notice.add (rs.getInt ("BillAmount"));
+ notice.add (getValidDate (rs, "BillDate"));
+ notice.add (rs.getBoolean ("ClarificationPending"));
+ notice.add (rs.getString("ClarificationRemarks"));
+ }
+ return notice;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return null;
+ }
+
+
+ }
+ private static final String JDBC = "jdbc:sqlite:";
+
+ static boolean updateLegalNoticeDraftStatus(int selectednotice_id, boolean created, boolean approved) {
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("UPDATE legalnotices "
+ + "SET DraftCreated=?, DraftApproved=? WHERE id=?;");
+ st.setBoolean(1, created);
+ st.setBoolean(2, approved);
+ st.setInt (3, selectednotice_id);
+ st.execute();
+ conn.close();
+ return true;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return false;
+ }
+