Resolved conflicts
This commit is contained in:
@@ -122,5 +122,10 @@ public class GepafinConstant {
|
|||||||
public static final String VALIDATION_FIELD_NOT_NULL = "validation.field.not_null";
|
public static final String VALIDATION_FIELD_NOT_NULL = "validation.field.not_null";
|
||||||
public static final String VALIDATION_FIELD_NOT_EMPTY = "validation.field.not_empty";
|
public static final String VALIDATION_FIELD_NOT_EMPTY = "validation.field.not_empty";
|
||||||
public static final String APPLICATION_ALREADY_EXISTS="application.already.exists";
|
public static final String APPLICATION_ALREADY_EXISTS="application.already.exists";
|
||||||
|
// 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 CURRENT_FORM_INCOMPLETE = "current.form.incomplete";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import net.gepafin.tendermanagement.repositories.ApplicationFormRepository;
|
|||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
import net.gepafin.tendermanagement.service.FormService;
|
import net.gepafin.tendermanagement.service.FormService;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
@@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
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 java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -31,13 +32,9 @@ public class ApplicationDao {
|
|||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(ApplicationDao.class);
|
private final Logger log = LoggerFactory.getLogger(ApplicationDao.class);
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CallService callService;
|
private CallService callService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationRepository applicationRepository;
|
private ApplicationRepository applicationRepository;
|
||||||
|
|
||||||
@@ -159,7 +156,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationEntity getApplicationOrCreate(UserEntity userEntity, CallEntity callEntity, FormEntity formEntity) {
|
public ApplicationEntity getApplicationOrCreate(UserEntity userEntity, CallEntity callEntity, FormEntity formEntity) {
|
||||||
ApplicationEntity applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), callEntity.getId());
|
ApplicationEntity applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), callEntity.getId()).orElse(null);
|
||||||
if (applicationEntity == null) {
|
if (applicationEntity == null) {
|
||||||
validateFormId(formEntity, callEntity);
|
validateFormId(formEntity, callEntity);
|
||||||
applicationEntity = createApplicationEntity(userEntity, callEntity);
|
applicationEntity = createApplicationEntity(userEntity, callEntity);
|
||||||
@@ -198,7 +195,7 @@ public class ApplicationDao {
|
|||||||
public ApplicationFormFieldEntity validateApplicationFormField(Long applicationFormFieldId) {
|
public ApplicationFormFieldEntity validateApplicationFormField(Long applicationFormFieldId) {
|
||||||
Optional<ApplicationFormFieldEntity> applicationFormFieldEntity = applicationFormFieldRepository.findById(applicationFormFieldId);
|
Optional<ApplicationFormFieldEntity> applicationFormFieldEntity = applicationFormFieldRepository.findById(applicationFormFieldId);
|
||||||
if (applicationFormFieldEntity.isEmpty()) {
|
if (applicationFormFieldEntity.isEmpty()) {
|
||||||
throw new CustomValidationException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND));
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND));
|
||||||
}
|
}
|
||||||
return applicationFormFieldEntity.get();
|
return applicationFormFieldEntity.get();
|
||||||
}
|
}
|
||||||
@@ -230,18 +227,16 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationGetResponseBean getApplicationByFormId( Long applicationId,Long formId, UserEntity userEntity) {
|
public ApplicationGetResponseBean getApplicationByFormId( Long applicationId,Long formId, UserEntity userEntity) {
|
||||||
|
|
||||||
ApplicationEntity applicationEntity=null;
|
|
||||||
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
|
List<FormApplicationResponse> formApplicationResponses = new ArrayList<>();
|
||||||
List<FormEntity> formEntities = new ArrayList<>();
|
List<FormEntity> formEntities = new ArrayList<>();
|
||||||
Optional<ApplicationEntity> applicationEntity1 = applicationRepository.findById(applicationId);
|
ApplicationEntity applicationEntity = applicationRepository.findById(applicationId)
|
||||||
applicationEntity=applicationEntity1.get();
|
.orElseThrow(() -> new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)));
|
||||||
if (applicationEntity == null) {
|
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG));
|
|
||||||
}
|
|
||||||
if (formId != null) {
|
if (formId != null) {
|
||||||
FormEntity formEntity = formService.validateForm(formId);
|
FormEntity formEntity = formService.validateForm(formId);
|
||||||
applicationEntity = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), formEntity.getCall().getId());
|
Optional<ApplicationEntity> application = applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),
|
||||||
|
formEntity.getCall().getId());
|
||||||
|
applicationEntity=application.get();
|
||||||
formEntities.add(formEntity);
|
formEntities.add(formEntity);
|
||||||
processForm(formEntity, applicationEntity, formApplicationResponses);
|
processForm(formEntity, applicationEntity, formApplicationResponses);
|
||||||
}
|
}
|
||||||
@@ -301,9 +296,26 @@ public class ApplicationDao {
|
|||||||
return applicationResponse;
|
return applicationResponse;
|
||||||
}
|
}
|
||||||
public void checkIfApplicationExists(CallEntity call,UserEntity userEntity){
|
public void checkIfApplicationExists(CallEntity call,UserEntity userEntity){
|
||||||
ApplicationEntity applicationEntity=applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),call.getId());
|
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(),call.getId());
|
||||||
if(applicationEntity!=null){
|
if(applicationEntity.isPresent()){
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ApplicationEntity getApplicationByCallAndUser(CallEntity call, UserEntity userEntity) {
|
||||||
|
return applicationRepository.findByUserIdAndCallIdAndIsDeletedFalse(userEntity.getId(), call.getId())
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) {
|
||||||
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
applicationEntity.setStatus(status.getValue());
|
||||||
|
if(status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
|
||||||
|
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
}
|
||||||
|
saveApplicationEntity(applicationEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
255
src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java
Normal file
255
src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationFormEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationFormFieldEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FlowDataEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FlowEdgesEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FormEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationFormFieldRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationFormRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.FlowDataRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.FlowEdgesRepository;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FlowFormDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FlowEdgesRepository flowEdgesRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FlowDataRepository flowDataRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationFormFieldRepository applicationFormFieldRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationFormRepository applicationFormRepository;
|
||||||
|
|
||||||
|
|
||||||
|
// Long getNextForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
// // vlaidation if next form findout and cuuent from is not fill the give error
|
||||||
|
// List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findBySourceIdAndCallId(currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
// ApplicationFormEntity applicationFormEntity = applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), currentFormEntity.getId());
|
||||||
|
// if(applicationFormEntity == null) {
|
||||||
|
// throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
// Translator.toLocale("current form is not fill"));
|
||||||
|
// }
|
||||||
|
// if(flowEdgesList.isEmpty()) {
|
||||||
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
// Translator.toLocale(GepafinConstant.NEXT_FORM_NOT_FOUND));
|
||||||
|
// } else if(flowEdgesList.size() == 1) {
|
||||||
|
// return flowEdgesList.get(0).getTargetId();
|
||||||
|
// } else {
|
||||||
|
// List<Long> nextFormIds = flowEdgesList.stream().map(FlowEdgesEntity::getTargetId).toList();
|
||||||
|
// FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndCallId(currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
//
|
||||||
|
// ApplicationFormFieldEntity applicationFormFieldEntity = applicationFormFieldRepository
|
||||||
|
// .findByFieldIdAndApplicationFormFormIdAndApplicationFormApplicationId(flowDataEntity.getChoosenField(),
|
||||||
|
// currentFormEntity.getId(), applicationEntity.getId()).orElseThrow(()-> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
// Translator.toLocale(GepafinConstant.NEXT_FORM_NOT_FOUND)));
|
||||||
|
//
|
||||||
|
// flowDataEntity = flowDataRepository.findByChoosenValueAndFormIdIn(applicationFormFieldEntity.getFieldValue(), nextFormIds).orElseThrow(()-> new NullPointerException());
|
||||||
|
// return flowDataEntity.getFormId();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
//
|
||||||
|
// // Step 1: Find all edges where the current form is the target (i.e., reverse flow)
|
||||||
|
// List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
||||||
|
// currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
//
|
||||||
|
// if (flowEdgesList.isEmpty()) {
|
||||||
|
// // If no previous edges are found, return null or handle this case based on your needs
|
||||||
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Step 2: If only one edge exists, return the source (previous) form ID directly have to look into it
|
||||||
|
// if (flowEdgesList.size() == 1) {
|
||||||
|
// return flowEdgesList.get(0).getSourceId();
|
||||||
|
// }
|
||||||
|
// List<Long> previousFormIds = flowEdgesList.stream().map(FlowEdgesEntity::getSourceId).toList();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // Step 3: Try to find flow data for the current form. If not found, we know it's the last step (or no field filtering is needed).
|
||||||
|
// List<FlowDataEntity> flowDataList = flowDataRepository.findByFormIdInAndCallId(
|
||||||
|
// previousFormIds, applicationEntity.getCall().getId());
|
||||||
|
//
|
||||||
|
// List<String> fieldValue = flowDataList.stream().map(FlowDataEntity::getChoosenValue).toList();
|
||||||
|
//
|
||||||
|
//// if (flowDataEntity == null || flowDataEntity.getChoosenField() == null) {
|
||||||
|
//// // If flow data is not found, simply return the first matching previous form
|
||||||
|
//// return flowEdgesList.get(0).getSourceId(); // You can modify this logic if needed
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// // Step 4: Fetch the field value from the application form fields
|
||||||
|
// Set<FormEntity> formList = applicationFormFieldRepository
|
||||||
|
// .findByFieldValueInAndAndApplicationFormApplicationId(
|
||||||
|
// fieldValue, applicationEntity.getId()).stream().map(applicationFormFieldEntity->applicationFormFieldEntity.getApplicationForm().getForm()).collect(Collectors.toSet());
|
||||||
|
//
|
||||||
|
// List<Long> fieldIds = formList.stream().map(formEntity->getNextForm(formEntity, applicationEntity)).toList();
|
||||||
|
// for(Long formId:previousFormIds) {
|
||||||
|
// fieldIds.contains(formId);
|
||||||
|
// return formId;
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
//// .orElseThrow(() -> new NullPointerException("Field value not found for the current form and application."));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// // Step 5: Check if there's a matching previous form based on the chosen value
|
||||||
|
//// FlowDataEntity previousFlowDataEntity = flowDataRepository.findByChoosenValueAndFormIdIn(
|
||||||
|
//// applicationFormFieldEntity.getFieldValue(), flowEdgesList.stream().map(FlowEdgesEntity::getSourceId).toList())
|
||||||
|
//// .orElse(null); // If no matching form is found, return null or the first source form
|
||||||
|
////
|
||||||
|
//// // Step 6: Return the formId of the matching previous form, or the first one if no specific match is found
|
||||||
|
//// return previousFlowDataEntity != null ? previousFlowDataEntity.getFormId() : flowEdgesList.get(0).getSourceId();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public Long getNextForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
// Validate if the current form has been filled
|
||||||
|
ApplicationFormEntity applicationFormEntity = applicationFormRepository.findByApplicationIdAndFormId(
|
||||||
|
applicationEntity.getId(), currentFormEntity.getId());
|
||||||
|
|
||||||
|
// Retrieve the flow edges for the next forms
|
||||||
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findBySourceIdAndCallId(
|
||||||
|
currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
|
||||||
|
if (flowEdgesList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
// Translator.toLocale(GepafinConstant.NEXT_FORM_NOT_FOUND));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If only one edge exists, return the target form ID
|
||||||
|
if (flowEdgesList.size() == 1) {
|
||||||
|
return flowEdgesList.get(0).getTargetId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applicationFormEntity == null) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.CURRENT_FORM_INCOMPLETE));
|
||||||
|
}
|
||||||
|
|
||||||
|
// For multiple edges, find the next form based on the chosen value
|
||||||
|
List<Long> nextFormIds = flowEdgesList.stream()
|
||||||
|
.map(FlowEdgesEntity::getTargetId)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Retrieve the flow data for the current form
|
||||||
|
FlowDataEntity flowDataEntity = flowDataRepository.findByFormIdAndCallId(
|
||||||
|
currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
|
||||||
|
// Fetch the application form field related to the chosen field
|
||||||
|
ApplicationFormFieldEntity applicationFormFieldEntity = applicationFormFieldRepository
|
||||||
|
.findByFieldIdAndApplicationFormFormIdAndApplicationFormApplicationId(
|
||||||
|
flowDataEntity.getChoosenField(), currentFormEntity.getId(), applicationEntity.getId()).orElse(null);
|
||||||
|
|
||||||
|
// Find the next form based on the chosen value and return its ID
|
||||||
|
return flowDataRepository.findByChoosenValueAndFormIdIn(
|
||||||
|
applicationFormFieldEntity.getFieldValue(), nextFormIds)
|
||||||
|
.map(FlowDataEntity::getFormId)
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
// Retrieve the flow edges for the previous forms
|
||||||
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
||||||
|
currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
|
||||||
|
if (flowEdgesList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
||||||
|
}
|
||||||
|
|
||||||
|
// If only one edge exists, return the source form ID
|
||||||
|
if (flowEdgesList.size() == 1) {
|
||||||
|
return flowEdgesList.get(0).getSourceId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// For multiple edges, find the previous form based on the chosen value
|
||||||
|
List<Long> previousFormIds = flowEdgesList.stream()
|
||||||
|
.map(FlowEdgesEntity::getSourceId)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Fetch the flow data based on previous form IDs
|
||||||
|
List<FlowDataEntity> flowDataList = flowDataRepository.findByFormIdInAndCallId(
|
||||||
|
previousFormIds, applicationEntity.getCall().getId());
|
||||||
|
|
||||||
|
List<String> chosenValues = flowDataList.stream()
|
||||||
|
.map(FlowDataEntity::getChoosenValue)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Fetch the previous forms based on the chosen field values
|
||||||
|
Set<FormEntity> formList = applicationFormFieldRepository
|
||||||
|
.findByFieldValueInAndApplicationFormApplicationId(chosenValues, applicationEntity.getId()).stream()
|
||||||
|
.map(fieldEntity -> fieldEntity.getApplicationForm().getForm())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// Find next form IDs recursively for all forms in the formList
|
||||||
|
List<Long> fieldIds = formList.stream()
|
||||||
|
.map(formEntity -> getNextForm(formEntity, applicationEntity))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Return the first matching previous form ID that corresponds to a next form
|
||||||
|
return previousFormIds.stream()
|
||||||
|
.filter(fieldIds::contains)
|
||||||
|
.findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
||||||
|
FormActionEnum action) {
|
||||||
|
FormEntity fromEntity = null;
|
||||||
|
if(formId == null) {
|
||||||
|
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||||
|
nextOrPreviousFormResponse.setNextFormId(getDefaultForm(applicationEntity));
|
||||||
|
return nextOrPreviousFormResponse;
|
||||||
|
}else {
|
||||||
|
fromEntity = Optional
|
||||||
|
.of(applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(), formId))
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.FORM_NOT_FOUND)))
|
||||||
|
.getForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
NextOrPreviousFormResponse nextOrPreviousFormResponse = new NextOrPreviousFormResponse();
|
||||||
|
if (action.equals(FormActionEnum.NEXT)) {
|
||||||
|
nextOrPreviousFormResponse.setNextFormId(getNextForm(fromEntity, applicationEntity));
|
||||||
|
} else {
|
||||||
|
nextOrPreviousFormResponse.setPreviousFormId(getPreviousForm(fromEntity, applicationEntity));
|
||||||
|
}
|
||||||
|
return nextOrPreviousFormResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long getDefaultForm(ApplicationEntity applicationEntity) {
|
||||||
|
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationIdOrderByCreatedDateAsc(applicationEntity.getId());
|
||||||
|
if(applicationFormList.isEmpty()) {
|
||||||
|
return applicationEntity.getCall().getInitialForm();
|
||||||
|
}
|
||||||
|
if(applicationFormList.get(applicationFormList.size()-1).getForm().getId().equals(applicationEntity.getCall().getFinalForm())) {
|
||||||
|
return applicationEntity.getCall().getInitialForm();
|
||||||
|
}
|
||||||
|
return getNextForm(applicationFormList.get(applicationFormList.size()-1).getForm(), applicationEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,7 +10,6 @@ import net.gepafin.tendermanagement.model.request.FormRequest;
|
|||||||
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
import net.gepafin.tendermanagement.model.response.ContentResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
import net.gepafin.tendermanagement.model.response.FormResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationFormRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationFormRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
|
||||||
import net.gepafin.tendermanagement.repositories.FormRepository;
|
import net.gepafin.tendermanagement.repositories.FormRepository;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
@@ -36,9 +35,6 @@ public class FormDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CallService callService;
|
private CallService callService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ApplicationRepository applicationRepository;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationFormRepository applicationFormRepository;
|
private ApplicationFormRepository applicationFormRepository;
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,10 @@ package net.gepafin.tendermanagement.entities;
|
|||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "APPLICATION_FORM")
|
@Table(name = "APPLICATION_FORM")
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class ApplicationFormEntity extends BaseEntity {
|
public class ApplicationFormEntity extends BaseEntity {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum FormActionEnum {
|
||||||
|
|
||||||
|
NEXT("NEXT"),
|
||||||
|
PREVIOUS("PREVIOUS");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
FormActionEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.gepafin.tendermanagement.model.BaseBean;
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class NextOrPreviousFormResponse {
|
||||||
|
|
||||||
|
Long nextFormId;
|
||||||
|
|
||||||
|
Long previousFormId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationFormFieldEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationFormFieldEntity;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface ApplicationFormFieldRepository extends JpaRepository<ApplicationFormFieldEntity,Long> {
|
public interface ApplicationFormFieldRepository extends JpaRepository<ApplicationFormFieldEntity,Long> {
|
||||||
@@ -12,4 +14,14 @@ public interface ApplicationFormFieldRepository extends JpaRepository<Applicatio
|
|||||||
public List<ApplicationFormFieldEntity> findByApplicationFormIdIn(List<Long> applicationFormIds);
|
public List<ApplicationFormFieldEntity> findByApplicationFormIdIn(List<Long> applicationFormIds);
|
||||||
|
|
||||||
public List<ApplicationFormFieldEntity> findByApplicationFormId(Long applicationFormId);
|
public List<ApplicationFormFieldEntity> findByApplicationFormId(Long applicationFormId);
|
||||||
|
|
||||||
|
public Optional<ApplicationFormFieldEntity> findByFieldIdAndApplicationFormFormIdAndApplicationFormApplicationId(
|
||||||
|
String fieldId, Long formId, Long applicationId);
|
||||||
|
|
||||||
|
public Optional<ApplicationFormFieldEntity> findByFieldValueInAndApplicationFormFormIdInAndApplicationFormApplicationId(
|
||||||
|
List<String> fieldValues, List<Long> previousFormIds, Long applicationId);
|
||||||
|
|
||||||
|
public List<ApplicationFormFieldEntity> findByFieldValueInAndApplicationFormApplicationId(
|
||||||
|
List<String> fieldValue, Long applicationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ public interface ApplicationFormRepository extends JpaRepository<ApplicationForm
|
|||||||
|
|
||||||
public List<ApplicationFormEntity> findByApplicationId(Long applicationId);
|
public List<ApplicationFormEntity> findByApplicationId(Long applicationId);
|
||||||
|
|
||||||
|
public List<ApplicationFormEntity> findByApplicationIdOrderByCreatedDateAsc(Long applicationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.util.Optional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface ApplicationRepository extends JpaRepository<ApplicationEntity,Long> {
|
public interface ApplicationRepository extends JpaRepository<ApplicationEntity,Long> {
|
||||||
|
|
||||||
public ApplicationEntity findByUserIdAndCallIdAndIsDeletedFalse(Long userId,Long callId);
|
public Optional<ApplicationEntity> findByUserIdAndCallIdAndIsDeletedFalse(Long userId,Long callId);
|
||||||
|
|
||||||
public List<ApplicationEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
public List<ApplicationEntity> findByUserIdAndIsDeletedFalse(Long userId);
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,16 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
|
public interface FlowDataRepository extends JpaRepository<FlowDataEntity,Long> {
|
||||||
|
|
||||||
public List<FlowDataEntity> findByCallId(Long callId);
|
public List<FlowDataEntity> findByCallId(Long callId);
|
||||||
|
|
||||||
|
public FlowDataEntity findByFormIdAndCallId(Long formId, Long callId);
|
||||||
|
|
||||||
|
public Optional<FlowDataEntity> findByChoosenValueAndFormIdIn(String fieldValue, List<Long> nextFormIds);
|
||||||
|
|
||||||
|
public List<FlowDataEntity> findByFormIdInAndCallId(List<Long> previousFormIds, Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,8 @@ import java.util.List;
|
|||||||
public interface FlowEdgesRepository extends JpaRepository<net.gepafin.tendermanagement.entities.FlowEdgesEntity,Long> {
|
public interface FlowEdgesRepository extends JpaRepository<net.gepafin.tendermanagement.entities.FlowEdgesEntity,Long> {
|
||||||
|
|
||||||
public List<FlowEdgesEntity> findByCallId(Long callId);
|
public List<FlowEdgesEntity> findByCallId(Long callId);
|
||||||
|
|
||||||
|
public List<FlowEdgesEntity> findBySourceIdAndCallId(Long sourceId, Long callId);
|
||||||
|
|
||||||
|
public List<FlowEdgesEntity> findByTargetIdAndCallId(Long targetId, Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,13 @@ package net.gepafin.tendermanagement.service;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -24,4 +27,7 @@ public interface ApplicationService {
|
|||||||
|
|
||||||
public ApplicationResponse createApplication(HttpServletRequest request, ApplicationRequest applicationRequest, Long callId);
|
public ApplicationResponse createApplication(HttpServletRequest request, ApplicationRequest applicationRequest, Long callId);
|
||||||
|
|
||||||
|
public NextOrPreviousFormResponse getnextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action);
|
||||||
|
|
||||||
|
public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,20 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
||||||
|
import net.gepafin.tendermanagement.dao.FlowFormDao;
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FormEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
|
import net.gepafin.tendermanagement.service.FormService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -23,6 +29,12 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationDao applicationDao;
|
private ApplicationDao applicationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FlowFormDao flowFormDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FormService formService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
@@ -58,6 +70,19 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
return applicationDao.createApplicationByCallId(applicationRequest,callId,userEntity);
|
return applicationDao.createApplicationByCallId(applicationRequest,callId,userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NextOrPreviousFormResponse getnextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
||||||
|
FormActionEnum action) {
|
||||||
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
return flowFormDao.getnextOrPreviousForm(applicationEntity, formId, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||||
|
applicationDao.updateApplicationStatus(applicationId, status);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request) {
|
public List<ApplicationResponse> getAllApplications(HttpServletRequest request) {
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
package net.gepafin.tendermanagement.web.rest.api;
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
@@ -8,18 +15,15 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Validated
|
@Validated
|
||||||
public interface ApplicationApi {
|
public interface ApplicationApi {
|
||||||
@@ -91,5 +95,38 @@ public interface ApplicationApi {
|
|||||||
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
|
@Parameter(description = " Flow request object", required = true) @Valid @RequestBody ApplicationRequest applicationRequest,
|
||||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "Api to get an next or previous form by current form id",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
|
@GetMapping(value = "/{applicationId}/form/next-previous", produces = "application/json")
|
||||||
|
ResponseEntity<Response<NextOrPreviousFormResponse>> getnextOrPreviousForm(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The applicaltion id", required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
|
@Parameter(description = "The form id", required = false) @RequestParam(value = "formId", required = false) Long formId,
|
||||||
|
@RequestParam("action") FormActionEnum action);
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "Api to update application status",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
|
@PutMapping(value = "/{applicationId}/status", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<Void>> updateApplicationStatus(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationStatusTypeEnum status);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,13 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.ApplicationApi;
|
import net.gepafin.tendermanagement.web.rest.api.ApplicationApi;
|
||||||
@@ -69,4 +72,21 @@ public class ApplicationApiController implements ApplicationApi {
|
|||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<NextOrPreviousFormResponse>> getnextOrPreviousForm(HttpServletRequest request,Long applicationId,
|
||||||
|
Long formId, FormActionEnum action) {
|
||||||
|
NextOrPreviousFormResponse data = applicationService.getnextOrPreviousForm(request, applicationId, formId, action);
|
||||||
|
log.info("Get Next Or Previous Form ");
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> updateApplicationStatus(HttpServletRequest request, Long applicationId,
|
||||||
|
ApplicationStatusTypeEnum status) {
|
||||||
|
applicationService.updateApplicationStatus(request, applicationId, status);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,3 +158,4 @@ validation.field.pattern=Field {0} does not match the required pattern.
|
|||||||
validation.field.not_null=Field {0} must not be null.
|
validation.field.not_null=Field {0} must not be null.
|
||||||
validation.field.not_empty=Field {0} must not be empty.
|
validation.field.not_empty=Field {0} must not be empty.
|
||||||
|
|
||||||
|
current.form.incomplete=Current form is not filled.
|
||||||
|
|||||||
@@ -153,3 +153,4 @@ validation.field.max_length=Il campo {0} deve essere lungo al massimo {1} caratt
|
|||||||
validation.field.pattern=Il campo {0} non corrisponde al modello richiesto.
|
validation.field.pattern=Il campo {0} non corrisponde al modello richiesto.
|
||||||
validation.field.not_null=Il campo {0} non deve essere nullo.
|
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 è compilato
|
||||||
Reference in New Issue
Block a user