/** * CBS Nexora — India Address Domain Object * Package: org.apache.fineract.portfolio.client.domain */ package org.apache.fineract.portfolio.client.domain; import jakarta.persistence.*; import java.time.LocalDateTime; @Entity @Table(name = "m_client_address_india", uniqueConstraints = { @UniqueConstraint(columnNames = { "client_id", "address_type" }) }) public class ClientAddressIndia { public enum AddressType { PERMANENT, CURRENT, OFFICE, CORRESPONDENCE } @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "client_id", nullable = false) private Client client; @Enumerated(EnumType.STRING) @Column(name = "address_type", nullable = false, length = 20) private AddressType addressType; @Column(name = "address_line_1", length = 500) private String addressLine1; @Column(name = "address_line_2", length = 500) private String addressLine2; @Column(name = "pin_code", length = 6) private String pinCode; @Column(name = "locality", length = 200) private String locality; @Column(name = "city", length = 200) private String city; @Column(name = "district", length = 200) private String district; @Column(name = "state", length = 200) private String state; @Column(name = "country", length = 100) private String country = "India"; @Column(name = "landmark", length = 300) private String landmark; // Permanent-specific @Column(name = "proof_type", length = 100) private String proofType; @Column(name = "proof_doc_number", length = 100) private String proofDocNumber; // Current-specific @Column(name = "residence_type", length = 50) private String residenceType; @Column(name = "years_at_address") private Integer yearsAtAddress; @Column(name = "same_as_permanent") private Boolean sameAsPermanent = false; // Office-specific @Column(name = "org_name", length = 300) private String orgName; @Column(name = "department", length = 200) private String department; @Column(name = "office_phone", length = 20) private String officePhone; @Column(name = "employment_type", length = 100) private String employmentType; @Column(name = "employee_id", length = 50) private String employeeId; @Column(name = "years_with_org") private Integer yearsWithOrg; // Correspondence-specific @Column(name = "comm_mode", length = 50) private String commMode; @Column(name = "contact_number", length = 20) private String contactNumber; // Audit @Column(name = "created_date", updatable = false) private LocalDateTime createdDate = LocalDateTime.now(); @Column(name = "last_modified_date") private LocalDateTime lastModifiedDate = LocalDateTime.now(); protected ClientAddressIndia() {} public static ClientAddressIndia create(Client client, AddressType type) { ClientAddressIndia addr = new ClientAddressIndia(); addr.client = client; addr.addressType = type; return addr; } public void update(java.util.Map data) { if (data.containsKey("addressLine1")) this.addressLine1 = (String) data.get("addressLine1"); if (data.containsKey("addressLine2")) this.addressLine2 = (String) data.get("addressLine2"); if (data.containsKey("pinCode")) this.pinCode = (String) data.get("pinCode"); if (data.containsKey("locality")) this.locality = (String) data.get("locality"); if (data.containsKey("city")) this.city = (String) data.get("city"); if (data.containsKey("district")) this.district = (String) data.get("district"); if (data.containsKey("state")) this.state = (String) data.get("state"); if (data.containsKey("country")) this.country = (String) data.get("country"); if (data.containsKey("landmark")) this.landmark = (String) data.get("landmark"); if (data.containsKey("proofType")) this.proofType = (String) data.get("proofType"); if (data.containsKey("proofDocNumber")) this.proofDocNumber = (String) data.get("proofDocNumber"); if (data.containsKey("residenceType")) this.residenceType = (String) data.get("residenceType"); if (data.containsKey("yearsAtAddress")) this.yearsAtAddress = toInt(data.get("yearsAtAddress")); if (data.containsKey("sameAsPermanent")) this.sameAsPermanent = (Boolean) data.get("sameAsPermanent"); if (data.containsKey("orgName")) this.orgName = (String) data.get("orgName"); if (data.containsKey("department")) this.department = (String) data.get("department"); if (data.containsKey("officePhone")) this.officePhone = (String) data.get("officePhone"); if (data.containsKey("employmentType")) this.employmentType = (String) data.get("employmentType"); if (data.containsKey("employeeId")) this.employeeId = (String) data.get("employeeId"); if (data.containsKey("yearsWithOrg")) this.yearsWithOrg = toInt(data.get("yearsWithOrg")); if (data.containsKey("commMode")) this.commMode = (String) data.get("commMode"); if (data.containsKey("contactNumber")) this.contactNumber = (String) data.get("contactNumber"); this.lastModifiedDate = LocalDateTime.now(); } private Integer toInt(Object val) { if (val == null) return null; if (val instanceof Integer) return (Integer) val; return Integer.parseInt(val.toString()); } // Getters public Long getId() { return id; } public Client getClient() { return client; } public AddressType getAddressType() { return addressType; } public String getAddressLine1() { return addressLine1; } public String getAddressLine2() { return addressLine2; } public String getPinCode() { return pinCode; } public String getLocality() { return locality; } public String getCity() { return city; } public String getDistrict() { return district; } public String getState() { return state; } public String getCountry() { return country; } public String getLandmark() { return landmark; } public String getProofType() { return proofType; } public String getResidenceType() { return residenceType; } public Boolean getSameAsPermanent() { return sameAsPermanent; } public String getOrgName() { return orgName; } public String getEmploymentType() { return employmentType; } public String getCommMode() { return commMode; } }