Done ticket BE-24,25
This commit is contained in:
@@ -125,8 +125,7 @@ public class GepafinConstant {
|
|||||||
// public static final String NEXT_FORM_NOT_FOUND = "next.form.not.found";
|
// public static final String NEXT_FORM_NOT_FOUND = "next.form.not.found";
|
||||||
// public static final String PREVIOUS_FORM_NOT_FOUND = "previous.form.not.found";
|
// public static final String PREVIOUS_FORM_NOT_FOUND = "previous.form.not.found";
|
||||||
public static final String CURRENT_FORM_INCOMPLETE = "current.form.incomplete";
|
public static final String CURRENT_FORM_INCOMPLETE = "current.form.incomplete";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final String FLOW_NOT_FOUND = "flow.not.found";
|
public static final String FLOW_NOT_FOUND = "flow.not.found";
|
||||||
|
public static final String VALIDATION_MESSAGE = "validation.message";
|
||||||
|
public static final String ACTION_REQUIRED = "action.required";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
ApplicationResponseBean applicationResponseBean= convertApplicationEntityToApplicationResponseBean(applicationEntity);
|
ApplicationResponseBean applicationResponseBean= convertApplicationEntityToApplicationResponseBean(applicationEntity);
|
||||||
applicationResponseBean.setFormFields(applicationFormFieldResponseBeans);
|
applicationResponseBean.setFormFields(applicationFormFieldResponseBeans);
|
||||||
applicationResponseBean.setCurrentFormId(formId);
|
|
||||||
return applicationResponseBean;
|
return applicationResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +310,8 @@ public class ApplicationDao {
|
|||||||
applicationGetResponseBean.setStatus(applicationEntity.getStatus());
|
applicationGetResponseBean.setStatus(applicationEntity.getStatus());
|
||||||
applicationGetResponseBean.setComments(applicationEntity.getComments());
|
applicationGetResponseBean.setComments(applicationEntity.getComments());
|
||||||
applicationGetResponseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
applicationGetResponseBean.setSubmissionDate(applicationEntity.getSubmissionDate());
|
||||||
|
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
|
||||||
|
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getDescriptionShort());
|
||||||
return applicationGetResponseBean;
|
return applicationGetResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,20 +3,13 @@ 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.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
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.enums.RoleStatusEnum;
|
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.service.*;
|
import net.gepafin.tendermanagement.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -53,7 +46,6 @@ import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
|||||||
|
|
||||||
import static net.gepafin.tendermanagement.enums.RoleStatusEnum.ROLE_SUPER_ADMIN;
|
import static net.gepafin.tendermanagement.enums.RoleStatusEnum.ROLE_SUPER_ADMIN;
|
||||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
import static org.springframework.security.authorization.AuthorityReactiveAuthorizationManager.hasRole;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CallDao {
|
public class CallDao {
|
||||||
|
|||||||
@@ -226,28 +226,50 @@ public class FlowFormDao {
|
|||||||
public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
||||||
FormActionEnum action) {
|
FormActionEnum action) {
|
||||||
Long calculatedFormId = null;
|
Long calculatedFormId = null;
|
||||||
FormEntity fromEntity = null;
|
FormEntity formEntity = null;
|
||||||
if (formId == null) {
|
if (formId == null) {
|
||||||
calculatedFormId = getDefaultForm(applicationEntity);
|
calculatedFormId = getDefaultForm(applicationEntity);
|
||||||
} else {
|
} else {
|
||||||
fromEntity = Optional
|
if(action==null) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.ACTION_REQUIRED));
|
||||||
|
}
|
||||||
|
formEntity = Optional
|
||||||
.of(applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), formId))
|
.of(applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), formId))
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.FORM_NOT_FOUND)))
|
Translator.toLocale(GepafinConstant.FORM_NOT_FOUND)))
|
||||||
.getForm();
|
.getForm();
|
||||||
|
|
||||||
if (action.equals(FormActionEnum.NEXT)) {
|
if (action.equals(FormActionEnum.NEXT)) {
|
||||||
calculatedFormId = getNextForm(fromEntity, applicationEntity);
|
calculatedFormId = getNextForm(formEntity, applicationEntity);
|
||||||
} else {
|
} else {
|
||||||
calculatedFormId = getPreviousForm(fromEntity, applicationEntity);
|
calculatedFormId = getPreviousForm(formEntity, applicationEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
NextOrPreviousFormResponse nextOrPreviousFormResponse = null;
|
||||||
if (calculatedFormId != null) {
|
if (calculatedFormId != null) {
|
||||||
|
nextOrPreviousFormResponse = setNextOrPreviousResponse(calculatedFormId, applicationEntity);
|
||||||
|
}
|
||||||
|
return nextOrPreviousFormResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NextOrPreviousFormResponse setNextOrPreviousResponse(Long calculatedFormId, ApplicationEntity applicationEntity) {
|
||||||
|
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||||
|
FormEntity formEntity = formService.validateForm(calculatedFormId);
|
||||||
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
nextOrPreviousFormResponse.setFormId(calculatedFormId);
|
||||||
nextOrPreviousFormResponse.setApplicationFormResponse(
|
nextOrPreviousFormResponse.setApplicationFormResponse(
|
||||||
applicationDao.processForm(formService.validateForm(calculatedFormId), applicationEntity));
|
applicationDao.processForm(formEntity, applicationEntity));
|
||||||
|
nextOrPreviousFormResponse.setCallId(applicationEntity.getCall().getId());
|
||||||
|
nextOrPreviousFormResponse.setCallTitle(applicationEntity.getCall().getDescriptionShort());
|
||||||
|
|
||||||
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||||
|
Long totalFormSteps = 3l;
|
||||||
|
if (flowEdgesList.size() == 1) {
|
||||||
|
totalFormSteps = 2l;
|
||||||
}
|
}
|
||||||
|
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationId(applicationEntity.getId());
|
||||||
|
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
||||||
|
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(applicationFormList.size()));
|
||||||
return nextOrPreviousFormResponse;
|
return nextOrPreviousFormResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
|
||||||
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -18,6 +16,10 @@ public class ApplicationGetResponseBean {
|
|||||||
|
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
private String callTitle;
|
||||||
|
|
||||||
private List<FormApplicationResponse> form;
|
private List<FormApplicationResponse> form;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,4 @@ public class ApplicationResponseBean extends BaseBean {
|
|||||||
|
|
||||||
private List<ApplicationFormFieldResponseBean> formFields;
|
private List<ApplicationFormFieldResponseBean> formFields;
|
||||||
|
|
||||||
private Long currentFormId;
|
|
||||||
|
|
||||||
private Long nextFormId;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,16 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class NextOrPreviousFormResponse {
|
public class NextOrPreviousFormResponse {
|
||||||
|
|
||||||
Long formId;
|
private Long formId;
|
||||||
|
|
||||||
FormApplicationResponse applicationFormResponse;
|
private Long callId;
|
||||||
|
|
||||||
|
private String callTitle;
|
||||||
|
|
||||||
|
private Long totalFormSteps;
|
||||||
|
|
||||||
|
private Long completedSteps;
|
||||||
|
|
||||||
|
private FormApplicationResponse applicationFormResponse;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,8 +32,6 @@ public class CallValidatorServiceImpl {
|
|||||||
.notEmpty(response.getAimedTo(), "aimedTo")
|
.notEmpty(response.getAimedTo(), "aimedTo")
|
||||||
.notEmpty(response.getCriteria(), "criteria")
|
.notEmpty(response.getCriteria(), "criteria")
|
||||||
.notEmpty(response.getDocs(), "docs")
|
.notEmpty(response.getDocs(), "docs")
|
||||||
.notEmpty(response.getFaq(), "faq")
|
|
||||||
.notEmpty(response.getImages(), "images")
|
|
||||||
.notEmpty(response.getCheckList(), "checkList");
|
.notEmpty(response.getCheckList(), "checkList");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class FieldValidator {
|
|||||||
|
|
||||||
public void validate() {
|
public void validate() {
|
||||||
if (!errors.isEmpty()) {
|
if (!errors.isEmpty()) {
|
||||||
throw new ValidationException(Status.VALIDATION_ERROR, errors);
|
throw new ValidationException(Status.VALIDATION_ERROR, errors, Translator.toLocale(GepafinConstant.VALIDATION_MESSAGE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public FieldValidator minLength(String value, Long minLength, String fieldName) {
|
public FieldValidator minLength(String value, Long minLength, String fieldName) {
|
||||||
|
|||||||
@@ -35,6 +35,15 @@ public class GlobalExceptionHandler {
|
|||||||
return new Response<>(null, ex.getStatus(), ex.getMessage());
|
return new Response<>(null, ex.getStatus(), ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
|
||||||
|
@ExceptionHandler(ValidationException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Response<Object> handleValidationException(final ValidationException ex) {
|
||||||
|
log.error(ex.getMessage());
|
||||||
|
log.error(ex.getLocalizedMessage(), ex);
|
||||||
|
return new Response<>(ex.getErrors(), ex.getStatus(), ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(ResourceNotFoundException.class)
|
@ExceptionHandler(ResourceNotFoundException.class)
|
||||||
public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) {
|
public ResponseEntity<Response<Void>> handleResourceNotFoundException(ResourceNotFoundException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ public class ValidationException extends CustomValidationException {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private final List<String> errors;
|
private final List<String> errors;
|
||||||
|
|
||||||
public ValidationException(Status status, List<String> errors) {
|
public ValidationException(Status status, List<String> errors, String message) {
|
||||||
super(status, errors.toString());
|
super(status, message);
|
||||||
this.errors = errors;
|
this.errors = errors;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,3 +160,5 @@ validation.field.not_empty=Field {0} must not be empty.
|
|||||||
|
|
||||||
current.form.incomplete=Current form is not filled.
|
current.form.incomplete=Current form is not filled.
|
||||||
flow.not.found=Flow not found.
|
flow.not.found=Flow not found.
|
||||||
|
validation.message=Validation messages.
|
||||||
|
action.required=Action field required.
|
||||||
|
|||||||
@@ -155,3 +155,5 @@ validation.field.not_null=Il campo {0} non deve essere nullo.
|
|||||||
validation.field.not_empty=Il campo {0} non deve essere vuoto.
|
validation.field.not_empty=Il campo {0} non deve essere vuoto.
|
||||||
current.form.incomplete=il modulo corrente non <20> compilato
|
current.form.incomplete=il modulo corrente non <20> compilato
|
||||||
flow.not.found=Flow not found.
|
flow.not.found=Flow not found.
|
||||||
|
validation.message=Messaggi di convalida.
|
||||||
|
action.required=Campo azione obbligatorio.
|
||||||
|
|||||||
Reference in New Issue
Block a user