List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:org.ow2.bonita.persistence.db.DbSessionImpl.java
@Override public List<Integer> getNumberOfFinishedCasesPerDay(Date since, final Date to) { final List<Integer> finishedCases = new ArrayList<Integer>(); while (since.before(to) || since.equals(to)) { final Date beginningOfTheDay = DateUtil.getBeginningOfTheDay(since); final Date nextBeginningOfTheDay = DateUtil.getBeginningOfTheDay(DateUtil.getNextDay(since)); final Query query = getSession().getNamedQuery("getNumberOfFinishedCases"); query.setLong("beginningOfTheDay", beginningOfTheDay.getTime()); query.setLong("nextBeginningOfTheDay", nextBeginningOfTheDay.getTime()); finishedCases.add(((Long) query.uniqueResult()).intValue()); since = DateUtil.getNextDay(since); }//from ww w.ja va2s . c o m return finishedCases; }
From source file:org.unitime.timetable.solver.studentsct.StudentSectioningDatabaseLoader.java
private String datePatternName(DatePattern dp, TimeLocation time) { if ("never".equals(iDatePatternFormat)) return dp.getName(); if ("extended".equals(iDatePatternFormat) && dp.getType() != DatePattern.sTypeExtended) return dp.getName(); if ("alternate".equals(iDatePatternFormat) && dp.getType() == DatePattern.sTypeAlternate) return dp.getName(); if (time.getWeekCode().isEmpty()) return time.getDatePatternName(); Calendar cal = Calendar.getInstance(Locale.US); cal.setLenient(true);//from w w w . j ava2 s . c o m cal.setTime(iDatePatternFirstDate); int idx = time.getWeekCode().nextSetBit(0); cal.add(Calendar.DAY_OF_YEAR, idx); Date first = null; while (idx < time.getWeekCode().size() && first == null) { if (time.getWeekCode().get(idx)) { int dow = cal.get(Calendar.DAY_OF_WEEK); switch (dow) { case Calendar.MONDAY: if ((time.getDayCode() & DayCode.MON.getCode()) != 0) first = cal.getTime(); break; case Calendar.TUESDAY: if ((time.getDayCode() & DayCode.TUE.getCode()) != 0) first = cal.getTime(); break; case Calendar.WEDNESDAY: if ((time.getDayCode() & DayCode.WED.getCode()) != 0) first = cal.getTime(); break; case Calendar.THURSDAY: if ((time.getDayCode() & DayCode.THU.getCode()) != 0) first = cal.getTime(); break; case Calendar.FRIDAY: if ((time.getDayCode() & DayCode.FRI.getCode()) != 0) first = cal.getTime(); break; case Calendar.SATURDAY: if ((time.getDayCode() & DayCode.SAT.getCode()) != 0) first = cal.getTime(); break; case Calendar.SUNDAY: if ((time.getDayCode() & DayCode.SUN.getCode()) != 0) first = cal.getTime(); break; } } cal.add(Calendar.DAY_OF_YEAR, 1); idx++; } if (first == null) return time.getDatePatternName(); cal.setTime(iDatePatternFirstDate); idx = time.getWeekCode().length() - 1; cal.add(Calendar.DAY_OF_YEAR, idx); Date last = null; while (idx >= 0 && last == null) { if (time.getWeekCode().get(idx)) { int dow = cal.get(Calendar.DAY_OF_WEEK); switch (dow) { case Calendar.MONDAY: if ((time.getDayCode() & DayCode.MON.getCode()) != 0) last = cal.getTime(); break; case Calendar.TUESDAY: if ((time.getDayCode() & DayCode.TUE.getCode()) != 0) last = cal.getTime(); break; case Calendar.WEDNESDAY: if ((time.getDayCode() & DayCode.WED.getCode()) != 0) last = cal.getTime(); break; case Calendar.THURSDAY: if ((time.getDayCode() & DayCode.THU.getCode()) != 0) last = cal.getTime(); break; case Calendar.FRIDAY: if ((time.getDayCode() & DayCode.FRI.getCode()) != 0) last = cal.getTime(); break; case Calendar.SATURDAY: if ((time.getDayCode() & DayCode.SAT.getCode()) != 0) last = cal.getTime(); break; case Calendar.SUNDAY: if ((time.getDayCode() & DayCode.SUN.getCode()) != 0) last = cal.getTime(); break; } } cal.add(Calendar.DAY_OF_YEAR, -1); idx--; } if (last == null) return time.getDatePatternName(); Formats.Format<Date> dpf = Formats.getDateFormat(Formats.Pattern.DATE_PATTERN); return dpf.format(first) + (first.equals(last) ? "" : " - " + dpf.format(last)); }
From source file:org.etudes.jforum.view.admin.ForumAction.java
/** * save forum start and end dates//from ww w. j av a2s . c om */ protected void saveForumDates() throws Exception { boolean isfacilitator = JForumUserUtil.isJForumFacilitator(UserDirectoryService.getCurrentUser().getId()) || SecurityService.isSuperUser(); if (!isfacilitator) { this.context.put("message", I18n.getMessage("User.NotAuthorizedToManage")); this.setTemplateName(TemplateKeys.MANAGE_NOT_AUTHORIZED); return; } JForumForumService jforumForumService = (JForumForumService) ComponentManager .get("org.etudes.api.app.jforum.JForumForumService"); JForumCategoryService jforumCategoryService = (JForumCategoryService) ComponentManager .get("org.etudes.api.app.jforum.JForumCategoryService"); List<org.etudes.api.app.jforum.Category> existingCategories = jforumCategoryService.getManageCategories( ToolManager.getInstance().getCurrentPlacement().getContext(), UserDirectoryService.getCurrentUser().getId()); Map<Integer, org.etudes.api.app.jforum.Forum> exisForumMap = new HashMap<Integer, org.etudes.api.app.jforum.Forum>(); for (org.etudes.api.app.jforum.Category exisCat : existingCategories) { for (org.etudes.api.app.jforum.Forum exisForum : exisCat.getForums()) { exisForumMap.put(Integer.valueOf(exisForum.getId()), exisForum); } } List errors = new ArrayList(); boolean errFlag = false; StringBuffer forumNameList = new StringBuffer(); Enumeration<?> paramNames = this.request.getParameterNames(); while (paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if (paramName.startsWith("startdate_")) { // paramName is in the format startdate_forumId String id[] = paramName.split("_"); String forumId = null; forumId = id[1]; //Forum existingForum = ForumRepository.getForum(Integer.parseInt(forumId)); //Forum f = new Forum(existingForum); org.etudes.api.app.jforum.Forum existingForum = exisForumMap.get(Integer.valueOf(forumId)); if (existingForum == null) { continue; } //startdate_forumId String startDateParam = null; Date startDate = null; Boolean hideUntilOpen = Boolean.FALSE; startDateParam = this.request.getParameter("startdate_" + id[1]); if (startDateParam != null && startDateParam.trim().length() > 0) { try { startDate = DateUtil.getDateFromString(startDateParam.trim()); //hideuntilopen_forumId String hideUntilOpenStr = this.request.getParameter("hideuntilopen_" + id[1]); if (hideUntilOpenStr != null && "1".equals(hideUntilOpenStr)) { hideUntilOpen = Boolean.TRUE; } } catch (ParseException e) { errFlag = true; forumNameList.append(existingForum.getName()); forumNameList.append(","); continue; } //f.setStartDate(startDate); } //enddate_forumId String endDateParam = null; endDateParam = this.request.getParameter("enddate_" + id[1]); Date endDate = null; boolean lockForum = false; if (endDateParam != null && endDateParam.trim().length() > 0) { try { endDate = DateUtil.getDateFromString(endDateParam.trim()); } catch (ParseException e) { errFlag = true; forumNameList.append(existingForum.getName()); forumNameList.append(","); continue; } //f.setEndDate(endDate); //lockforum_forumId /*String lockForumStr = this.request.getParameter("lockforum_"+ id[1]); if (lockForumStr!= null && "1".equals(lockForumStr)) { //f.setLockForum(true); lockForum = true; } else { //f.setLockForum(false); }*/ } //allowuntildate_forumId String allowUntilDateParam = null; allowUntilDateParam = this.request.getParameter("allowuntildate_" + id[1]); Date allowUntilDate = null; if (allowUntilDateParam != null && allowUntilDateParam.trim().length() > 0) { try { allowUntilDate = DateUtil.getDateFromString(allowUntilDateParam.trim()); } catch (ParseException e) { errFlag = true; forumNameList.append(existingForum.getName()); forumNameList.append(","); continue; } } // update if there are date changes boolean datesChanged = false; // open date if (existingForum.getAccessDates().getOpenDate() == null) { if (startDate != null) { datesChanged = true; } } else { if (startDate == null) { datesChanged = true; } else if (!startDate.equals(existingForum.getAccessDates().getOpenDate())) { datesChanged = true; } else if (startDate.equals(existingForum.getAccessDates().getOpenDate())) { if (!existingForum.getAccessDates().isHideUntilOpen().equals(hideUntilOpen)) { datesChanged = true; } } } // due date if (!datesChanged) { if (existingForum.getAccessDates().getDueDate() == null) { if (endDate != null) { datesChanged = true; } } else { if (endDate == null) { datesChanged = true; } else if (!endDate.equals(existingForum.getAccessDates().getDueDate())) { datesChanged = true; } } } // allow until date if (!datesChanged) { if (existingForum.getAccessDates().getAllowUntilDate() == null) { if (allowUntilDate != null) { datesChanged = true; } } else { if (allowUntilDate == null) { datesChanged = true; } else if (!allowUntilDate.equals(existingForum.getAccessDates().getAllowUntilDate())) { datesChanged = true; } } } if (datesChanged) { if (startDate != null) { existingForum.getAccessDates().setOpenDate(startDate); existingForum.getAccessDates().setHideUntilOpen(hideUntilOpen); } else { existingForum.getAccessDates().setOpenDate(null); existingForum.getAccessDates().setHideUntilOpen(null); } if (endDate != null) { existingForum.getAccessDates().setDueDate(endDate); } else { existingForum.getAccessDates().setDueDate(null); } if (allowUntilDate != null) { existingForum.getAccessDates().setAllowUntilDate(allowUntilDate); } else { existingForum.getAccessDates().setAllowUntilDate(null); } jforumForumService.updateDates(existingForum); /*int topicDatesCount = DataAccessDriver.getInstance().newTopicDAO().getTopicDatesCountByForum(f.getId()); Category c = DataAccessDriver.getInstance().newCategoryDAO().selectById(f.getCategoryId()); boolean categoryDates = false; if ((c.getStartDate() != null) || (c.getEndDate() != null)) { categoryDates = true; } if (topicDatesCount > 0 || categoryDates) { f.setStartDate(null); f.setEndDate(null); f.setLockForum(false); }*/ //DataAccessDriver.getInstance().newForumDAO().updateDates(f); // remove existing special access if no dates /*if ((f.getStartDate() == null) && (f.getEndDate() == null)) { deleteForumSpecialAccess(f); }*/ // update gradable forums and topics with date changes in the gradebook /*if (f.getGradeType() == Forum.GRADE_BY_FORUM) { Grade forumGrade = DataAccessDriver.getInstance().newGradeDAO().selectByForumId(f.getId()); boolean addToGradeBook = false; if (forumGrade != null && forumGrade.isAddToGradeBook()) { Date endDate = f.getEndDate(); if (endDate == null) { endDate = c.getEndDate(); } addToGradeBook = updateGradebook(forumGrade, endDate); forumGrade.setAddToGradeBook(addToGradeBook); DataAccessDriver.getInstance().newGradeDAO().updateAddToGradeBookStatus(forumGrade.getId(), addToGradeBook); } } else if (f.getGradeType() == Forum.GRADE_BY_TOPIC) { updateGradebookTopics(c, f); }*/ } } } if (errFlag == true) { String forumNameListStr = forumNameList.toString(); if (forumNameListStr.endsWith(",")) { forumNameListStr = forumNameListStr.substring(0, forumNameListStr.length() - 1); } errors.add(I18n.getMessage("Forums.List.CannotUpdateForumDates", new Object[] { forumNameListStr })); } if (errors.size() > 0) { this.context.put("errorMessage", errors); } }
From source file:edu.harvard.iq.dvn.core.web.admin.OptionsPage.java
private boolean isHarvestingDateUpdated(Date previousDate, Date tempDate) { boolean isUpdated = false; if (previousDate == null) { if (tempDate != null) { isUpdated = true;//from w w w. j av a 2 s . co m } } else if (!previousDate.equals(tempDate)) { isUpdated = true; } return isUpdated; }
From source file:com.virtusa.akura.student.controller.StudentAcademicLifeController.java
/** * handle POST requests for Academic-details view with student term mark data. * //ww w. ja v a 2 s. c o m * @param request - HttpServletRequest. * @param modelMap - ModelMap attribute. * @param session - HttpSession attribute. * @return the name of the view. * @throws AkuraAppException throws when exception occurs. */ @RequestMapping(value = ACTION_FOR_SHOW_MARKS, method = RequestMethod.POST) public ModelAndView showMarks(HttpServletRequest request, ModelMap modelMap, HttpSession session) throws AkuraAppException { String yearA = null; String studentGrade = ""; int intYear = 0; String selectedStudClassId = null; if (request.getParameter(SELECTED_GRADE) != null) { StudentClassInfo studentClassInfo = studentService .findStudentClassInfoById(Integer.parseInt(request.getParameter(SELECTED_GRADE))); selectedStudClassId = studentClassInfo.getClassGrade().getGrade().getDescription(); yearA = DateUtil.getStringYear(studentClassInfo.getYear()); if (yearA.equals(DateUtil.getStringYear(new Date()))) { modelMap.addAttribute(AkuraConstant.ENABLE_ADD_EDIT_DELETE, AkuraConstant.EMPTY_STRING); } } else { int studentId = 0; if (session.getAttribute(STUDENT_ID) != null) { studentId = (Integer) session.getAttribute(STUDENT_ID); } Date currentDate = new Date(); yearA = DateUtil.getStringYear(currentDate); intYear = Integer.parseInt(yearA); List<StudentClassInfo> studentClassInfo = studentService.getStudentClassInfoByStudentId(studentId, intYear); if (!studentClassInfo.isEmpty()) { studentGrade = studentClassInfo.get(0).getClassGrade().getGrade().getDescription(); } selectedStudClassId = studentGrade; modelMap.addAttribute(AkuraConstant.ENABLE_ADD_EDIT_DELETE, AkuraConstant.EMPTY_STRING); } int intStudentId = getStudentSessionId(session); double avgAcademicLifeRating = 0.0; double faithLifeAverage = 0.0; double attendanceAverage = 0.0; Date dateTypeYear; if (yearA != null) { dateTypeYear = DateUtil.getDateTypeYearValue(yearA); intYear = Integer.parseInt(yearA); } else { intYear = DateUtil.currentYearOnly(); yearA = Integer.toString(intYear); dateTypeYear = DateUtil.getDateTypeYearValue(yearA); } if (session.getAttribute(STUDENT_GRADE) != null) { studentGrade = (String) session.getAttribute(STUDENT_GRADE); } if (!"".equals(studentGrade)) { // when the student is assigned to a // class. // List<StudentTermMarkDTO> studentTermMarkObjList = // studentService.getStudentMarksSubjectTermByStudentIdYear(intStudentId, intYear); List<StudentSubjectAverageViewDTO> studentTermMarkObjList = studentService .getStudentSubjectAverage(intStudentId, intYear); List<Map<String, Object>> mylastList = new ArrayList<Map<String, Object>>(); List<String> tempSubjectList = new ArrayList<String>(); for (StudentSubjectAverageViewDTO dto : studentTermMarkObjList) { String subject = dto.getSubject(); boolean foundSubject = false; if (tempSubjectList.isEmpty()) { foundSubject = false; } else if (tempSubjectList.contains(subject)) { foundSubject = true; } if (!foundSubject) { Map<String, Object> mymap = new TreeMap<String, Object>(); for (StudentSubjectAverageViewDTO dtoObj : studentTermMarkObjList) { if (dtoObj.getSubject().equals(subject)) { mymap.put("Subject", dtoObj.getSubject()); if (dtoObj.isAbsent()) { mymap.put(dtoObj.getTerm(), AkuraConstant.ABSENT + " (" + dtoObj.getGradeAverage() + ")" + " (" + dtoObj.getClassAverage() + ")"); } else { // totMarks = totMarks + dtoObj.getMarks(); mymap.put(dtoObj.getTerm(), dtoObj.getMarks() + " (" + dtoObj.getGradeAverage() + ")" + " (" + dtoObj.getClassAverage() + ")"); } if (dtoObj.getTerm().equals("Term 1")) { mymap.put("flag1", dtoObj.getMarks()); } if (dtoObj.getTerm().equals("Term 2")) { mymap.put("flag2", dtoObj.getMarks()); } if (dtoObj.getTerm().equals("Term 3")) { mymap.put("flag3", dtoObj.getMarks()); } } } mylastList.add(mymap); tempSubjectList.add(subject); } } setTotalAndAverageMarks(modelMap, studentTermMarkObjList); TreeList lastList2 = new TreeList(mylastList); modelMap.addAttribute("LastList", lastList2); } Map<String, List<?>> mapNew = this.loadInformationToPage(intStudentId, intYear); if (mapNew != null) { if (mapNew.containsKey(PREFECTS)) { List<?> pList = mapNew.get(PREFECTS); if (!pList.isEmpty()) { modelMap.addAttribute(PREFECTS, pList); } } if (mapNew.containsKey(SCHOLARSHIPS)) { List<?> sList = mapNew.get(SCHOLARSHIPS); if (!sList.isEmpty()) { modelMap.addAttribute(SCHOLARSHIPS, sList); } } } populateSeminarsList(modelMap, intStudentId, dateTypeYear); List<Achievement> achList = this.loadAchievementDetailsForStudent(intStudentId, dateTypeYear); if (!achList.isEmpty()) { modelMap.addAttribute(MAP_KEY_NAME_ACHIEVEMENT, achList); } // handling term data List<Term> termList = commonService.getTermList(); modelMap.addAttribute(MODEL_ATT_SELECTED_ID, selectedStudClassId); modelMap.addAttribute(ATTR_NAME_YEAR, intYear); modelMap.addAttribute(TERM_LIST, termList); modelMap.addAttribute(ATTR_NAME_YEAR, yearA); // if year equal current year if (dateTypeYear.equals(DateUtil.getDateTypeYearValue(Integer.toString(DateUtil.currentYearOnly())))) { if (session.getAttribute(AVERAGE_FAITH_LIFE_RATING) != null) { faithLifeAverage = (Double) session.getAttribute(AVERAGE_FAITH_LIFE_RATING); modelMap.addAttribute(MODEL_ATT_STUDENT_FAITH_LIFE, (int) Math.round(faithLifeAverage)); } if (session.getAttribute(AVERAGE_ATTENDANCE_RATING) != null) { attendanceAverage = (Double) session.getAttribute(AVERAGE_ATTENDANCE_RATING); modelMap.addAttribute(MODEL_ATT_ATTENDANCE_RATING, (int) Math.round(attendanceAverage)); } if (session.getAttribute(AVERAGE_ACADEMIC_LIFE_RATING) != null) { avgAcademicLifeRating = (Double) session.getAttribute(AVERAGE_ACADEMIC_LIFE_RATING); modelMap.addAttribute(MODEL_ATT_STUDENT_ACADEMIC_LIFE, (int) Math.round(avgAcademicLifeRating)); } } else { Map<String, Double> averageMap = studentLoginDelegate.populateStudentProgressBar(intStudentId, dateTypeYear); faithLifeAverage = averageMap.get(AVERAGE_FAITH_LIFE_RATING); modelMap.addAttribute(MODEL_ATT_STUDENT_FAITH_LIFE, (int) Math.round(faithLifeAverage)); avgAcademicLifeRating = averageMap.get(AVERAGE_ACADEMIC_LIFE_RATING); modelMap.addAttribute(MODEL_ATT_STUDENT_ACADEMIC_LIFE, (int) Math.round(avgAcademicLifeRating)); attendanceAverage = averageMap.get(AVERAGE_ATTENDANCE_RATING); modelMap.addAttribute(MODEL_ATT_ATTENDANCE_RATING, (int) Math.round(attendanceAverage)); } // handling marks display color in the table double greenLower = Double .parseDouble(PropertyReader.getPropertyValue(SYSTEM_CONFIG_PROPERTIES, COLOR_GREEN_LOWER)); double yellowUpper = Double .parseDouble(PropertyReader.getPropertyValue(SYSTEM_CONFIG_PROPERTIES, COLOR_YELLOW_UPPER)); double yellowLower = Double .parseDouble(PropertyReader.getPropertyValue(SYSTEM_CONFIG_PROPERTIES, COLOR_YELLOW_LOWER)); double redUpper = Double .parseDouble(PropertyReader.getPropertyValue(SYSTEM_CONFIG_PROPERTIES, COLOR_RED_UPPER)); modelMap.addAttribute(GREEN_LOWER, greenLower); modelMap.addAttribute(YELLOW_UPPER, yellowUpper); modelMap.addAttribute(YELLOW_LOWER, yellowLower); modelMap.addAttribute(RED_UPPER, redUpper); return new ModelAndView(VIEW_ACADEMIC_LIFE_PAGE, modelMap); }
From source file:org.celllife.idart.gui.patient.AddPatient.java
public Map<String, String> arvStartDateValidation() { Map<String, String> map = new HashMap<String, String>(); map.put(KEY_RESULT, String.valueOf(true)); map.put(KEY_TITLE, EMPTY);/*from w w w . ja v a 2s. c o m*/ map.put(KEY_MESSAGE, EMPTY); boolean newpatient = false; try { // Is this a new patient or a patient update? newpatient = (localPatient.getId() <= 0); // Checking if ARV Start date is before patient's date of birth. Date dteA = localPatient.getDateOfBirth(); Date dteB = btnARVStart.getDate(); if (dteA.after(dteB)) { String msg = Messages.getString("patient.error.arvStartDateBeforeDOB"); //$NON-NLS-1$ map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, msg); getLog().info("ARV Test Failure: Patient birth date is after the ARV Start Date." + //$NON-NLS-1$ " ARV Start Date should be after the patient's date of birth"); //$NON-NLS-1$ return map; } // If this is not a new patient, has he/she received ARV Drugs? boolean receivedARVDrug = false; List<Packages> packList = PackageManager.getAllPackagesForPatient(getHSession(), localPatient); if (packList != null) { receivedARVDrug = PackageManager.packagesContainARVDrug(packList); // Test only if patient received arv drugs // else issue error for not having arv drugs. if (receivedARVDrug) { for (Packages packs : packList) { List<PackagedDrugs> packDrugsList = packs.getPackagedDrugs(); for (PackagedDrugs pd : packDrugsList) { if (pd.getStock().getDrug().getSideTreatment() == 'F') { Date dte_1 = btnARVStart.getDate(); Date dte_2 = packs.getPickupDate() == null ? new Date() : packs.getPickupDate(); if (dte_1.after(dte_2)) { // This means that a ARV Start date is after // the // pickup date for the pack. String msg = MessageFormat.format( Messages.getString( "patient.error.arvStartDateDifferentToDispensedDate"), //$NON-NLS-1$ iDARTUtil.format(packs.getPickupDate())); map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, msg); getLog().info( "ARV Start Date test failed: ARV Start Date [AFTER] pick up date for ARV package " //$NON-NLS-1$ + pd.getParentPackage().getPackageId()); return map; } } } } getLog().info("ARV Start Date NOT before any ARV Packages."); //$NON-NLS-1$ } else if (!newpatient && !receivedARVDrug) { // Cannot test ARV Start Date on update // if this patient has not been issued with // any arv drug. getLog().info("No ARV Drugs dispensed for patient " //$NON-NLS-1$ + localPatient.getFirstNames()); } } // If this is a new patient, test: // date < episode date if "new patient episode" : // new patient cannot have arv date before new episode. // date > episode date if "any other episodes" : // any other episode as new patient should have arv date before // episode start - *** if he has been receiving arv drugs, // but only the user knows this so we assume he has. Episode epi = localPatient.getEpisodes().get(0); String episodeStartReason = epi.getStartReason(); Date dteEpiStartDate = epi.getStartDate(); Date dte_1 = btnARVStart.getDate(); Date dte_2 = dteEpiStartDate; if (episodeStartReason.equalsIgnoreCase(Episode.REASON_NEW_PATIENT)) { //$NON-NLS-1$ if (dte_1.before(dte_2)) { String msg = MessageFormat.format( Messages.getString("patient.error.arvStartDateBeforeEpisodeStartDate"), //$NON-NLS-1$ iDARTUtil.format(dteEpiStartDate)); map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, msg); getLog().info("ARV Start Date test [FAILED]: ARV Start Date [BEFORE] New Episode Start Date."); //$NON-NLS-1$ return map; } else { getLog().info("ARV Start Date is correct for New Patient Episode"); //$NON-NLS-1$ return map; } } else { if (dte_1.after(dte_2) || dte_1.equals(dte_2)) { String msg = MessageFormat.format( Messages.getString("patient.error.arvStartDateAfterEpisodeStart"), //$NON-NLS-1$ episodeStartReason, iDARTUtil.format(dteEpiStartDate), iDARTUtil.format(dteEpiStartDate)); map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, msg); getLog().info("ARV Start Date test [FAILED]: ARV Start Date [AFTER] " //$NON-NLS-1$ + episodeStartReason + " Episode Start Date."); //$NON-NLS-1$ return map; } else { getLog().info("ARV Start Date is correct for " //$NON-NLS-1$ + episodeStartReason + " Episode"); //$NON-NLS-1$ return map; } } } catch (Exception e) { if (localPatient.getEpisodes() == null) { getLog().error("Patient has not been set with any episodes, " //$NON-NLS-1$ + "therefore ARV Start Date check is not possible for new patient.", //$NON-NLS-1$ e); map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, Messages.getString("patient.error.incorrectEpisode")); //$NON-NLS-1$ } else if (btnARVStart.getDate() == null) { getLog().info("ARV Start Date not specified: ARV Start Date Test [not done].");//$NON-NLS-1$ map.put(KEY_RESULT, String.valueOf(true)); map.put(KEY_TITLE, EMPTY); map.put(KEY_MESSAGE, EMPTY); } else { if (!newpatient) { getLog().error("Problem testing ARV Start Date.", e); //$NON-NLS-1$ map.put(KEY_RESULT, String.valueOf(false)); map.put(KEY_TITLE, Messages.getString("patient.error.arvStartDate.title")); //$NON-NLS-1$ map.put(KEY_MESSAGE, Messages.getString("patient.error.arvStartDateTestFailed")); //$NON-NLS-1$ } } return map; } }
From source file:com.sr.apps.freightbit.operations.action.OperationsAction.java
public void filterVesselSchedule() { List<VesselSchedules> vesselSchedules = vesselSchedulesService.findAllVesselSchedules(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/* ww w . ja v a 2s . com*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date dateWithoutTime = cal.getTime(); for (VesselSchedules vesselScheduleElem : vesselSchedules) { String dateString = vesselScheduleElem.getDepartureDate(); SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy"); try { Date departureDate = formatter.parse(dateString); if (dateWithoutTime.before(departureDate) || dateWithoutTime.equals(departureDate)) { vesselScheduleList.add(transformToVesselSchedule(vesselScheduleElem)); } } catch (ParseException e) { e.printStackTrace(); } } }
From source file:com.krawler.spring.hrms.common.hrmsCommonController.java
public ModelAndView terminateEmp(HttpServletRequest request, HttpServletResponse response) { String hql = ""; SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy"); JSONObject msg = new JSONObject(); //Create transaction DefaultTransactionDefinition def = new DefaultTransactionDefinition(); def.setName("JE_Tx"); def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_UNCOMMITTED); TransactionStatus status = txnManager.getTransaction(def); try {/*from www.j a v a 2s .com*/ boolean isCompanySuperAdmin = false; Empprofile e = null; String ids[] = request.getParameterValues("ids"); String masterid = request.getParameter("tercause"); String desc = ((StringUtil.isNullOrEmpty(request.getParameter("terdesc"))) ? "" : request.getParameter("terdesc")); String reldate = request.getParameter("relievedate"); Date rvdate = fmt.parse(reldate); Empprofile emp = null; UserLogin usl = null; User usr = null; Date now = new Date(); // User updatedby=(User)session.get(User.class,sessionHandlerImplObj.getUserid(request)); // User updatedby=(User)kwlCommonTablesDAOObj.getObject("com.krawler.common.admin.User", sessionHandlerImplObj.getUserid(request)); String updatedby = sessionHandlerImplObj.getUserid(request); String companyid = sessionHandlerImplObj.getCompanyid(request); for (int i = 0; i < ids.length; i++) { if (hrmsCommonDAOObj.isCompanySuperAdmin(ids[i], companyid)) { isCompanySuperAdmin = true; break; } } if (isCompanySuperAdmin) { msg.put("msg", "adminerror"); msg.put("success", true); txnManager.commit(status); return new ModelAndView("jsonView", "model", msg.toString()); } for (int i = 0; i < ids.length; i++) { e = (Empprofile) kwlCommonTablesDAOObj.getObject("com.krawler.hrms.ess.Empprofile", ids[i]); if (e != null) { if (e.getJoindate() != null) { if (e.getJoindate().after(rvdate)) { msg.put("msg", "invalidterminatedate"); msg.put("success", true); txnManager.commit(status); return new ModelAndView("jsonView", "model", msg.toString()); } } } // hql = "from Empprofile where userLogin.userID=?"; // List lst = HibernateUtil.executeQuery(session, hql, new Object[]{ids[i]}); //// usl=(UserLogin)session.get(UserLogin.class,ids[i]); // usl=(UserLogin)HibernateUtil.getPrimary("com.krawler.common.admin.UserLogin", "userID"); //// usr=(User)session.get(User.class,ids[i]); // usr=(User)HibernateUtil.getPrimary("com.krawler.common.admin.User", "userID"); // if(lst.isEmpty()){ // emp=new Empprofile(); // emp.setUserLogin(usl); // }else{ // emp=(Empprofile)session.get(Empprofile.class,ids[i]); // } // Emphistory ehst=new Emphistory(); // ehst.setUserid(usr); // ehst.setDepartment(usr.getDepartment()); // ehst.setDesignation(usr.getDesignationid()); // ehst.setSalary(usr.getSalary()); // ehst.setEmpid(usr.getEmployeeid()); // ehst.setUpdatedon(rvdate); // ehst.setJoindate(emp.getJoindate()); // ehst.setEnddate(rvdate); // ehst.setUpdatedby(updatedby); // ehst.setCategory(Emphistory.Emp_Desg_change); // emp.setTerminatedby(updatedby); // emp.setTercause((MasterData)session.get(MasterData.class,masterid)); // emp.setRelievedate(rvdate); // emp.setTerReason(desc); // emp.setTermnd(true); // usr.setDeleted(true); // session.saveOrUpdate(ehst); // session.saveOrUpdate(emp); // session.saveOrUpdate(usr); // //@@ProfileHandler.insertAuditLog(session, AuditAction.EMPLOYEE_TERMINATED, "Employee " + sessionHandlerImplObj.getFullName(usr) + " terminated by " + sessionHandlerImplObj.getFullName(session, sessionHandlerImplObj.getUserid(request)),request); HashMap<String, Object> requestParams = new HashMap<String, Object>(); if (rvdate.before(now) || rvdate.equals(now)) { requestParams.put("termnd", true); } requestParams.put("userid", ids[i]); requestParams.put("terminatedby", updatedby); requestParams.put("tercause", masterid); requestParams.put("terReason", desc); requestParams.put("relievedate", reldate); KwlReturnObject result = hrmsCommonDAOObj.addEmpprofile(requestParams); HashMap<String, Object> deleteJobj = organizationService.deleteNode(ids[i]); if (rvdate.before(now) || rvdate.equals(now)) { requestParams.clear(); requestParams.put("UserID", ids[i]); requestParams.put("Deleteflag", 1); hrmsCommonDAOObj.adduser(requestParams); } } msg.put("success", true); txnManager.commit(status); } catch (Exception e) { e.printStackTrace(); txnManager.rollback(status); } finally { return new ModelAndView("jsonView", "model", msg.toString()); } }
From source file:com.xpn.xwiki.doc.XWikiDocument.java
public void setDate(Date date) { if ((date != null) && (!date.equals(this.updateDate))) { setMetaDataDirty(true);// ww w. j a v a 2 s .com } // Make sure we drop milliseconds for consistency with the database if (date != null) { date.setTime((date.getTime() / 1000) * 1000); } this.updateDate = date; }
From source file:com.xpn.xwiki.doc.XWikiDocument.java
public void setCreationDate(Date date) { if ((date != null) && (!date.equals(this.creationDate))) { setMetaDataDirty(true);//from w w w . j a v a2 s .co m } // Make sure we drop milliseconds for consistency with the database if (date != null) { date.setTime((date.getTime() / 1000) * 1000); } this.creationDate = date; }