refactor: add lombok to reportmailingjob module

This commit is contained in:
Hemant Gupta
2022-10-12 12:55:28 +02:00
committed by Arnold Gálovics
parent 8862f1f824
commit 6d2447e327
11 changed files with 156 additions and 796 deletions
@@ -165,25 +165,25 @@ public class ExecuteReportMailingJobsTasklet implements Tasklet {
final LocalDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();
ReportMailingJobPreviousRunStatus reportMailingJobPreviousRunStatus = ReportMailingJobPreviousRunStatus.SUCCESS;
reportMailingJob.updatePreviousRunErrorLog(null);
reportMailingJob.setPreviousRunErrorLog(null);
if (errorLog != null && errorLog.length() > 0) {
reportMailingJobPreviousRunStatus = ReportMailingJobPreviousRunStatus.ERROR;
reportMailingJob.updatePreviousRunErrorLog(errorLog.toString());
reportMailingJob.setPreviousRunErrorLog(errorLog.toString());
}
reportMailingJob.increaseNumberOfRunsByOne();
reportMailingJob.updatePreviousRunStatus(reportMailingJobPreviousRunStatus.getValue());
reportMailingJob.updatePreviousRunDateTime(reportMailingJob.getNextRunDateTime());
reportMailingJob.setPreviousRunStatus(reportMailingJobPreviousRunStatus.getValue());
reportMailingJob.setPreviousRunDateTime(reportMailingJob.getNextRunDateTime());
if (StringUtils.isEmpty(recurrence)) {
reportMailingJob.deactivate();
reportMailingJob.setActive(false);
reportMailingJob.updateNextRunDateTime(null);
reportMailingJob.setNextRunDateTime(null);
} else if (nextRunDateTime != null) {
final LocalDateTime nextRecurringDateTime = createNextRecurringDateTime(recurrence, nextRunDateTime);
reportMailingJob.updateNextRunDateTime(nextRecurringDateTime);
reportMailingJob.setNextRunDateTime(nextRecurringDateTime);
}
reportMailingJobRepository.save(reportMailingJob);
@@ -202,8 +202,8 @@ public class ExecuteReportMailingJobsTasklet implements Tasklet {
byteArrayOutputStream.writeTo(outputStream);
for (String emailRecipient : emailRecipients) {
final ReportMailingJobEmailData reportMailingJobEmailData = new ReportMailingJobEmailData(emailRecipient,
reportMailingJob.getEmailMessage(), reportMailingJob.getEmailSubject(), file);
final ReportMailingJobEmailData reportMailingJobEmailData = new ReportMailingJobEmailData().setTo(emailRecipient)
.setText(reportMailingJob.getEmailMessage()).setSubject(reportMailingJob.getEmailSubject()).setAttachment(file);
reportMailingJobEmailService.sendEmailWithAttachment(reportMailingJobEmailData);
}
@@ -18,23 +18,21 @@
*/
package org.apache.fineract.infrastructure.reportmailingjob.data;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Immutable data object representing report mailing job configuration data.
**/
@Data
@NoArgsConstructor
@Accessors(chain = true)
public final class ReportMailingJobConfigurationData {
private final int id;
private final String name;
private final String value;
/**
* ReportMailingJobConfigurationData private constructor
**/
private ReportMailingJobConfigurationData(final int id, final String name, final String value) {
this.id = id;
this.name = name;
this.value = value;
}
private int id;
private String name;
private String value;
/**
* creates an instance of the ReportMailingJobConfigurationData class
@@ -42,27 +40,6 @@ public final class ReportMailingJobConfigurationData {
* @return ReportMailingJobConfigurationData object
**/
public static ReportMailingJobConfigurationData newInstance(final int id, final String name, final String value) {
return new ReportMailingJobConfigurationData(id, name, value);
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the value
*/
public String getValue() {
return value;
return new ReportMailingJobConfigurationData().setId(id).setName(name).setValue(value);
}
}
@@ -20,67 +20,42 @@ package org.apache.fineract.infrastructure.reportmailingjob.data;
import java.time.ZonedDateTime;
import java.util.List;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.dataqueries.data.ReportData;
/**
* Immutable data object representing report mailing job data.
**/
@Data
@NoArgsConstructor
@Accessors(chain = true)
public final class ReportMailingJobData {
private final Long id;
private final String name;
private final String description;
private final ZonedDateTime startDateTime;
private final String recurrence;
private final ReportMailingJobTimelineData timeline;
private final String emailRecipients;
private final String emailSubject;
private final String emailMessage;
private final EnumOptionData emailAttachmentFileFormat;
private final ReportData stretchyReport;
private final String stretchyReportParamMap;
private final ZonedDateTime previousRunDateTime;
private final ZonedDateTime nextRunDateTime;
private final String previousRunStatus;
private final String previousRunErrorLog;
private final String previousRunErrorMessage;
private final Integer numberOfRuns;
private final boolean isActive;
private final List<EnumOptionData> emailAttachmentFileFormatOptions;
private final List<EnumOptionData> stretchyReportParamDateOptions;
private final Long runAsUserId;
private ReportMailingJobData(final Long id, final String name, final String description, final ZonedDateTime startDateTime,
final String recurrence, final ReportMailingJobTimelineData timeline, final String emailRecipients, final String emailSubject,
final String emailMessage, final EnumOptionData emailAttachmentFileFormat, final ReportData stretchyReport,
final String stretchyReportParamMap, final ZonedDateTime previousRunDateTime, final ZonedDateTime nextRunDateTime,
final String previousRunStatus, final String previousRunErrorLog, final String previousRunErrorMessage,
final Integer numberOfRuns, final boolean isActive, final List<EnumOptionData> emailAttachmentFileFormatOptions,
final List<EnumOptionData> stretchyReportParamDateOptions, final Long runAsUserId) {
this.id = id;
this.name = name;
this.description = description;
this.startDateTime = startDateTime;
this.recurrence = recurrence;
this.timeline = timeline;
this.emailRecipients = emailRecipients;
this.emailMessage = emailMessage;
this.emailSubject = emailSubject;
this.emailAttachmentFileFormat = emailAttachmentFileFormat;
this.stretchyReport = stretchyReport;
this.stretchyReportParamMap = stretchyReportParamMap;
this.previousRunDateTime = previousRunDateTime;
this.nextRunDateTime = nextRunDateTime;
this.previousRunStatus = previousRunStatus;
this.previousRunErrorLog = previousRunErrorLog;
this.previousRunErrorMessage = previousRunErrorMessage;
this.isActive = isActive;
this.numberOfRuns = numberOfRuns;
this.emailAttachmentFileFormatOptions = emailAttachmentFileFormatOptions;
this.stretchyReportParamDateOptions = stretchyReportParamDateOptions;
this.runAsUserId = runAsUserId;
}
private Long id;
private String name;
private String description;
private ZonedDateTime startDateTime;
private String recurrence;
private ReportMailingJobTimelineData timeline;
private String emailRecipients;
private String emailSubject;
private String emailMessage;
private EnumOptionData emailAttachmentFileFormat;
private ReportData stretchyReport;
private String stretchyReportParamMap;
private ZonedDateTime previousRunDateTime;
private ZonedDateTime nextRunDateTime;
private String previousRunStatus;
private String previousRunErrorLog;
private String previousRunErrorMessage;
private Integer numberOfRuns;
private boolean isActive;
private List<EnumOptionData> emailAttachmentFileFormatOptions;
private List<EnumOptionData> stretchyReportParamDateOptions;
private Long runAsUserId;
/**
* @return an instance of the ReportMailingJobData class
@@ -92,9 +67,13 @@ public final class ReportMailingJobData {
final ZonedDateTime previousRunDateTime, final ZonedDateTime nextRunDateTime, final String previousRunStatus,
final String previousRunErrorLog, final String previousRunErrorMessage, final Integer numberOfRuns, final boolean isActive,
final Long runAsUserId) {
return new ReportMailingJobData(id, name, description, startDateTime, recurrence, timeline, emailRecipients, emailSubject,
emailMessage, emailAttachmentFileFormat, stretchyReport, stretchyReportParamMap, previousRunDateTime, nextRunDateTime,
previousRunStatus, previousRunErrorLog, previousRunErrorMessage, numberOfRuns, isActive, null, null, runAsUserId);
return new ReportMailingJobData().setId(id).setName(name).setDescription(description).setStartDateTime(startDateTime)
.setRecurrence(recurrence).setTimeline(timeline).setEmailRecipients(emailRecipients).setEmailSubject(emailSubject)
.setEmailMessage(emailMessage).setEmailAttachmentFileFormat(emailAttachmentFileFormat).setStretchyReport(stretchyReport)
.setStretchyReportParamMap(stretchyReportParamMap).setPreviousRunDateTime(previousRunDateTime)
.setNextRunDateTime(nextRunDateTime).setPreviousRunStatus(previousRunStatus).setPreviousRunErrorLog(previousRunErrorLog)
.setPreviousRunErrorMessage(previousRunErrorMessage).setNumberOfRuns(numberOfRuns).setActive(isActive)
.setRunAsUserId(runAsUserId);
}
/**
@@ -102,8 +81,8 @@ public final class ReportMailingJobData {
**/
public static ReportMailingJobData newInstance(final List<EnumOptionData> emailAttachmentFileFormatOptions,
final List<EnumOptionData> stretchyReportParamDateOptions) {
return new ReportMailingJobData(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, false, emailAttachmentFileFormatOptions, stretchyReportParamDateOptions, null);
return new ReportMailingJobData().setEmailAttachmentFileFormatOptions(emailAttachmentFileFormatOptions)
.setStretchyReportParamDateOptions(stretchyReportParamDateOptions);
}
/**
@@ -111,168 +90,21 @@ public final class ReportMailingJobData {
**/
public static ReportMailingJobData newInstance(final ReportMailingJobData dataWithoutEnumOptions,
final ReportMailingJobData dataWithEnumOptions) {
return new ReportMailingJobData(dataWithoutEnumOptions.id, dataWithoutEnumOptions.name, dataWithoutEnumOptions.description,
dataWithoutEnumOptions.startDateTime, dataWithoutEnumOptions.recurrence, dataWithoutEnumOptions.timeline,
dataWithoutEnumOptions.emailRecipients, dataWithoutEnumOptions.emailSubject, dataWithoutEnumOptions.emailMessage,
dataWithoutEnumOptions.emailAttachmentFileFormat, dataWithoutEnumOptions.stretchyReport,
dataWithoutEnumOptions.stretchyReportParamMap, dataWithoutEnumOptions.previousRunDateTime,
dataWithoutEnumOptions.nextRunDateTime, dataWithoutEnumOptions.previousRunStatus,
dataWithoutEnumOptions.previousRunErrorLog, dataWithoutEnumOptions.previousRunErrorMessage,
dataWithoutEnumOptions.numberOfRuns, dataWithoutEnumOptions.isActive, dataWithEnumOptions.emailAttachmentFileFormatOptions,
dataWithEnumOptions.stretchyReportParamDateOptions, dataWithoutEnumOptions.runAsUserId);
}
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @return the startDateTime
*/
public ZonedDateTime getStartDateTime() {
return startDateTime;
}
/**
* @return the recurrence
*/
public String getRecurrence() {
return recurrence;
}
/**
* @return the timeline
*/
public ReportMailingJobTimelineData getTimeline() {
return timeline;
}
/**
* @return the emailRecipients
*/
public String getEmailRecipients() {
return emailRecipients;
}
/**
* @return the emailSubject
*/
public String getEmailSubject() {
return emailSubject;
}
/**
* @return the emailMessage
*/
public String getEmailMessage() {
return emailMessage;
}
/**
* @return the emailAttachmentFileFormat
*/
public EnumOptionData getEmailAttachmentFileFormat() {
return emailAttachmentFileFormat;
}
/**
* @return the stretchyReport
*/
public ReportData getStretchyReport() {
return stretchyReport;
}
/**
* @return the stretchyReportParamMap
*/
public String getStretchyReportParamMap() {
return stretchyReportParamMap;
}
/**
* @return the previousRunDateTime
*/
public ZonedDateTime getPreviousRunDateTime() {
return previousRunDateTime;
}
/**
* @return the nextRunDateTime
*/
public ZonedDateTime getNextRunDateTime() {
return nextRunDateTime;
}
/**
* @return the previousRunStatus
*/
public String getPreviousRunStatus() {
return previousRunStatus;
}
/**
* @return the previousRunErrorLog
*/
public String getPreviousRunErrorLog() {
return previousRunErrorLog;
}
/**
* @return the previousRunErrorMessage
*/
public String getPreviousRunErrorMessage() {
return previousRunErrorMessage;
}
/**
* @return the isActive
*/
public boolean isActive() {
return isActive;
}
/**
* @return the emailAttachmentFileFormatOptions
*/
public List<EnumOptionData> getEmailAttachmentFileFormatOptions() {
return emailAttachmentFileFormatOptions;
}
/**
* @return the stretchyReportParamDateOptions
**/
public List<EnumOptionData> getStretchyReportParamDateOptions() {
return this.stretchyReportParamDateOptions;
}
/**
* @return the numberOfRuns
*/
public Integer getNumberOfRuns() {
return numberOfRuns;
}
/**
* @return the runAsUserId
*/
public Long getRunAsUserId() {
return runAsUserId;
return new ReportMailingJobData().setId(dataWithoutEnumOptions.id).setName(dataWithoutEnumOptions.name)
.setDescription(dataWithoutEnumOptions.description).setStartDateTime(dataWithoutEnumOptions.startDateTime)
.setRecurrence(dataWithoutEnumOptions.recurrence).setTimeline(dataWithoutEnumOptions.timeline)
.setEmailRecipients(dataWithoutEnumOptions.emailRecipients).setEmailSubject(dataWithoutEnumOptions.emailSubject)
.setEmailMessage(dataWithoutEnumOptions.emailMessage)
.setEmailAttachmentFileFormat(dataWithoutEnumOptions.emailAttachmentFileFormat)
.setStretchyReport(dataWithoutEnumOptions.stretchyReport)
.setStretchyReportParamMap(dataWithoutEnumOptions.stretchyReportParamMap)
.setPreviousRunDateTime(dataWithoutEnumOptions.previousRunDateTime)
.setNextRunDateTime(dataWithoutEnumOptions.nextRunDateTime).setPreviousRunStatus(dataWithoutEnumOptions.previousRunStatus)
.setPreviousRunErrorLog(dataWithoutEnumOptions.previousRunErrorLog)
.setPreviousRunErrorMessage(dataWithoutEnumOptions.previousRunErrorMessage)
.setNumberOfRuns(dataWithoutEnumOptions.numberOfRuns).setActive(dataWithoutEnumOptions.isActive)
.setEmailAttachmentFileFormatOptions(dataWithEnumOptions.emailAttachmentFileFormatOptions)
.setStretchyReportParamDateOptions(dataWithEnumOptions.stretchyReportParamDateOptions)
.setRunAsUserId(dataWithoutEnumOptions.runAsUserId);
}
}
@@ -19,49 +19,21 @@
package org.apache.fineract.infrastructure.reportmailingjob.data;
import java.io.File;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Immutable data object representing report mailing job email data.
**/
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class ReportMailingJobEmailData {
private final String to;
private final String text;
private final String subject;
private final File attachment;
private String to;
private String text;
private String subject;
private File attachment;
public ReportMailingJobEmailData(final String to, final String text, final String subject, final File attachment) {
this.to = to;
this.text = text;
this.subject = subject;
this.attachment = attachment;
}
/**
* @return the to
*/
public String getTo() {
return to;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @return the subject
*/
public String getSubject() {
return subject;
}
/**
* @return the attachment
*/
public File getAttachment() {
return attachment;
}
}
@@ -19,33 +19,25 @@
package org.apache.fineract.infrastructure.reportmailingjob.data;
import java.time.ZonedDateTime;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Immutable data object representing report mailing job run history data.
**/
@Data
@NoArgsConstructor
@Accessors(chain = true)
public final class ReportMailingJobRunHistoryData {
private final Long id;
private final Long reportMailingJobId;
private final ZonedDateTime startDateTime;
private final ZonedDateTime endDateTime;
private final String status;
private final String errorMessage;
private final String errorLog;
/**
* ReportMailingJobRunHistoryData private constructor
**/
private ReportMailingJobRunHistoryData(Long id, Long reportMailingJobId, ZonedDateTime startDateTime, ZonedDateTime endDateTime,
String status, String errorMessage, String errorLog) {
this.id = id;
this.reportMailingJobId = reportMailingJobId;
this.startDateTime = startDateTime;
this.endDateTime = endDateTime;
this.status = status;
this.errorMessage = errorMessage;
this.errorLog = errorLog;
}
private Long id;
private Long reportMailingJobId;
private ZonedDateTime startDateTime;
private ZonedDateTime endDateTime;
private String status;
private String errorMessage;
private String errorLog;
/**
* creates an instance of the ReportMailingJobRunHistoryData class
@@ -54,55 +46,7 @@ public final class ReportMailingJobRunHistoryData {
**/
public static ReportMailingJobRunHistoryData newInstance(Long id, Long reportMailingJobId, ZonedDateTime startDateTime,
ZonedDateTime endDateTime, String status, String errorMessage, String errorLog) {
return new ReportMailingJobRunHistoryData(id, reportMailingJobId, startDateTime, endDateTime, status, errorMessage, errorLog);
}
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @return the reportMailingJobId
*/
public Long getReportMailingJobId() {
return reportMailingJobId;
}
/**
* @return the startDateTime
*/
public ZonedDateTime getStartDateTime() {
return startDateTime;
}
/**
* @return the endDateTime
*/
public ZonedDateTime getEndDateTime() {
return endDateTime;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @return the errorMessage
*/
public String getErrorMessage() {
return errorMessage;
}
/**
* @return the errorLog
*/
public String getErrorLog() {
return errorLog;
return new ReportMailingJobRunHistoryData().setId(id).setReportMailingJobId(reportMailingJobId).setStartDateTime(startDateTime)
.setEndDateTime(endDateTime).setStatus(status).setErrorMessage(errorMessage).setErrorLog(errorLog);
}
}
@@ -19,42 +19,25 @@
package org.apache.fineract.infrastructure.reportmailingjob.data;
import java.time.LocalDate;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* Immutable data object represent the timeline events of a report mailing job (creation)
**/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@SuppressWarnings("unused")
public class ReportMailingJobTimelineData {
private final LocalDate createdOnDate;
private final String createdByUsername;
private final String createdByFirstname;
private final String createdByLastname;
private final LocalDate updatedOnDate;
private final String updatedByUsername;
private final String updatedByFirstname;
private final String updatedByLastname;
/**
* @param createdOnDate
* @param createdByUsername
* @param createdByFirstname
* @param createdByLastname
* @param updatedOnDate
* @param updatedByUsername
* @param updatedByFirstname
* @param updatedByLastname
*/
public ReportMailingJobTimelineData(LocalDate createdOnDate, String createdByUsername, String createdByFirstname,
String createdByLastname, LocalDate updatedOnDate, String updatedByUsername, String updatedByFirstname,
String updatedByLastname) {
this.createdOnDate = createdOnDate;
this.createdByUsername = createdByUsername;
this.createdByFirstname = createdByFirstname;
this.createdByLastname = createdByLastname;
this.updatedOnDate = updatedOnDate;
this.updatedByUsername = updatedByUsername;
this.updatedByFirstname = updatedByFirstname;
this.updatedByLastname = updatedByLastname;
}
private LocalDate createdOnDate;
private String createdByUsername;
private String createdByFirstname;
private String createdByLastname;
private LocalDate updatedOnDate;
private String updatedByUsername;
private String updatedByFirstname;
private String updatedByLastname;
}
@@ -28,6 +28,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
@@ -35,11 +39,14 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.dataqueries.domain.Report;
import org.apache.fineract.infrastructure.reportmailingjob.ReportMailingJobConstants;
import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobEmailAttachmentFileFormat;
import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobPreviousRunStatus;
import org.apache.fineract.useradministration.domain.AppUser;
@Entity
@Table(name = "m_report_mailing_job", uniqueConstraints = { @UniqueConstraint(columnNames = { "name" }, name = "unique_name") })
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ReportMailingJob extends AbstractAuditableCustom {
private static final long serialVersionUID = -2197602941230009227L;
@@ -103,64 +110,6 @@ public class ReportMailingJob extends AbstractAuditableCustom {
@JoinColumn(name = "run_as_userid", nullable = false)
private AppUser runAsUser;
/**
* ReportMailingJob protected constructor
**/
protected ReportMailingJob() {}
/**
* ReportMailingJob private constructor
**/
private ReportMailingJob(final String name, final String description, final LocalDateTime startDateTime, final String recurrence,
final String emailRecipients, final String emailSubject, final String emailMessage,
final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat, final Report stretchyReport,
final String stretchyReportParamMap, final LocalDateTime previousRunDateTime, final LocalDateTime nextRunDateTime,
final ReportMailingJobPreviousRunStatus previousRunStatus, final String previousRunErrorLog,
final String previousRunErrorMessage, final boolean isActive, final boolean isDeleted, final AppUser runAsUser) {
this.name = name;
this.description = description;
this.startDateTime = null;
if (startDateTime != null) {
this.startDateTime = startDateTime;
}
this.recurrence = recurrence;
this.emailRecipients = emailRecipients;
this.emailSubject = emailSubject;
this.emailMessage = emailMessage;
this.emailAttachmentFileFormat = emailAttachmentFileFormat.getValue();
this.stretchyReport = stretchyReport;
this.stretchyReportParamMap = stretchyReportParamMap;
this.previousRunDateTime = null;
if (previousRunDateTime != null) {
this.previousRunDateTime = previousRunDateTime;
}
this.nextRunDateTime = null;
if (nextRunDateTime != null) {
this.nextRunDateTime = nextRunDateTime;
}
this.previousRunStatus = null;
if (previousRunStatus != null) {
this.previousRunStatus = previousRunStatus.getValue();
}
if (numberOfRuns == null) {
this.numberOfRuns = 0;
}
this.previousRunErrorLog = previousRunErrorLog;
this.previousRunErrorMessage = previousRunErrorMessage;
this.isActive = isActive;
this.isDeleted = isDeleted;
this.runAsUser = runAsUser;
}
/**
* create a new instance of the ReportMailingJob for a new entry
*
@@ -170,9 +119,10 @@ public class ReportMailingJob extends AbstractAuditableCustom {
final String recurrence, final String emailRecipients, final String emailSubject, final String emailMessage,
final ReportMailingJobEmailAttachmentFileFormat emailAttachmentFileFormat, final Report stretchyReport,
final String stretchyReportParamMap, final boolean isActive, final AppUser runAsUser) {
return new ReportMailingJob(name, description, startDateTime, recurrence, emailRecipients, emailSubject, emailMessage,
emailAttachmentFileFormat, stretchyReport, stretchyReportParamMap, null, null, null, null, null, isActive, false,
runAsUser);
return new ReportMailingJob().setName(name).setDescription(description).setStartDateTime(startDateTime).setRecurrence(recurrence)
.setEmailRecipients(emailRecipients).setEmailSubject(emailSubject).setEmailMessage(emailMessage)
.setEmailAttachmentFileFormat(emailAttachmentFileFormat.getValue()).setStretchyReport(stretchyReport)
.setStretchyReportParamMap(stretchyReportParamMap).setActive(isActive).setDeleted(false).setRunAsUser(runAsUser);
}
/**
@@ -207,9 +157,11 @@ public class ReportMailingJob extends AbstractAuditableCustom {
}
}
return new ReportMailingJob(name, description, startDateTime, recurrence, emailRecipients, emailSubject, emailMessage,
emailAttachmentFileFormat, stretchyReport, stretchyReportParamMap, null, startDateTime, null, null, null, isActive, false,
runAsUser);
return new ReportMailingJob().setName(name).setDescription(description).setStartDateTime(startDateTime).setRecurrence(recurrence)
.setEmailRecipients(emailRecipients).setEmailSubject(emailSubject).setEmailMessage(emailMessage)
.setEmailAttachmentFileFormat(emailAttachmentFileFormat.getValue()).setStretchyReport(stretchyReport)
.setStretchyReportParamMap(stretchyReportParamMap).setNextRunDateTime(startDateTime).setActive(isActive).setDeleted(false)
.setRunAsUser(runAsUser);
}
/**
@@ -324,19 +276,6 @@ public class ReportMailingJob extends AbstractAuditableCustom {
return actualChanges;
}
/**
* update the stretchy report entity associated with the credit check
*
* @param stretchyReport
* -- Report entity
*
**/
public void update(final Report stretchyReport) {
if (stretchyReport != null) {
this.stretchyReport = stretchyReport;
}
}
/**
* delete the report mailing job, set the isDeleted property to 1 and alter the name
*
@@ -348,153 +287,6 @@ public class ReportMailingJob extends AbstractAuditableCustom {
this.name = this.name + "_deleted_" + this.getId();
}
/**
* @return the value of the name property
**/
public String getName() {
return this.name;
}
/**
* @return the value of the description property
**/
public String getDescription() {
return this.description;
}
/**
* @return the value of the startDateTime property
**/
public LocalDateTime getStartDateTime() {
return this.startDateTime;
}
/**
* @return the value of the recurrence property
**/
public String getRecurrence() {
return this.recurrence;
}
/**
* @return value of the isDeleted property
**/
public boolean isDeleted() {
return this.isDeleted;
}
/**
* @return boolean true if isDeleted property equals 0, else false
**/
public boolean isNotDeleted() {
return !this.isDeleted;
}
/**
* @return the value of the isActive property
**/
public boolean isActive() {
return this.isActive;
}
/**
* @return boolean true if isActive property equals 0, else false
**/
public boolean isNotActive() {
return !this.isActive;
}
/**
* @return the emailRecipients
*/
public String getEmailRecipients() {
return emailRecipients;
}
/**
* @return the emailSubject
*/
public String getEmailSubject() {
return emailSubject;
}
/**
* @return the emailMessage
*/
public String getEmailMessage() {
return emailMessage;
}
/**
* @return the emailAttachmentFileFormat
*/
public String getEmailAttachmentFileFormat() {
return emailAttachmentFileFormat;
}
/**
* @return the stretchyReport
*/
public Report getStretchyReport() {
return stretchyReport;
}
/**
* @return the stretchyReportParamMap
*/
public String getStretchyReportParamMap() {
return stretchyReportParamMap;
}
/**
* @return the previousRunDateTime
*/
public LocalDateTime getPreviousRunDateTime() {
return this.previousRunDateTime;
}
/**
* @return the nextRunDateTime
*/
public LocalDateTime getNextRunDateTime() {
return this.nextRunDateTime;
}
/**
* @return the previousRunStatus
*/
public String getPreviousRunStatus() {
return previousRunStatus;
}
/**
* @return the previousRunErrorLog
*/
public String getPreviousRunErrorLog() {
return previousRunErrorLog;
}
/**
* @return the previousRunErrorMessage
*/
public String getPreviousRunErrorMessage() {
return previousRunErrorMessage;
}
/**
* @return the numberOfRuns
*/
public Integer getNumberOfRuns() {
return numberOfRuns;
}
/**
* @return the runAsUser
*/
public AppUser getRunAsUser() {
return runAsUser;
}
/**
* increase the numberOfRuns by 1
*
@@ -504,66 +296,4 @@ public class ReportMailingJob extends AbstractAuditableCustom {
this.numberOfRuns++;
}
/**
* update the previousRunStatus
*
* @param previousRunStatus
* -- the status of the previous job execution
*
**/
public void updatePreviousRunStatus(final String previousRunStatus) {
if (!StringUtils.isEmpty(previousRunStatus)) {
this.previousRunStatus = previousRunStatus;
}
}
/**
* update the previousRunDateTime
*
* @param previousRunDateTime
* -- previous run date
*
**/
public void updatePreviousRunDateTime(final LocalDateTime previousRunDateTime) {
if (previousRunDateTime != null) {
this.previousRunDateTime = previousRunDateTime;
}
}
/**
* update the nextRunDateTime
*
* @param nextRunDateTime
* -- the next run DateTime
*
**/
public void updateNextRunDateTime(final LocalDateTime nextRunDateTime) {
if (nextRunDateTime != null) {
this.nextRunDateTime = nextRunDateTime;
}
else {
this.nextRunDateTime = null;
}
}
/**
* deactivate the report mailing job by setting the isActive property to 0
*
*
**/
public void deactivate() {
this.isActive = false;
}
/**
* update the previousRunErrorLog property
*
* @param previousRunErrorLog
* -- the previous job run error log
*
**/
public void updatePreviousRunErrorLog(final String previousRunErrorLog) {
this.previousRunErrorLog = previousRunErrorLog;
}
}
@@ -22,11 +22,19 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity
@Table(name = "m_report_mailing_job_configuration", uniqueConstraints = {
@UniqueConstraint(columnNames = { "name" }, name = "unique_name") })
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ReportMailingJobConfiguration extends AbstractPersistableCustom {
private static final long serialVersionUID = 3099279770861263184L;
@@ -37,39 +45,12 @@ public class ReportMailingJobConfiguration extends AbstractPersistableCustom {
@Column(name = "value", nullable = false)
private String value;
/**
* ReportMailingJobConfiguration protected constructor
**/
protected ReportMailingJobConfiguration() {}
/**
* ReportMailingJobConfiguration private constructor
**/
private ReportMailingJobConfiguration(final String name, final String value) {
this.name = name;
this.value = value;
}
/**
* creates an instance of the ReportMailingJobConfiguration class
*
* @return ReportMailingJobConfiguration object
**/
public static ReportMailingJobConfiguration newInstance(final String name, final String value) {
return new ReportMailingJobConfiguration(name, value);
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the value
*/
public String getValue() {
return value;
return new ReportMailingJobConfiguration().setName(name).setValue(value);
}
}
@@ -24,10 +24,18 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity
@Table(name = "m_report_mailing_job_run_history")
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
private static final long serialVersionUID = -3757370929988421076L;
@@ -51,34 +59,6 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
@Column(name = "error_log", nullable = false)
private String errorLog;
/**
* ReportMailingJobRunHistory protected constructor
**/
protected ReportMailingJobRunHistory() {}
/**
* ReportMailingJobRunHistory private constructor
**/
private ReportMailingJobRunHistory(final ReportMailingJob reportMailingJob, final LocalDateTime startDateTime,
final LocalDateTime endDateTime, final String status, final String errorMessage, final String errorLog) {
this.reportMailingJob = reportMailingJob;
this.startDateTime = null;
if (startDateTime != null) {
this.startDateTime = startDateTime;
}
this.endDateTime = null;
if (endDateTime != null) {
this.endDateTime = endDateTime;
}
this.status = status;
this.errorMessage = errorMessage;
this.errorLog = errorLog;
}
/**
* Creates an instance of the ReportMailingJobRunHistory class
*
@@ -86,48 +66,7 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
**/
public static ReportMailingJobRunHistory newInstance(final ReportMailingJob reportMailingJob, final LocalDateTime startDateTime,
final LocalDateTime endDateTime, final String status, final String errorMessage, final String errorLog) {
return new ReportMailingJobRunHistory(reportMailingJob, startDateTime, endDateTime, status, errorMessage, errorLog);
}
/**
* @return the reportMailingJobId
*/
public ReportMailingJob getReportMailingJob() {
return this.reportMailingJob;
}
/**
* @return the startDateTime
*/
public LocalDateTime getStartDateTime() {
return this.startDateTime;
}
/**
* @return the endDateTime
*/
public LocalDateTime getEndDateTime() {
return this.endDateTime;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @return the errorMessage
*/
public String getErrorMessage() {
return errorMessage;
}
/**
* @return the errorLog
*/
public String getErrorLog() {
return errorLog;
return new ReportMailingJobRunHistory().setReportMailingJob(reportMailingJob).setStartDateTime(startDateTime)
.setEndDateTime(endDateTime).setStatus(status).setErrorMessage(errorMessage).setErrorLog(errorLog);
}
}
@@ -181,8 +181,10 @@ public class ReportMailingJobReadPlatformServiceImpl implements ReportMailingJob
final String updatedByUsername = rs.getString("updatedByUsername");
final String updatedByFirstname = rs.getString("updatedByFirstname");
final String updatedByLastname = rs.getString("updatedByLastname");
final ReportMailingJobTimelineData timeline = new ReportMailingJobTimelineData(createdOnDate, createdByUsername,
createdByFirstname, createdByLastname, updatedOnDate, updatedByUsername, updatedByFirstname, updatedByLastname);
final ReportMailingJobTimelineData timeline = new ReportMailingJobTimelineData().setCreatedOnDate(createdOnDate)
.setCreatedByUsername(createdByUsername).setCreatedByFirstname(createdByFirstname)
.setCreatedByLastname(createdByLastname).setUpdatedOnDate(updatedOnDate).setUpdatedByUsername(updatedByUsername)
.setUpdatedByFirstname(updatedByFirstname).setUpdatedByLastname(updatedByLastname);
final Long runAsUserId = JdbcSupport.getLong(rs, "runAsUserId");
final Long reportId = JdbcSupport.getLong(rs, "reportId");
@@ -123,7 +123,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
final Report stretchyReport = this.reportRepositoryWrapper.findOneThrowExceptionIfNotFound(stretchyReportId);
// update the stretchy report
reportMailingJob.update(stretchyReport);
reportMailingJob.setStretchyReport(stretchyReport);
}
// check if the recurrence was updated
@@ -146,13 +146,13 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
final LocalDateTime nextRecurringDateTime = this.createNextRecurringDateTime(recurrence, startDateTime);
// update the next run time property
reportMailingJob.updateNextRunDateTime(nextRecurringDateTime);
reportMailingJob.setNextRunDateTime(nextRecurringDateTime);
// check if the next run LocalDateTime is not empty and the
// recurrence is empty
} else if (StringUtils.isBlank(recurrence) && (nextRunDateTime != null)) {
// the next run LocalDateTime should be set to null
reportMailingJob.updateNextRunDateTime(null);
reportMailingJob.setNextRunDateTime(null);
}
}
@@ -170,7 +170,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
}
// update the next run time property
reportMailingJob.updateNextRunDateTime(nextRecurringDateTime);
reportMailingJob.setNextRunDateTime(nextRecurringDateTime);
}
if (!changes.isEmpty()) {