Skip to content

Commit

Permalink
Merge pull request #963 from balaji-alluru/release-1.2.1.x-1
Browse files Browse the repository at this point in the history
[MOSIP-32649]Updated Dynamic service impl
  • Loading branch information
ckm007 authored Apr 29, 2024
2 parents c5c8838 + 7f913cd commit 75fb882
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.mosip.kernel.masterdata.dto;

import java.util.List;

import org.json.JSONArray;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand All @@ -19,7 +21,6 @@ public class DynamicFieldConsolidateResponseDto {

private String description;

@JsonIgnore
private JSONArray jsonValues;
private List<DynamicFieldCodeValueDTO> values;

}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<DynamicFieldCodeValueDTO> dtolist = new ArrayList<DynamicFieldCodeValueDTO>();
if (withValue == true) {

List<JSONObject> 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));
}
Expand Down

0 comments on commit 75fb882

Please sign in to comment.