From 9f9f9c027af227ad508ca6d77f635b5c21e1f484 Mon Sep 17 00:00:00 2001 From: Balaji <74903654+balaji-alluru@users.noreply.github.com> Date: Fri, 20 Jan 2023 15:56:15 +0530 Subject: [PATCH 1/2] Updated Dynamic service impl Signed-off-by: Balaji <74903654+balaji-alluru@users.noreply.github.com> --- .../dto/DynamicFieldCodeValueDTO.java | 19 +++++++++++++++++++ .../service/impl/DynamicFieldServiceImpl.java | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldCodeValueDTO.java diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldCodeValueDTO.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldCodeValueDTO.java new file mode 100644 index 00000000000..75b91f7eb5b --- /dev/null +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldCodeValueDTO.java @@ -0,0 +1,19 @@ +package io.mosip.kernel.masterdata.dto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class DynamicFieldCodeValueDTO { + + private String code; + + private String value; + +} diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java index d974d8ac16d..599b1fa091e 100644 --- a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java @@ -511,14 +511,15 @@ public DynamicFieldConsolidateResponseDto getDynamicFieldByNameAndLangcode(Strin DynamicFieldConsolidateResponseDto dto = new DynamicFieldConsolidateResponseDto(); dto.setDescription(lst.get(0).getDescription()); dto.setName(lst.get(0).getName()); - dto.setJsonValues(null); + List dtolist = new ArrayList(); if (withValue == true) { List l = new ArrayList<>(); for (int i = 0; i < lst.size(); i++) { l.add(new JSONObject(lst.get(i).getValueJson())); + dtolist.add(objectMapper.readValue(lst.get(i).getValueJson(),DynamicFieldCodeValueDTO.class)); } - dto.setJsonValues(new JSONArray(l)); + dto.setValues(dtolist); } return dto; From 7f913cddede8c9bb235e8d3936a6a4bcf2b1152a Mon Sep 17 00:00:00 2001 From: Balaji <74903654+balaji-alluru@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:14:45 +0530 Subject: [PATCH 2/2] Fixed build failure Signed-off-by: Balaji <74903654+balaji-alluru@users.noreply.github.com> --- .../masterdata/dto/DynamicFieldConsolidateResponseDto.java | 5 +++-- .../masterdata/service/impl/DynamicFieldServiceImpl.java | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldConsolidateResponseDto.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldConsolidateResponseDto.java index 755d5e9e5e2..d380c22a6b2 100644 --- a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldConsolidateResponseDto.java +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/dto/DynamicFieldConsolidateResponseDto.java @@ -1,5 +1,7 @@ package io.mosip.kernel.masterdata.dto; +import java.util.List; + import org.json.JSONArray; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -19,7 +21,6 @@ public class DynamicFieldConsolidateResponseDto { private String description; - @JsonIgnore - private JSONArray jsonValues; + private List values; } diff --git a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java index 599b1fa091e..3364000eeb0 100644 --- a/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java +++ b/admin/kernel-masterdata-service/src/main/java/io/mosip/kernel/masterdata/service/impl/DynamicFieldServiceImpl.java @@ -1,9 +1,11 @@ package io.mosip.kernel.masterdata.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.mosip.kernel.core.dataaccess.exception.DataAccessLayerException; import io.mosip.kernel.masterdata.constant.SchemaErrorCode; +import io.mosip.kernel.masterdata.dto.DynamicFieldCodeValueDTO; import io.mosip.kernel.masterdata.dto.DynamicFieldConsolidateResponseDto; import io.mosip.kernel.masterdata.dto.DynamicFieldDefDto; import io.mosip.kernel.masterdata.dto.DynamicFieldDto; @@ -524,7 +526,7 @@ public DynamicFieldConsolidateResponseDto getDynamicFieldByNameAndLangcode(Strin return dto; - } catch (DataAccessLayerException | DataAccessException | JSONException e) { + } catch (DataAccessLayerException | DataAccessException | JSONException | JsonProcessingException e) { throw new MasterDataServiceException(SchemaErrorCode.DYNAMIC_FIELD_FETCH_EXCEPTION.getErrorCode(), ExceptionUtils.parseException(e)); }