Code for amendment module

This commit is contained in:
nisha
2024-12-12 11:42:51 +05:30
parent 2a5f344ea0
commit 3937fb76f1
16 changed files with 145 additions and 10 deletions

View File

@@ -341,5 +341,6 @@ public class GepafinConstant {
public static final String POLLING_THREAD_NAME = "Ndg-Polling-Thread-"; 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 DOCUMENT_UPLOADING_IN_PROGRESS = "document.uploading.is.in.progress";
public static final String ASYNC_DOCUMENT_UPLOAD_NAME = "AsyncDocumentUpload-"; 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";
} }

View File

@@ -105,12 +105,33 @@ public class ApplicationAmendmentRequestDao {
@Autowired @Autowired
private AssignedApplicationsDao assignedApplicationsDao; private AssignedApplicationsDao assignedApplicationsDao;
@Autowired
private ApplicationEvaluationDao applicationEvaluationDao;
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) { public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId); log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId); ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
Long applicationId = applicationEvaluationEntity.getApplicationId(); 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 // Set common application-level details
String callName = application.getCall().getName(); String callName = application.getCall().getName();
Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null) Long protocolNumber = (application.getProtocol() != null && application.getProtocol().getProtocolNumber() != null)
@@ -135,11 +156,18 @@ public class ApplicationAmendmentRequestDao {
List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId); List<ApplicationFormEntity> forms = applicationFormRepository.findByApplicationId(applicationId);
List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>(); List<AmendmentFormFieldResponse> allFormFields = new ArrayList<>();
Map<String, FieldRequest> fieldRequestMap = evaluationFileRequests.stream()
.collect(Collectors.toMap(FieldRequest::getId, fieldRequest -> fieldRequest));
for (ApplicationFormEntity form : forms) { for (ApplicationFormEntity form : forms) {
String content = form.getForm().getContent(); String content = form.getForm().getContent();
List<Map<String, Object>> result = filterByName(content, "fileupload"); 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); response.setFormFields(allFormFields);
@@ -243,6 +271,9 @@ public class ApplicationAmendmentRequestDao {
String formFieldsJson = Utils.convertObjectToJson(formFieldRequestBean); String formFieldsJson = Utils.convertObjectToJson(formFieldRequestBean);
applicationAmendmentRequestEntity.setFormFields(formFieldsJson); applicationAmendmentRequestEntity.setFormFields(formFieldsJson);
} }
if(Boolean.FALSE.equals(applicationAmendmentRequest.getAmendmentDocument().isEmpty())) {
setAmendmentDocuments(applicationAmendmentRequest.getAmendmentDocument(), applicationAmendmentRequestEntity);
}
List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(applicationEvaluationEntity.getId()); List<ApplicationAmendmentRequestEntity> amendmentRequest = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(applicationEvaluationEntity.getId());
// Ensure startDate and initialDays are not null to avoid NullPointerException // Ensure startDate and initialDays are not null to avoid NullPointerException
if (amendmentRequest !=null && amendmentRequest.isEmpty() && applicationEvaluationEntity.getStartDate() != null && applicationEvaluationEntity.getInitialDays() != null ) { if (amendmentRequest !=null && amendmentRequest.isEmpty() && applicationEvaluationEntity.getStartDate() != null && applicationEvaluationEntity.getInitialDays() != null ) {
@@ -261,7 +292,7 @@ public class ApplicationAmendmentRequestDao {
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub()); Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity( ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber, applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber,
userEntity.getHub().getId()); userEntity.getHub().getId(),false);
applicationAmendmentRequestEntity.setProtocol(protocolEntity); applicationAmendmentRequestEntity.setProtocol(protocolEntity);
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT); ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
String evaluationStatusType = applicationEvaluationEntity.getStatus(); String evaluationStatusType = applicationEvaluationEntity.getStatus();
@@ -302,6 +333,16 @@ public class ApplicationAmendmentRequestDao {
return applicationAmendment; 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) { public ApplicationAmendmentRequestEntity saveApplicationAmendmentRequestEntity(ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity,ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity,VersionActionTypeEnum actionTypeEnum) {
ApplicationAmendmentRequestEntity applicationAmendmentRequest = applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity); ApplicationAmendmentRequestEntity applicationAmendmentRequest = applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
@@ -320,12 +361,31 @@ public class ApplicationAmendmentRequestDao {
List<AmendmentFormField> amendmentFormFields = Utils.convertJsonStringToList( List<AmendmentFormField> amendmentFormFields = Utils.convertJsonStringToList(
applicationAmendmentRequestEntity.getFormFields(), AmendmentFormField.class); applicationAmendmentRequestEntity.getFormFields(), AmendmentFormField.class);
Map<String, ApplicationFormFieldEntity> formFieldEntityMap = getApplicationFormFieldEntityMap(applicationAmendmentRequestEntity, amendmentFormFields); 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); processFormFields(amendmentFormFields, fieldIdToLabelMap, formFieldEntityMap, response);
return 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) { private ApplicationAmendmentRequestResponse initializeBasicResponse(ApplicationAmendmentRequestEntity entity) {
ApplicationAmendmentRequestResponse response = new ApplicationAmendmentRequestResponse(); ApplicationAmendmentRequestResponse response = new ApplicationAmendmentRequestResponse();
response.setId(entity.getId()); response.setId(entity.getId());
@@ -519,6 +579,7 @@ public class ApplicationAmendmentRequestDao {
} }
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
setAmendmentDocuments(updateRequest.getAmendmentDocuments(),existingApplicationAmendment);
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment,oldApplicationAmendmentEntity,VersionActionTypeEnum.UPDATE); ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment,oldApplicationAmendmentEntity,VersionActionTypeEnum.UPDATE);
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment); ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment);
log.info("Application Amendment updated successfully: {}", response); log.info("Application Amendment updated successfully: {}", response);
@@ -585,7 +646,7 @@ public class ApplicationAmendmentRequestDao {
String fieldId) { String fieldId) {
AmendmentFormField amendmentFormField = amendmentFormFieldMap.get(fieldId); AmendmentFormField amendmentFormField = amendmentFormFieldMap.get(fieldId);
if (amendmentFormField == null) { 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; return amendmentFormField;
} }

