List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getUrgentTasks(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getUrgentTasks " + Username); Date date = new Date(); Calendar cal = Calendar.getInstance(); GregorianCalendar cal121 = new GregorianCalendar(); cal121.setTime(date); cal121.add(Calendar.DATE, 3); Date days3 = cal121.getTime(); String username = Username.getUserName(); cal.add(Calendar.DATE, 3);/* www .ja v a2 s . c om*/ String year = Integer.toString(cal.get(Calendar.YEAR)); String month = Integer.toString(cal.get(Calendar.MONTH) + 1); String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); String minute = Integer.toString(cal.get(Calendar.MINUTE)); Date date1 = new Date(); Calendar cal1 = Calendar.getInstance(); cal1.add(Calendar.DATE, 4); String year1 = Integer.toString(cal1.get(Calendar.YEAR)); String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1); String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH)); String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY)); String minute1 = Integer.toString(cal1.get(Calendar.MINUTE)); String sql = ""; if (onlyUser == null) { sql = "select * from " + Username.getcompany() + ".tasks where ((taskfrom = '" + username + "' ) or (taskto1 = '" + username + "') or (taskto2 = '" + username + "') or (taskto3 = '" + username + "') or (taskto4 = '" + username + "') or (taskto5 = '" + username + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username + "') or (taskto8 = '" + username + "') or (taskto9 = '" + username + "') or (taskto10 = '" + username + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username + "') or (taskto13 = '" + username + "') or (taskto14 = '" + username + "') or (taskto15 = '" + username + "'))and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')"; } else { if (onlyUser.length() < 3) { sql = "select * from " + Username.getcompany() + ".tasks where ((taskfrom = '" + username + "' ) or (taskto1 = '" + username + "') or (taskto2 = '" + username + "') or (taskto3 = '" + username + "') or (taskto4 = '" + username + "') or (taskto5 = '" + username + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username + "') or (taskto8 = '" + username + "') or (taskto9 = '" + username + "') or (taskto10 = '" + username + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username + "') or (taskto13 = '" + username + "') or (taskto14 = '" + username + "') or (taskto15 = '" + username + "'))and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')"; } else { sql = "select * from " + Username.getcompany() + ".tasks where (taskfrom = '" + onlyUser + "' ) and ((taskto1 = '" + username + "') or (taskto2 = '" + username + "') or (taskto3 = '" + username + "') or (taskto4 = '" + username + "') or (taskto5 = '" + username + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username + "') or (taskto8 = '" + username + "') or (taskto9 = '" + username + "') or (taskto10 = '" + username + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username + "') or (taskto13 = '" + username + "') or (taskto14 = '" + username + "') or (taskto15 = '" + username + "')) and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')"; } } PreparedStatement pstm = conn.prepareStatement(sql); // pstm.setString(1, Username); ResultSet rs = pstm.executeQuery(); ArrayList<Tasks> list = new ArrayList<Tasks>(); while (rs.next()) { Date date10 = new Date(); Calendar cal10 = new GregorianCalendar(); if (rs.getTimestamp("revdate") == null) { cal1.setTime(rs.getTimestamp("enddate")); } else { cal1.setTime(rs.getTimestamp("revdate")); } String year10 = Integer.toString(cal10.get(Calendar.YEAR)); String month10 = Integer.toString(cal10.get(Calendar.MONTH) + 1); String day10 = Integer.toString(cal10.get(Calendar.DAY_OF_MONTH)); String hour10 = Integer.toString(cal10.get(Calendar.HOUR_OF_DAY)); String minute10 = Integer.toString(cal10.get(Calendar.MINUTE)); if (hour10.length() == 1) { hour10 = "0" + hour10; } if (minute10.length() == 1) { minute10 = "0" + minute10; } if (month10.length() == 1) { month10 = "0" + month10; } if (day10.length() == 1) { day10 = "0" + day10; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs.getString("tranid"); String taskfrom = rs.getString("taskfrom"); String description = rs.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs.getString("taskstat"); } //String taskstat = rs.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; if (date.after(rs.getTimestamp("revdate"))) { color1 = "red"; } if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) { color1 = "orange"; } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); String color2 = "black"; if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1")))) || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2")))) || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3")))) || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4")))) || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5")))) || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6")))) || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7")))) || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8")))) || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9")))) || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10")))) || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11")))) || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12")))) || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13")))) || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14")))) || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } String sql1 = ""; if (onlyUser == null) { sql1 = "select * from " + Username.getcompany() + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')"; } else { if (onlyUser.length() < 3) { sql1 = "select * from " + Username.getcompany() + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')"; } else { sql1 = "select * from " + Username.getcompany() + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or(taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59') and (taskfrom = '" + onlyUser + "')"; } } PreparedStatement pstm1 = conn.prepareStatement(sql1); pstm1.setString(1, Username.getUserName()); pstm1.setString(2, Username.getUserName()); pstm1.setString(3, Username.getUserName()); pstm1.setString(4, Username.getUserName()); pstm1.setString(5, Username.getUserName()); pstm1.setString(6, Username.getUserName()); pstm1.setString(7, Username.getUserName()); pstm1.setString(8, Username.getUserName()); pstm1.setString(9, Username.getUserName()); pstm1.setString(10, Username.getUserName()); pstm1.setString(11, Username.getUserName()); pstm1.setString(12, Username.getUserName()); pstm1.setString(13, Username.getUserName()); pstm1.setString(14, Username.getUserName()); pstm1.setString(15, Username.getUserName()); ResultSet rs1 = pstm1.executeQuery(); while (rs1.next()) { Date date11 = new Date(); Calendar cal11 = new GregorianCalendar(); if (rs1.getTimestamp("revdate") == null) { cal1.setTime(rs.getTimestamp("enddate")); } else { cal1.setTime(rs1.getTimestamp("revdate")); } // cal1.setTime(rs1.getTimestamp("revdate")); String year11 = Integer.toString(cal11.get(Calendar.YEAR)); String month11 = Integer.toString(cal11.get(Calendar.MONTH) + 1); String day11 = Integer.toString(cal11.get(Calendar.DAY_OF_MONTH)); String hour11 = Integer.toString(cal11.get(Calendar.HOUR_OF_DAY)); String minute11 = Integer.toString(cal11.get(Calendar.MINUTE)); if (hour11.length() == 1) { hour11 = "0" + hour11; } if (minute11.length() == 1) { minute11 = "0" + minute11; } if (month11.length() == 1) { month11 = "0" + month11; } if (day11.length() == 1) { day11 = "0" + day11; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs1.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs1.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs1.getString("tranid"); String taskfrom = rs1.getString("taskfrom"); String description = rs1.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs1.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs1.getString("taskstat"); } //String taskstat = rs1.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; if (date.after(rs1.getTimestamp("revdate"))) { color1 = "red"; } if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) { color1 = "orange"; } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); String color2 = "black"; if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1")))) || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2")))) || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3")))) || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4")))) || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5")))) || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6")))) || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7")))) || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8")))) || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9")))) || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10")))) || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11")))) || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12")))) || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13")))) || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14")))) || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTask(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getTask " + Username.getUserName() + " " + onlyUser); Date date = new Date(); Calendar cal = Calendar.getInstance(); Calendar cal7 = Calendar.getInstance(); GregorianCalendar cal121 = new GregorianCalendar(); cal121.setTime(date); cal121.add(Calendar.DATE, 3); Date days3 = cal121.getTime(); String year = Integer.toString(cal.get(Calendar.YEAR)); String month = Integer.toString(cal.get(Calendar.MONTH) + 1); String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); String minute = Integer.toString(cal.get(Calendar.MINUTE)); String sql = ""; if (onlyUser == null) { onlyUser = ""; }//from w w w . java 2 s .c o m if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where (recur = '0') and (startdate < '" + year + "/" + month + "/" + day + " 23:59') and ((taskstat <> 'Completed') or (taskstat is NULL)) and (((taskto1 = ? ) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)))) "; } else { sql = "select * from " + Username.getcompany() + ".tasks where (recur = '0') and (startdate < '" + year + "/" + month + "/" + day + " 23:59') and ((taskstat <> 'Completed') or (taskstat is NULL)) and (((taskto1 = ? ) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)))) and (taskfrom = '" + onlyUser + "')"; } PreparedStatement pstm = conn.prepareStatement(sql); pstm.setString(1, Username.getUserName()); pstm.setString(2, Username.getUserName()); pstm.setString(3, Username.getUserName()); pstm.setString(4, Username.getUserName()); pstm.setString(5, Username.getUserName()); pstm.setString(6, Username.getUserName()); pstm.setString(7, Username.getUserName()); pstm.setString(8, Username.getUserName()); pstm.setString(9, Username.getUserName()); pstm.setString(10, Username.getUserName()); pstm.setString(11, Username.getUserName()); pstm.setString(12, Username.getUserName()); pstm.setString(13, Username.getUserName()); pstm.setString(14, Username.getUserName()); pstm.setString(15, Username.getUserName()); ResultSet rs = pstm.executeQuery(); ArrayList<Tasks> list = new ArrayList<Tasks>(); while (rs.next()) { Date date1 = new Date(); Calendar cal1 = new GregorianCalendar(); if (rs.getTimestamp("revdate") == null) { cal1.setTime(rs.getTimestamp("enddate")); } else { cal1.setTime(rs.getTimestamp("revdate")); } // cal1.setTime(rs.getTimestamp("revdate")); String year1 = Integer.toString(cal1.get(Calendar.YEAR)); String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1); String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH)); String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY)); String minute1 = Integer.toString(cal1.get(Calendar.MINUTE)); if (hour1.length() == 1) { hour1 = "0" + hour1; } if (minute1.length() == 1) { minute1 = "0" + minute1; } if (month1.length() == 1) { month1 = "0" + month1; } if (day1.length() == 1) { day1 = "0" + day1; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs.getString("tranid"); String taskfrom = rs.getString("taskfrom"); String description = rs.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String taskstat; if (rs.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs.getString("taskstat"); } String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; //String taskstat = rs.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; String color2 = "black"; if (rs.getTimestamp("revdate") == null) { cal7.setTime(rs.getTimestamp("enddate")); } else { cal7.setTime(rs.getTimestamp("revdate")); } if (date.after(cal7.getTime())) { color1 = "red"; } if (color1 == "" && days3.after(cal7.getTime())) { color1 = "orange"; } // if (date.after(rs.getTimestamp("revdate"))) { // color1 = "red"; // } // if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) { // color1 = "orange"; // } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); // System.out.println("getTask " + color1 ); if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1")))) || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2")))) || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3")))) || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4")))) || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5")))) || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6")))) || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7")))) || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8")))) || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9")))) || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10")))) || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11")))) || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12")))) || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13")))) || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14")))) || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } String sql1 = "select * from " + Username.getcompany() + ".tasks where (recur =1) and ((taskstat <> 'Completed') or (taskstat is NULL)) and (startdate <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 <= '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate10 < enddate)))"; PreparedStatement pstm1 = conn.prepareStatement(sql1); pstm1.setString(1, Username.getUserName()); pstm1.setString(2, Username.getUserName()); pstm1.setString(3, Username.getUserName()); pstm1.setString(4, Username.getUserName()); pstm1.setString(5, Username.getUserName()); pstm1.setString(6, Username.getUserName()); pstm1.setString(7, Username.getUserName()); pstm1.setString(8, Username.getUserName()); pstm1.setString(9, Username.getUserName()); pstm1.setString(10, Username.getUserName()); pstm1.setString(11, Username.getUserName()); pstm1.setString(12, Username.getUserName()); pstm1.setString(13, Username.getUserName()); pstm1.setString(14, Username.getUserName()); pstm1.setString(15, Username.getUserName()); ResultSet rs1 = pstm1.executeQuery(); while (rs1.next()) { Date date1 = new Date(); Calendar cal1 = new GregorianCalendar(); if (rs1.getTimestamp("revdate") == null) { cal1.setTime(rs1.getTimestamp("enddate")); } else { cal1.setTime(rs1.getTimestamp("revdate")); } // cal1.setTime(rs1.getTimestamp("revdate")); String year1 = Integer.toString(cal1.get(Calendar.YEAR)); String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1); String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH)); String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY)); String minute1 = Integer.toString(cal1.get(Calendar.MINUTE)); if (hour1.length() == 1) { hour1 = "0" + hour1; } if (minute1.length() == 1) { minute1 = "0" + minute1; } if (month1.length() == 1) { month1 = "0" + month1; } if (day1.length() == 1) { day1 = "0" + day1; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs1.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs1.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs1.getString("tranid"); String taskfrom = rs1.getString("taskfrom"); String description = rs1.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs1.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs1.getString("taskstat"); } //String taskstat = rs1.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; if (date.after(rs1.getTimestamp("revdate"))) { color1 = "red"; } if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) { color1 = "orange"; } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); String color2 = "black"; if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1")))) || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2")))) || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3")))) || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4")))) || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5")))) || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6")))) || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7")))) || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8")))) || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9")))) || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10")))) || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11")))) || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12")))) || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13")))) || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14")))) || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTaskInFuture(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getTaskInFuture " + onlyUser); Date date = new Date(); Calendar cal = Calendar.getInstance(); GregorianCalendar cal121 = new GregorianCalendar(); cal121.setTime(date); cal121.add(Calendar.DATE, 3); Date days3 = cal121.getTime(); String year = Integer.toString(cal.get(Calendar.YEAR)); String month = Integer.toString(cal.get(Calendar.MONTH) + 1); String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); String minute = Integer.toString(cal.get(Calendar.MINUTE)); String sql = ""; if (onlyUser == null) { onlyUser = ""; }//from w ww. j a va2 s .c om if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where (startdate > '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and ( recur = '0') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)))) and (taskstat <> 'Completed')"; } else { sql = "select * from " + Username.getcompany() + ".tasks where (startdate > '" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and ( recur = '0') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)))) and (taskstat <> 'Completed') and (taskfrom = '" + onlyUser + "')"; } PreparedStatement pstm = conn.prepareStatement(sql); pstm.setString(1, Username.getUserName()); pstm.setString(2, Username.getUserName()); pstm.setString(3, Username.getUserName()); pstm.setString(4, Username.getUserName()); pstm.setString(5, Username.getUserName()); pstm.setString(6, Username.getUserName()); pstm.setString(7, Username.getUserName()); pstm.setString(8, Username.getUserName()); pstm.setString(9, Username.getUserName()); pstm.setString(10, Username.getUserName()); pstm.setString(11, Username.getUserName()); pstm.setString(12, Username.getUserName()); pstm.setString(13, Username.getUserName()); pstm.setString(14, Username.getUserName()); pstm.setString(15, Username.getUserName()); ResultSet rs = pstm.executeQuery(); ArrayList<Tasks> list = new ArrayList<Tasks>(); while (rs.next()) { Date date1 = new Date(); Calendar cal1 = new GregorianCalendar(); if (rs.getTimestamp("revdate") == null) { cal1.setTime(rs.getTimestamp("startdate")); } else { cal1.setTime(rs.getTimestamp("revdate")); } String year1 = Integer.toString(cal1.get(Calendar.YEAR)); String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1); String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH)); String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY)); String minute1 = Integer.toString(cal1.get(Calendar.MINUTE)); if (hour1.length() == 1) { hour1 = "0" + hour1; } if (minute1.length() == 1) { minute1 = "0" + minute1; } if (month1.length() == 1) { month1 = "0" + month1; } if (day1.length() == 1) { day1 = "0" + day1; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs.getString("tranid"); String taskfrom = rs.getString("taskfrom"); String description = rs.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs.getString("taskstat"); } //String taskstat = rs.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; if (date.after(rs.getTimestamp("revdate"))) { color1 = "red"; } if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) { color1 = "orange"; } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); String color2 = "black"; if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1")))) || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2")))) || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3")))) || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4")))) || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5")))) || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6")))) || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7")))) || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8")))) || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9")))) || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10")))) || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11")))) || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12")))) || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13")))) || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14")))) || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } String sql1 = ""; if (onlyUser == null) { onlyUser = ""; } if (onlyUser.equals(null) | onlyUser.length() < 4) { sql1 = "select * from " + Username.getcompany() + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate10 < enddate)))"; } else { sql1 = "select * from " + Username.getcompany() + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 >'" + year + "/" + month + "/" + day + " " + hour + ":" + minute + ":00') and (recurdate10 < enddate))) and (taskfrom ='" + onlyUser + "')"; } PreparedStatement pstm1 = conn.prepareStatement(sql1); pstm1.setString(1, Username.getUserName()); pstm1.setString(2, Username.getUserName()); pstm1.setString(3, Username.getUserName()); pstm1.setString(4, Username.getUserName()); pstm1.setString(5, Username.getUserName()); pstm1.setString(6, Username.getUserName()); pstm1.setString(7, Username.getUserName()); pstm1.setString(8, Username.getUserName()); pstm1.setString(9, Username.getUserName()); pstm1.setString(10, Username.getUserName()); pstm1.setString(11, Username.getUserName()); pstm1.setString(12, Username.getUserName()); pstm1.setString(13, Username.getUserName()); pstm1.setString(14, Username.getUserName()); pstm1.setString(15, Username.getUserName()); ResultSet rs1 = pstm1.executeQuery(); while (rs1.next()) { Date date1 = new Date(); Calendar cal1 = new GregorianCalendar(); if (rs1.getTimestamp("revdate") == null) { cal1.setTime(rs1.getTimestamp("enddate")); } else { cal1.setTime(rs1.getTimestamp("revdate")); } // cal1.setTime(rs1.getTimestamp("revdate")); String year1 = Integer.toString(cal1.get(Calendar.YEAR)); String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1); String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH)); String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY)); String minute1 = Integer.toString(cal1.get(Calendar.MINUTE)); if (hour1.length() == 1) { hour1 = "0" + hour1; } if (minute1.length() == 1) { minute1 = "0" + minute1; } if (month1.length() == 1) { month1 = "0" + month1; } if (day1.length() == 1) { day1 = "0" + day1; } Date date2 = new Date(); Calendar cal2 = new GregorianCalendar(); cal2.setTime(rs1.getTimestamp("enddate")); String year2 = Integer.toString(cal2.get(Calendar.YEAR)); String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1); String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH)); String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY)); String minute2 = Integer.toString(cal2.get(Calendar.MINUTE)); if (hour2.length() == 1) { hour2 = "0" + hour2; } if (minute2.length() == 1) { minute2 = "0" + minute2; } if (month2.length() == 1) { month2 = "0" + month2; } if (day2.length() == 1) { day2 = "0" + day2; } Date date3 = new Date(); Calendar cal3 = new GregorianCalendar(); cal3.setTime(rs1.getTimestamp("startdate")); String year3 = Integer.toString(cal3.get(Calendar.YEAR)); String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1); String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH)); String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY)); String minute3 = Integer.toString(cal3.get(Calendar.MINUTE)); if (hour3.length() == 1) { hour3 = "0" + hour3; } if (minute3.length() == 1) { minute3 = "0" + minute3; } if (month3.length() == 1) { month3 = "0" + month3; } if (day3.length() == 1) { day3 = "0" + day3; } String tranid = rs1.getString("tranid"); String taskfrom = rs1.getString("taskfrom"); String description = rs1.getString("description"); String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1; String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs1.getString("taskstat") == null) { taskstat = "Not Started"; } else { taskstat = rs1.getString("taskstat"); } //String taskstat = rs1.getString("taskstat"); String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3; Tasks task = new Tasks(); task.setTranid(tranid); task.setTaskfrom(taskfrom); task.setDescription(description); task.setRevdate(revdate); task.setEnddate(enddate); task.setTaskstat(taskstat); task.setStartdate(startdate); String color1 = ""; if (date.after(rs1.getTimestamp("revdate"))) { color1 = "red"; } if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) { color1 = "orange"; } if (color1 == "") { color1 = "green"; } task.setlinkup1(color1); String color2 = "black"; if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1")))) || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2")))) || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3")))) || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4")))) || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5")))) || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6")))) || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7")))) || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8")))) || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9")))) || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10")))) || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11")))) || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12")))) || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13")))) || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14")))) || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) { color2 = "green"; } task.setlinkup2(color2); list.add(task); } return list; }
From source file:ucar.unidata.data.storm.AtcfStormDataSource.java
/** * _more_/*from w w w . j a v a 2 s . c o m*/ * * @param stormInfo _more_ * @param tracks _more_ * @param trackFile _more_ * @param waysToUse _more_ * @param throwError _more_ * * * @return _more_ * @throws Exception _more_ */ private boolean readTracks(StormInfo stormInfo, StormTrackCollection tracks, String trackFile, Hashtable<String, Boolean> waysToUse, boolean throwError) throws Exception { long t1 = System.currentTimeMillis(); byte[] bytes = readFile(trackFile, true); long t2 = System.currentTimeMillis(); // System.err.println("read time:" + (t2 - t1)); boolean isZip = trackFile.endsWith(".gz"); if ((bytes == null) && isZip) { String withoutGZ = trackFile.substring(0, trackFile.length() - 3); bytes = readFile(withoutGZ, true); isZip = false; } if (bytes == null) { if (throwError) { throw new BadDataException("Unable to read track file:" + trackFile); } return false; } if (isZip) { GZIPInputStream zin = new GZIPInputStream(new ByteArrayInputStream(bytes)); bytes = IOUtil.readBytes(zin); zin.close(); } GregorianCalendar convertCal = new GregorianCalendar(DateUtil.TIMEZONE_GMT); convertCal.clear(); String trackData = new String(bytes); List lines = StringUtil.split(trackData, "\n", true, true); SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHH"); fmt.setTimeZone(TimeZone.getTimeZone("UTC")); Hashtable trackMap = new Hashtable(); Real altReal = new Real(RealType.Altitude, 0); // System.err.println("obs:" + lines.size()); /* Hashtable okWays = new Hashtable(); okWays.put(WAY_CARQ, ""); okWays.put(WAY_WRNG, ""); okWays.put(WAY_BEST, ""); okWays.put("ETA", ""); okWays.put("NGX", ""); okWays.put("BAMS", "");*/ Hashtable seenDate = new Hashtable(); initParams(); int xcnt = 0; // check if the tech num is included // some actf files do not have tech num for some reasom. List toks1 = StringUtil.split(lines.get(1), ",", true); String techNum = (String) toks1.get(IDX_TECHNUM); if (techNum.length() > 0 && !techNum.matches("\\d+")) { IDX_TECH = IDX_TECH - 1; IDX_TAU = IDX_TAU - 1; IDX_LAT = IDX_LAT - 1; IDX_LON = IDX_LON - 1; IDX_VMAX = IDX_VMAX - 1; IDX_MSLP = IDX_MSLP - 1; IDX_TY = IDX_TY - 1; } for (int i = 0; i < lines.size(); i++) { String line = (String) lines.get(i); if (i == 0) { // System.err.println(line); } List toks = StringUtil.split(line, ",", true); /* System.err.println(toks.size() + " " + BASEIDX); if(toks.size()<BASEIDX-1) { System.err.println("bad line:" + line); continue; } else { System.err.println("good line:" + line); } */ //BASIN,CY,YYYYMMDDHH,TECHNUM,TECH,TAU,LatN/S,LonE/W,VMAX,MSLP,TY,RAD,WINDCODE,RAD1,RAD2,RAD3,RAD4,RADP,RRP,MRD,GUSTS,EYE,SUBREGION,MAXSEAS,INITIALS,DIR,SPEED,STORMNAME,DEPTH,SEAS,SEASCODE,SEAS1,SEAS2,SEAS3,SEAS4 //AL, 01, 2007050612, , BEST, 0, 355N, 740W, 35, 1012, EX, 34, NEQ, 0, 0, 0, 120, //AL, 01, 2007050812, 01, CARQ, -24, 316N, 723W, 55, 0, DB, 34, AAA, 0, 0, 0, 0, String dateString = (String) toks.get(IDX_YYYYMMDDHH); String wayString = (String) toks.get(IDX_TECH); // if (okWays.get(wayString) == null) { // continue; // } boolean isBest = wayString.equals(WAY_BEST); boolean isWarning = wayString.equals(WAY_WRNG); boolean isCarq = wayString.equals(WAY_CARQ); int category = ((IDX_TY < toks.size()) ? getCategory((String) toks.get(IDX_TY)) : CATEGORY_XX); if (category != CATEGORY_XX) { // System.err.println("cat:" + category); } String fhour = (String) toks.get(IDX_TAU); int forecastHour = new Integer(fhour).intValue(); //A hack - we've seen some atfc files that have a 5 character forecast hour //right padded with "00", eg., 01200 if ((fhour.length() == 5) && (forecastHour > 100)) { forecastHour = forecastHour / 100; } if (isWarning || isCarq) { forecastHour = -forecastHour; } //Check for unique dates for this way String dttmkey = wayString + "_" + dateString + "_" + forecastHour; if (seenDate.get(dttmkey) != null) { continue; } seenDate.put(dttmkey, dttmkey); Date dttm = fmt.parse(dateString); convertCal.setTime(dttm); String key; Way way = getWay(wayString, null); if (!isBest && (waysToUse != null) && (waysToUse.size() > 0) && (waysToUse.get(wayString) == null)) { continue; } if (isBest) { key = wayString; } else { key = wayString + "_" + dateString; convertCal.add(Calendar.HOUR_OF_DAY, forecastHour); } dttm = convertCal.getTime(); StormTrack track = (StormTrack) trackMap.get(key); if (track == null) { way = (isBest ? Way.OBSERVATION : way); track = new StormTrack(stormInfo, addWay(way), new DateTime(dttm), obsParams); trackMap.put(key, track); tracks.addTrack(track); } String latString = (String) toks.get(IDX_LAT); String lonString = (String) toks.get(IDX_LON); String t = latString + " " + lonString; boolean south = latString.endsWith("S"); boolean west = lonString.endsWith("W"); double latitude = Double.parseDouble(latString.substring(0, latString.length() - 1)) / 10.0; double longitude = Double.parseDouble(lonString.substring(0, lonString.length() - 1)) / 10.0; if (south) { latitude = -latitude; } if (west) { longitude = -longitude; } EarthLocation elt = new EarthLocationLite(new Real(RealType.Latitude, latitude), new Real(RealType.Longitude, longitude), altReal); List<Real> attributes = new ArrayList<Real>(); double windspeed = ((IDX_VMAX < toks.size()) ? getDouble((String) toks.get(IDX_VMAX)) : Double.NaN); double pressure = ((IDX_MSLP < toks.size()) ? getDouble((String) toks.get(IDX_MSLP)) : Double.NaN); attributes.add(PARAM_STORMCATEGORY.getReal((double) category)); attributes.add(PARAM_MINPRESSURE.getReal(pressure)); attributes.add(PARAM_MAXWINDSPEED_KTS.getReal(windspeed)); StormTrackPoint stp = new StormTrackPoint(elt, new DateTime(dttm), forecastHour, attributes); track.addPoint(stp); } return true; }
From source file:org.redis.shop.test.InitData.java
@Test public void br_addStockRemoval() { List<Category> categories = categoryService.getByProperty(categoryService.getAll(), "level", 3); List<Center> centers = centerService.getAll(); List<Enterprise> enterprises = enterpriseService.getAll(); GregorianCalendar cal = new GregorianCalendar(); for (int i = 0; i < categories.size(); i++) { cal.setTime(new Date()); cal.add(Calendar.DATE, 0 - i); for (int j = 0; j < centers.size(); j++) { for (int k = 0; k < enterprises.size(); k++) { StockRemoval stockRemoval = new StockRemoval(); stockRemoval.setCategory(categories.get(i)); stockRemoval.setCenter(centers.get(j)); stockRemoval.setEnterprise(enterprises.get(k)); stockRemoval.setInTime(cal.getTime()); stockRemoval.setOutTime(cal.getTime()); stockRemoval.setPrice(i * j * k + 1); stockRemoval.setWeight((i * j * k + 1) * 2); stockRemoval.setState(Enum_Transaction.CL); stockRemovalService.save(stockRemoval); }//from ww w.ja v a 2 s . co m } } }
From source file:org.exoplatform.calendar.service.impl.JCRDataStorage.java
/** * {@inheritDoc}//from w w w . ja va2 s . co m */ public void saveEvent(Node calendarNode, CalendarEvent event, Node reminderFolder, boolean isNew) throws Exception { Node eventNode; Boolean isRepeatNode = false; if (isNew) { eventNode = calendarNode.addNode(event.getId(), Utils.EXO_CALENDAR_EVENT); eventNode.setProperty(Utils.EXO_ID, event.getId()); if (Utils.isRepeatEvent(event)) { eventNode.addMixin(Utils.EXO_REPEAT_CALENDAR_EVENT); eventNode.addMixin(Utils.MIX_REFERENCEABLE); isRepeatNode = true; } if (Utils.isExceptionOccurrence(event)) { eventNode.addMixin(Utils.EXO_REPEAT_CALENDAR_EVENT); isRepeatNode = true; } } else { try { eventNode = calendarNode.getNode(event.getId()); if (Utils.isRepeatEvent(event)) { if (!eventNode.isNodeType(Utils.EXO_REPEAT_CALENDAR_EVENT)) eventNode.addMixin(Utils.EXO_REPEAT_CALENDAR_EVENT); if (!eventNode.isNodeType(Utils.MIX_REFERENCEABLE)) eventNode.addMixin(Utils.MIX_REFERENCEABLE); isRepeatNode = true; } } catch (Exception e) { eventNode = calendarNode.addNode(event.getId(), Utils.EXO_CALENDAR_EVENT); eventNode.setProperty(Utils.EXO_ID, event.getId()); } try { removeReminder(eventNode); } catch (Exception e) { if (log.isDebugEnabled()) log.debug(e); } finally { // systemSession.close() ; } } eventNode.setProperty(Utils.EXO_SUMMARY, event.getSummary()); eventNode.setProperty(Utils.EXO_CALENDAR_ID, event.getCalendarId()); eventNode.setProperty(Utils.EXO_EVENT_CATEGORYID, event.getEventCategoryId()); eventNode.setProperty(Utils.EXO_EVENT_CATEGORY_NAME, event.getEventCategoryName()); eventNode.setProperty(Utils.EXO_DESCRIPTION, event.getDescription()); eventNode.setProperty(Utils.EXO_LOCATION, event.getLocation()); eventNode.setProperty(Utils.EXO_TASK_DELEGATOR, event.getTaskDelegator()); GregorianCalendar dateTime = Utils.getInstanceTempCalendar(); // convert date time to GMT time zone before saving to database. // dateTime.setTimeZone(TimeZone.getTimeZone("GMT")); dateTime.setTime(event.getFromDateTime()); eventNode.setProperty(Utils.EXO_FROM_DATE_TIME, dateTime); dateTime.setTime(event.getToDateTime()); eventNode.setProperty(Utils.EXO_TO_DATE_TIME, dateTime); eventNode.setProperty(Utils.EXO_EVENT_TYPE, event.getEventType()); eventNode.setProperty(Utils.EXO_REPEAT, event.getRepeatType()); eventNode.setProperty(Utils.EXO_PRIORITY, event.getPriority()); eventNode.setProperty(Utils.EXO_IS_PRIVATE, event.isPrivate()); eventNode.setProperty(Utils.EXO_EVENT_STATE, event.getEventState()); if (event.getInvitation() == null) event.setInvitation(new String[] {}); eventNode.setProperty(Utils.EXO_INVITATION, event.getInvitation()); if (event.getParticipant() == null) event.setParticipant(new String[] {}); eventNode.setProperty(Utils.EXO_PARTICIPANT, event.getParticipant()); List<Reminder> reminders = event.getReminders(); if (reminders != null && !reminders.isEmpty()) { for (Reminder rm : reminders) { rm.setFromDateTime(event.getFromDateTime()); addReminder(eventNode, reminderFolder, rm); } } if (eventNode.hasNode(Utils.ATTACHMENT_NODE)) { while (eventNode.getNodes().hasNext()) { eventNode.getNodes().nextNode().remove(); } eventNode.save(); } List<Attachment> attachments = event.getAttachment(); if (attachments != null) { for (Attachment att : attachments) { addAttachment(eventNode, att, isNew); } } // TODO CS-764 eventNode.setProperty(Utils.EXO_MESSAGE, event.getMessage()); eventNode.setProperty(Utils.EXO_SEND_OPTION, event.getSendOption()); if (event.getParticipantStatus() == null) event.setParticipantStatus(new String[] {}); eventNode.setProperty(Utils.EXO_PARTICIPANT_STATUS, event.getParticipantStatus()); if (isRepeatNode) { if (event.getRecurrenceId() != null) eventNode.setProperty(Utils.EXO_RECURRENCE_ID, event.getRecurrenceId()); else eventNode.setProperty(Utils.EXO_RECURRENCE_ID, Utils.EMPTY_STR); if (event.getIsExceptionOccurrence() != null) eventNode.setProperty(Utils.EXO_IS_EXCEPTION, event.getIsExceptionOccurrence()); else eventNode.setProperty(Utils.EXO_IS_EXCEPTION, (Value) null); if (event.getExcludeId() != null && event.getExcludeId().length > 0) eventNode.setProperty(Utils.EXO_EXCLUDE_ID, event.getExcludeId()); else eventNode.setProperty(Utils.EXO_EXCLUDE_ID, (Value[]) null); if (event.getRepeatUntilDate() != null) { dateTime = Utils.getInstanceTempCalendar(); dateTime.setTime(event.getRepeatUntilDate()); eventNode.setProperty(Utils.EXO_REPEAT_UNTIL, dateTime); } else { eventNode.setProperty(Utils.EXO_REPEAT_UNTIL, (Value) null); } if (event.getOriginalReference() != null) eventNode.setProperty(Utils.EXO_ORIGINAL_REFERENCE, event.getOriginalReference()); else eventNode.setProperty(Utils.EXO_ORIGINAL_REFERENCE, (Value) null); eventNode.setProperty(Utils.EXO_REPEAT_COUNT, event.getRepeatCount()); eventNode.setProperty(Utils.EXO_REPEAT_INTERVAL, event.getRepeatInterval()); if (event.getRepeatByDay() != null) eventNode.setProperty(Utils.EXO_REPEAT_BYDAY, event.getRepeatByDay()); else eventNode.setProperty(Utils.EXO_REPEAT_BYDAY, (Value[]) null); if (event.getRepeatByMonthDay() != null) { long[] monthDays = event.getRepeatByMonthDay(); String[] byMonthDay = new String[monthDays.length]; for (int i = 0; i < monthDays.length; i++) byMonthDay[i] = String.valueOf(monthDays[i]); eventNode.setProperty(Utils.EXO_REPEAT_BYMONTHDAY, byMonthDay); } else { eventNode.setProperty(Utils.EXO_REPEAT_BYMONTHDAY, (Value[]) null); } // if event is original repeating event, calculate the end-date to save String repeatType = event.getRepeatType(); if (!Utils.isEmpty(repeatType) && !repeatType.equals(CalendarEvent.RP_NOREPEAT)) { Date repeatFinish = calculateRecurrenceFinishDate(event); if (repeatFinish != null) { dateTime = Utils.getInstanceTempCalendar(); dateTime.setTime(repeatFinish); eventNode.setProperty(Utils.EXO_REPEAT_FINISH_DATE, dateTime); } } } calendarNode.getSession().save(); addEvent(event); }
From source file:org.redis.shop.test.InitData.java
@Test public void bm_addSaleInfo() throws Exception { List<Category> categories = categoryService.getByBasicProperty(categoryService.getAll(), "level", 3); categories = categoryService.getByPropertyNotNull(categories, "parentCategory"); User user = userService.get("name", "c1"); Center center = centerService.get("user.userId", user.getUserId()); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date parse = sdf.parse("2015-11-01"); Date today = new Date(); today = sdf.parse(sdf.format(today)); Calendar calendar = Calendar.getInstance(); calendar.setTime(parse);/*from w w w .ja v a2 s .co m*/ long time1 = calendar.getTimeInMillis(); calendar.setTime(today); long time2 = calendar.getTimeInMillis(); long betweenDays = (time2 - time1) / (1000 * 3600 * 24); GregorianCalendar cal = new GregorianCalendar(); List<SaleInfo> saleInfos = new ArrayList<SaleInfo>(); for (int i = 0; i <= betweenDays; i++) { cal.setTime(parse); cal.add(Calendar.DATE, i); Date dateNow = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, 7); Date endDate = cal.getTime(); for (Category category : categories) { SaleInfo si = new SaleInfo(); si.setCategory(category); si.setCenter(center); si.setStartDate(dateNow); si.setPerson("cwj"); si.setPhone("123456789"); si.setEndDate(endDate); si.setTitle("?" + category.getName()); si.setPrice(DataUtil.getRandm(20, 25)); si.setWeight((double) DataUtil.getRandm(200, 209)); System.out.println(si.getPrice()); System.out.println(si.getWeight()); si.setUnit("?"); si.setState(Enum_sale.D); si.setOutTime(dateNow); // saleInfoService.save(si); saleInfos.add(si); } } saleInfoService.save(saleInfos); }
From source file:org.redis.shop.test.InitData.java
@Test public void ay_addPrice() throws Exception { List<Center> centers = centerService.getAll(); // List<Center> centers1 = centerService.getByProperty( // centerService.getAll(), "name", "????"); List<Category> categorys = categoryService.getByBasicProperty(categoryService.getAll(), "level", 2); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date parse = sdf.parse("2014-11-01"); Date today = new Date(); today = sdf.parse(sdf.format(today)); Calendar calendar = Calendar.getInstance(); calendar.setTime(parse);//from w ww . ja va 2 s.co m long time1 = calendar.getTimeInMillis(); calendar.setTime(today); long time2 = calendar.getTimeInMillis(); long betweenDays = (time2 - time1) / (1000 * 3600 * 24); GregorianCalendar cal = new GregorianCalendar(); List<Price> prices = new ArrayList<Price>(); for (int i = 0; i <= betweenDays; i++) { for (Center center : centers) { for (Category category : categorys) { cal.setTime(parse); cal.add(Calendar.DATE, i); Date dateNow = cal.getTime(); Price price = new Price(); price.setCreateDate(dateNow); price.setUpdateDate(dateNow); price.setCreator("jack"); price.setSite(null); price.setUnit("?"); price.setCenter(center); price.setCategory(category); price.setIsNewest("0"); if (i == betweenDays) { price.setIsNewest("1"); } price.setIsGuidencePrice("1");//? price.setPrice(DataUtil.getRandm(100, 500)); prices.add(price); // priceService.save(price); } } } priceService.save(prices); centers = centerService.getByProperty(centerService.getAll(), "name", "????1"); for (int i = 0; i <= 10; i++) { for (Category category : categorys) { Price price = new Price(); price.setCreateDate(new Date()); price.setUpdateDate(new Date()); price.setCreator("jack"); price.setSite(null); price.setUnit("?"); price.setCenter(centers.get(0)); price.setIsGuidencePrice("1");//? price.setCategory(category); price.setIsNewest("0"); price.setPrice(DataUtil.getRandm(100, 500)); priceService.save(price); } } List<Category> list = categoryService.getByBasicProperty(categoryService.getAll(), "level", 1); List<Site> sites = siteService.getAll(); for (Site site : sites) { for (Category category : list) { Price price = new Price(); price.setCreateDate(new Date()); price.setUpdateDate(new Date()); price.setCreator("jack"); price.setSite(site); price.setUnit("?"); price.setCenter(null); price.setCategory(category); price.setIsNewest("1"); price.setIsGuidencePrice("1");//? price.setPrice(DataUtil.getRandm(100, 500)); priceService.save(price); } } }
From source file:org.ramadda.geodata.cdmdata.PointDatabaseTypeHandler.java
/** * _more_/*from ww w . j a va 2 s. co m*/ * * * @param request _more_ * @param entry _more_ * @param metadata _more_ * @param fdp _more_ * @param connection _more_ * @param newEntry _more_ * * @throws Exception _more_ */ private void insertData(Request request, Entry entry, List<PointDataMetadata> metadata, FeatureDatasetPoint fdp, Connection connection, boolean newEntry) throws Exception { String tableName = getTableName(entry); String[] ARRAY = new String[metadata.size()]; for (PointDataMetadata pdm : metadata) { ARRAY[pdm.getColumnNumber()] = pdm.getColumnName(); } String insertString = SqlUtil.makeInsert(tableName, SqlUtil.commaNoDot(ARRAY), SqlUtil.getQuestionMarks(ARRAY.length)); double north = 0, south = 0, east = 0, west = 0; long minTime = (newEntry ? Long.MAX_VALUE : entry.getStartDate()); long maxTime = (newEntry ? Long.MIN_VALUE : entry.getEndDate()); PreparedStatement insertStmt = connection.prepareStatement(insertString); Object[] values = new Object[metadata.size()]; int cnt = 0; int batchCnt = 0; GregorianCalendar calendar = new GregorianCalendar(RepositoryUtil.TIMEZONE_DEFAULT); boolean didone = false; Hashtable properties = getProperties(entry); int baseId = Misc.getProperty(properties, PROP_ID, 0); int totalCnt = Misc.getProperty(properties, PROP_CNT, 0); long t1 = System.currentTimeMillis(); long tt1 = System.currentTimeMillis(); // for(int i=0;i<200;i++) { PointFeatureIterator pfi = CdmDataOutputHandler.getPointIterator(fdp); while (pfi.hasNext()) { PointFeature po = (PointFeature) pfi.next(); ucar.unidata.geoloc.EarthLocation el = po.getLocation(); if (el == null) { continue; } double lat = el.getLatitude(); double lon = el.getLongitude(); double alt = el.getAltitude(); Date time = po.getNominalTimeAsDate(); long tmpTime = time.getTime(); if (tmpTime < minTime) { minTime = tmpTime; } if (tmpTime > maxTime) { maxTime = tmpTime; } if (didone) { north = Math.max(north, lat); south = Math.min(south, lat); west = Math.min(west, lon); east = Math.max(east, lon); } else { north = (newEntry ? lat : entry.hasNorth() ? entry.getNorth() : lat); south = (newEntry ? lat : entry.hasSouth() ? entry.getSouth() : lat); east = (newEntry ? lon : entry.hasEast() ? entry.getEast() : lon); west = (newEntry ? lon : entry.hasWest() ? entry.getWest() : lon); } didone = true; calendar.setTime(time); StructureData structure = po.getData(); boolean hadAnyNumericValues = false; boolean hadGoodNumericValue = false; /* if(totalCnt<5) { StructureMembers.Member member = structure.findMember("altitude"); if(member!=null) { double d = structure.convertScalarFloat(member); } else { System.err.println("no member"); } } */ for (PointDataMetadata pdm : metadata) { Object value; if (COL_ID.equals(pdm.getColumnName())) { value = new Integer(baseId); baseId++; } else if (COL_LATITUDE.equals(pdm.getColumnName())) { value = new Double(checkWriteValue(lat)); } else if (COL_LONGITUDE.equals(pdm.getColumnName())) { value = new Double(checkWriteValue(lon)); } else if (COL_ALTITUDE.equals(pdm.getColumnName())) { value = new Double(checkWriteValue(alt)); } else if (COL_DATE.equals(pdm.getColumnName())) { value = time; } else if (COL_HOUR.equals(pdm.getColumnName())) { value = new Integer(calendar.get(GregorianCalendar.HOUR)); } else if (COL_MONTH.equals(pdm.getColumnName())) { value = new Integer(calendar.get(GregorianCalendar.MONTH)); } else { StructureMembers.Member member = structure.findMember((String) pdm.shortName); if (pdm.isString()) { value = structure.getScalarString(member); if (value == null) { value = ""; } value = value.toString().trim(); } else { double d = structure.convertScalarFloat(member); hadAnyNumericValues = true; if (d == d) { hadGoodNumericValue = true; } value = new Double(checkWriteValue(d)); } } values[pdm.getColumnNumber()] = value; } if (hadAnyNumericValues && !hadGoodNumericValue) { continue; } totalCnt++; getDatabaseManager().setValues(insertStmt, values); insertStmt.addBatch(); batchCnt++; if (batchCnt > 100) { insertStmt.executeBatch(); batchCnt = 0; } if (((++cnt) % 5000) == 0) { System.err.println("added " + cnt + " observations " + (System.currentTimeMillis() - tt1)); } } // } if (batchCnt > 0) { insertStmt.executeBatch(); } insertStmt.close(); long t2 = System.currentTimeMillis(); System.err.println("inserted " + cnt + " observations in " + (t2 - t1) + "ms"); properties.put(PROP_CNT, totalCnt + ""); properties.put(PROP_ID, baseId + ""); setProperties(entry, properties); if (didone) { entry.setWest(west); entry.setEast(east); entry.setNorth(north); entry.setSouth(south); } if (minTime != Long.MAX_VALUE) { entry.setStartDate(minTime); entry.setEndDate(maxTime); } }
From source file:org.redis.shop.test.InitData.java
@Test public void bc_addTagAndTransaction() throws ParseException { Tag tag = null;/*from w w w . j av a 2 s . c om*/ Transaction transaction = null; Category category1 = categoryService.getList("name", "?").get(1); Category category2 = categoryService.getList("name", "").get(0); Category category3 = categoryService.getList("name", "").get(0); Category category4 = categoryService.getList("name", "").get(1); Category category5 = categoryService.getList("name", "?").get(0); PlateformScale plateformScale = plateformScaleService.get("plateformScaleNum", "TB-0001"); Vechile vechile1 = vechileService.get("vechileNum", "CH-0001"); Vechile vechile2 = vechileService.get("vechileNum", "CH-0002"); Vechile vechile3 = vechileService.get("vechileNum", "CH-0003"); Vechile vechile4 = vechileService.get("vechileNum", "CH-0004"); Vechile vechile5 = vechileService.get("vechileNum", "CH-0005"); Site site1 = siteService.get("user.name", "s1"); Center center1 = centerService.get("user.name", "c1"); Site site2 = siteService.get("user.name", "s2"); Center center2 = centerService.get("user.name", "c2"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date before = sdf.parse("2015-01-01"); Date today = sdf.parse(sdf.format(new Date())); Calendar calendar = Calendar.getInstance(); calendar.setTime(before); long beforeTime = calendar.getTimeInMillis(); calendar.setTime(today); long todayTime = calendar.getTimeInMillis(); long betweenDays = (todayTime - beforeTime) / (1000 * 3600 * 24); GregorianCalendar cal = new GregorianCalendar(); float weight1 = 1000f; float weight2 = 2000f; float weight3 = 3000f; float weight4 = 2500f; float weight5 = 2800f; for (int i = 0; i <= betweenDays; i++) { cal.setTime(before); cal.add(Calendar.DATE, i); Date dateNow = cal.getTime(); List<Tag> tags = new ArrayList<>(); if (i % 5 == 0) { tag = new Tag(); tag.setTime(dateNow); tag.setWeight(weight1); tag.setPrice(10f); tag.setType(Enum_TagType.WR); tag.setCategory(category1); tag.setTagNum("RFID-1" + i); tag.setVechile(vechileService.get("vechileNum", "CH-0001")); tag.setPlateformScale(plateformScale); // String tagId = (String) tagService.save(tag); tags.add(tag); transaction = new Transaction(); transaction.setTags(tags); transaction.setPrice(tag.getPrice()); transaction.setTotalPrice(tag.getPrice() * tag.getWeight()); transaction.setState(Enum_Transaction.IT); transaction.setInTime(dateNow); transaction.setOutTime(dateNow); transaction.setVechile(vechile1); transaction.setTransactionProperty(Enum_TransactionProperty.HAO); if (i % 2 == 0) { transaction.setCenter(center1); transaction.setSite(site1); } else { transaction.setCenter(center2); transaction.setSite(site2); } tagService.save(tag); transactionService.save(transaction); tag.setTransaction(transaction); tagService.update(tag); } else if (i % 5 == 1) { tag = new Tag(); tag.setTime(dateNow); tag.setVechile(vechileService.get("vechileNum", "CH-0002")); tag.setWeight(weight2); tag.setPrice(10f); tag.setType(Enum_TagType.WR); tag.setCategory(category2); tag.setTagNum("RFID-2" + i); tag.setPlateformScale(plateformScale); // String tagId = (String) tagService.save(tag); tags.add(tag); transaction = new Transaction(); transaction.setTags(tags); transaction.setPrice(tag.getPrice()); transaction.setTotalPrice(tag.getPrice() * tag.getWeight()); transaction.setState(Enum_Transaction.IT); transaction.setInTime(dateNow); transaction.setOutTime(dateNow); transaction.setVechile(vechile2); transaction.setTransactionProperty(Enum_TransactionProperty.HAO); if (i % 2 == 0) { transaction.setCenter(center1); transaction.setSite(site1); } else { transaction.setCenter(center2); transaction.setSite(site2); } tagService.save(tag); transactionService.save(transaction); tag.setTransaction(transaction); tagService.update(tag); } else if (i % 5 == 2) { tag = new Tag(); tag.setTime(dateNow); tag.setWeight(weight3); tag.setPrice(10f); tag.setVechile(vechileService.get("vechileNum", "CH-0003")); tag.setType(Enum_TagType.AR); tag.setCategory(category3); tag.setTagNum("RFID-3" + i); tag.setPlateformScale(plateformScale); // String tagId = (String) tagService.save(tag); tags.add(tag); transaction = new Transaction(); transaction.setTags(tags); transaction.setPrice(tag.getPrice()); transaction.setTotalPrice(tag.getPrice() * tag.getWeight()); transaction.setState(Enum_Transaction.IT); transaction.setInTime(dateNow); transaction.setOutTime(dateNow); transaction.setVechile(vechile3); transaction.setTransactionProperty(Enum_TransactionProperty.HAO); if (i % 2 == 0) { transaction.setCenter(center1); transaction.setSite(site1); } else { transaction.setCenter(center2); transaction.setSite(site2); } tagService.save(tag); transactionService.save(transaction); tag.setTransaction(transaction); tagService.update(tag); } else if (i % 5 == 3) { tag = new Tag(); tag.setTime(dateNow); tag.setWeight(weight4); tag.setPrice(10f); tag.setType(Enum_TagType.AR); tag.setCategory(category4); tag.setVechile(vechileService.get("vechileNum", "CH-0004")); tag.setTagNum("RFID-4" + i); tag.setPlateformScale(plateformScale); // String tagId = (String) tagService.save(tag); tags.add(tag); transaction = new Transaction(); transaction.setTags(tags); transaction.setPrice(tag.getPrice()); transaction.setTotalPrice(tag.getPrice() * tag.getWeight()); transaction.setState(Enum_Transaction.IT); transaction.setInTime(dateNow); transaction.setOutTime(dateNow); transaction.setVechile(vechile4); transaction.setTransactionProperty(Enum_TransactionProperty.HAO); if (i % 2 == 0) { transaction.setCenter(center1); transaction.setSite(site1); } else { transaction.setCenter(center2); transaction.setSite(site2); } tagService.save(tag); transactionService.save(transaction); tag.setTransaction(transaction); tagService.update(tag); } else { tag = new Tag(); tag.setTime(dateNow); tag.setWeight(weight5); tag.setPrice(10f); tag.setType(Enum_TagType.WR); tag.setCategory(category5); tag.setVechile(vechileService.get("vechileNum", "CH-0005")); tag.setTagNum("RFID-5" + i); tag.setPlateformScale(plateformScale); // String tagId = (String) tagService.save(tag); tags.add(tag); transaction = new Transaction(); transaction.setTags(tags); transaction.setPrice(tag.getPrice()); transaction.setTotalPrice(tag.getPrice() * tag.getWeight()); transaction.setState(Enum_Transaction.IT); transaction.setInTime(dateNow); transaction.setOutTime(dateNow); transaction.setVechile(vechile5); transaction.setTransactionProperty(Enum_TransactionProperty.HAO); if (i % 2 == 0) { transaction.setCenter(center1); transaction.setSite(site1); } else { transaction.setCenter(center2); transaction.setSite(site2); } tagService.save(tag); transactionService.save(transaction); tag.setTransaction(transaction); tagService.update(tag); } weight1 += 3f; weight2 += 2f; weight3 += 2.5f; weight4 += 1.5f; weight5 += 1.7f; } /*List<Transaction> transactions = new ArrayList<Transaction>(); transactions = transactionService.getAll(); for(Transaction t : transactions){ if(t.getTags()!=null&&t.getTags().size()!=0){ for(Tag tt : t.getTags()){ if(tt.getCategory()!=null){ if(tt.getCategory().getParentCategory()!=null){ if(tt.getCategory().getParentCategory().getParentCategory()!=null){ if(tt.getCategory().getParentCategory().getParentCategory().getParentCategory()!=null){ t.setCategoryName(tt.getCategory().getParentCategory().getParentCategory().getParentCategory().getName()); }else{ t.setCategoryName(tt.getCategory().getParentCategory().getParentCategory().getName()); } }else{ t.setCategoryName(tt.getCategory().getParentCategory().getName()); } }else{ t.setCategoryName(tt.getCategory().getName()); } } transactionService.update(t); } } }*/ }