Merge pull request #39 from Kitzanos/feature/GEPAFINBE-38

GEPAFINBE-38(Assigned Protocol Number Upon Call Submission)
This commit is contained in:
rajeshkhore
2024-10-09 05:52:03 -07:00
committed by GitHub
13 changed files with 187 additions and 66 deletions

View File

@@ -195,8 +195,10 @@ public class GepafinConstant {
public static final String CALL_NOT_STARTED_YET = "call.not.started.yet";
public static final String CALL_ALREADY_ENDED = "call.already.ended";
public static final String APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "application.status.updated.successfully";
public static final String APPLICATION_ALREADY_IN_PREVIOUS_STATUS = "application.already.in.provided.status";
public static final String DELEGATION_NOT_FOUND = "delegation.not.found";
public static final String USER_COMPANY_RELATION_NOT_FOUND = "user.company.relation.not.found";
public static final String DELEGATION_DELETE_SUCCESS = "delegation.delete.success";
}

View File

@@ -31,6 +31,7 @@ import jakarta.persistence.criteria.Predicate;
import java.text.MessageFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -72,6 +73,9 @@ public class ApplicationDao {
@Autowired
private Validator validator;
@Autowired
private ProtocolRepository protocolRepository;
public ApplicationResponseBean createApplication(ApplicationRequestBean applicationRequestBean, UserEntity userEntity, Long formId, Long applicationId) {
FormEntity formEntity = formService.validateForm(formId);
@@ -260,6 +264,9 @@ public class ApplicationDao {
responseBean.setComments(applicationEntity.getComments());
responseBean.setCompanyId(applicationEntity.getCompany().getId());
responseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
if(applicationEntity.getProtocol() != null) {
responseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}
return responseBean;
}
@@ -279,6 +286,9 @@ public class ApplicationDao {
response.setCallId(entity.getCall().getId());
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
if(entity.getProtocol() != null) {
response.setProtocolNumber(entity.getProtocol().getProtocolNumber());
}
return response;
}
@@ -472,6 +482,9 @@ public class ApplicationDao {
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getName());
applicationGetResponseBean.setCompanyId(applicationEntity.getCompany().getId());
if(applicationEntity.getProtocol() != null) {
applicationGetResponseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}
applicationGetResponseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
return applicationGetResponseBean;
}
@@ -506,6 +519,9 @@ public class ApplicationDao {
public ApplicationResponse updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(status.getValue()))){
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS));
}
if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
callService.validatePublishedCall(applicationEntity.getCall().getId());
// CallEntity callEntity = applicationEntity.getCall();
@@ -525,6 +541,10 @@ public class ApplicationDao {
if (totalSteps.intValue() != completedSteps) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
}
Integer maxProtocolNumber=protocolRepository.findMaxProtocolNumber();
Integer protocolNumber = (maxProtocolNumber != null) ? maxProtocolNumber + 1 : 10000;
ProtocolEntity protocolEntity=createProtocolEntity(applicationEntity,protocolNumber);
applicationEntity.setProtocol(protocolEntity);
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
} else {
@@ -608,4 +628,15 @@ public class ApplicationDao {
}
}
public ProtocolEntity createProtocolEntity(ApplicationEntity applicationEntity,Integer protocolNumber){
ProtocolEntity protocolEntity=new ProtocolEntity();
protocolEntity.setCall(applicationEntity.getCall().getId());
LocalDateTime utcDateTime = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
protocolEntity.setYear(utcDateTime.getYear());
protocolEntity.setProtocolNumber(Long.valueOf(protocolNumber));
protocolEntity.setTime(LocalTime.now());
protocolEntity.setApplicationId(applicationEntity.getId());
protocolRepository.save(protocolEntity);
return protocolEntity;
}
}

View File

@@ -307,6 +307,9 @@ public class FlowFormDao {
completedSteps = getCompletedSteps(applicationEntity);
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
nextOrPreviousFormResponse.setCurrentStep(currentStep);
if(applicationEntity.getProtocol() != null) {
nextOrPreviousFormResponse.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
}
return nextOrPreviousFormResponse;
}

