Updated code
This commit is contained in:
@@ -203,6 +203,9 @@ public class ApplicationEvaluationDao {
|
|||||||
case "paragraph":
|
case "paragraph":
|
||||||
handleParagraphField(applicationId, formField, contentBean, mappedField);
|
handleParagraphField(applicationId, formField, contentBean, mappedField);
|
||||||
break;
|
break;
|
||||||
|
case "table":
|
||||||
|
handleTableField(applicationId, formField, contentBean, mappedField);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
|
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentBean);
|
||||||
}
|
}
|
||||||
@@ -710,6 +713,9 @@ public class ApplicationEvaluationDao {
|
|||||||
case "paragraph":
|
case "paragraph":
|
||||||
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||||
break;
|
break;
|
||||||
|
case "table":
|
||||||
|
handleTableField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
|
populateOptionFieldsAsFieldValue(mappedField, formFieldId, applicationForm, applicationId, contentResponseBean);
|
||||||
@@ -993,7 +999,7 @@ public class ApplicationEvaluationDao {
|
|||||||
boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName());
|
boolean isCheckbox = "checkboxes".equals(contentResponseBean.getName());
|
||||||
boolean isFileUpload = "fileupload".equals(contentResponseBean.getName());
|
boolean isFileUpload = "fileupload".equals(contentResponseBean.getName());
|
||||||
boolean isParagraph = "paragraph".equals(contentResponseBean.getName());
|
boolean isParagraph = "paragraph".equals(contentResponseBean.getName());
|
||||||
|
boolean isTable = "table".equals(contentResponseBean.getName());
|
||||||
if (isFileUpload) {
|
if (isFileUpload) {
|
||||||
handleFileUpload(applicationId, criteriaFormField, mappedField);
|
handleFileUpload(applicationId, criteriaFormField, mappedField);
|
||||||
} else if (isCheckbox) {
|
} else if (isCheckbox) {
|
||||||
@@ -1001,11 +1007,63 @@ public class ApplicationEvaluationDao {
|
|||||||
}
|
}
|
||||||
else if (isParagraph) {
|
else if (isParagraph) {
|
||||||
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
handleParagraphField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||||
|
} else if (isTable) {
|
||||||
|
handleTableField(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handleOtherFields(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
handleOtherFields(applicationId, criteriaFormField, contentResponseBean, mappedField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void handleTableField(Long applicationId, CriteriaFormFieldEntity criteriaFormField,
|
||||||
|
ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||||
|
Map<String, String> stateFieldMap = new HashMap<>();
|
||||||
|
Map<String, Boolean> stateFieldBoolean = new HashMap<>();
|
||||||
|
|
||||||
|
contentResponseBean.getSettings().stream()
|
||||||
|
.filter(setting -> "table_columns".equals(setting.getName()))
|
||||||
|
.map(SettingResponseBean::getValue)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(settingValue -> settingValue instanceof Map)
|
||||||
|
.map(settingValue -> (Map<String, Object>) settingValue)
|
||||||
|
.map(valueMap -> (List<Map<String, Object>>) valueMap.get("stateFieldData"))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.forEach(fieldData -> {
|
||||||
|
String fieldName = (String) fieldData.get("name");
|
||||||
|
String fieldLabel = (String) fieldData.get("label");
|
||||||
|
Boolean predefined = (Boolean) fieldData.getOrDefault("predefined", false);
|
||||||
|
|
||||||
|
if (fieldName != null) {
|
||||||
|
stateFieldMap.put(fieldName, fieldLabel);
|
||||||
|
stateFieldBoolean.put(fieldName, predefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||||
|
String fieldValue1 = formField.getFieldValue();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Map<String, String>> rowsData = objectMapper.readValue(fieldValue1, new TypeReference<List<Map<String, String>>>() {});
|
||||||
|
|
||||||
|
List<Map<String, Object>> tableData = new ArrayList<>();
|
||||||
|
for (Map<String, String> rowData : rowsData) {
|
||||||
|
Map<String, Object> mappedRow = new HashMap<>();
|
||||||
|
rowData.forEach((fieldKey, fieldValue) -> {
|
||||||
|
String columnLabel = stateFieldMap.getOrDefault(fieldKey, fieldKey);
|
||||||
|
mappedRow.put(columnLabel, fieldValue);
|
||||||
|
});
|
||||||
|
tableData.add(mappedRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
mappedField.setFieldValue(tableData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleParagraphField(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
private void handleParagraphField(Long applicationId, CriteriaFormFieldEntity criteriaFormField, ContentResponseBean contentResponseBean, CriteriaMappedField mappedField) {
|
||||||
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
findFormFieldValue(applicationId, criteriaFormField.getFormFieldId()).ifPresent(formField -> {
|
||||||
String paragraph = contentResponseBean.getSettings().stream()
|
String paragraph = contentResponseBean.getSettings().stream()
|
||||||
|
|||||||
Reference in New Issue
Block a user