List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:com.collabnet.ccf.teamforge.TFAppHandler.java
/** * This method retrieves all the comments added to a particular artifact * (represented by the ArtifactSoapDO) and adds all the comments that are * added after the lastModifiedDate into the ArtifcatSoapDO's flex fields * with the field name as "Comment Text" [as this is the name displayed in * the TF trackers for the Comments]/*from ww w.j av a 2 s . com*/ * * It calls the private method addComments which can add comments for a list * of artifacts by querying the ISourceForgeSoap object for this particular * TF system. * * The comments added by the connector user are ignored by this method. * * @param artifact * - The ArtifactSoapDO object whose comments need to be added * @param lastModifiedDate * - The last read time of this tracker * @param connectorUser * - The username that is configured to log into the TF to * retrieve the artifact data. * @param resyncUser * - The resync user for CCF */ public void addComments(ArtifactDO artifact, Date lastModifiedDate, String connectorUser, String resyncUser, boolean isPreserveBulkCommentOrder) { try { CommentList commentList = connection.getTeamForgeClient().getCommentList(artifact.getId()); CommentRow[] comments = commentList.getDataRows(); if (comments != null) { if (isPreserveBulkCommentOrder && comments.length > 1) { Collections.reverse(Arrays.asList(comments)); } for (CommentRow comment : comments) { String createdBy = comment.getCreatedBy(); Date createdDate = comment.getDateCreated(); if (createdBy.equals(connectorUser) || createdBy.equals(resyncUser)) { continue; } if (lastModifiedDate.after(createdDate) || lastModifiedDate.equals(createdDate)) { continue; } String description = comment.getDescription(); description = "\nOriginal commenter: " + createdBy + "\n" + description; this.addComment(TFArtifactMetaData.TFFields.commentText.getFieldName(), artifact, description); } } } catch (RemoteException e) { log.error("Could not get comments list for artifact " + artifact.getId() + ": " + e.getMessage()); } }
From source file:org.craftercms.studio.impl.v1.service.content.DmRenameServiceImpl.java
/** * * Prepares and starts workflow//from w w w . j a va2s. c o m * * Reverts any child nodes which are not in the same version as staging since only URL changes has to be pushed to staging. * A copy of the new version is placed in a temp location and recovered once we push things to workflow * */ protected void submitWorkflow(final String site, final List<DmDependencyTO> submittedItems, Date now, Date scheduledDate, final String approver, MultiChannelPublishingContext mcpContext) throws ServiceException { final String assignee = "";//DmUtils.getAssignee(site, sub); final List<String> paths = new ArrayList<>(); final List<String> dependenices = new ArrayList<>(); Date launchDate = scheduledDate.equals(now) ? null : scheduledDate; final boolean isScheduled = launchDate == null ? false : true; String pathPrefix = "/wem-projects/" + site + "/" + site + "/work-area"; //label will keep track of all nodes that has been reverted to staging version and used during postStagingSubmission final StringBuilder label = new StringBuilder(); label.append( isScheduled ? DmConstants.SCHEDULE_RENAME_WORKFLOW_PREFIX : DmConstants.RENAME_WORKFLOW_PREFIX); label.append(":"); final Set<String> rescheduledUris = new HashSet<String>(); for (DmDependencyTO submittedItem : submittedItems) { String workflowLabel = getWorkflowPaths(site, submittedItem, pathPrefix, paths, dependenices, isScheduled, rescheduledUris); label.append(workflowLabel); label.append(","); } Set<String> uris = new HashSet<String>(); Map<String, String> submittedBy = new HashMap<>(); for (String path : paths) { String uri = path.substring(pathPrefix.length()); uris.add(uri); dmPublishService.cancelScheduledItem(site, uri); } GoLiveContext context = new GoLiveContext(approver, site); SubmitLifeCycleOperation operation = null; if (launchDate == null) { operation = new PreGoLiveOperation(workflowService, uris, context, rescheduledUris); } else { //uri will not be have dependencies for (String dependency : dependenices) { String uri = dependency.substring(pathPrefix.length()); uris.add(uri); } operation = new PreScheduleOperation(workflowService, uris, launchDate, context, rescheduledUris); } workflowProcessor.addToWorkflow(site, paths, launchDate, label.toString(), operation, approver, mcpContext); logger.debug("Go live rename: paths posted " + paths + "for workflow scheduled at : " + launchDate); }
From source file:org.xwiki.contrib.mailarchive.timeline.internal.TimeLineGenerator.java
/** * {@inheritDoc}//ww w. j a va2 s. com * * @see org.xwiki.contrib.mailarchive.timeline.ITimeLineGenerator#compute() */ @Override public String compute(int maxItems) { try { config.reloadConfiguration(); } catch (MailArchiveException e) { logger.error("Could not load mail archive configuration", e); return null; } Map<String, IMailingList> mailingLists = config.getMailingLists(); Map<String, IType> types = config.getMailTypes(); try { this.userStatsUrl = xwiki.getDocument(docResolver.resolve("MailArchive.ViewUserMessages"), context) .getURL("view", context); } catch (XWikiException e1) { logger.warn("Could not retrieve user stats url {}", ExceptionUtils.getRootCauseMessage(e1)); } TreeMap<Long, TimeLineEvent> sortedEvents = new TreeMap<Long, TimeLineEvent>(); // Set loading user in context (for rights) String loadingUser = config.getLoadingUser(); context.setUserReference(docResolver.resolve(loadingUser)); try { // Search topics String xwql = "select doc.fullName, topic.author, topic.subject, topic.topicid, topic.startdate, topic.lastupdatedate from Document doc, doc.object(" + XWikiPersistence.CLASS_TOPICS + ") as topic order by topic.lastupdatedate desc"; List<Object[]> result = queryManager.createQuery(xwql, Query.XWQL).setLimit(maxItems).execute(); for (Object[] item : result) { XWikiDocument doc = null; try { String docurl = (String) item[0]; String author = (String) item[1]; String subject = (String) item[2]; String topicId = (String) item[3]; Date date = (Date) item[4]; Date end = (Date) item[5]; String action = ""; // Retrieve associated emails TreeMap<Long, TopicEventBubble> emails = getTopicMails(topicId, subject); if (emails == null || emails.isEmpty()) { // Invalid topic, not emails attached, do not show it logger.warn("Invalid topic, no emails attached " + doc); } else { if (date != null && end != null && date.equals(end)) { // Add 10 min just to see the tape end.setTime(end.getTime() + 600000); } doc = xwiki.getDocument(docResolver.resolve(docurl), context); final List<String> tagsList = doc.getTagsList(context); List<String> topicTypes = doc.getListValue(XWikiPersistence.CLASS_TOPICS, "type"); // Email type icon List<String> icons = new ArrayList<String>(); for (String topicType : topicTypes) { IType type = types.get(topicType); if (type != null && !StringUtils.isEmpty(type.getIcon())) { icons.add(xwiki.getSkinFile("icons/silk/" + type.getIcon() + ".png", context)); // http://localhost:8080/xwiki/skins/colibri/icons/silk/bell // http://localhost:8080/xwiki/resources/icons/silk/bell.png } } // Author and avatar final IMAUser wikiUser = mailUtils.parseUser(author, config.isMatchLdap()); final String authorAvatar = getAuthorAvatar(wikiUser.getWikiProfile()); final TimeLineEvent timelineEvent = new TimeLineEvent(); TimeLineEvent additionalEvent = null; timelineEvent.beginDate = date; timelineEvent.title = subject; timelineEvent.icons = icons; timelineEvent.lists = doc.getListValue(XWikiPersistence.CLASS_TOPICS, "list"); timelineEvent.author = wikiUser.getDisplayName(); timelineEvent.authorAvatar = authorAvatar; timelineEvent.extract = getExtract(topicId); if (emails.size() == 1) { logger.debug("Adding instant event for email '" + subject + "'"); // Unique email, we show a punctual email event timelineEvent.url = emails.firstEntry().getValue().link; timelineEvent.action = "New Email "; } else { // For email with specific type icon, and a duration, both a band and a point should be added (so 2 events) // because no icon is displayed for duration events. if (CollectionUtils.isNotEmpty(icons)) { logger.debug( "Adding additional instant event to display type icon for first email in topic"); additionalEvent = new TimeLineEvent(timelineEvent); additionalEvent.url = emails.firstEntry().getValue().link; additionalEvent.action = "New Email "; } // Email thread, we show a topic event (a range) logger.debug("Adding duration event for topic '" + subject + "'"); timelineEvent.endDate = end; timelineEvent.url = doc.getURL("view", context); timelineEvent.action = "New Topic "; timelineEvent.messages = emails; } // Add the generated Event to the list if (sortedEvents.containsKey(date.getTime())) { // Avoid having more than 1 event at exactly the same time, because some timeline don't like it date.setTime(date.getTime() + 1); } sortedEvents.put(date.getTime(), timelineEvent); if (additionalEvent != null) { sortedEvents.put(date.getTime() + 1, additionalEvent); } } } catch (Throwable t) { logger.warn("Exception for " + doc, t); } } } catch (Throwable e) { logger.warn("could not compute timeline data", e); } return printEvents(sortedEvents); }
From source file:com.virtusa.akura.reporting.controller.GenarateTeacherWisePresentAndAbsentDaysReportController.java
/** * Check the given date is a holiday or not. * * @param holidayList - list consits of Holidays for the given time period. * @param currentDate - currentDate// w w w . ja va 2s .co m * @param start - Calender object * @return boolean */ public boolean isHoliday(List<Holiday> holidayList, Date currentDate, Calendar start) { boolean flag = false; int dayOfWeek = start.get(Calendar.DAY_OF_WEEK); for (Holiday tempHoliday : holidayList) { if ((currentDate.after(tempHoliday.getStartDate()) && currentDate.before(tempHoliday.getEndDate())) || currentDate.equals(tempHoliday.getStartDate()) || currentDate.equals(tempHoliday.getEndDate()) || Calendar.SATURDAY == dayOfWeek || Calendar.SUNDAY == dayOfWeek) { flag = true; break; } } return flag; }
From source file:org.openmrs.module.rwandasphstudyreports.api.db.hibernate.HibernateCDCReportsDAO.java
@Override public boolean matchTestEnrollmentArtInitAndReturnVisitDates(Date testDate, Date hivEnrollmentDate, Date artInitDate, Date returnVisitDate, String[] datesToMatch, Date startDate, Date endDate) { boolean matched = false; if (startDate != null && endDate != null) { if (datesToMatch != null && ArrayUtils.isNotEmpty(datesToMatch)) { for (int i = 0; i < datesToMatch.length; i++) { String d = datesToMatch[i]; if (StringUtils.isNotBlank(d)) { if ((d.equals("test") && (testDate != null && (testDate.equals(startDate) || testDate.after(startDate)) && (testDate.equals(endDate) || testDate.before(endDate)))) || (d.equals("enrollment") && (hivEnrollmentDate != null && (hivEnrollmentDate.equals(startDate) || hivEnrollmentDate.after(startDate)) && (hivEnrollmentDate.equals(endDate) || hivEnrollmentDate.before(endDate)))) || (d.equals("initiation") && (artInitDate != null && (artInitDate.equals(startDate) || artInitDate.after(startDate)) && (artInitDate.equals(endDate) || artInitDate.before(endDate)))) || (d.equals("returnVisit") && (returnVisitDate != null && (returnVisitDate.equals(startDate) || returnVisitDate.after(startDate)) && (returnVisitDate.equals(endDate) || returnVisitDate.before(endDate))))) { matched = matched || i == 0 ? true : false; } else matched = false; } else { matched = false;/* w w w.j a va 2 s .c o m*/ } } } else matched = true; } return matched; }
From source file:org.mifos.accounts.api.StandardAccountService.java
public void handleLoanDisbursal(Locale locale, LoanBO loan, PersonnelBO personnelBO, BigDecimal paymentAmount, PaymentTypeDto paymentType, LocalDate receiptLocalDate, LocalDate paymentLocalDate, String receiptId, Short paymentTypeIdForFees, Integer accountForTransferId) throws PersistenceException, AccountException { if ("MPESA".equals(paymentType.getName())) { paymentAmount = computeWithdrawnForMPESA(paymentAmount, loan); }//from w ww . j a v a2 s . com PaymentTypeEntity paymentTypeEntity = legacyMasterDao.getPersistentObject(PaymentTypeEntity.class, paymentType.getValue()); Money amount = new Money(loan.getCurrency(), paymentAmount); Date receiptDate = null; if (null != receiptLocalDate) { receiptDate = receiptLocalDate.toDateMidnight().toDate(); } Date transactionDate = paymentLocalDate.toDateMidnight().toDate(); AccountPaymentEntity disbursalPayment = new AccountPaymentEntity(loan, amount, receiptId, receiptDate, paymentTypeEntity, transactionDate); disbursalPayment.setCreatedByUser(personnelBO); Double interestRate = loan.getInterestRate(); Date oldDisbursementDate = loan.getDisbursementDate(); List<RepaymentScheduleInstallment> originalInstallments = loan.toRepaymentScheduleDto(locale); loan.disburseLoan(disbursalPayment, paymentTypeIdForFees, accountForTransferId); if (!loan.isVariableInstallmentsAllowed()) { originalInstallments = loan.toRepaymentScheduleDto(locale); } Date newDisbursementDate = loan.getDisbursementDate(); boolean variableInstallmentsAllowed = loan.isVariableInstallmentsAllowed(); loanBusinessService.adjustDatesForVariableInstallments(variableInstallmentsAllowed, loan.isFixedRepaymentSchedule(), originalInstallments, oldDisbursementDate, newDisbursementDate, loan.getOfficeId()); Date today = new LocalDate().toDateMidnight().toDate(); Date disburseDay = new LocalDate(oldDisbursementDate).toDateMidnight().toDate(); if (!today.equals(disburseDay)) { loanBusinessService .applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(newDisbursementDate, loan, variableInstallmentsAllowed, amount, interestRate), originalInstallments); } loanBusinessService.persistOriginalSchedule(loan); }
From source file:org.apache.lens.cube.parse.StorageCandidate.java
private boolean isTimeRangeCoverable(Date timeRangeStart, Date timeRangeEnd, Set<UpdatePeriod> intervals) throws LensException { if (timeRangeStart.equals(timeRangeEnd) || timeRangeStart.after(timeRangeEnd)) { return true; }/* w w w . j a va 2 s . co m*/ if (intervals == null || intervals.isEmpty()) { return false; } UpdatePeriod maxInterval = CubeFactTable.maxIntervalInRange(timeRangeStart, timeRangeEnd, intervals); if (maxInterval == null) { return false; } if (maxInterval == UpdatePeriod.CONTINUOUS && getCubeQueryContext().getRangeWriter().getClass().equals(BetweenTimeRangeWriter.class)) { return true; } Date maxIntervalStorageTableStartDate = getStorageTableStartDate(maxInterval); Date maxIntervalStorageTableEndDate = getStorageTableEndDate(maxInterval); Set<UpdatePeriod> remainingIntervals = Sets.difference(intervals, Sets.newHashSet(maxInterval)); if (!isCandidatePartiallyValidForTimeRange(maxIntervalStorageTableStartDate, maxIntervalStorageTableEndDate, timeRangeStart, timeRangeEnd)) { //Check the time range in remainingIntervals as maxInterval is not useful return isTimeRangeCoverable(timeRangeStart, timeRangeEnd, remainingIntervals); } Date ceilFromDate = DateUtil .getCeilDate(timeRangeStart.after(maxIntervalStorageTableStartDate) ? timeRangeStart : maxIntervalStorageTableStartDate, maxInterval); Date floorToDate = DateUtil.getFloorDate( timeRangeEnd.before(maxIntervalStorageTableEndDate) ? timeRangeEnd : maxIntervalStorageTableEndDate, maxInterval); if (ceilFromDate.equals(floorToDate) || floorToDate.before(ceilFromDate)) { return isTimeRangeCoverable(timeRangeStart, timeRangeEnd, remainingIntervals); } //ceilFromDate to floorToDate time range is covered by maxInterval (though there may be holes.. but that's ok) //Check the remaining part of time range in remainingIntervals return isTimeRangeCoverable(timeRangeStart, ceilFromDate, remainingIntervals) && isTimeRangeCoverable(floorToDate, timeRangeEnd, remainingIntervals); }
From source file:org.openmrs.api.impl.ProgramWorkflowServiceImpl.java
/** * @see org.openmrs.api.ProgramWorkflowService#voidPatientProgram(org.openmrs.PatientProgram, * java.lang.String)//ww w. ja v a 2 s.c om */ public PatientProgram unvoidPatientProgram(PatientProgram patientProgram) { Date voidDate = patientProgram.getDateVoided(); patientProgram.setVoided(false); for (PatientState state : patientProgram.getStates()) { if (voidDate != null && voidDate.equals(state.getDateVoided())) { state.setVoided(false); state.setVoidedBy(null); state.setDateVoided(null); state.setVoidReason(null); } } return Context.getProgramWorkflowService().savePatientProgram(patientProgram); // The savePatientProgram method handles all of the unvoiding defaults }
From source file:br.com.hslife.orcamento.task.AgendamentoTask.java
@Scheduled(fixedDelay = 3600000) @SuppressWarnings("deprecation") public void executarTarefa() { try {/*www.j a v a 2 s .c o m*/ CriterioAgendamento criterioAgendamento = new CriterioAgendamento(); criterioAgendamento.setTipo(TipoAgendamento.PREVISAO); List<Agenda> agendamentos = getService().buscarPorCriterioAgendamento(criterioAgendamento); List<LancamentoConta> lancamentosAtualizados = new ArrayList<>(); LancamentoConta lancamento; Date dataLancamento; for (Agenda agenda : agendamentos) { Date dataAgenda = new Date(agenda.getInicio().getYear() + 1900, agenda.getInicio().getMonth(), agenda.getInicio().getDate(), 0, 0, 0); switch (agenda.getEntity()) { case "LancamentoConta": lancamento = getLancamentoContaService().buscarPorID(agenda.getIdEntity()); if (lancamento != null) { dataLancamento = new Date(lancamento.getDataPagamento().getYear() + 1900, lancamento.getDataPagamento().getMonth(), lancamento.getDataPagamento().getDate(), 0, 0, 0); if (lancamento.getStatusLancamentoConta().equals(StatusLancamentoConta.AGENDADO) && dataLancamento.equals(dataAgenda)) { lancamentosAtualizados.add(lancamento); } else { getService().excluir(agenda); } } else { getService().excluir(agenda); } break; default: break; } } CriterioBuscaLancamentoConta criterioBusca = new CriterioBuscaLancamentoConta(); criterioBusca.setStatusLancamentoConta(new StatusLancamentoConta[] { StatusLancamentoConta.AGENDADO }); criterioBusca.setDataInicio(new Date()); List<LancamentoConta> lancamentos = getLancamentoContaService().buscarPorCriterioBusca(criterioBusca); lancamentos.removeAll(lancamentosAtualizados); for (LancamentoConta l : lancamentos) { Agenda agenda = new Agenda(); agenda.setDescricao(l.getDescricao()); agenda.setInicio(l.getDataPagamento()); agenda.setFim(l.getDataPagamento()); agenda.setDiaInteiro(true); agenda.setEmitirAlerta(true); agenda.setTipoAgendamento(TipoAgendamento.PREVISAO); agenda.setNotas(l.getObservacao()); agenda.setUsuario(l.getConta().getUsuario()); agenda.setIdEntity(l.getId()); agenda.setEntity(l.getClass().getSimpleName()); getService().cadastrar(agenda); } } catch (Exception e) { logger.catching(e); e.printStackTrace(); } }
From source file:org.openmrs.api.impl.ProgramWorkflowServiceImpl.java
/** * @see org.openmrs.api.ProgramWorkflowService#retireProgram(org.openmrs.Program) *///from w ww . j ava 2 s . co m public Program unretireProgram(Program program) throws APIException { Date lastModifiedDate = program.getDateChanged(); program.setRetired(false); for (ProgramWorkflow workflow : program.getAllWorkflows()) { if (lastModifiedDate != null && lastModifiedDate.equals(workflow.getDateChanged())) { workflow.setRetired(false); for (ProgramWorkflowState state : workflow.getStates()) { if (lastModifiedDate.equals(state.getDateChanged())) { state.setRetired(false); } } } } return saveProgram(program); }