List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:com.flexoodb.common.FlexUtils.java
/** * use this method to instantiate an object given an XML document and the reference class. * * @param xml string contents containing the elements and values for the object. * @param c the reference class that wil be used for instantiation. * @return the instantiated and value-populated object. * @see Hashtable/* ww w . j a v a 2 s . c om*/ * @see Element */ public Object getObject(String xml, Class c) throws Exception { Object obj = c.newInstance(); XMLConfiguration x = new XMLConfiguration(); x.setDelimiterParsingDisabled(true); x.load(new ByteArrayInputStream(xml.getBytes())); Iterator it = x.getKeys(); //Method[] m = c.getMethods(); Vector ve = retrieveMethods(obj.getClass(), null); Method[] m = new Method[ve.size()]; ve.toArray(m); String method = null; String type = null; boolean hasmethod = false; while (it.hasNext()) { String s = (String) it.next(); // make sure they have the same type? if (s.contains("[@")) { type = x.getString(s); if (method != null) { hasmethod = true; } } else { method = s; } if (hasmethod && type != null && method != null) { // check if class has the method. for (int i = 0; i < m.length; i++) { if (m[i].getName().toLowerCase().equals("set" + method)) { Object[] o = new Object[1]; Class ct = null; if (type.endsWith("String")) { ct = String.class; o[0] = x.getString(method); } else if (type.endsWith("XMLGregorianCalendar") || type.equalsIgnoreCase("timestamp")) { // dirty 'temporary' workaround // 2009-01-01T10:00:00.000+08:00 Date d = null; try { d = new Date(Long.parseLong(x.getString(method))); } catch (Exception a) { try { d = (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S")) .parse(x.getString(method)); } catch (Exception e) { try { d = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) .parse(x.getString(method)); } catch (Exception f) { try // must be a date only { d = (new SimpleDateFormat("yyyy-MM-dd")).parse(x.getString(method)); } catch (Exception g) // ok must be a time? { d = (new SimpleDateFormat("HH:mm:ss")).parse(x.getString(method)); } } } } GregorianCalendar gc = new GregorianCalendar(); gc.setTime(d); XMLGregorianCalendar cal = ((new com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl()) .newXMLGregorianCalendar(gc)); ct = XMLGregorianCalendar.class; o[0] = cal; } else if (type.endsWith("Date")) { ct = Date.class; // assume use default java date format //o[0] = (new SimpleDateFormat("EEE MMM d HH:mm:ss Z yyyy")).parse(x.getString(method)); try { o[0] = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse(x.getString(method)); } catch (Exception e) { //if not must be in long version //o[0] = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date(Long.parseLong(x.getString(method)))); o[0] = new Date(Long.parseLong(x.getString(method))); } } else if (type.endsWith("BigInteger")) { ct = BigInteger.class; o[0] = new BigInteger(x.getString(method)); } else if (type.endsWith("BigDecimal")) { ct = BigDecimal.class; o[0] = new BigDecimal(x.getString(method)); } else if (type.endsWith(".Integer") || type.equals("Integer") || type.equalsIgnoreCase("int unsigned") || type.equalsIgnoreCase("tinyint")) { ct = Integer.class; o[0] = x.getInt(method); } else if (type.endsWith("Long")) { ct = Long.class; o[0] = x.getLong(method); } else if (type.endsWith("Double")) { ct = Double.class; o[0] = x.getDouble(method); } else if (type.endsWith("Float")) { ct = Float.class; o[0] = x.getFloat(method); } else if (type.endsWith("Short")) { ct = Short.class; o[0] = x.getShort(method); } else if (type.endsWith("boolean")) { ct = boolean.class; o[0] = x.getBoolean(method); } else if (type.endsWith("Boolean")) { ct = Boolean.class; o[0] = x.getBoolean(method); } else if (type.endsWith("byte[]")) { ct = byte[].class; o[0] = x.getString(method).getBytes(); } else if (type.endsWith("Serializable")) { ct = Serializable.class; o[0] = x.getString(method).getBytes(); } else { throw new Exception("Unknown type:" + type + " for element:" + method); } Class[] c2 = new Class[1]; c2[0] = ct; //Method met = c.getMethod("set"+method,c2); Method met = c.getMethod(m[i].getName(), c2); met.invoke(obj, o); break; } } type = null; method = null; hasmethod = false; } } return obj; }
From source file:com.ext.portlet.epsos.EpsosHelperService.java
public EhrPatientClientDto createPatFilter(PatientSearchForm searchForm) { EhrPatientClientDto patFilter = new EhrPatientClientDto(); if (Validator.isNotNull(searchForm.getSurName())) patFilter.setFamilyName(searchForm.getSurName()); if (Validator.isNotNull(searchForm.getGivenName())) patFilter.setGivenName(searchForm.getGivenName()); if (Validator.isNotNull(searchForm.getBirthDate())) { try {//from ww w . ja v a2 s .c o m Date date = EpsosHelperService.dateFormat.parse(searchForm.getBirthDate()); GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); cal.setTime(date); XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); patFilter.setBirthdate(xmlCal); } catch (Exception e) { } } if (Validator.isNotNull(searchForm.getSex())) patFilter.setSex(searchForm.getSex()); if (Validator.isNotNull(searchForm.getStreet())) patFilter.setStreetAddress(searchForm.getStreet()); if (Validator.isNotNull(searchForm.getZipCode())) patFilter.setZip(searchForm.getZipCode()); if (Validator.isNotNull(searchForm.getCity())) patFilter.setCity(searchForm.getCity()); if (Validator.isNotNull(searchForm.getCountry())) patFilter.setCountry(searchForm.getCountry()); // Identifier criteria if (Validator.isNotNull(searchForm.country)) { String DEFAULT_PATIENT_IDS = GetterUtil.getString( GnPropsUtil.get("portalb", "epsos.search.patient.ids.default"), "ssnNumber,driversLicense,accountNumber"); //String[] countryPatientIds = GetterUtil.getString(GnPropsUtil.get("portalb", "epsos.search.patient.ids."+searchForm.country), DEFAULT_PATIENT_IDS).split(","); EpsosHelperImpl eh = new EpsosHelperImpl(); Vector countryPatientIds = EpsosHelperService.getInstance() .getCountryIdsFromCS(searchForm.getCountry()); // Vector<StrutsFormFields> fields = eh.getFieldsForCountryFromNCP(searchForm.getCountry()); // String mainPIDType = GetterUtil.getString(GnPropsUtil.get("portalb", "epsos.patient.identifier.main.type"), "PI"); // // if (Validator.isNotNull(searchForm.getPid())) { // EhrPIDClientDto pidDto = new EhrPIDClientDto(); // pidDto.setPatientID(searchForm.getPid()); // pidDto.setPatientIDType(mainPIDType); // // String RRI_OID = GetterUtil.getString(GnPropsUtil.get("portalb", "RRI." + searchForm.getCountry()), ""); // EhrDomainClientDto domain = new EhrDomainClientDto(); // domain.setAuthUniversalID(RRI_OID); // pidDto.setDomain(domain); // // patFilter.getPid().add(pidDto); // } String idType = ""; if (countryPatientIds != null && countryPatientIds.size() > 0) { int i = 1; for (int j = 0; j < countryPatientIds.size(); j++) //for (String idType: countryPatientIds) { SearchMask sm = (SearchMask) countryPatientIds.get(j); idType = sm.getDomain(); if (idType != null && !idType.equals("none") && Validator.isNotNull(searchForm.getPid(i))) { EhrPIDClientDto pidDto = new EhrPIDClientDto(); pidDto.setPatientID(searchForm.getPid(i)); //pidDto.setPatientIDType(idType); EhrDomainClientDto domain = new EhrDomainClientDto(); domain.setAuthUniversalID(idType); pidDto.setDomain(domain); patFilter.getPid().add(pidDto); } i++; } } } if (Validator.isNotNull(searchForm.getSsnNumber())) patFilter.setSsnNumber(searchForm.getSsnNumber()); if (Validator.isNotNull(searchForm.getDriversLicense())) patFilter.setDrivingLicense(searchForm.getDriversLicense()); if (Validator.isNotNull(searchForm.getAccountNumber())) patFilter.setAccountNumber(searchForm.getAccountNumber()); return patFilter; }
From source file:org.socraticgrid.displaymaildata.DisplayMailDataHandler.java
/** * Retrieve mail for user.//from w w w .jav a2 s . c om * * @param userType = "P" if logged in user is a provider * "T" if logged in user is a patient * @param userId = unique id of logged in user. * @param login = email server user name of logged in user. * @param pswd = password of logged in user. * @param folderName = * @param displayName = full name * @param onlyNew = * * @return * @throws java.lang.Exception */ //private //DBG ONLY - REMOVE COMMENT MARKS public List<SummaryData> retrieveMail(String userType, String userId, String patientId, String login, String pswd, String folderName, String patientName, boolean onlyNew, String mailHost, String mailUrl) throws Exception, DatatypeConfigurationException { List<SummaryData> dataList = new LinkedList<SummaryData>(); IMAPSSLStore sslStore = null; IMAPFolder currentFolder = null; String folderToOpen = folderName; System.out.println("===> retrieveMail Incoming params:"); System.out.println("===> mailHost=" + mailHost); System.out.println("===> mailUrl=" + mailUrl); System.out.println("===> maillogin=" + login); System.out.println("===> folderName=" + folderName); try { //Get session Session session = Session.getInstance(new Properties()); URLName urlName = new URLName(mailUrl); //Get the sslStore sslStore = new IMAPSSLStore(session, urlName); sslStore.connect(mailHost, login, pswd); folderToOpen = this.mapKmrLocationToImapFolder(folderName, this.host); currentFolder = (IMAPFolder) sslStore.getFolder(folderToOpen); currentFolder.open(Folder.READ_ONLY); Message[] allMessages = currentFolder.getMessages(); GregorianCalendar cal = new GregorianCalendar(); System.out.println("====> FILTER PARAMS for Emails:"); System.out.println("====> folder = " + folderToOpen); System.out.println("====> User = " + login); // System.out.println("====> from = "+ patientName +"/"+ patientEmail); // System.out.println("====> ptid = "+ patientId); System.out.println("====> Total Emails found = " + allMessages.length); System.out.println(); // TMN - CHECK SLOW PERFORMANCE ISSUE HERE: //Loop through each email and find ONLY the ones required for return. for (Message msg : allMessages) { if (msg == null) { continue; } // Keep this in case we want to search entire message // // OutputStream os = new ByteArrayOutputStream(); // msg.writeTo(os); // String msgContent = os.toString(); SummaryData summaryData = new SummaryData(); summaryData.setDataSource(DATA_SOURCE); String from = ""; Address[] fromAddr = msg.getFrom(); if (fromAddr != null && fromAddr.length > 0) { String fromFull = fromAddr[0].toString(); from = getContactIdFromEmail(extractEmailAddressFromSender(fromFull)); //System.out.println("retrieveMail: FROM=" + fromFull + " ldap.cn=" + from); } //------------------------------------------------------ //FILTERING: Check to exclude email if // 0) patientId is passed in as a param // AND 1) email does NOT contain PATIENTID=<patientId> // AND 2) email FROM field <> patientName // AND 3) email FROM field <> patientEmail. // // because must becoming from EMR inbox and looking for emails // addressed to userId BUT only ABOUT or FROM patientId. //------------------------------------------------------ summaryData.setFrom(from); summaryData.setAuthor(summaryData.getFrom()); cal.setTime(msg.getReceivedDate()); summaryData.setDateCreated(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal)); summaryData.setDescription(msg.getSubject()); summaryData.setItemId(userType + userId + ITEM_ID_SEPARATER + msg.getFolder().getName() + ITEM_ID_SEPARATER + msg.getHeader("Message-ID")[0]); //this.printMsgIdSubject(msg); //DBG printout boolean msgRead = msg.isSet(Flags.Flag.SEEN); addNameValue(summaryData.getItemValues(), ITEM_READ, String.valueOf(msgRead)); boolean msgStar = msg.isSet(Flags.Flag.FLAGGED); if (msgStar) { addNameValue(summaryData.getItemValues(), ITEM_STARRED, "Starred"); } addNameValue(summaryData.getItemValues(), ITEM_REPLIED, String.valueOf(msg.isSet(Flags.Flag.ANSWERED))); addNameValue(summaryData.getItemValues(), "MESSAGE_TYPE", msg.getFolder().getName()); if (onlyNew) { if (!msg.isSet(Flags.Flag.SEEN)) { dataList.add(summaryData); } } else { dataList.add(summaryData); } } } catch (MessagingException me) { log.error("Error in processing email"); me.printStackTrace(); } finally { // Close connections if (currentFolder != null) { try { currentFolder.close(false); } catch (Exception e) { } } if (sslStore != null) { try { sslStore.close(); } catch (Exception e) { } } } return dataList; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTaskByMeComp(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getTaskByMeComp " + 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 w w . j a va2s.co m if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where (taskfrom = ?) and (taskstat = 'Completed')"; } else { sql = "select * from " + Username.getcompany() + ".tasks where (taskfrom = ?) and (taskstat = 'Completed') and ((taskto1 ='" + onlyUser + "') or (taskto2 ='" + onlyUser + "') or (taskto3 ='" + onlyUser + "') or (taskto4 ='" + onlyUser + "') or (taskto5 ='" + onlyUser + "') or (taskto6 ='" + onlyUser + "') or (taskto7 ='" + onlyUser + "') or (taskto8 ='" + onlyUser + "') or (taskto9 ='" + onlyUser + "') or (taskto10 ='" + onlyUser + "') or (taskto11 ='" + onlyUser + "') or (taskto12 ='" + onlyUser + "') or (taskto13 ='" + onlyUser + "') or (taskto14 ='" + onlyUser + "') or (taskto15 ='" + onlyUser + "'))"; } PreparedStatement pstm = conn.prepareStatement(sql); pstm.setString(1, 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); task.setTaskto1(rs.getString("taskto1")); 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); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTaskByMe(Connection conn, UserAccount Username, String onlyUser) throws SQLException { 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 = ""; }/* w w w . ja v a2 s . c o m*/ if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where (taskfrom = ?) and ((taskstat <> 'Completed') or (taskstat is NULL))"; } else { sql = "select * from " + Username.getcompany() + ".tasks where ((taskfrom = ?) and ((taskstat <> 'Completed') or (taskstat is NULL)) ) and ((taskto1 = '" + onlyUser + "') or (taskto2 = '" + onlyUser + "') or (taskto3 = '" + onlyUser + "') or (taskto4 = '" + onlyUser + "') or (taskto5 = '" + onlyUser + "') or (taskto6 = '" + onlyUser + "') or (taskto7 = '" + onlyUser + "') or (taskto8 = '" + onlyUser + "') or (taskto9 = '" + onlyUser + "') or (taskto10 = '" + onlyUser + "') or (taskto11 = '" + onlyUser + "') or (taskto12 = '" + onlyUser + "') or (taskto13 = '" + onlyUser + "') or (taskto14 = '" + onlyUser + "') or (taskto15 = '" + onlyUser + "')) "; } PreparedStatement pstm = conn.prepareStatement(sql); pstm.setString(1, 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 enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2; String taskstat; if (rs.getString("taskstat") == null) { taskstat = "Not Started"; } else { 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); task.setTaskto1(rs.getString("taskto1")); 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); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTrainingTask(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getTrainingTask " + 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 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 ww w .j ava 2 s . com if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "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)))) or (taskfrom = ?))and (taskstat <> 'Completed') and (train = 'Y')"; } else { sql = "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)))) or (taskfrom = ?))and (taskstat <> 'Completed') and (train = 'Y') 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()); pstm.setString(16, 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")); } 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); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getNewTask(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getNewTask " + 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 w w.ja va 2 s .com*/ if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where ((taskstat <> 'Completed') or (taskstat is null)) and (((taskstat1 <> 'Completed') or (taskstat1 is null)) and (taskto1 = ?) and (comadd1 is null)) or (((taskstat2 <> 'Completed') or (taskstat2 is null)) and (taskto2 = ?) and (comadd2 is null)) or (((taskstat3 <> 'Completed') or (taskstat3 is null)) and (taskto3 = ?) and (comadd3 is null)) or (((taskstat4 <> 'Completed') or (taskstat4 is null)) and (taskto4 = ?) and (comadd4 is null)) or (((taskstat5 <> 'Completed') or (taskstat5 is null)) and (taskto5 = ?) and (comadd5 is null)) or (((taskstat6 <> 'Completed') or (taskstat6 is null)) and (taskto6 = ?) and (comadd6 is null)) or (((taskstat7 <> 'Completed') or (taskstat7 is null)) and (taskto7 = ?) and (comadd7 is null)) or (((taskstat8 <> 'Completed') or (taskstat8 is null)) and (taskto8 = ?) and (comadd8 is null)) or (((taskstat9 <> 'Completed') or (taskstat9 is null)) and (taskto9 = ?) and (comadd9 is null)) or (((taskstat11 <> 'Completed') or (taskstat11 is null)) and (taskto11 = ?) and (comadd11 is null)) or (((taskstat12 <> 'Completed') or (taskstat12 is null)) and (taskto12 = ?) and (comadd12 is null)) or (((taskstat13 <> 'Completed') or (taskstat13 is null)) and (taskto13 = ?) and (comadd13 is null)) or (((taskstat14 <> 'Completed') or (taskstat14 is null)) and (taskto14 = ?) and (comadd14 is null)) or (((taskstat15 <> 'Completed') or (taskstat15 is null)) and (taskto15 = ?) and (comadd15 is null)) or (((taskstat10 <> 'Completed') or (taskstat10 is null)) and (taskto10 = ?) and (comadd10 is null)) or (((taskstat <> 'Completed') or (taskstat is null)) and (taskfrom = ?) and (comaddf is null)) "; } else { sql = "select * from " + Username.getcompany() + ".tasks where (((taskstat <> 'Completed') or (taskstat is null)) and (((taskstat1 <> 'Completed') or (taskstat1 is null)) and (taskto1 = ?) and (comadd1 is null)) or (((taskstat2 <> 'Completed') or (taskstat2 is null)) and (taskto2 = ?) and (comadd2 is null)) or (((taskstat3 <> 'Completed') or (taskstat3 is null)) and (taskto3 = ?) and (comadd3 is null)) or (((taskstat4 <> 'Completed') or (taskstat4 is null)) and (taskto4 = ?) and (comadd4 is null)) or (((taskstat5 <> 'Completed') or (taskstat5 is null)) and (taskto5 = ?) and (comadd5 is null)) or (((taskstat6 <> 'Completed') or (taskstat6 is null)) and (taskto6 = ?) and (comadd6 is null)) or (((taskstat7 <> 'Completed') or (taskstat7 is null)) and (taskto7 = ?) and (comadd7 is null)) or (((taskstat8 <> 'Completed') or (taskstat8 is null)) and (taskto8 = ?) and (comadd8 is null)) or (((taskstat9 <> 'Completed') or (taskstat9 is null)) and (taskto9 = ?) and (comadd9 is null)) or (((taskstat11 <> 'Completed') or (taskstat11 is null)) and (taskto11 = ?) and (comadd11 is null)) or (((taskstat12 <> 'Completed') or (taskstat12 is null)) and (taskto12 = ?) and (comadd12 is null)) or (((taskstat13 <> 'Completed') or (taskstat13 is null)) and (taskto13 = ?) and (comadd13 is null)) or (((taskstat14 <> 'Completed') or (taskstat14 is null)) and (taskto14 = ?) and (comadd14 is null)) or (((taskstat15 <> 'Completed') or (taskstat15 is null)) and (taskto15 = ?) and (comadd15 is null)) or (((taskstat10 <> 'Completed') or (taskstat10 is null)) and (taskto10 = ?) and (comadd10 is null)) or (((taskstat <> 'Completed') or (taskstat is null)) and (taskfrom = ?) and (comaddf 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()); pstm.setString(16, 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); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getUpdatedTasks(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getUpdatedTasks " + 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 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 = ""; }//ww w. ja va 2 s. c o m if (onlyUser == null) { sql = "select * from " + Username.getcompany() + ".tasks where (((taskstat1 <> 'Completed') or (taskstat1 is null)) and (taskto1 = ?) and (newt1 is null)) or (((taskstat2 <> 'Completed') or (taskstat2 is null)) and (taskto2 = ?) and (newt2 is null)) or (((taskstat3 <> 'Completed') or (taskstat3 is null)) and (taskto3 = ?) and (newt3 is null)) or(((taskstat4 <> 'Completed') or (taskstat4 is null)) and (taskto4 = ?) and (newt4 is null)) or (((taskstat5 <> 'Completed') or (taskstat5 is null)) and (taskto5 = ?) and (newt5 is null)) or (((taskstat6 <> 'Completed') or (taskstat6 is null)) and (taskto6 = ?) and (newt6 is null)) or (((taskstat7 <> 'Completed') or (taskstat7 is null)) and (taskto7 = ?) and (newt7 is null)) or (((taskstat8 <> 'Completed') or (taskstat8 is null)) and (taskto8 = ?) and (newt8 is null)) or (((taskstat9 <> 'Completed') or (taskstat9 is null)) and (taskto9 = ?) and (newt9 is null)) or (((taskstat11 <> 'Completed') or (taskstat11 is null)) and (taskto11 = ?) and (newt11 is null)) or (((taskstat12 <> 'Completed') or (taskstat12 is null)) and (taskto12 = ?) and (newt12 is null)) or (((taskstat13 <> 'Completed') or (taskstat12 is null)) and (taskto13 = ?) and (newt13 is null)) or (((taskstat14 <> 'Completed') or (taskstat14 is null)) and (taskto14 = ?) and (newt14 is null)) or (((taskstat15 <> 'Completed') or (taskstat15 is null)) and (taskto15 = ?) and (newt15 is null)) or (((taskstat10 <> 'Completed') or (taskstat10 is null)) and (taskto10 = ?) and (newt10 is null)) or (((taskstat <> 'Completed') or (taskstat is null)) and (taskfrom = ?) and (newtf is null))"; } else { if (onlyUser.length() < 3) { sql = "select * from " + Username.getcompany() + ".tasks where (((taskstat1 <> 'Completed') or (taskstat1 is null)) and (taskto1 = ?) and (newt1 is null)) or (((taskstat2 <> 'Completed') or (taskstat2 is null)) and (taskto2 = ?) and (newt2 is null)) or (((taskstat3 <> 'Completed') or (taskstat3 is null)) and (taskto3 = ?) and (newt3 is null)) or(((taskstat4 <> 'Completed') or (taskstat4 is null)) and (taskto4 = ?) and (newt4 is null)) or (((taskstat5 <> 'Completed') or (taskstat5 is null)) and (taskto5 = ?) and (newt5 is null)) or (((taskstat6 <> 'Completed') or (taskstat6 is null)) and (taskto6 = ?) and (newt6 is null)) or (((taskstat7 <> 'Completed') or (taskstat7 is null)) and (taskto7 = ?) and (newt7 is null)) or (((taskstat8 <> 'Completed') or (taskstat8 is null)) and (taskto8 = ?) and (newt8 is null)) or (((taskstat9 <> 'Completed') or (taskstat9 is null)) and (taskto9 = ?) and (newt9 is null)) or (((taskstat11 <> 'Completed') or (taskstat11 is null)) and (taskto11 = ?) and (newt11 is null)) or (((taskstat12 <> 'Completed') or (taskstat12 is null)) and (taskto12 = ?) and (newt12 is null)) or (((taskstat13 <> 'Completed') or (taskstat12 is null)) and (taskto13 = ?) and (newt13 is null)) or (((taskstat14 <> 'Completed') or (taskstat14 is null)) and (taskto14 = ?) and (newt14 is null)) or (((taskstat15 <> 'Completed') or (taskstat15 is null)) and (taskto15 = ?) and (newt15 is null)) or (((taskstat10 <> 'Completed') or (taskstat10 is null)) and (taskto10 = ?) and (newt10 is null)) or (((taskstat <> 'Completed') or (taskstat is null)) and (taskfrom = ?) and (newtf is null))"; } else { sql = "select * from " + Username.getcompany() + ".tasks where ((((taskstat1 <> 'Completed') or (taskstat1 is null)) and (taskto1 = ?) and (newt1 is null)) or (((taskstat2 <> 'Completed') or (taskstat2 is null)) and (taskto2 = ?) and (newt2 is null)) or (((taskstat3 <> 'Completed') or (taskstat3 is null)) and (taskto3 = ?) and (newt3 is null)) or(((taskstat4 <> 'Completed') or (taskstat4 is null)) and (taskto4 = ?) and (newt4 is null)) or (((taskstat5 <> 'Completed') or (taskstat5 is null)) and (taskto5 = ?) and (newt5 is null)) or (((taskstat6 <> 'Completed') or (taskstat6 is null)) and (taskto6 = ?) and (newt6 is null)) or (((taskstat7 <> 'Completed') or (taskstat7 is null)) and (taskto7 = ?) and (newt7 is null)) or (((taskstat8 <> 'Completed') or (taskstat8 is null)) and (taskto8 = ?) and (newt8 is null)) or (((taskstat9 <> 'Completed') or (taskstat9 is null)) and (taskto9 = ?) and (newt9 is null)) or (((taskstat11 <> 'Completed') or (taskstat11 is null)) and (taskto11 = ?) and (newt11 is null)) or (((taskstat12 <> 'Completed') or (taskstat12 is null)) and (taskto12 = ?) and (newt12 is null)) or (((taskstat13 <> 'Completed') or (taskstat12 is null)) and (taskto13 = ?) and (newt13 is null)) or (((taskstat14 <> 'Completed') or (taskstat14 is null)) and (taskto14 = ?) and (newt14 is null)) or (((taskstat15 <> 'Completed') or (taskstat15 is null)) and (taskto15 = ?) and (newt15 is null)) or (((taskstat10 <> 'Completed') or (taskstat10 is null)) and (taskto10 = ?) and (newt10 is null)) or (((taskstat <> 'Completed') or (taskstat is null)) and (taskfrom = ?) and (newtf 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()); pstm.setString(16, 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")); } 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); } return list; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<Tasks> getTaskToMeComp(Connection conn, UserAccount Username, String onlyUser) throws SQLException { System.out.println("getTaskToMeComp " + 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 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)); if (onlyUser == null) { onlyUser = ""; }/* w w w . j a v a 2s . com*/ String sql = ""; if (onlyUser.equals(null) | onlyUser.length() < 4) { sql = "select * from " + Username.getcompany() + ".tasks where (((taskto1 = ?) and (taskstat1 = 'Completed')) or ((taskto2 = ?) and (taskstat2 = 'Completed')) or ((taskto3 = ?) and (taskstat3 = 'Completed')) or ((taskto4 = ?) and (taskstat4 = 'Completed')) or ((taskto5 = ?) and (taskstat5 = 'Completed')) or ((taskto6 = ?) and (taskstat6 = 'Completed')) or ((taskto7 = ?) and (taskstat7 = 'Completed')) or ((taskto8 = ?) and (taskstat8 = 'Completed')) or ((taskto9 = ?) and (taskstat9 = 'Completed')) or ((taskto10 = ?) and (taskstat10 = 'Completed')) or ((taskto11 = ?) and (taskstat11 = 'Completed')) or ((taskto12 = ?) and (taskstat12 = 'Completed')) or ((taskto13 = ?) and (taskstat13 = 'Completed')) or ((taskto14 = ?) and (taskstat14 = 'Completed')) or ((taskto15 = ?) and (taskstat15 = 'Completed')) ) and (recur = '0')"; } else { sql = "select * from " + Username.getcompany() + ".tasks where ((((taskto1 = ?) and (taskstat1 = 'Completed')) or ((taskto2 = ?) and (taskstat2 = 'Completed')) or ((taskto3 = ?) and (taskstat3 = 'Completed')) or ((taskto4 = ?) and (taskstat4 = 'Completed')) or ((taskto5 = ?) and (taskstat5 = 'Completed')) or ((taskto6 = ?) and (taskstat6 = 'Completed')) or ((taskto7 = ?) and (taskstat7 = 'Completed')) or ((taskto8 = ?) and (taskstat8 = 'Completed')) or ((taskto9 = ?) and (taskstat9 = 'Completed')) or ((taskto10 = ?) and (taskstat10 = 'Completed')) or ((taskto11 = ?) and (taskstat11 = 'Completed')) or ((taskto12 = ?) and (taskstat12 = 'Completed')) or ((taskto13 = ?) and (taskstat13 = 'Completed')) or ((taskto14 = ?) and (taskstat14 = 'Completed')) or ((taskto15 = ?) and (taskstat15 = 'Completed')) ) and (recur = '0')) 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 = "select * from " + Username.getcompany() + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 = 'Completed') or (recurdate1 > enddate))) or((taskto2 = ?) and ((taskstat2 = 'Completed') or (recurdate2 > enddate))) or((taskto3 = ?) and ((taskstat3 = 'Completed') or (recurdate3 > enddate))) or((taskto4 = ?) and ((taskstat4 = 'Completed') or (recurdate4 > enddate))) or ((taskto5 = ?) and ((taskstat5 = 'Completed') or (recurdate5 > enddate))) or ((taskto6 = ?) and ((taskstat6 = 'Completed') or (recurdate6 > enddate))) or ((taskto7 = ?) and ((taskstat7 = 'Completed') or (recurdate7 > enddate))) or ((taskto8 = ?) and ((taskstat8 = 'Completed') or (recurdate8 > enddate))) or((taskto9 = ?) and ((taskstat9 = 'Completed') or (recurdate9 > enddate))) or ((taskto11 = ?) and ((taskstat11 = 'Completed') or (recurdate11 > enddate))) or ((taskto12 = ?) and ((taskstat12 = 'Completed') or (recurdate12 > enddate))) or ((taskto13 = ?) and ((taskstat13 = 'Completed') or (recurdate13 > enddate))) or ((taskto14 = ?) and ((taskstat14 = 'Completed') or (recurdate14 > enddate))) or ((taskto15 = ?) and ((taskstat15 = 'Completed') or (recurdate15 > enddate))) or ((taskto10 = ?) and ((taskstat10 = 'Completed') or (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(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); } return list; }
From source file:com.ext.portlet.epsos.EpsosHelperService.java
public final boolean addPatientConsent(PatientConsentObject object, EhrPatientClientDto patient, HttpServletRequest request) {/*ww w. ja v a 2 s .c o m*/ boolean consentCreated = false; PatientConsentObject result = null; SpiritUserClientDto usr = (SpiritUserClientDto) request.getSession() .getAttribute(EPSOS_LOGIN_INFORMATION_ATTRIBUTE); if (usr != null) { //upload consent document try { SpiritEhrWsClientInterface webservice = this.getWebService(request); List<PolicySetGroup> objGroupList = webservice.queryPolicySetsForPatient(patient).getGroupList(); String[] policyids = request.getParameterValues("policyid"); if (policyids != null && objGroupList != null) { for (PolicySetGroup g : objGroupList) { // first unselect all policies: for (PolicySetItem i : g.getPolicySetItemList()) { i.setSelected(false); } // then only select the ones selected by the user in the interface for (String id : policyids) { String groupCode = id.substring(0, id.indexOf("$$$")); if (groupCode.equals(g.getCode())) { String policyId = id.substring(id.indexOf("$$$") + 3); for (PolicySetItem i : g.getPolicySetItemList()) { if (i.getPolicySetId().equals(policyId)) { i.setSelected(true); GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); Date fromDate = GetterUtil.getDate( request.getParameter(groupCode + "$$$" + policyId + "_fromDate"), dateTimeFormat, null); if (fromDate != null) { cal.setTime(fromDate); XMLGregorianCalendar fromCal = DatatypeFactory.newInstance() .newXMLGregorianCalendar(cal); i.setEffectiveDateFrom(fromCal); } Date toDate = GetterUtil.getDate( request.getParameter(groupCode + "$$$" + policyId + "_toDate"), dateTimeFormat, null); if (toDate != null) { cal.setTime(toDate); XMLGregorianCalendar toCal = DatatypeFactory.newInstance() .newXMLGregorianCalendar(cal); i.setEffectiveDateTo(toCal); } } } } } } } EpsosHelperService.getInstance() .createLog("CREATE PATIENT CONSENT REQUEST:" + patient.getGivenName(), usr); webservice.saveConsent(patient, GeneralUtils.getLocale(request), "Patient Consent", objGroupList); consentCreated = true; EpsosHelperService.getInstance() .createLog("CREATE PATIENT CONSENT RESPONSE OK:" + patient.getGivenName(), usr); } catch (Exception e1) { EpsosHelperService.getInstance().createLog("CREATE PATIENT CONSENT RESPONSE FAILURE:" + patient.getGivenName() + ".ERROR: " + e1.getMessage(), usr); request.setAttribute("exception", e1.getMessage()); e1.printStackTrace(); } //result = object; } return consentCreated; }