List of usage examples for org.joda.time LocalDate toString
@ToString
public String toString()
From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
private void updateTriggerDates(Long campaignId) { final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); }// ww w . j av a 2 s.c o m LocalDateTime nextTriggerDate = emailCampaign.getNextTriggerDate(); emailCampaign.setLastTriggerDate(nextTriggerDate.toDate()); //calculate new trigger date and insert into next trigger date /** * next run time has to be in the future if not calculate a new future date */ LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means next run time is in the past calculate a new future date nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant()); } final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(newTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); }
From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override/*from w w w . j a v a 2 s . c om*/ public CommandProcessingResult activateEmailCampaign(Long campaignId, JsonCommand command) { final AppUser currentUser = this.context.authenticatedUser(); this.emailCampaignValidator.validateActivation(command.json()); final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate"); emailCampaign.activate(currentUser, fmt, activationDate); this.emailCampaignRepository.saveAndFlush(emailCampaign); if (emailCampaign.isDirect()) { insertDirectCampaignIntoEmailOutboundTable(emailCampaign.getParamValue(), emailCampaign.getEmailSubject(), emailCampaign.getEmailMessage(), emailCampaign.getCampaignName(), emailCampaign.getId()); } else { if (emailCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = emailCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); } } /* if campaign is direct insert campaign message into scheduledemail outbound table else if its a schedule create a job process for it */ return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(emailCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.scheduledemail.service.EmailCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override/*from ww w . ja va 2s . c om*/ public CommandProcessingResult reactivateEmailCampaign(final Long campaignId, JsonCommand command) { this.emailCampaignValidator.validateActivation(command.json()); final AppUser currentUser = this.context.authenticatedUser(); final EmailCampaign emailCampaign = this.emailCampaignRepository.findOne(campaignId); if (emailCampaign == null) { throw new EmailCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate reactivationDate = command.localDateValueOfParameterNamed("activationDate"); emailCampaign.reactivate(currentUser, fmt, reactivationDate); if (emailCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger date when activating */ LocalDate nextTriggerDate = null; if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = emailCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); emailCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.emailCampaignRepository.saveAndFlush(emailCampaign); } return new CommandProcessingResultBuilder() // .withEntityId(emailCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
private void updateTriggerDates(Long campaignId) { final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); }/*from w ww .j a v a 2 s. c om*/ LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate(); smsCampaign.setLastTriggerDate(nextTriggerDate.toDate()); //calculate new trigger date and insert into next trigger date /** * next run time has to be in the future if not calculate a new future date */ LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means next run time is in the past calculate a new future date nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant()); } final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextRuntime.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(newTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override// w w w .j a v a2 s.c o m public CommandProcessingResult activateSmsCampaign(Long campaignId, JsonCommand command) { final AppUser currentUser = this.context.authenticatedUser(); this.smsCampaignValidator.validateActivation(command.json()); final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate"); smsCampaign.activate(currentUser, fmt, activationDate); this.smsCampaignRepository.saveAndFlush(smsCampaign); if (smsCampaign.isDirect()) { insertDirectCampaignIntoSmsOutboundTable(smsCampaign.getParamValue(), smsCampaign.getMessage(), smsCampaign.getCampaignName()); } else { if (smsCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = smsCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); } } /* if campaign is direct insert campaign message into sms outbound table else if its a schedule create a job process for it */ return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(smsCampaign.getId()) // .build(); }
From source file:org.apache.fineract.infrastructure.sms.service.SmsCampaignWritePlatformCommandHandlerImpl.java
License:Apache License
@Transactional @Override/* w w w .j a v a 2 s.c o m*/ public CommandProcessingResult reactivateSmsCampaign(final Long campaignId, JsonCommand command) { this.smsCampaignValidator.validateActivation(command.json()); final AppUser currentUser = this.context.authenticatedUser(); final SmsCampaign smsCampaign = this.smsCampaignRepository.findOne(campaignId); if (smsCampaign == null) { throw new SmsCampaignNotFound(campaignId); } final Locale locale = command.extractLocale(); final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale); final LocalDate reactivationDate = command.localDateValueOfParameterNamed("activationDate"); smsCampaign.reactivate(currentUser, fmt, reactivationDate); if (smsCampaign.isSchedule()) { /** * if recurrence start date is in the future calculate * next trigger date if not use recurrence start date us next trigger * date when activating */ LocalDate nextTriggerDate = null; if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); } else { nextTriggerDate = smsCampaign.getRecurrenceStartDate(); } // to get time of tenant final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final String dateString = nextTriggerDate.toString() + " " + getTime.getHourOfDay() + ":" + getTime.getMinuteOfHour() + ":" + getTime.getSecondOfMinute(); final DateTimeFormatter simpleDateFormat = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); smsCampaign.setNextTriggerDate(nextTriggerDateWithTime.toDate()); this.smsCampaignRepository.saveAndFlush(smsCampaign); } return new CommandProcessingResultBuilder() // .withEntityId(smsCampaign.getId()) // .build(); }
From source file:org.apache.fineract.portfolio.calendar.domain.Calendar.java
License:Apache License
public Map<String, Object> updateStartDateAndDerivedFeilds(final LocalDate newMeetingStartDate) { final Map<String, Object> actualChanges = new LinkedHashMap<>(9); final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); if (newMeetingStartDate.isBefore(currentDate)) { final String defaultUserMessage = "New meeting effective from date cannot be in past"; throw new CalendarDateException("new.start.date.cannot.be.in.past", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else if (isStartDateAfter(newMeetingStartDate) && isStartDateBeforeOrEqual(currentDate)) { // new meeting date should be on or after start date or current // date//from w ww . ja v a2s .c o m final String defaultUserMessage = "New meeting effective from date cannot be a date before existing meeting start date"; throw new CalendarDateException("new.start.date.before.existing.date", defaultUserMessage, newMeetingStartDate, getStartDateLocalDate()); } else { actualChanges.put(CALENDAR_SUPPORTED_PARAMETERS.START_DATE.getValue(), newMeetingStartDate.toString()); this.startDate = newMeetingStartDate.toDate(); /* * If meeting start date is changed then there is possibilities of * recurring day may change, so derive the recurring day and update * it if it is changed. For weekly type is weekday and for monthly * type it is day of the month */ CalendarFrequencyType calendarFrequencyType = CalendarUtils.getFrequency(this.recurrence); Integer interval = CalendarUtils.getInterval(this.recurrence); Integer repeatsOnDay = null; /* * Repeats on day, need to derive based on the start date */ if (calendarFrequencyType.isWeekly()) { repeatsOnDay = newMeetingStartDate.getDayOfWeek(); } else if (calendarFrequencyType.isMonthly()) { repeatsOnDay = newMeetingStartDate.getDayOfMonth(); } // TODO cover other recurrence also this.recurrence = constructRecurrence(calendarFrequencyType, interval, repeatsOnDay); } return actualChanges; }
From source file:org.apache.fineract.portfolio.loanaccount.serialization.LoanEventApiJsonValidator.java
License:Apache License
public void validateDisbursementDateWithMeetingDate(final LocalDate actualDisbursementDate, final CalendarInstance calendarInstance) { if (null != calendarInstance) { final Calendar calendar = calendarInstance.getCalendar(); if (!calendar.isValidRecurringDate(actualDisbursementDate)) { // Disbursement date should fall on a meeting date final String errorMessage = "Expected disbursement date '" + actualDisbursementDate.toString() + "' does not fall on a meeting date."; throw new NotValidRecurringDateException("loan.actual.disbursement.date", errorMessage, actualDisbursementDate.toString(), calendar.getTitle()); }/*w w w . j av a2 s . com*/ } }
From source file:org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java
License:Apache License
private void validateSubmittedOnDate(final SavingsAccount savingsAccount) { final LocalDate startDate = savingsAccount.savingsProduct().getStartDate(); final LocalDate closeDate = savingsAccount.savingsProduct().getCloseDate(); final LocalDate submittedOnDate = savingsAccount.getSubmittedOnDate(); String defaultUserMessage = ""; if (startDate != null && submittedOnDate.isBefore(startDate)) { defaultUserMessage = "submittedOnDate cannot be before the savings product startDate."; throw new SavingsApplicationDateException( "submitted.on.date.cannot.be.before.the.savings.product.start.date", defaultUserMessage, submittedOnDate.toString(), startDate.toString()); }//from w w w. ja v a2 s. c o m if (closeDate != null && submittedOnDate.isAfter(closeDate)) { defaultUserMessage = "submittedOnDate cannot be after the savings product closeDate."; throw new SavingsApplicationDateException( "submitted.on.date.cannot.be.after.the.savings.product.close.date", defaultUserMessage, submittedOnDate.toString(), closeDate.toString()); } }
From source file:org.apache.isis.applib.fixturescripts.ExecutionParameters.java
License:Apache License
public void setParameter(final String parameterName, final LocalDate parameterValue) { setParameter(parameterName, parameterValue != null ? parameterValue.toString() : null); }