View File

@@ -36,4 +36,7 @@ public class ApplicationEntity extends BaseEntity {
@Column(name="IS_DELETED")
private Boolean isDeleted;
@OneToOne
@JoinColumn(name = "PROTOCOL_NUMBER")
private ProtocolEntity protocol;
}

View File

@@ -0,0 +1,28 @@
package net.gepafin.tendermanagement.entities;
import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalTime;
@Entity
@Table(name = "PROTOCOL")
@Data
public class ProtocolEntity extends BaseEntity {
@Column(name = "PROTOCOL_NUMBER", nullable = false)
private Long protocolNumber;
@Column(name = "YEAR", nullable = false)
private Integer year;
@Column(name="CALL_ID")
private Long call;
@Column(name = "TIME", nullable = false)
private LocalTime time;
@Column(name="APPLICATION_ID")
private Long applicationId;
}

View File

@@ -24,6 +24,8 @@ public class ApplicationGetResponseBean {
private String companyName;
private Long protocolNumber;
private List<FormApplicationResponse> form;
}

View File

@@ -31,4 +31,6 @@ public class ApplicationResponse{
private String companyName;
private Long protocolNumber;
}

View File

@@ -17,6 +17,8 @@ public class ApplicationResponseBean extends BaseBean {
private String comments;
private Long protocolNumber;
private List<ApplicationFormFieldResponseBean> formFields;
}

View File

@@ -22,6 +22,8 @@ public class NextOrPreviousFormResponse {
private String companyName;
private Long protocolNumber;
private ApplicationStatusTypeEnum applicationStatus;
private FormApplicationResponse applicationFormResponse;

View File

@@ -0,0 +1,13 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.ProtocolEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository
public interface ProtocolRepository extends JpaRepository<ProtocolEntity,Long> {
@Query("SELECT MAX(p.protocolNumber) FROM ProtocolEntity p")
Integer findMaxProtocolNumber();
}

View File

@@ -942,4 +942,35 @@
columnName="field_value"
newDataType="TEXT"/>
</changeSet>
<changeSet id="08-10-2024_2" author="Nisha Kashyap">
<createTable tableName="protocol">
<column name="id" type="INTEGER" autoIncrement="true">
<constraints nullable="false" primaryKey="true"
primaryKeyName="protocol_pkey" />
</column>
<column name="protocol_number" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="year" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="call_id" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="time" type="TIME">
<constraints nullable="false"/>
</column>
<column name="application_id" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
</createTable>
<addColumn tableName="application">
<column name="protocol_number" type="INTEGER">
</column>
</addColumn>
</changeSet>
</databaseChangeLog>

View File

@@ -220,6 +220,7 @@ call.not.started.yet = The call has not started yet. Please wait until the speci
call.already.ended = The call has already ended. You cannot submit the application after the deadline.
status.updated.successfully=Status updated successfully.
application.status.updated.successfully = Application status updated successfully.
application.already.in.provided.status=Application is already in provided status.
delegation.not.found=Delegation not found.
user.company.relation.not.found=User with the specified company relation not found.
delegation.delete.success=Delegation deleted successfully.

View File

@@ -215,6 +215,7 @@ call.not.started.yet = La chiamata non <20> ancora iniziata. Attendere fino alla
call.already.ended = La chiamata <20> gi<67> terminata. Non <20> possibile inviare l'applicazione dopo la scadenza.
status.updated.successfully=Stato aggiornato con successo.
application.status.updated.successfully = Stato dell'applicazione aggiornato con successo.
application.already.in.provided.status=L'applicazione <20> gi<67> nello stato fornito.
delegation.not.found=Delega non trovata.
user.company.relation.not.found=Relazione utente con l'azienda specificata non trovata.
delegation.delete.success=Delega eliminata con successo.