refactor(client): reformat ClientMapper.java
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
73db4ee114
commit
cfcd24efad
+281
-276
@@ -1,276 +1,281 @@
|
|||||||
/**
|
/**
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
* to you under the Apache License, Version 2.0 (the
|
* to you under the Apache License, Version 2.0 (the
|
||||||
* "License"); you may not use this file except in compliance
|
* "License"); you may not use this file except in compliance
|
||||||
* with the License. You may obtain a copy of the License at
|
* with the License. You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.client.mapper;
|
package org.apache.fineract.portfolio.client.mapper;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.Period;
|
import java.time.Period;
|
||||||
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
|
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
|
||||||
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
|
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
|
||||||
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
||||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||||
import org.apache.fineract.portfolio.client.data.ClientTimelineData;
|
import org.apache.fineract.portfolio.client.data.ClientTimelineData;
|
||||||
import org.apache.fineract.portfolio.client.domain.Client;
|
import org.apache.fineract.portfolio.client.domain.Client;
|
||||||
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
|
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.MappingTarget;
|
import org.mapstruct.MappingTarget;
|
||||||
import org.mapstruct.Named;
|
import org.mapstruct.Named;
|
||||||
|
|
||||||
@Mapper(config = MapstructMapperConfig.class)
|
@Mapper(config = MapstructMapperConfig.class)
|
||||||
public interface ClientMapper {
|
public interface ClientMapper {
|
||||||
|
|
||||||
@Mapping(target = "accountNo", source = "accountNumber")
|
@Mapping(target = "accountNo", source = "accountNumber")
|
||||||
@Mapping(target = "status", source = "source", qualifiedByName = "clientStatusEnum")
|
@Mapping(target = "status", source = "source", qualifiedByName = "clientStatusEnum")
|
||||||
@Mapping(target = "subStatus", source = "source", qualifiedByName = "clientSubStatusCode")
|
@Mapping(target = "subStatus", source = "source", qualifiedByName = "clientSubStatusCode")
|
||||||
@Mapping(target = "officeId", source = "office.id")
|
@Mapping(target = "officeId", source = "office.id")
|
||||||
@Mapping(target = "officeName", source = "office.name")
|
@Mapping(target = "officeName", source = "office.name")
|
||||||
@Mapping(target = "transferToOfficeId", source = "transferToOffice.id")
|
@Mapping(target = "transferToOfficeId", source = "transferToOffice.id")
|
||||||
@Mapping(target = "transferToOfficeName", source = "transferToOffice.name")
|
@Mapping(target = "transferToOfficeName", source = "transferToOffice.name")
|
||||||
@Mapping(target = "externalId", source = "externalId")
|
@Mapping(target = "externalId", source = "externalId")
|
||||||
@Mapping(target = "gender", source = "source", qualifiedByName = "clientGenderCode")
|
@Mapping(target = "gender", source = "source", qualifiedByName = "clientGenderCode")
|
||||||
@Mapping(target = "salutation", source = "source", qualifiedByName = "salutationCode")
|
@Mapping(target = "salutation", source = "source", qualifiedByName = "salutationCode")
|
||||||
@Mapping(target = "salutationOptions", ignore = true)
|
@Mapping(target = "salutationOptions", ignore = true)
|
||||||
@Mapping(target = "imageId", source = "imageId")
|
@Mapping(target = "imageId", source = "imageId")
|
||||||
@Mapping(target = "staffId", source = "staff.id")
|
@Mapping(target = "staffId", source = "staff.id")
|
||||||
@Mapping(target = "staffName", source = "staff.displayName")
|
@Mapping(target = "staffName", source = "staff.displayName")
|
||||||
@Mapping(target = "timeline", source = "source", qualifiedByName = "clientTimelineData")
|
@Mapping(target = "timeline", source = "source", qualifiedByName = "clientTimelineData")
|
||||||
@Mapping(target = "savingsProductId", source = "savingsProductId")
|
@Mapping(target = "savingsProductId", source = "savingsProductId")
|
||||||
@Mapping(target = "savingsProductName", source = "id")
|
@Mapping(target = "savingsProductName", source = "id")
|
||||||
@Mapping(target = "savingsAccountId", source = "savingsAccountId")
|
@Mapping(target = "savingsAccountId", source = "savingsAccountId")
|
||||||
@Mapping(target = "clientType", source = "source", qualifiedByName = "clientTypeCode")
|
@Mapping(target = "clientType", source = "source", qualifiedByName = "clientTypeCode")
|
||||||
@Mapping(target = "clientClassification", source = "source", qualifiedByName = "clientClassificationCode")
|
@Mapping(target = "clientClassification", source = "source", qualifiedByName = "clientClassificationCode")
|
||||||
@Mapping(target = "occupationCategory", source = "source", qualifiedByName = "occupationCategoryCode")
|
@Mapping(target = "occupationCategory", source = "source", qualifiedByName = "occupationCategoryCode")
|
||||||
@Mapping(target = "occupation", source = "source", qualifiedByName = "occupationCode")
|
@Mapping(target = "occupation", source = "source", qualifiedByName = "occupationCode")
|
||||||
@Mapping(target = "maritalStatus", source = "source", qualifiedByName = "maritalStatusCode")
|
@Mapping(target = "maritalStatus", source = "source", qualifiedByName = "maritalStatusCode")
|
||||||
@Mapping(target = "educationLevel", source = "source", qualifiedByName = "educationLevelCode")
|
@Mapping(target = "educationLevel", source = "source", qualifiedByName = "educationLevelCode")
|
||||||
@Mapping(target = "degreeQualification", source = "source", qualifiedByName = "degreeQualificationCode")
|
@Mapping(target = "degreeQualification", source = "source", qualifiedByName = "degreeQualificationCode")
|
||||||
@Mapping(target = "religion", source = "source", qualifiedByName = "religionCode")
|
@Mapping(target = "religion", source = "source", qualifiedByName = "religionCode")
|
||||||
@Mapping(target = "socialCategory", source = "source", qualifiedByName = "socialCategoryCode")
|
@Mapping(target = "socialCategory", source = "source", qualifiedByName = "socialCategoryCode")
|
||||||
@Mapping(target = "occupationCategoryOptions", ignore = true)
|
@Mapping(target = "occupationCategoryOptions", ignore = true)
|
||||||
@Mapping(target = "occupationOptions", ignore = true)
|
@Mapping(target = "occupationOptions", ignore = true)
|
||||||
@Mapping(target = "educationLevelOptions", ignore = true)
|
@Mapping(target = "educationLevelOptions", ignore = true)
|
||||||
@Mapping(target = "degreeQualificationOptions", ignore = true)
|
@Mapping(target = "degreeQualificationOptions", ignore = true)
|
||||||
@Mapping(target = "religionOptions", ignore = true)
|
@Mapping(target = "religionOptions", ignore = true)
|
||||||
@Mapping(target = "socialCategoryOptions", ignore = true)
|
@Mapping(target = "socialCategoryOptions", ignore = true)
|
||||||
@Mapping(target = "legalForm", source = "source", qualifiedByName = "clientLegalFormEnum")
|
@Mapping(target = "legalForm", source = "source", qualifiedByName = "clientLegalFormEnum")
|
||||||
@Mapping(target = "isStaff", source = "source", qualifiedByName = "clientIsStaff")
|
@Mapping(target = "isStaff", source = "source", qualifiedByName = "clientIsStaff")
|
||||||
@Mapping(target = "ageYears", ignore = true)
|
@Mapping(target = "ageYears", ignore = true)
|
||||||
@Mapping(target = "ageMonths", ignore = true)
|
@Mapping(target = "ageMonths", ignore = true)
|
||||||
@Mapping(target = "ageDays", ignore = true)
|
@Mapping(target = "ageDays", ignore = true)
|
||||||
@Mapping(target = "guardianClientId", source = "source", qualifiedByName = "guardianClientIdValue")
|
@Mapping(target = "guardianClientId", source = "source", qualifiedByName = "guardianClientIdValue")
|
||||||
@Mapping(target = "guardianClientDisplayName", source = "source", qualifiedByName = "guardianClientDisplayNameValue")
|
@Mapping(target = "guardianClientDisplayName", source = "source", qualifiedByName = "guardianClientDisplayNameValue")
|
||||||
@Mapping(target = "imagePresent", ignore = true)
|
@Mapping(target = "imagePresent", ignore = true)
|
||||||
@Mapping(target = "officeOptions", ignore = true)
|
@Mapping(target = "officeOptions", ignore = true)
|
||||||
@Mapping(target = "staffOptions", ignore = true)
|
@Mapping(target = "staffOptions", ignore = true)
|
||||||
@Mapping(target = "narrations", ignore = true)
|
@Mapping(target = "narrations", ignore = true)
|
||||||
@Mapping(target = "savingProductOptions", ignore = true)
|
@Mapping(target = "savingProductOptions", ignore = true)
|
||||||
@Mapping(target = "savingAccountOptions", ignore = true)
|
@Mapping(target = "savingAccountOptions", ignore = true)
|
||||||
@Mapping(target = "genderOptions", ignore = true)
|
@Mapping(target = "genderOptions", ignore = true)
|
||||||
@Mapping(target = "clientTypeOptions", ignore = true)
|
@Mapping(target = "clientTypeOptions", ignore = true)
|
||||||
@Mapping(target = "clientClassificationOptions", ignore = true)
|
@Mapping(target = "clientClassificationOptions", ignore = true)
|
||||||
@Mapping(target = "clientNonPersonConstitutionOptions", ignore = true)
|
@Mapping(target = "clientNonPersonConstitutionOptions", ignore = true)
|
||||||
@Mapping(target = "clientNonPersonMainBusinessLineOptions", ignore = true)
|
@Mapping(target = "clientNonPersonMainBusinessLineOptions", ignore = true)
|
||||||
@Mapping(target = "clientLegalFormOptions", ignore = true)
|
@Mapping(target = "clientLegalFormOptions", ignore = true)
|
||||||
@Mapping(target = "familyMemberOptions", ignore = true)
|
@Mapping(target = "familyMemberOptions", ignore = true)
|
||||||
@Mapping(target = "clientNonPersonDetails", ignore = true)
|
@Mapping(target = "clientNonPersonDetails", ignore = true)
|
||||||
@Mapping(target = "address", ignore = true)
|
@Mapping(target = "address", ignore = true)
|
||||||
@Mapping(target = "isAddressEnabled", ignore = true)
|
@Mapping(target = "isAddressEnabled", ignore = true)
|
||||||
@Mapping(target = "datatables", ignore = true)
|
@Mapping(target = "datatables", ignore = true)
|
||||||
@Mapping(target = "rowIndex", ignore = true)
|
@Mapping(target = "rowIndex", ignore = true)
|
||||||
@Mapping(target = "dateFormat", ignore = true)
|
@Mapping(target = "dateFormat", ignore = true)
|
||||||
@Mapping(target = "locale", ignore = true)
|
@Mapping(target = "locale", ignore = true)
|
||||||
@Mapping(target = "clientTypeId", ignore = true)
|
@Mapping(target = "clientTypeId", ignore = true)
|
||||||
@Mapping(target = "genderId", ignore = true)
|
@Mapping(target = "genderId", ignore = true)
|
||||||
@Mapping(target = "clientClassificationId", ignore = true)
|
@Mapping(target = "clientClassificationId", ignore = true)
|
||||||
@Mapping(target = "legalFormId", ignore = true)
|
@Mapping(target = "legalFormId", ignore = true)
|
||||||
@Mapping(target = "clientCollateralManagements", ignore = true)
|
@Mapping(target = "clientCollateralManagements", ignore = true)
|
||||||
@Mapping(target = "groups", ignore = true)
|
@Mapping(target = "groups", ignore = true)
|
||||||
ClientData map(Client source);
|
ClientData map(Client source);
|
||||||
|
|
||||||
@Named("clientTypeCode")
|
@Named("clientTypeCode")
|
||||||
default CodeValueData clientTypeCode(Client client) {
|
default CodeValueData clientTypeCode(Client client) {
|
||||||
final CodeValue code = client.getClientType();
|
final CodeValue code = client.getClientType();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientClassificationCode")
|
@Named("clientClassificationCode")
|
||||||
default CodeValueData clientClassificationCode(Client client) {
|
default CodeValueData clientClassificationCode(Client client) {
|
||||||
final CodeValue code = client.getClientClassification();
|
final CodeValue code = client.getClientClassification();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("occupationCategoryCode")
|
@Named("occupationCategoryCode")
|
||||||
default CodeValueData occupationCategoryCode(Client client) {
|
default CodeValueData occupationCategoryCode(Client client) {
|
||||||
final CodeValue code = client.getOccupationCategory();
|
final CodeValue code = client.getOccupationCategory();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("occupationCode")
|
@Named("occupationCode")
|
||||||
default CodeValueData occupationCode(Client client) {
|
default CodeValueData occupationCode(Client client) {
|
||||||
final CodeValue code = client.getOccupation();
|
final CodeValue code = client.getOccupation();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("salutationCode")
|
@Named("salutationCode")
|
||||||
default CodeValueData salutationCode(Client client) {
|
default CodeValueData salutationCode(Client client) {
|
||||||
final CodeValue code = client.getSalutation();
|
final CodeValue code = client.getSalutation();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("maritalStatusCode")
|
@Named("maritalStatusCode")
|
||||||
default CodeValueData maritalStatusCode(Client client) {
|
default CodeValueData maritalStatusCode(Client client) {
|
||||||
final CodeValue code = client.getMaritalStatus();
|
final CodeValue code = client.getMaritalStatus();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("educationLevelCode")
|
@Named("educationLevelCode")
|
||||||
default CodeValueData educationLevelCode(Client client) {
|
default CodeValueData educationLevelCode(Client client) {
|
||||||
final CodeValue code = client.getEducationLevel();
|
final CodeValue code = client.getEducationLevel();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("degreeQualificationCode")
|
@Named("degreeQualificationCode")
|
||||||
default CodeValueData degreeQualificationCode(Client client) {
|
default CodeValueData degreeQualificationCode(Client client) {
|
||||||
final CodeValue code = client.getDegreeQualification();
|
final CodeValue code = client.getDegreeQualification();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("religionCode")
|
@Named("religionCode")
|
||||||
default CodeValueData religionCode(Client client) {
|
default CodeValueData religionCode(Client client) {
|
||||||
final CodeValue code = client.getReligion();
|
final CodeValue code = client.getReligion();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("socialCategoryCode")
|
@Named("socialCategoryCode")
|
||||||
default CodeValueData socialCategoryCode(Client client) {
|
default CodeValueData socialCategoryCode(Client client) {
|
||||||
final CodeValue code = client.getSocialCategory();
|
final CodeValue code = client.getSocialCategory();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientSubStatusCode")
|
@Named("clientSubStatusCode")
|
||||||
default CodeValueData clientSubStatusCode(Client client) {
|
default CodeValueData clientSubStatusCode(Client client) {
|
||||||
final CodeValue code = client.getSubStatus();
|
final CodeValue code = client.getSubStatus();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientGenderCode")
|
@Named("clientGenderCode")
|
||||||
default CodeValueData clientGenderCode(Client client) {
|
default CodeValueData clientGenderCode(Client client) {
|
||||||
final CodeValue code = client.getGender();
|
final CodeValue code = client.getGender();
|
||||||
if (code == null) {
|
if (code == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return CodeValueData.instance(code.getId(), code.getLabel());
|
return CodeValueData.instance(code.getId(), code.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientLegalFormEnum")
|
@Named("clientLegalFormEnum")
|
||||||
default EnumOptionData clientLegalFormEnum(Client client) {
|
default EnumOptionData clientLegalFormEnum(Client client) {
|
||||||
return ClientEnumerations.legalForm(client.getLegalForm());
|
return ClientEnumerations.legalForm(client.getLegalForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientStatusEnum")
|
@Named("clientStatusEnum")
|
||||||
default EnumOptionData clientStatusEnum(Client client) {
|
default EnumOptionData clientStatusEnum(Client client) {
|
||||||
return ClientEnumerations.status(client.getStatus());
|
return ClientEnumerations.status(client.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("clientTimelineData")
|
@Named("clientTimelineData")
|
||||||
default ClientTimelineData clientTimelineData(Client client) {
|
default ClientTimelineData clientTimelineData(Client client) {
|
||||||
if (client.isClosed()) {
|
if (client.isClosed()) {
|
||||||
final AppUser activatedBy = client.getActivatedBy();
|
final AppUser activatedBy = client.getActivatedBy();
|
||||||
if (activatedBy != null) {
|
if (activatedBy != null) {
|
||||||
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(),
|
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(),
|
||||||
activatedBy.getUsername(), activatedBy.getFirstname(), activatedBy.getLastname(), client.getClosureDate(),
|
activatedBy.getUsername(), activatedBy.getFirstname(), activatedBy.getLastname(), client.getClosureDate(),
|
||||||
client.getClosedBy().getUsername(), client.getClosedBy().getFirstname(), client.getClosedBy().getLastname());
|
client.getClosedBy().getUsername(), client.getClosedBy().getFirstname(), client.getClosedBy().getLastname());
|
||||||
} else {
|
} else {
|
||||||
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(), null, null, null,
|
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(), null, null, null,
|
||||||
client.getClosureDate(), client.getClosedBy().getUsername(), client.getClosedBy().getFirstname(),
|
client.getClosureDate(), client.getClosedBy().getUsername(), client.getClosedBy().getFirstname(),
|
||||||
client.getClosedBy().getLastname());
|
client.getClosedBy().getLastname());
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (client.isActive()) {
|
} else if (client.isActive()) {
|
||||||
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(),
|
final AppUser activatedBy = client.getActivatedBy();
|
||||||
client.getActivatedBy().getUsername(), client.getActivatedBy().getFirstname(), client.getActivatedBy().getLastname(),
|
if (activatedBy != null) {
|
||||||
null, null, null, null);
|
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(),
|
||||||
} else {
|
activatedBy.getUsername(), activatedBy.getFirstname(), activatedBy.getLastname(),
|
||||||
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, null, null, null, null, null, null, null, null);
|
null, null, null, null);
|
||||||
}
|
}
|
||||||
}
|
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, client.getActivationDate(),
|
||||||
|
null, null, null, null, null, null, null);
|
||||||
@Named("clientIsStaff")
|
} else {
|
||||||
default Boolean clientIsStaff(Client client) {
|
return new ClientTimelineData(client.getSubmittedOnDate(), null, null, null, null, null, null, null, null, null, null, null);
|
||||||
return Boolean.valueOf(client.isStaff());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("guardianClientIdValue")
|
@Named("clientIsStaff")
|
||||||
default Long guardianClientIdValue(Client client) {
|
default Boolean clientIsStaff(Client client) {
|
||||||
return client.getGuardianClient() != null ? client.getGuardianClient().getId() : null;
|
return Boolean.valueOf(client.isStaff());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Named("guardianClientDisplayNameValue")
|
@Named("guardianClientIdValue")
|
||||||
default String guardianClientDisplayNameValue(Client client) {
|
default Long guardianClientIdValue(Client client) {
|
||||||
return client.getGuardianClient() != null ? client.getGuardianClient().getDisplayName() : null;
|
return client.getGuardianClient() != null ? client.getGuardianClient().getId() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMapping
|
@Named("guardianClientDisplayNameValue")
|
||||||
default void computeAge(Client source, @MappingTarget ClientData target) {
|
default String guardianClientDisplayNameValue(Client client) {
|
||||||
final LocalDate dob = source.getDateOfBirth();
|
return client.getGuardianClient() != null ? client.getGuardianClient().getDisplayName() : null;
|
||||||
if (dob != null) {
|
}
|
||||||
final Period age = Period.between(dob, LocalDate.now());
|
|
||||||
target.setAgeYears(age.getYears());
|
@AfterMapping
|
||||||
target.setAgeMonths(age.getMonths());
|
default void computeAge(Client source, @MappingTarget ClientData target) {
|
||||||
target.setAgeDays(age.getDays());
|
final LocalDate dob = source.getDateOfBirth();
|
||||||
}
|
if (dob != null) {
|
||||||
}
|
final Period age = Period.between(dob, LocalDate.now());
|
||||||
|
target.setAgeYears(age.getYears());
|
||||||
}
|
target.setAgeMonths(age.getMonths());
|
||||||
|
target.setAgeDays(age.getDays());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user