Merge pull request #13 from Kitzanos/added-lookUpData-in-faq

Added lookUpData in Faq
This commit is contained in:
rajeshkhore
2024-08-29 18:45:50 +05:30
committed by GitHub
11 changed files with 50 additions and 14 deletions

View File

@@ -82,7 +82,6 @@ public class GepafinConstant {
public static final String STATUS_SAME_ERROR = "status.same.error"; public static final String STATUS_SAME_ERROR = "status.same.error";
public static final String INVALID_STATUS_CHANGE_FROM_DRAFT = "invalid.status.change.from.draft"; public static final String INVALID_STATUS_CHANGE_FROM_DRAFT = "invalid.status.change.from.draft";
public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed"; public static final String STATUS_CANNOT_BE_CHANGED = "status.cannot.be.changed";
public static final String INVALID_STATUS_TRANSITION = "invalid.status.transition";
public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update"; public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
} }

View File

@@ -79,7 +79,7 @@ public class CallDao {
UserEntity userEntity = userService.validateUser(userId); UserEntity userEntity = userService.validateUser(userId);
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId()); createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
CallEntity callEntity = convertToCallEntity(createCallRequest); CallEntity callEntity = convertToCallEntity(createCallRequest);
convertToFaqEntities(createCallRequest.getFaq(), callEntity, userEntity); convertToFaqEntities(createCallRequest.getFaq(), callEntity, userEntity,LookUpDataTypeEnum.FAQ);
convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity, convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity,
LookUpDataTypeEnum.AIMED_TO); LookUpDataTypeEnum.AIMED_TO);
// createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(), // createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(),
@@ -199,21 +199,33 @@ public class CallDao {
return documentEntity; return documentEntity;
} }
public List<FaqEntity> convertToFaqEntities(List<FaqReq> faqReqList, CallEntity callEntity, UserEntity userEntity) { public List<FaqEntity> convertToFaqEntities(List<FaqReq> faqReqList, CallEntity callEntity, UserEntity userEntity, LookUpDataTypeEnum type) {
if (faqReqList == null) { if (faqReqList == null) {
return null; return null;
} }
List<FaqEntity> faqEntities = faqReqList.stream().map(req -> convertToFaqEntity(req, callEntity, userEntity)) List<FaqEntity> existingFaqEntities = faqRepository.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), type.getValue());
List<Long> incomingIds = faqReqList.stream()
.map(FaqReq::getId)
.filter(id -> id != null && id > 0)
.collect(Collectors.toList());
existingFaqEntities.stream()
.filter(entity -> !incomingIds.contains(entity.getId()))
.forEach(this::softDeleteFaq);
List<FaqEntity> faqEntities = faqReqList.stream()
.map(req -> convertToFaqEntity(req, callEntity, userEntity, type))
.collect(Collectors.toList()); .collect(Collectors.toList());
faqRepository.saveAll(faqEntities); faqRepository.saveAll(faqEntities);
return faqEntities; return faqEntities;
} }
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity) {
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity,LookUpDataTypeEnum type) {
FaqEntity faqEntity = new FaqEntity(); FaqEntity faqEntity = new FaqEntity();
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(faqReq, type);
validateFaqEntity(faqReq.getQuestion()); validateFaqEntity(faqReq.getQuestion());
faqEntity.setUser(userEntity); faqEntity.setUser(userEntity);
faqEntity.setIsVisible(false); faqEntity.setIsVisible(true);
faqEntity.setLookupData(lookupDataEntity);
if (faqReq.getIsVisible() != null) { if (faqReq.getIsVisible() != null) {
faqEntity.setIsVisible(faqReq.getIsVisible()); faqEntity.setIsVisible(faqReq.getIsVisible());
} }
@@ -321,6 +333,9 @@ public class CallDao {
public FaqResponseBean convertToFaqResponseBean(FaqEntity entity) { public FaqResponseBean convertToFaqResponseBean(FaqEntity entity) {
FaqResponseBean responseBean = new FaqResponseBean(); FaqResponseBean responseBean = new FaqResponseBean();
responseBean.setId(entity.getId()); responseBean.setId(entity.getId());
responseBean.setLookUpDataId(entity.getLookupData().getId());
responseBean.setValue(entity.getLookupData().getValue());
responseBean.setTitle(entity.getLookupData().getTitle());
responseBean.setQuestionShort(entity.getQuestionShort()); responseBean.setQuestionShort(entity.getQuestionShort());
responseBean.setResponseShort(entity.getResponseShort()); responseBean.setResponseShort(entity.getResponseShort());
responseBean.setResponse(entity.getResponse()); responseBean.setResponse(entity.getResponse());
@@ -666,6 +681,7 @@ public class CallDao {
callEntity.setStatus(CallStatusEnum.READY_TO_PUBLISH.getValue()); callEntity.setStatus(CallStatusEnum.READY_TO_PUBLISH.getValue());
callRepository.save(callEntity); callRepository.save(callEntity);
callResponseBean.setCurrentStep(GepafinConstant.VALIDATE_REQUEST); callResponseBean.setCurrentStep(GepafinConstant.VALIDATE_REQUEST);
callResponseBean.setStatus(CallStatusEnum.READY_TO_PUBLISH);
return callResponseBean; return callResponseBean;
} }
@@ -696,9 +712,6 @@ public class CallDao {
case EXPIRED: case EXPIRED:
throw new CustomValidationException(Status.VALIDATION_ERROR, throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED)); Translator.toLocale(GepafinConstant.STATUS_CANNOT_BE_CHANGED));
default:
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.INVALID_STATUS_TRANSITION));
} }
} }

