public static JSONObject getJsonForAction( Connection conn, PreparedStatement pstmt, ResultSet rs, HttpServletRequest request, String callerFlag) throws ServiceException { java.text.SimpleDateFormat sdf1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); JSONObject jobj = new JSONObject(); ResultSet rs2 = null; try { int aid = rs.getInt("actionid"); String author = AuthHandler.getAuthor(conn, rs.getString("actionby")); String params = rs.getString("params"); String userparam[] = params.split(","); String query2 = "select textkey from actions where actionid = ?"; pstmt = conn.prepareStatement(query2); pstmt.setInt(1, aid); rs2 = pstmt.executeQuery(); Object[] strParam = new Object[userparam.length]; for (int i = 0; i < userparam.length; i++) { strParam[i] = userparam[i]; } rs2.next(); String action = rs2.getString("textkey"); String useraction = MessageSourceProxy.getMessage(action, strParam, request); String sdtStr = Timezone.toCompanyTimezone( conn, rs.getTimestamp("timestamp").toString(), AuthHandler.getCompanyid(request)); jobj.put("logid", rs.getInt("logid")); jobj.put("actionby", author); jobj.put("description", useraction); if (callerFlag.equals("all") || callerFlag.equals("projname")) { String projectname = ""; String projid = rs.getString("projectid"); if (!StringUtil.isNullOrEmpty(projid)) { projectname = projdb.getProjectName(conn, projid); } jobj.put("projname", projectname); } jobj.put("timestamp", sdtStr); } catch (ServiceException ex) { Logger.getLogger(AuditTrail.class.getName()).log(Level.SEVERE, null, ex); } catch (JSONException ex) { throw ServiceException.FAILURE("AuditTrail.getJsonForAction", ex); } catch (Exception ex) { throw ServiceException.FAILURE("AuditTrail.getJsonForAction", ex); } finally { return jobj; } }
public static String getDateString(Connection conn, HttpServletRequest request, String loginid) throws ServiceException { String d = ""; try { String fromdate = request.getParameter("fromdate"), todate = request.getParameter("todate"); if (!StringUtil.isNullOrEmpty(fromdate) && StringUtil.isNullOrEmpty(todate)) { fromdate = Timezone.fromCompanyToSystem(conn, fromdate, loginid); d = " and timestamp >= TIMESTAMP('" + fromdate + "')"; } else if (!StringUtil.isNullOrEmpty(todate) && StringUtil.isNullOrEmpty(fromdate)) { todate = Timezone.fromCompanyToSystem(conn, todate, loginid); d = " and timestamp <= TIMESTAMP('" + todate + "')"; } else if (!StringUtil.isNullOrEmpty(todate) && !StringUtil.isNullOrEmpty(fromdate)) { fromdate = Timezone.fromCompanyToSystem(conn, fromdate, loginid); todate = Timezone.fromCompanyToSystem(conn, todate, loginid); d = " and timestamp BETWEEN TIMESTAMP('" + fromdate + "') and TIMESTAMP('" + todate + "')"; } else { d = ""; } } catch (Exception e) { d = ""; } finally { return d; } }