Skip to content

Commit

Permalink
FINERACT-2103: refactor boilerplate code under portfolio package us…
Browse files Browse the repository at this point in the history
…ing Lombok annotations.
  • Loading branch information
Zeyad2003 authored and adamsaghy committed Jul 4, 2024
1 parent 0358921 commit f5add87
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collection;
import lombok.Builder;
import lombok.Getter;
import org.apache.fineract.infrastructure.codes.data.CodeValueData;

@Getter
@Builder
public final class ClientFamilyMembersData implements Serializable {

private final Long id;
Expand Down Expand Up @@ -68,124 +72,4 @@ public final class ClientFamilyMembersData implements Serializable {
private final Collection<CodeValueData> maritalStatusIdOptions;
private final Collection<CodeValueData> professionIdOptions;

private ClientFamilyMembersData(final Long id, final Long clientId, final String firstName, final String middleName,
final String lastName, final String qualification, final String mobileNumber, final Long age, final Boolean isDependent,
final String relationship, final Long relationshipId, final String maritalStatus, final Long maritalStatusId,
final String gender, final Long genderId, final LocalDate dateOfBirth, final String profession, final Long professionId,
final Collection<CodeValueData> relationshipIdOptions, final Collection<CodeValueData> genderIdOptions,
final Collection<CodeValueData> maritalStatusIdOptions, final Collection<CodeValueData> professionIdOptions) {
this.id = id;
this.clientId = clientId;
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.qualification = qualification;
this.relationship = relationship;
this.relationshipId = relationshipId;
this.maritalStatus = maritalStatus;
this.maritalStatusId = maritalStatusId;
this.gender = gender;
this.genderId = genderId;
this.dateOfBirth = dateOfBirth;
this.profession = profession;
this.professionId = professionId;
this.mobileNumber = mobileNumber;
this.age = age;
this.isDependent = isDependent;
this.relationshipIdOptions = relationshipIdOptions;
this.genderIdOptions = genderIdOptions;
this.maritalStatusIdOptions = maritalStatusIdOptions;
this.professionIdOptions = professionIdOptions;

}

public static ClientFamilyMembersData instance(final Long id, final Long clientId, final String firstName, final String middleName,
final String lastName, final String qualification, final String mobileNumber, final Long age, final Boolean isDependent,
final String relationship, final Long relationshipId, final String maritalStatus, final Long maritalStatusId,
final String gender, final Long genderId, final LocalDate dateOfBirth, final String profession, final Long professionId) {
return new ClientFamilyMembersData(id, clientId, firstName, middleName, lastName, qualification, mobileNumber, age, isDependent,
relationship, relationshipId, maritalStatus, maritalStatusId, gender, genderId, dateOfBirth, profession, professionId, null,
null, null, null);
}

public static ClientFamilyMembersData templateInstance(final Collection<CodeValueData> relationshipIdOptions,
final Collection<CodeValueData> genderIdOptions, final Collection<CodeValueData> maritalStatusIdOptions,
final Collection<CodeValueData> professionIdOptions) {

return new ClientFamilyMembersData(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, relationshipIdOptions, genderIdOptions, maritalStatusIdOptions, professionIdOptions);
}

public Long getId() {
return this.id;
}

public Long getClientId() {
return this.clientId;
}

public String getFirstName() {
return this.firstName;
}

public String getMiddleName() {
return this.middleName;
}

public String getLastName() {
return this.lastName;
}

public String getQualification() {
return this.qualification;
}

public Long getRelationshipId() {
return this.relationshipId;
}

public String getRelationship() {
return this.relationship;
}

public Long getMaritalStatusId() {
return this.maritalStatusId;
}

public String getMaritalStatus() {
return this.maritalStatus;
}

public Long getGenderId() {
return this.genderId;
}

public String getGender() {
return this.gender;
}

public LocalDate getDateOfBirth() {
return this.dateOfBirth;
}

public Long getProfessionId() {
return this.professionId;
}

public String getProfession() {
return this.profession;
}

public String getMobileNumber() {
return this.mobileNumber;
}

public Long getAge() {
return this.age;
}

public Boolean getIsDependent() {
return this.isDependent;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

import java.io.Serializable;
import java.time.LocalDate;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* Immutable data object represent the important time-line events of a loan application and loan.
*/
@SuppressWarnings("unused")
@Getter
@AllArgsConstructor
public class ClientTimelineData implements Serializable {

private final LocalDate submittedOnDate;
Expand All @@ -43,26 +45,4 @@ public class ClientTimelineData implements Serializable {
private final String closedByUsername;
private final String closedByFirstname;
private final String closedByLastname;

public ClientTimelineData(final LocalDate submittedOnDate, final String submittedByUsername, final String submittedByFirstname,
final String submittedByLastname, final LocalDate activatedOnDate, final String activatedByUsername,
final String activatedByFirstname, final String activatedByLastname, final LocalDate closedOnDate,
final String closedByUsername, final String closedByFirstname, final String closedByLastname) {
this.submittedOnDate = submittedOnDate;
this.submittedByUsername = submittedByUsername;
this.submittedByFirstname = submittedByFirstname;
this.submittedByLastname = submittedByLastname;

this.activatedOnDate = activatedOnDate;
this.activatedByUsername = activatedByUsername;
this.activatedByFirstname = activatedByFirstname;
this.activatedByLastname = activatedByLastname;

this.closedOnDate = closedOnDate;
this.closedByUsername = closedByUsername;
this.closedByFirstname = closedByFirstname;
this.closedByLastname = closedByLastname;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
package org.apache.fineract.portfolio.note.data;

import java.time.OffsetDateTime;
import lombok.Builder;
import lombok.Getter;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;

/**
* Immutable data object represent note or case information about a client, loan or loan transaction.
*/
@Getter
@Builder
public class NoteData {

private final Long id;
Expand All @@ -43,25 +45,4 @@ public class NoteData {
private final Long updatedById;
private final String updatedByUsername;
private final OffsetDateTime updatedOn;

public NoteData(final Long id, final Long clientId, final Long groupId, final Long loanId, final Long transactionId,
final Long depositAccountId, final Long savingAccountId, final EnumOptionData noteType, final String note,
final OffsetDateTime createdDate, final Long createdById, final String createdByUsername, final OffsetDateTime lastModifiedDate,
final Long lastModifiedById, final String updatedByUsername) {
this.id = id;
this.clientId = clientId;
this.groupId = groupId;
this.loanId = loanId;
this.loanTransactionId = transactionId;
this.depositAccountId = depositAccountId;
this.savingAccountId = savingAccountId;
this.noteType = noteType;
this.note = note;
this.createdOn = createdDate;
this.createdById = createdById;
this.createdByUsername = createdByUsername;
this.updatedOn = lastModifiedDate;
this.updatedById = lastModifiedById;
this.updatedByUsername = updatedByUsername;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public JournalEntryData mapRow(final ResultSet rs, @SuppressWarnings("unused") f
final Long noteId = JdbcSupport.getLong(rs, "noteId");
if (noteId != null) {
final String note = rs.getString("transactionNote");
noteData = new NoteData(noteId, null, null, null, null, null, null, null, note, null, null, null, null, null, null);
noteData = NoteData.builder().id(noteId).note(note).build();
}
Long transaction = null;
if (entityType != null && transactionId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public ClientFamilyMembersData mapRow(final ResultSet rs, @SuppressWarnings("unu
final String profession = rs.getString("profession");
final long professionId = rs.getLong("professionId");

return ClientFamilyMembersData.instance(id, clientId, firstName, middleName, lastName, qualification, mobileNumber, age,
isDependent, relationship, relationshipId, maritalStatus, maritalStatusId, gender, genderId, dateOfBirth, profession,
professionId);

return ClientFamilyMembersData.builder().id(id).clientId(clientId).firstName(firstName).middleName(middleName)
.lastName(lastName).qualification(qualification).mobileNumber(mobileNumber).age(age).isDependent(isDependent)
.relationship(relationship).relationshipId(relationshipId).maritalStatus(maritalStatus).maritalStatusId(maritalStatusId)
.gender(gender).genderId(genderId).dateOfBirth(dateOfBirth).profession(profession).professionId(professionId).build();
}
}

Expand Down Expand Up @@ -126,7 +126,8 @@ public ClientFamilyMembersData retrieveTemplate() {
final List<CodeValueData> professionOptions = new ArrayList<>(
this.codeValueReadPlatformService.retrieveCodeValuesByCode("PROFESSION"));

return ClientFamilyMembersData.templateInstance(relationshipOptions, genderOptions, maritalStatusOptions, professionOptions);
return ClientFamilyMembersData.builder().relationshipIdOptions(relationshipOptions).genderIdOptions(genderOptions)
.maritalStatusIdOptions(maritalStatusOptions).professionIdOptions(professionOptions).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ public NoteData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int
final String updatedByUsername = rs.getString("modifiedBy");
final OffsetDateTime createdDate = createdDateUtc != null ? createdDateUtc : createdDateLocal;
final OffsetDateTime lastModifiedDate = lastModifiedDateUtc != null ? lastModifiedDateUtc : lastModifiedDateLocal;
return new NoteData(id, clientId, groupId, loanId, transactionId, null, null, noteType, note, createdDate, createdById,
createdByUsername, lastModifiedDate, lastModifiedById, updatedByUsername);

return NoteData.builder().id(id).clientId(clientId).groupId(groupId).loanId(loanId).loanTransactionId(transactionId)
.noteType(noteType).note(note).createdOn(createdDate).createdById(createdById).createdByUsername(createdByUsername)
.updatedOn(lastModifiedDate).updatedById(lastModifiedById).updatedByUsername(updatedByUsername).build();
}
}

Expand Down

0 comments on commit f5add87

Please sign in to comment.