View File

@@ -813,7 +813,7 @@ public class ApplicationDao {
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) { if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId()); callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId());
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub()); 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.setProtocol(protocolEntity);
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue()); applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));

View File

@@ -894,7 +894,7 @@ public class ApplicationEvaluationDao {
} }
private DocumentResponseBean createDocumentResponseBean(DocumentEntity documentEntity) { public DocumentResponseBean createDocumentResponseBean(DocumentEntity documentEntity) {
DocumentResponseBean responseBean = new DocumentResponseBean(); DocumentResponseBean responseBean = new DocumentResponseBean();
responseBean.setId(documentEntity.getId()); responseBean.setId(documentEntity.getId());
responseBean.setName(documentEntity.getFileName()); responseBean.setName(documentEntity.getFileName());

View File

@@ -4,6 +4,7 @@ import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.enums.ProtocolTypeEnum;
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum; import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest; import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
import net.gepafin.tendermanagement.util.LoggingUtil; import net.gepafin.tendermanagement.util.LoggingUtil;
@@ -42,7 +43,7 @@ public class ProtocolDao {
return (maxProtocolNumber != null) ? maxProtocolNumber + 1 : startNumber; 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 protocolEntity=new ProtocolEntity();
protocolEntity.setCall(applicationEntity.getCall().getId()); protocolEntity.setCall(applicationEntity.getCall().getId());
LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
@@ -51,6 +52,11 @@ public class ProtocolDao {
protocolEntity.setTime(LocalTime.now()); protocolEntity.setTime(LocalTime.now());
protocolEntity.setApplicationId(applicationEntity.getId()); protocolEntity.setApplicationId(applicationEntity.getId());
protocolEntity.setHubId(hubId); protocolEntity.setHubId(hubId);
if(Boolean.TRUE.equals(isForApplication)){
protocolEntity.setType(ProtocolTypeEnum.INPUT.getValue());
}else {
protocolEntity.setType(ProtocolTypeEnum.OUTPUT.getValue());
}
protocolRepository.save(protocolEntity); protocolRepository.save(protocolEntity);
/** This code is responsible for adding a version history log for "create protocol" operation. **/ /** This code is responsible for adding a version history log for "create protocol" operation. **/

View File

@@ -50,4 +50,7 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
@Column(name = "end_date") @Column(name = "end_date")
private LocalDateTime endDate; private LocalDateTime endDate;
@Column(name = "amendment_document")
private String amendmentDocument;
} }

View File

@@ -28,4 +28,7 @@ public class ProtocolEntity extends BaseEntity {
@Column(name="HUB_ID") @Column(name="HUB_ID")
private Long hubId; private Long hubId;
@Column(name = "type")
private String type;
} }

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -11,4 +11,5 @@ public class ApplicationAmendmentRequest {
private Long responseDays; private Long responseDays;
private Boolean isSendNotification; private Boolean isSendNotification;
private Boolean isSendEmail; private Boolean isSendEmail;
private List<AmendmentFieldRequest> amendmentDocument;
} }

View File

@@ -8,4 +8,5 @@ import lombok.Data;
public class ApplicationAmendmentRequestBean { public class ApplicationAmendmentRequestBean {
private String note; private String note;
private List<ApplicationFormFieldRequestBean> applicationFormFields; private List<ApplicationFormFieldRequestBean> applicationFormFields;
private List<AmendmentFieldRequest> amendmentDocuments;
} }

View File

@@ -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;
}

View File

@@ -21,6 +21,7 @@ public class ApplicationAmendmentRequestResponse {
private String beneficiaryName; private String beneficiaryName;
private List<AmendmentFormFieldResponse> formFields; private List<AmendmentFormFieldResponse> formFields;
private List<ApplicationFormFieldResponseBean> applicationFormFields; private List<ApplicationFormFieldResponseBean> applicationFormFields;
private List<AmendmentDocumentResponse> amendmentDocuments;
private Long applicationId; private Long applicationId;
private Long applicationEvaluationId; private Long applicationEvaluationId;
private LocalDateTime evaluationEndDate; private LocalDateTime evaluationEndDate;

View File

@@ -1991,5 +1991,12 @@
<column name="document_attachment_id" type="TEXT"/> <column name="document_attachment_id" type="TEXT"/>
</addColumn> </addColumn>
</changeSet> </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> </databaseChangeLog>

View File

@@ -335,3 +335,4 @@ upload.document.is.only.for.gepafin = Document cant be uploaded, this is only av
appointment.created.successfully = Appointment created successfully. appointment.created.successfully = Appointment created successfully.
error.try.again = Service call error while performing the operation. Please try again. error.try.again = Service call error while performing the operation. Please try again.
document.uploading.is.in.progress = Document uploading is in progress. 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.

View File

@@ -325,3 +325,4 @@ upload.document.is.only.for.gepafin = Il documento non pu? essere caricato, ques
appointment.created.successfully = Appuntamento creato con successo. appointment.created.successfully = Appuntamento creato con successo.
error.try.again = Errore di chiamata di servizio durante l'esecuzione dell'operazione. Riprovare. 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. 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.