Resolved conflicts
This commit is contained in:
@@ -234,6 +234,13 @@ public class GepafinConstant {
|
||||
public static final String GET_USERS_SUCCESS_MSG = "get.users.success.msg";
|
||||
public static final String CANNOT_CREATE_BENEFICIARY_USER="cannot.create.beneficiary.user";
|
||||
|
||||
public static final String APPLICATION_ASSIGNED= "application.assigned.success.msg";
|
||||
public static final String APPLICATION_ALREADY_ASSIGNED = "application.already.assigned.msg";
|
||||
public static final String ASSIGNED_APPLICATION_NOT_FOUND_MSG="aasigned.application.not.found";
|
||||
public static final String DELETE_ASSIGNED_APPLICATION_SUCCESS_MSG = "assigned.application.deleted.success";
|
||||
public static final String GET_ASSIGNED_APPLICATION_SUCCESS_MSG = "assigned.application.get.success";
|
||||
public static final String ASSIGNED_APPLICATION_UPDATE_SUCCESSFULLY_MSG = "assigned.application.update.successfully";
|
||||
|
||||
public static final String HUB_CREATE_SUCCESS = "hub_create_success";
|
||||
public static final String HUB_UPDATE_SUCCESS = "hub_update_success";
|
||||
public static final String HUB_GET_SUCCESS = "hub_get_success";
|
||||
@@ -242,6 +249,5 @@ public class GepafinConstant {
|
||||
public static final String HUB_NOT_FOUND = "hub_not_found";
|
||||
public static final String EVALUATIONCRITERIA_INVALID = "evaluationCriteria.invalid";
|
||||
public static final String APPLICATION_NOT_IN_DRAFT_STATUS="application.not.in.draft.status";
|
||||
public static final String APPLICATION_ALREADY_ASSIGNED="application.already.assigned";
|
||||
}
|
||||
|
||||
|
||||
@@ -283,11 +283,11 @@ public class ApplicationDao {
|
||||
// return applicationResponses;
|
||||
// }
|
||||
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId) {
|
||||
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,String status) {
|
||||
|
||||
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
|
||||
|
||||
Specification<ApplicationEntity> spec = search(userEntity.getId(), callId, companyId);
|
||||
Specification<ApplicationEntity> spec = search(userEntity.getId(), callId, companyId,status);
|
||||
|
||||
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
|
||||
|
||||
@@ -297,7 +297,7 @@ public class ApplicationDao {
|
||||
}
|
||||
|
||||
|
||||
private Specification<ApplicationEntity> search(Long userId, Long callId, Long companyId) {
|
||||
private Specification<ApplicationEntity> search(Long userId, Long callId, Long companyId,String status) {
|
||||
return (root, query, builder) -> {
|
||||
Boolean isBeneficiary = validator.checkIsBeneficiary();
|
||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||
@@ -310,6 +310,10 @@ public class ApplicationDao {
|
||||
if (companyId != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId));
|
||||
}
|
||||
if (status != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("status"), status));
|
||||
}
|
||||
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.log;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
public class AssignedApplicationsDao {
|
||||
|
||||
@Autowired
|
||||
ApplicationService applicationService;
|
||||
|
||||
@Autowired
|
||||
AssignedApplicationsRepository assignedApplicationsRepository;
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
public AssignedApplicationsResponse createAssignedApplications(Long applicationId, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){
|
||||
log.info("Assigning application to pre-Instructor with details: {}", applicationId,userId);
|
||||
|
||||
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
|
||||
if(assignedApplications!=null){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_ASSIGNED));
|
||||
}
|
||||
ApplicationEntity application = applicationService.validateApplication(applicationId);
|
||||
UserEntity user = userService.validateUser(userId);
|
||||
AssignedApplicationsEntity assignment = createAssignmentEntity(application, user.getId(), assignedByUser, assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse assignApplicationToInstructorResponse = convertEntityToResponse(assignment, assignedApplicationsRequest);
|
||||
|
||||
log.info("Application assigned succesfully {}", assignApplicationToInstructorResponse);
|
||||
return assignApplicationToInstructorResponse;
|
||||
}
|
||||
|
||||
public AssignedApplicationsEntity createAssignmentEntity(ApplicationEntity application, Long userId, UserEntity assignedByUser, AssignedApplicationsRequest assignedApplicationsRequest){
|
||||
AssignedApplicationsEntity assignApplication= new AssignedApplicationsEntity();
|
||||
assignApplication.setApplication(application);
|
||||
assignApplication.setAssignedBy(assignedByUser.getId());
|
||||
assignApplication.setUserId(userId);
|
||||
assignApplication.setStatus(assignedApplicationsRequest.getStatus().getValue());
|
||||
assignApplication.setNote(assignedApplicationsRequest.getNote());
|
||||
assignApplication.setIsDeleted(false);
|
||||
assignApplication.setAssignedAt(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
AssignedApplicationsEntity assignedApplicationsEntity = saveAssignedApplication(assignApplication);
|
||||
return assignedApplicationsEntity;
|
||||
|
||||
}
|
||||
public AssignedApplicationsEntity saveAssignedApplication(AssignedApplicationsEntity assignedApplicationsEntity){
|
||||
AssignedApplicationsEntity assignedApplication= assignedApplicationsRepository.save(assignedApplicationsEntity);
|
||||
return assignedApplication;
|
||||
}
|
||||
|
||||
public AssignedApplicationsResponse convertEntityToResponse(AssignedApplicationsEntity application, AssignedApplicationsRequest assignedApplicationsRequest){
|
||||
AssignedApplicationsResponse assignedApplicationsResponse = new AssignedApplicationsResponse();
|
||||
assignedApplicationsResponse.setId(application.getId());
|
||||
assignedApplicationsResponse.setApplicationId(application.getApplication().getId());
|
||||
assignedApplicationsResponse.setAssignedBy(application.getAssignedBy());
|
||||
assignedApplicationsResponse.setUserId(application.getUserId());
|
||||
assignedApplicationsResponse.setCreatedDate(application.getCreatedDate());
|
||||
assignedApplicationsResponse.setUpdatedDate(application.getUpdatedDate());
|
||||
assignedApplicationsResponse.setNote(application.getNote());
|
||||
assignedApplicationsResponse.setStatus(AssignedApplicationEnum.valueOf(application.getStatus()));
|
||||
assignedApplicationsResponse.setAssignedAt(application.getAssignedAt());
|
||||
return assignedApplicationsResponse;
|
||||
}
|
||||
|
||||
public AssignedApplicationsEntity validateAssignedApplication(Long id){
|
||||
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(id).orElseThrow(()->
|
||||
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
|
||||
return assignedApplication;
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting assigned application with ID: {}", id);
|
||||
AssignedApplicationsEntity assignedApplicationsEntity= validateAssignedApplication(id);
|
||||
assignedApplicationsEntity.setIsDeleted(true);
|
||||
assignedApplicationsEntity= saveAssignedApplication(assignedApplicationsEntity);
|
||||
log.info("Assigned Application deleted with ID: {}", id);
|
||||
}
|
||||
|
||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId){
|
||||
Specification<AssignedApplicationsEntity> spec = search(userId);
|
||||
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
|
||||
return assignedApplicationsEntityList.stream()
|
||||
.map(entity -> convertEntityToResponse(entity, new AssignedApplicationsRequest()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
private Specification<AssignedApplicationsEntity> search(Long userId) {
|
||||
return (root, query, builder) -> {
|
||||
Predicate predicate = builder.isFalse(root.get("isDeleted"));
|
||||
if (userId != null) {
|
||||
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
|
||||
}
|
||||
return predicate;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public AssignedApplicationsResponse updateAssignedApplication(
|
||||
Long id, AssignedApplicationsRequest updateRequest, UserEntity updatedByUser) {
|
||||
|
||||
log.info("Updating assigned application with ID: {}", id);
|
||||
AssignedApplicationsEntity existingAssignment = validateAssignedApplication(id);
|
||||
|
||||
setIfUpdated(existingAssignment::getNote, existingAssignment::setNote, updateRequest.getNote());
|
||||
setIfUpdated(existingAssignment::getStatus, existingAssignment::setStatus, updateRequest.getStatus().name());
|
||||
setIfUpdated(existingAssignment::getAssignedBy, existingAssignment::setAssignedBy, updatedByUser.getId());
|
||||
|
||||
existingAssignment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
|
||||
AssignedApplicationsEntity updatedAssignment = saveAssignedApplication(existingAssignment);
|
||||
AssignedApplicationsResponse response = convertEntityToResponse(updatedAssignment, updateRequest);
|
||||
log.info("Assigned application updated successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public AssignedApplicationsResponse getAssignedApplicationById(Long id) {
|
||||
log.info("Fetching assigned application with ID: {}", id);
|
||||
AssignedApplicationsEntity assignedApplication = validateAssignedApplication(id);
|
||||
AssignedApplicationsResponse response = convertEntityToResponse(assignedApplication, new AssignedApplicationsRequest());
|
||||
log.info("Assigned application fetched successfully: {}", response);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class CallDao {
|
||||
}
|
||||
|
||||
List<DocumentEntity> existingDocuments = documentRepository
|
||||
.findBySourceIdAndTypeAndIsDeletedFalse(sourceId, documentType.getValue());
|
||||
.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(sourceId, DocumentSourceTypeEnum.CALL.getValue(), documentType.getValue());
|
||||
|
||||
List<Long> incomingIds = documentReqList.stream().map(DocumentReq::getId).filter(id -> id != null && id > 0)
|
||||
.collect(Collectors.toList());
|
||||
@@ -267,7 +267,7 @@ public class CallDao {
|
||||
|
||||
private DocumentEntity convertToDocumentEntity(DocumentReq documentReq,Long sourceId) {
|
||||
validateDocumentEntity(documentReq.getId());
|
||||
DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndIsDeletedFalse(documentReq.getId(),sourceId)
|
||||
DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndSourceAndIsDeletedFalse(documentReq.getId(),sourceId, DocumentSourceTypeEnum.CALL.getValue())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
|
||||
return documentEntity;
|
||||
@@ -622,10 +622,10 @@ public class CallDao {
|
||||
}
|
||||
|
||||
private CallResponse getCallResponseBean(CallEntity callEntity) {
|
||||
List<DocumentEntity> documentEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(),
|
||||
DocumentTypeEnum.DOCUMENT.getValue());
|
||||
List<DocumentEntity> imageEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(),
|
||||
DocumentTypeEnum.IMAGES.getValue());
|
||||
List<DocumentEntity> documentEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(),DocumentSourceTypeEnum.CALL.getValue()
|
||||
, DocumentTypeEnum.DOCUMENT.getValue());
|
||||
List<DocumentEntity> imageEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(), DocumentSourceTypeEnum.CALL.getValue()
|
||||
, DocumentTypeEnum.IMAGES.getValue());
|
||||
List<LookUpDataResponse> amiedTo = callTargetAudienceChecklistRepository
|
||||
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream()
|
||||
.map(this::convertToLookUpDataResponseBean).toList();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "assigned_applications")
|
||||
|
||||
public class AssignedApplicationsEntity extends BaseEntity{
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "APPLICATION_ID")
|
||||
private ApplicationEntity application;
|
||||
|
||||
@Column(name = "USER_ID")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "ASSIGNED_BY")
|
||||
private Long assignedBy;
|
||||
|
||||
@Column(name = "STATUS")
|
||||
private String status;
|
||||
|
||||
@Column(name = "NOTE")
|
||||
private String note;
|
||||
|
||||
@Column(name="IS_DELETED")
|
||||
private Boolean isDeleted=false;
|
||||
|
||||
@Column(nullable = false)
|
||||
private LocalDateTime assignedAt;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum AssignedApplicationEnum {
|
||||
ASSIGNED("ASSIGNED"),
|
||||
APPROVED("APPROVED"),
|
||||
REJECTED("REJECTED");
|
||||
|
||||
|
||||
private final String value;
|
||||
|
||||
AssignedApplicationEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationsRequest {
|
||||
private String note;
|
||||
private AssignedApplicationEnum status;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationsResponse extends BaseBean {
|
||||
private Long applicationId;
|
||||
private Long userId;
|
||||
private Long assignedBy;
|
||||
private AssignedApplicationEnum status;
|
||||
private String note;
|
||||
private LocalDateTime assignedAt;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface AssignedApplicationsRepository extends JpaRepository<AssignedApplicationsEntity,Long>, JpaSpecificationExecutor<AssignedApplicationsEntity>{
|
||||
Optional<AssignedApplicationsEntity> findByApplicationIdAndIsDeletedFalse(Long applicationId);
|
||||
Optional<AssignedApplicationsEntity> findByIdAndIsDeletedFalse(Long id);
|
||||
|
||||
}
|
||||
@@ -15,12 +15,15 @@ public interface DocumentRepository extends JpaRepository<DocumentEntity, Long>
|
||||
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
||||
Optional<DocumentEntity> findById(@Param("id") Long id);
|
||||
|
||||
List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
||||
// List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
|
||||
|
||||
Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId);
|
||||
// Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId);
|
||||
|
||||
List<DocumentEntity> findBySource(String source);
|
||||
|
||||
List<DocumentEntity> findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type);
|
||||
|
||||
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface ApplicationService {
|
||||
|
||||
ApplicationGetResponseBean getApplicationByFormId(HttpServletRequest request, Long applicationId,Long formId);
|
||||
|
||||
List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId);
|
||||
List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId,String status);
|
||||
|
||||
void deleteApplication(HttpServletRequest request, Long applicationId);
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AssignedApplicationsService {
|
||||
|
||||
AssignedApplicationsResponse createAssignedApplications(
|
||||
HttpServletRequest request, Long applicationId, Long userId, AssignedApplicationsRequest assignedApplicationsRequest);
|
||||
|
||||
void deleteApplication(HttpServletRequest request, Long id);
|
||||
|
||||
List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId);
|
||||
AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest assignedApplicationsRequest);
|
||||
AssignedApplicationsResponse getAssignedApplicationById(Long id);
|
||||
}
|
||||
@@ -85,12 +85,12 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId) {
|
||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId , String status) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
if (companyId != null) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
}
|
||||
return applicationDao.getAllApplications(userEntity, callId, companyId);
|
||||
return applicationDao.getAllApplications(userEntity, callId, companyId , status);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -116,4 +116,6 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
return applicationDao.validateApplication(request, applicationId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.AssignedApplicationsDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AssignedApplicationsServiceImpl implements AssignedApplicationsService {
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private AssignedApplicationsDao assignedApplicationsDao;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AssignedApplicationsResponse createAssignedApplications(HttpServletRequest request, Long applicationId, Long userId, AssignedApplicationsRequest assignedApplicationsRequest) {
|
||||
UserEntity assignedByUser= validator.validateUser(request);
|
||||
return assignedApplicationsDao.createAssignedApplications(applicationId,userId,assignedByUser, assignedApplicationsRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteApplication(HttpServletRequest request, Long id) {
|
||||
assignedApplicationsDao.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<AssignedApplicationsResponse> getAllAssignedApplications(Long userId) {
|
||||
return assignedApplicationsDao.getAllAssignedApplications(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AssignedApplicationsResponse updateAssignedApplication(HttpServletRequest request, Long id , AssignedApplicationsRequest updatedAssignedApplicationRequest) {
|
||||
UserEntity updatedByUser= validator.validateUser(request);
|
||||
return assignedApplicationsDao.updateAssignedApplication(id,updatedAssignedApplicationRequest,updatedByUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public AssignedApplicationsResponse getAssignedApplicationById(Long id) {
|
||||
return assignedApplicationsDao.getAssignedApplicationById(id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class Validator {
|
||||
|
||||
public CallEntity validateUserWithCall(UserEntity user, Long callId) {
|
||||
CallEntity callEntity = callService.validateCall(callId);
|
||||
if(user.getHub().getId().equals(callEntity.getHub().getId())) {
|
||||
if(Boolean.FALSE.equals(user.getHub().getId().equals(callEntity.getHub().getId()))) {
|
||||
throw new ForbiddenAccessException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||
}
|
||||
return callEntity;
|
||||
|
||||
@@ -71,7 +71,8 @@ public interface ApplicationApi {
|
||||
@GetMapping(value = "", produces = "application/json")
|
||||
ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId);
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
|
||||
@Parameter(description = "Application status" ,required = false) @RequestParam(value = "status",required = false)String status);
|
||||
|
||||
@Operation(summary = "Api to delete application",
|
||||
responses = {
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Validated
|
||||
public interface AssignedApplicationsApi {
|
||||
|
||||
@Operation(summary = "Api to assign a application to preInstructor",
|
||||
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) }))
|
||||
})
|
||||
@PostMapping(value = "/application/{applicationId}")
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> createAssignedApplications(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "ID of the application", required = true) @PathVariable Long applicationId,
|
||||
@Parameter(description = "The User ID", required = true) @RequestParam("userId") Long userId,
|
||||
@Valid @RequestBody AssignedApplicationsRequest assignedApplicationsRequest
|
||||
);
|
||||
|
||||
@Operation(summary = "Api to delete assigned application",
|
||||
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) })) })
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
ResponseEntity<Response<Void>> deleteAssignedApplication(HttpServletRequest request,
|
||||
@Parameter(description = "The assigned application id", required = true) @PathVariable("id") Long id);
|
||||
|
||||
@Operation(summary = "Api to get all assigned applications",
|
||||
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 = "", produces = "application/json")
|
||||
ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(@Parameter(description = "The User ID", required = false) @RequestParam(value = "userId",required = false) Long userId);
|
||||
|
||||
@Operation(summary = "Api to update assigned application",
|
||||
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 = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> updateAssignedApplication(HttpServletRequest request,
|
||||
@Parameter(description = "The Assigned Application id", required = true) @PathVariable("id") Long id,
|
||||
@Parameter(description = "Assigned Application request object", required = true) @Valid @RequestBody AssignedApplicationsRequest assignedApplicationsRequest);
|
||||
|
||||
@Operation(summary = "Api to get an assigned application by 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 = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(@Parameter(description = "The assigned application id", required = true) @PathVariable(value = "id", required = true) Long id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -76,8 +76,8 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId) {
|
||||
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId);
|
||||
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId, String status) {
|
||||
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId,status);
|
||||
log.info("Get All Applications");
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.AssignedApplicationsRequest;
|
||||
import net.gepafin.tendermanagement.model.response.AssignedApplicationsResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.AssignedApplicationsService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.AssignedApplicationsApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/assignedApplication}")
|
||||
@Log4j2
|
||||
public class AssignedApplicationsController implements AssignedApplicationsApi {
|
||||
|
||||
@Autowired
|
||||
AssignedApplicationsService assignedApplicationsService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> createAssignedApplications(HttpServletRequest request, Long applicationId, Long userId, AssignedApplicationsRequest assignedApplicationsRequest) {
|
||||
log.info("Assigning Application To PreInstructor");
|
||||
AssignedApplicationsResponse responseData = assignedApplicationsService.createAssignedApplications(request,applicationId,userId, assignedApplicationsRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(responseData, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_ASSIGNED)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> deleteAssignedApplication(HttpServletRequest request, Long id) {
|
||||
log.info("Delete Assigned Application - Assigned Application ID: {}", id);
|
||||
assignedApplicationsService.deleteApplication(request,id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<AssignedApplicationsResponse>>> getAllAssignedApplications(Long userId) {
|
||||
log.info("Get All Assigned Applications");
|
||||
List<AssignedApplicationsResponse> applications = assignedApplicationsService.getAllAssignedApplications(userId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> updateAssignedApplication(HttpServletRequest request, Long id, AssignedApplicationsRequest updateAssignedApplicationRequest) {
|
||||
log.info("Update Assigned Application");
|
||||
AssignedApplicationsResponse updateAssignedApplication = assignedApplicationsService.updateAssignedApplication(request, id, updateAssignedApplicationRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(updateAssignedApplication, Status.SUCCESS, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_UPDATE_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<AssignedApplicationsResponse>> getAssignedApplicationById(Long id) {
|
||||
log.info("Get Assigned Applications By Id");
|
||||
AssignedApplicationsResponse application = assignedApplicationsService.getAssignedApplicationById(id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ASSIGNED_APPLICATION_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1212,6 +1212,38 @@
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="21-10-2024_1" author="Harish Bagora">
|
||||
<createTable tableName="assigned_applications">
|
||||
<column autoIncrement="true" name="id" type="INTEGER">
|
||||
<constraints nullable="false" primaryKey="true"
|
||||
primaryKeyName="pk_assigned_applications"/>
|
||||
</column>
|
||||
<column name="user_id" type="INTEGER">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="assigned_by" type="INTEGER">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="application_id" type="INTEGER">
|
||||
<constraints nullable="false" foreignKeyName="fk_application_assigned_applications" references="application(id)"/>
|
||||
</column>
|
||||
<column name="STATUS" type="VARCHAR(50)" />
|
||||
<column name="note" type="TEXT"></column>
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="assigned_at" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</createTable>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="17-10-2024_1" author="Rajesh Khore">
|
||||
<!-- Step 1: Add the HUB_ID column as nullable initially -->
|
||||
|
||||
@@ -265,7 +265,12 @@ hub_delete_success=Hub deleted successfully
|
||||
hub_not_found=Hub not found
|
||||
|
||||
application.not.in.draft.status=Application is not in DRAFT status.
|
||||
application.already.assigned=Application is already assigned.
|
||||
|
||||
|
||||
|
||||
application.assigned.success.msg = Application assigned successfully.
|
||||
application.already.assigned.msg = Application is already assigned.
|
||||
aasigned.application.not.found=Assigned Application not found with the given ID.
|
||||
assigned.application.deleted.success=Assigned Application successfully deleted.
|
||||
assigned.application.get.success=Assigned Application details fetched successfully.
|
||||
assigned.application.update.successfully=Assigned Application updated successfully.
|
||||
|
||||
@@ -253,6 +253,13 @@ cannot.create.beneficiary.user = La creazione di un utente beneficiario non <20>
|
||||
evaluationCriteria.invalid=Questo criterio di valutazione non appartiene alla chiamata corrente.
|
||||
|
||||
|
||||
application.assigned.success.msg =Domanda assegnata con successo
|
||||
application.already.assigned.msg =La domanda <20> gi<67> assegnata
|
||||
aasigned.application.not.found = Applicazione assegnata non trovata con l'ID specificato.
|
||||
assigned.application.deleted.success =Applicazione assegnata eliminata con successo.
|
||||
assigned.application.get.success =Dettagli dell'applicazione assegnata recuperati correttamente.
|
||||
assigned.application.update.successfully = Applicazione assegnata aggiornata correttamente.
|
||||
|
||||
# Hub Messages
|
||||
hub_create_success=Hub creato con successo
|
||||
hub_update_success=Hub aggiornato con successo
|
||||
@@ -261,5 +268,4 @@ hub_get_all_success=Hub recuperati con successo
|
||||
hub_delete_success=Hub eliminato con successo
|
||||
hub_not_found=Hub non trovato
|
||||
|
||||
application.not.in.draft.status=La domanda non è in stato DRAFT.
|
||||
application.already.assigned=L'applicazione è già assegnata.
|
||||
application.not.in.draft.status=La domanda non <EFBFBD> in stato DRAFT.
|
||||
|
||||
Reference in New Issue
Block a user