Code for amendment module
This commit is contained in:
@@ -341,5 +341,6 @@ public class GepafinConstant {
|
||||
public static final String POLLING_THREAD_NAME = "Ndg-Polling-Thread-";
|
||||
public static final String DOCUMENT_UPLOADING_IN_PROGRESS = "document.uploading.is.in.progress";
|
||||
public static final String ASYNC_DOCUMENT_UPLOAD_NAME = "AsyncDocumentUpload-";
|
||||
public static final String All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED="all.document.checked.and.one.checklist.checked";
|
||||
}
|
||||
|
||||
|
||||
@@ -105,12 +105,33 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private AssignedApplicationsDao assignedApplicationsDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
Long applicationId = applicationEvaluationEntity.getApplicationId();
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
List<FieldRequest> evaluationFileRequests=new ArrayList<>();
|
||||
List<ChecklistRequest> checklistRequests=new ArrayList<>();
|
||||
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
String file=applicationEvaluationEntity.getFile();
|
||||
String checkList=applicationEvaluationEntity.getChecklist();
|
||||
if(file != null){
|
||||
evaluationFileRequests=Utils.convertJsonStringToList(file,FieldRequest.class);
|
||||
}
|
||||
Boolean allValid = evaluationFileRequests.stream()
|
||||
.anyMatch(fieldRequest -> fieldRequest.getValid() == null);
|
||||
if(checkList != null) {
|
||||
checklistRequests=Utils.convertJsonStringToList(checkList,ChecklistRequest.class);
|
||||
}
|
||||
boolean resultCheckList = checklistRequests.stream()
|
||||
.anyMatch(checklistRequest -> Boolean.TRUE.equals(checklistRequest.getValid())) ? false : true;
|
||||
|
||||
if(Boolean.TRUE.equals(allValid) || Boolean.TRUE.equals(resultCheckList)){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.All_DOCUMENT_CHECKED_AND_ONE_CHECKLIST_CHECKED));
|
||||
}
|
||||
// Set common application-level details
|
||||
String callName = application.getCall().getName();
|
||||
Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null)
|
||||
@@ -135,11 +156,18 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId);
|
||||
List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>();
|
||||
|
||||
Map<String, FieldRequest> fieldRequestMap = evaluationFileRequests.stream()
|
||||
.collect(Collectors.toMap(FieldRequest::getId, fieldRequest -> fieldRequest));
|
||||
for (ApplicationFormEntity form : forms) {
|
||||
String content = form.getForm().getContent();
|
||||
List<Map<String, Object>> result = filterByName(content, "fileupload");
|
||||
allFormFields.addAll(getIdAndLabelFromResult(result));
|
||||
List<AmendmentFormFieldResponse> amendmentFormFieldResponses= getIdAndLabelFromResult(result);
|
||||
amendmentFormFieldResponses.removeIf(amendmentFormFieldResponse -> {
|
||||
FieldRequest matchingRequest = fieldRequestMap.get(amendmentFormFieldResponse.getFieldId());
|
||||
// Remove if no matching FieldRequest exists or if valid is true
|
||||
return matchingRequest == null || Boolean.TRUE.equals(matchingRequest.getValid());
|
||||
});
|
||||
allFormFields.addAll(amendmentFormFieldResponses);
|
||||
}
|
||||
|
||||
response.setFormFields(allFormFields);
|
||||
@@ -243,6 +271,9 @@ public class ApplicationAmendmentRequestDao {
|
||||
String formFieldsJson = Utils.convertObjectToJson(formFieldRequestBean);
|
||||
applicationAmendmentRequestEntity.setFormFields(formFieldsJson);
|
||||
}
|
||||
if(Boolean.FALSE.equals(applicationAmendmentRequest.getAmendmentDocument().isEmpty())) {
|
||||
setAmendmentDocuments(applicationAmendmentRequest.getAmendmentDocument(), applicationAmendmentRequestEntity);
|
||||
}
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(applicationEvaluationEntity.getId());
|
||||
// Ensure startDate and initialDays are not null to avoid NullPointerException
|
||||
if (amendmentRequest !=null && amendmentRequest.isEmpty() && applicationEvaluationEntity.getStartDate() != null && applicationEvaluationEntity.getInitialDays() != null ) {
|
||||
@@ -261,7 +292,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
|
||||
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
|
||||
applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber,
|
||||
userEntity.getHub().getId());
|
||||
userEntity.getHub().getId(),false);
|
||||
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
|
||||
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
|
||||
String evaluationStatusType = applicationEvaluationEntity.getStatus();
|
||||
@@ -302,6 +333,16 @@ public class ApplicationAmendmentRequestDao {
|
||||
return applicationAmendment;
|
||||
}
|
||||
|
||||
private void setAmendmentDocuments(List<AmendmentFieldRequest> amendmentFieldRequest, ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity) {
|
||||
amendmentFieldRequest.stream().forEach(amendmentData->{
|
||||
String fieldValue=amendmentData.getFileValue();
|
||||
if(fieldValue!=null){
|
||||
documentService.validateDocument(Long.valueOf(fieldValue));
|
||||
}
|
||||
});
|
||||
applicationAmendmentRequestEntity.setAmendmentDocument(Utils.convertListToJsonString(amendmentFieldRequest));
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestEntity saveApplicationAmendmentRequestEntity(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity,ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity,VersionActionTypeEnum actionTypeEnum) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequest = applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
||||
|
||||
@@ -320,12 +361,31 @@ public class ApplicationAmendmentRequestDao {
|
||||
List<AmendmentFormField> amendmentFormFields = Utils.convertJsonStringToList(
|
||||
applicationAmendmentRequestEntity.getFormFields(), AmendmentFormField.class);
|
||||
Map<String, ApplicationFormFieldEntity> formFieldEntityMap = getApplicationFormFieldEntityMap(applicationAmendmentRequestEntity, amendmentFormFields);
|
||||
|
||||
List<AmendmentFieldRequest> amendmentFieldRequests = Utils.convertJsonStringToList(applicationAmendmentRequestEntity.getAmendmentDocument(),AmendmentFieldRequest.class);
|
||||
if (amendmentFieldRequests != null) {
|
||||
List<AmendmentDocumentResponse> amendmentDocumentResponses = amendmentFieldRequests.stream()
|
||||
.map(this::createAmendmentDocumentResponse)
|
||||
.toList();
|
||||
response.setAmendmentDocuments(amendmentDocumentResponses);
|
||||
}
|
||||
processFormFields(amendmentFormFields, fieldIdToLabelMap, formFieldEntityMap, response);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private AmendmentDocumentResponse createAmendmentDocumentResponse(AmendmentFieldRequest amendmentFieldRequest) {
|
||||
AmendmentDocumentResponse amendmentDocumentResponse = new AmendmentDocumentResponse();
|
||||
amendmentDocumentResponse.setFieldId(amendmentFieldRequest.getFieldId());
|
||||
amendmentDocumentResponse.setNameValue(amendmentFieldRequest.getNameValue());
|
||||
amendmentDocumentResponse.setIsValid(amendmentFieldRequest.getIsValid());
|
||||
|
||||
DocumentEntity documentEntity = documentService.validateDocument(Long.valueOf(amendmentFieldRequest.getFileValue()));
|
||||
DocumentResponseBean responseBean = applicationEvaluationDao.createDocumentResponseBean(documentEntity);
|
||||
amendmentDocumentResponse.setFileValue(responseBean);
|
||||
|
||||
return amendmentDocumentResponse;
|
||||
}
|
||||
|
||||
private ApplicationAmendmentRequestResponse initializeBasicResponse(ApplicationAmendmentRequestEntity entity) {
|
||||
ApplicationAmendmentRequestResponse response = new ApplicationAmendmentRequestResponse();
|
||||
response.setId(entity.getId());
|
||||
@@ -519,6 +579,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
}
|
||||
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
|
||||
setAmendmentDocuments(updateRequest.getAmendmentDocuments(),existingApplicationAmendment);
|
||||
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment,oldApplicationAmendmentEntity,VersionActionTypeEnum.UPDATE);
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
|
||||
log.info("Application Amendment updated successfully: {}", response);
|
||||
@@ -585,7 +646,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
String fieldId) {
|
||||
AmendmentFormField amendmentFormField = amendmentFormFieldMap.get(fieldId);
|
||||
if (amendmentFormField == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND);
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_FORM_FIELD_NOT_FOUND));
|
||||
}
|
||||
return amendmentFormField;
|
||||
}
|
||||
|
||||
@@ -813,7 +813,7 @@ public class ApplicationDao {
|
||||
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
|
||||
callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId());
|
||||
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
|
||||
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity, protocolNumber, userEntity.getHub().getId());
|
||||
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity, protocolNumber, userEntity.getHub().getId(),true);
|
||||
applicationEntity.setProtocol(protocolEntity);
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
|
||||
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
|
||||
@@ -894,7 +894,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
|
||||
|
||||
private DocumentResponseBean createDocumentResponseBean(DocumentEntity documentEntity) {
|
||||
public DocumentResponseBean createDocumentResponseBean(DocumentEntity documentEntity) {
|
||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||
responseBean.setId(documentEntity.getId());
|
||||
responseBean.setName(documentEntity.getFileName());
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.enums.ProtocolTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -42,7 +43,7 @@ public class ProtocolDao {
|
||||
return (maxProtocolNumber != null) ? maxProtocolNumber + 1 : startNumber;
|
||||
}
|
||||
|
||||
public ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Long protocolNumber, Long hubId){
|
||||
public ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Long protocolNumber, Long hubId,Boolean isForApplication){
|
||||
ProtocolEntity protocolEntity=new ProtocolEntity();
|
||||
protocolEntity.setCall(applicationEntity.getCall().getId());
|
||||
LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
@@ -51,6 +52,11 @@ public class ProtocolDao {
|
||||
protocolEntity.setTime(LocalTime.now());
|
||||
protocolEntity.setApplicationId(applicationEntity.getId());
|
||||
protocolEntity.setHubId(hubId);
|
||||
if(Boolean.TRUE.equals(isForApplication)){
|
||||
protocolEntity.setType(ProtocolTypeEnum.INPUT.getValue());
|
||||
}else {
|
||||
protocolEntity.setType(ProtocolTypeEnum.OUTPUT.getValue());
|
||||
}
|
||||
protocolRepository.save(protocolEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for "create protocol" operation. **/
|
||||
|
||||
@@ -50,4 +50,7 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
|
||||
@Column(name = "end_date")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
@Column(name = "amendment_document")
|
||||
private String amendmentDocument;
|
||||
|
||||
}
|
||||
|
||||
@@ -28,4 +28,7 @@ public class ProtocolEntity extends BaseEntity {
|
||||
@Column(name="HUB_ID")
|
||||
private Long hubId;
|
||||
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum ProtocolTypeEnum {
|
||||
INPUT("INPUT"),
|
||||
OUTPUT("OUTPUT");
|
||||
|
||||
private String value;
|
||||
|
||||
ProtocolTypeEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AmendmentFieldRequest {
|
||||
|
||||
private String fieldId;
|
||||
private String nameValue;
|
||||
private String fileValue;
|
||||
private Boolean isValid = false;
|
||||
|
||||
}
|
||||
@@ -11,4 +11,5 @@ public class ApplicationAmendmentRequest {
|
||||
private Long responseDays;
|
||||
private Boolean isSendNotification;
|
||||
private Boolean isSendEmail;
|
||||
private List<AmendmentFieldRequest> amendmentDocument;
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ import lombok.Data;
|
||||
public class ApplicationAmendmentRequestBean {
|
||||
private String note;
|
||||
private List<ApplicationFormFieldRequestBean> applicationFormFields;
|
||||
private List<AmendmentFieldRequest> amendmentDocuments;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AmendmentDocumentResponse {
|
||||
|
||||
private String fieldId;
|
||||
private String nameValue;
|
||||
private DocumentResponseBean fileValue;
|
||||
private Boolean isValid = false;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public class ApplicationAmendmentRequestResponse {
|
||||
private String beneficiaryName;
|
||||
private List<AmendmentFormFieldResponse> formFields;
|
||||
private List<ApplicationFormFieldResponseBean> applicationFormFields;
|
||||
private List<AmendmentDocumentResponse> amendmentDocuments;
|
||||
private Long applicationId;
|
||||
private Long applicationEvaluationId;
|
||||
private LocalDateTime evaluationEndDate;
|
||||
|
||||
@@ -1991,5 +1991,12 @@
|
||||
<column name="document_attachment_id" type="TEXT"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="12_12_2024_1" author="Nisha Kashyap">
|
||||
<addColumn tableName="protocol">
|
||||
<column name="type" type="VARCHAR(255)"></column>
|
||||
</addColumn>
|
||||
<addColumn tableName="application_amendment_request">
|
||||
<column name="amendment_document" type="TEXT"></column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -335,3 +335,4 @@ upload.document.is.only.for.gepafin = Document cant be uploaded, this is only av
|
||||
appointment.created.successfully = Appointment created successfully.
|
||||
error.try.again = Service call error while performing the operation. Please try again.
|
||||
document.uploading.is.in.progress = Document uploading is in progress.
|
||||
all.document.checked.and.one.checklist.checked=All document should be checked and at least one checklist should be checked.
|
||||
@@ -325,3 +325,4 @@ upload.document.is.only.for.gepafin = Il documento non pu? essere caricato, ques
|
||||
appointment.created.successfully = Appuntamento creato con successo.
|
||||
error.try.again = Errore di chiamata di servizio durante l'esecuzione dell'operazione. Riprovare.
|
||||
document.uploading.is.in.progress = Il documento è in fase di caricamento.
|
||||
all.document.checked.and.one.checklist.checked=Tutti i documenti devono essere controllati e almeno una checklist deve essere controllata.
|
||||
Reference in New Issue
Block a user