Updated put api of call
This commit is contained in:
@@ -133,5 +133,5 @@ public class GepafinConstant {
|
|||||||
public static final String INITAL_AND_FINAL_FORM_CANNOT_NULL="initial.and.final.form.cannot.null";
|
public static final String INITAL_AND_FINAL_FORM_CANNOT_NULL="initial.and.final.form.cannot.null";
|
||||||
public static final String APPLICATION_FORM_NOT_FOUND="application.form.not.found";
|
public static final String APPLICATION_FORM_NOT_FOUND="application.form.not.found";
|
||||||
public static final String UPDATING_FORM_VALUE_IMPACT_ON_FLOW="updating.form.value.impact.on.flow";
|
public static final String UPDATING_FORM_VALUE_IMPACT_ON_FLOW="updating.form.value.impact.on.flow";
|
||||||
|
public static final String FAILED_RETAIN_FIELD="failed.retain.field";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package net.gepafin.tendermanagement.dao;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.service.*;
|
import net.gepafin.tendermanagement.service.*;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@@ -424,7 +426,13 @@ public class CallDao {
|
|||||||
|
|
||||||
public CallResponse updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
public CallResponse updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
||||||
CallEntity callEntity = validateCall(callId);
|
CallEntity callEntity = validateCall(callId);
|
||||||
validateUpdate(callEntity);
|
if(Boolean.TRUE.equals(callEntity.getStatus().equals(CallStatusEnum.PUBLISH.getValue()))) {
|
||||||
|
try {
|
||||||
|
Utils.retainOnlySpecificFields(updateCallRequest, Collections.singletonList("faq"));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.FAILED_RETAIN_FIELD));
|
||||||
|
}
|
||||||
|
}
|
||||||
UserEntity userEntity = userService.validateUser(userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
isValidDateRange(updateCallRequest, callEntity);
|
isValidDateRange(updateCallRequest, callEntity);
|
||||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.apache.commons.collections4.MapUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -147,4 +148,17 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public static <T> void retainOnlySpecificFields(T requestObject, List<T> retainFields) throws IllegalAccessException {
|
||||||
|
// Get all declared fields of the request object's class
|
||||||
|
Field[] fields = requestObject.getClass().getDeclaredFields();
|
||||||
|
|
||||||
|
for (Field field : fields) {
|
||||||
|
field.setAccessible(true); // To allow access to private fields
|
||||||
|
|
||||||
|
// Check if the field is in the retainFields list
|
||||||
|
if (!retainFields.contains(field.getName())) {
|
||||||
|
field.set(requestObject, null); // Set the field to null if not in the retain list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,4 +168,5 @@ call.not.published=Call is not published.
|
|||||||
application.form.not.found=Application form not found.
|
application.form.not.found=Application form not found.
|
||||||
|
|
||||||
updating.form.value.impact.on.flow=Updating this value of form {0} can make impact on flow.
|
updating.form.value.impact.on.flow=Updating this value of form {0} can make impact on flow.
|
||||||
|
failed.retain.field=Failed to retain specific fields.
|
||||||
|
|
||||||
|
|||||||
@@ -163,3 +163,4 @@ call.not.published=La chiamata non
|
|||||||
application.form.not.found=Modulo di domanda non trovato.
|
application.form.not.found=Modulo di domanda non trovato.
|
||||||
|
|
||||||
updating.form.value.impact.on.flow=L'aggiornamento di questo valore del modulo {0} può avere un impatto sul flusso.
|
updating.form.value.impact.on.flow=L'aggiornamento di questo valore del modulo {0} può avere un impatto sul flusso.
|
||||||
|
failed.retain.field=Impossibile conservare campi specifici.
|
||||||
Reference in New Issue
Block a user