View File

@@ -4,6 +4,7 @@ import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant; import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.CallEntity; import net.gepafin.tendermanagement.entities.CallEntity;
import net.gepafin.tendermanagement.entities.FaqEntity; import net.gepafin.tendermanagement.entities.FaqEntity;
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
import net.gepafin.tendermanagement.entities.UserEntity; import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.request.FaqReq; import net.gepafin.tendermanagement.model.request.FaqReq;
import net.gepafin.tendermanagement.model.response.FaqResponseBean; import net.gepafin.tendermanagement.model.response.FaqResponseBean;
@@ -39,7 +40,7 @@ public class FaqDao {
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, .orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND))); Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
UserEntity userEntity = userService.validateUser(userId); UserEntity userEntity = userService.validateUser(userId);
entity = callDao.convertToFaqEntity(faqRequest, callEntity, userEntity); entity = callDao.convertToFaqEntity(faqRequest, callEntity, userEntity, LookUpDataEntity.LookUpDataTypeEnum.FAQ);
faqRepository.save(entity); faqRepository.save(entity);
return convertFaqEntityToResponseBean(entity); return convertFaqEntityToResponseBean(entity);
} }

View File

@@ -39,6 +39,10 @@ public class FaqEntity extends BaseEntity {
@Column(name = "RESPONSE", columnDefinition = "TEXT") @Column(name = "RESPONSE", columnDefinition = "TEXT")
private String response; private String response;
@ManyToOne
@JoinColumn(name = "LOOKUP_DATA_ID")
private LookUpDataEntity lookupData;
@Column(name = "RESPONSE_DATE") @Column(name = "RESPONSE_DATE")
private LocalDateTime responseDate; private LocalDateTime responseDate;

View File

@@ -21,7 +21,8 @@ public class LookUpDataEntity extends BaseEntity{
public enum LookUpDataTypeEnum { public enum LookUpDataTypeEnum {
CHECKLIST("CHECKLIST"), CHECKLIST("CHECKLIST"),
AIMED_TO("AIMED_TO"), AIMED_TO("AIMED_TO"),
EVALUATION_CRITERIA("EVALUATION_CRITERIA"); EVALUATION_CRITERIA("EVALUATION_CRITERIA"),
FAQ("FAQ");
private String value; private String value;

View File

@@ -3,7 +3,7 @@ package net.gepafin.tendermanagement.model.request;
import lombok.Data; import lombok.Data;
@Data @Data
public class FaqReq { public class FaqReq extends LookUpDataReq{
private Long id; private Long id;
private Boolean isVisible; private Boolean isVisible;

View File

@@ -23,4 +23,12 @@ public class FaqResponseBean extends BaseBean {
private LocalDateTime responseDate; private LocalDateTime responseDate;
private Long lookUpDataId;
private String title;
private String value;
} }

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.repositories; package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.EvaluationCriteriaEntity;
import net.gepafin.tendermanagement.entities.FaqEntity; import net.gepafin.tendermanagement.entities.FaqEntity;
import java.util.List; import java.util.List;
@@ -17,4 +18,6 @@ public interface FaqRepository extends JpaRepository<FaqEntity, Long> {
Optional<FaqEntity> findById(@Param("id") Long id); Optional<FaqEntity> findById(@Param("id") Long id);
List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId); List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId);
List<FaqEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long callId, String type);
} }

View File

@@ -453,4 +453,13 @@
<dropNotNullConstraint tableName="call" columnName="amount_max"/> <dropNotNullConstraint tableName="call" columnName="amount_max"/>
</changeSet> </changeSet>
<changeSet id="29-08-2024_1" author="Harish Bagora">
<addColumn tableName="FAQ">
<column name="lookup_data_id" type="INTEGER">
<constraints nullable="false"
foreignKeyName="fk_lookup_data_faq"
references="lookup_data(id)" />
</column>
</addColumn>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -54,7 +54,6 @@ update_call_status_success_msg=The call status has been updated successfully.
status.same.error=Status is already set. status.same.error=Status is already set.
invalid.status.change.from.draft=Status cannot be changed to READY_TO_PUBLISH or PUBLISH from DRAFT. invalid.status.change.from.draft=Status cannot be changed to READY_TO_PUBLISH or PUBLISH from DRAFT.
status.cannot.be.changed=Status cannot be changed. status.cannot.be.changed=Status cannot be changed.
invalid.status.transition=Invalid status transition.
published.call.not.update=Published call cannot be updated. published.call.not.update=Published call cannot be updated.

View File

@@ -54,7 +54,6 @@ update_call_status_success_msg=Lo stato della chiamata
status.same.error=Lo stato è già impostato. status.same.error=Lo stato è già impostato.
invalid.status.change.from.draft=Lo stato non può essere cambiato in READY_TO_PUBLISH o PUBLISH da DRAFT. invalid.status.change.from.draft=Lo stato non può essere cambiato in READY_TO_PUBLISH o PUBLISH da DRAFT.
status.cannot.be.changed=Lo stato non può essere cambiato. status.cannot.be.changed=Lo stato non può essere cambiato.
invalid.status.transition=Transizione di stato non valida.
published.call.not.update=Il bando pubblicato non può essere aggiornato. published.call.not.update=Il bando pubblicato non può essere aggiornato.