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/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 d974d8ac16d..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; @@ -511,19 +513,20 @@ 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; - } catch (DataAccessLayerException | DataAccessException | JSONException e) { + } catch (DataAccessLayerException | DataAccessException | JSONException | JsonProcessingException e) { throw new MasterDataServiceException(SchemaErrorCode.DYNAMIC_FIELD_FETCH_EXCEPTION.getErrorCode(), ExceptionUtils.parseException(e)); }