Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-32649]Updated Dynamic service impl #963

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading