resolved conflict

This commit is contained in:
nisha
2024-10-08 17:40:22 +05:30
10 changed files with 138 additions and 23 deletions

View File

@@ -179,6 +179,9 @@ public class GepafinConstant {
public static final String UNAUTHORIZED = "UNAUTHORIZED";
public static final String COMPANY_ID_MANDATORY = "company.id.mandatory";
public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company";
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";
}

View File

@@ -75,7 +75,7 @@ public class ApplicationDao {
public ApplicationResponseBean createApplication(ApplicationRequestBean applicationRequestBean, UserEntity userEntity, Long formId, Long applicationId) {
FormEntity formEntity = formService.validateForm(formId);
callService.validatePublishedCall(formEntity.getCall().getId());
// callService.validatePublishedCall(formEntity.getCall().getId());
validateFormFields(applicationRequestBean,formEntity);
ApplicationEntity applicationEntity = validateApplication(applicationId);
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) {
@@ -323,8 +323,12 @@ public class ApplicationDao {
}
}
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
if(applicationFormFieldRequestBean.getFieldValue() ==null || Boolean.FALSE.equals(applicationFormFieldRequestBean.getFieldValue().isEmpty())) {
applicationFormFieldEntity.setFieldValue(applicationFormFieldRequestBean.getFieldValue());
if(applicationFormFieldRequestBean.getFieldValue() !=null ) {
applicationFormFieldEntity.setFieldValue(Utils.convertObjectToJsonString(applicationFormFieldRequestBean.getFieldValue()));
}
if(applicationFormFieldRequestBean.getFieldValue() ==null ) {
applicationFormFieldEntity.setFieldValue(null);
}
return applicationFormFieldRepository.save(applicationFormFieldEntity);
}
@@ -335,11 +339,16 @@ public class ApplicationDao {
for (ContentResponseBean contentResponseBean:contentResponseBeans){
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
String documentId = applicationFormFieldRequestBean.getFieldValue();
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
if (fieldValueObject instanceof String) {
// Safely cast the object to a string
String documentId = (String) fieldValueObject;
// Now you can use documentId as needed
documentIds = validateDocumentIds(documentId);
}
}
}
}
return documentIds;
}
@@ -377,7 +386,9 @@ public class ApplicationDao {
ApplicationFormFieldResponseBean applicationFormFieldResponseBean = new ApplicationFormFieldResponseBean();
applicationFormFieldResponseBean.setApplicationFormId(applicationFormId);
applicationFormFieldResponseBean.setFieldId(applicationFormFieldEntity.getFieldId());
applicationFormFieldResponseBean.setFieldValue(applicationFormFieldEntity.getFieldValue());
if(applicationFormFieldEntity.getFieldValue() != null) {
applicationFormFieldResponseBean.setFieldValue(Utils.getFieldValueAsObject(applicationFormFieldEntity.getFieldValue()));
}
applicationFormFieldResponseBean.setId(applicationFormFieldEntity.getId());
applicationFormFieldResponseBean.setCreatedDate(applicationFormFieldEntity.getCreatedDate());
applicationFormFieldResponseBean.setUpdatedDate(applicationFormFieldEntity.getUpdatedDate());
@@ -477,7 +488,7 @@ public class ApplicationDao {
public ApplicationResponse createApplicationByCallId(CompanyEntity companyEntity,
ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) {
CallEntity call = callService.validateCall(callId);
call = callService.validatePublishedCall(call.getId());
// call = callService.validatePublishedCall(call.getId());
checkIfApplicationExists(call, companyEntity);
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, companyEntity);
applicationEntity.setComments(applicationRequest.getComments());
@@ -496,6 +507,7 @@ public class ApplicationDao {
ApplicationEntity applicationEntity = validateApplication(applicationId);
if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
callService.validatePublishedCall(applicationEntity.getCall().getId());
// CallEntity callEntity = applicationEntity.getCall();
// Long initialFormId = callEntity.getInitialForm();
// Long finalFormId = callEntity.getFinalForm();

View File

@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.dao;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -673,6 +674,25 @@ public class CallDao {
Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED));
}
LocalDate currentDate = LocalDate.now();
LocalTime currentTime = LocalTime.now();
if (currentDate.isBefore(callEntity.getStartDate().toLocalDate()) ||
(currentDate.isEqual(callEntity.getStartDate().toLocalDate()) && currentTime.isBefore(callEntity.getStartTime()))) {
throw new CustomValidationException(
Status.BAD_REQUEST,
Translator.toLocale(GepafinConstant.CALL_NOT_STARTED_YET)
);
}
if (currentDate.isAfter(callEntity.getEndDate().toLocalDate()) ||
(currentDate.isEqual(callEntity.getEndDate().toLocalDate()) && currentTime.isAfter(callEntity.getEndTime()))) {
throw new CustomValidationException(
Status.BAD_REQUEST,
Translator.toLocale(GepafinConstant.CALL_ALREADY_ENDED)
);
}
return callEntity;
}

View File

@@ -15,6 +15,7 @@ import net.gepafin.tendermanagement.util.Utils;
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.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@@ -205,10 +206,12 @@ public class FormDao {
public void validateFormField(List<ApplicationFormFieldRequestBean> applicationFormFieldRequestList, ApplicationEntity applicationEntity, FormEntity formEntity) {
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
for(ApplicationFormFieldRequestBean applicationFormFieldRequestBean:applicationFormFieldRequestList) {
if(applicationFormFieldRequestBean.getFieldValue()==null || applicationFormFieldRequestBean.getFieldValue().isEmpty())
if(applicationFormFieldRequestBean.getFieldValue()==null )
continue;
formFieldMap.put(applicationFormFieldRequestBean.getFieldId(),applicationFormFieldRequestBean.getFieldValue());
}
if (applicationFormFieldRequestBean.getFieldValue() != null ) {
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
checkObjectData(applicationFormFieldRequestBean.getFieldId(), fieldValue, formFieldMap);
}}
FormResponseBean formResponseBean = convertFormEntityToFormResponseBean(formEntity);
ApplicationFormEntity applicationFormEntity=applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(),formEntity.getId());
@@ -238,6 +241,28 @@ public class FormDao {
validator.validate();
}
private void checkObjectData(String fieldId, Object fieldValue, Map<String, Object> formFieldMap) {
if (fieldValue instanceof List<?>) {
List<?> list = (List<?>) fieldValue;
// Only map if the list is not empty and contains Strings
if (!list.isEmpty() && list.get(0) instanceof String) {
for (Object value : list) {
setFormFieldMap(fieldId, formFieldMap, value);
}
}
}
else setFormFieldMap(fieldId, formFieldMap, fieldValue);
}
private void setFormFieldMap(String fieldId, Map<String, Object> formFieldMap, Object value) {
if (value instanceof String) {
if(value !=null && Boolean.FALSE.equals(StringUtils.isEmpty((String)value))) {
formFieldMap.put(fieldId, value);
}
}
}
private Boolean getApplicationFormExist(ApplicationFormEntity applicationFormEntity) {
if(applicationFormEntity !=null) {
return true;

View File

@@ -9,6 +9,6 @@ public class ApplicationFormFieldRequestBean {
private String fieldId;
private String fieldValue;
private Object fieldValue;
}

View File

@@ -76,6 +76,7 @@ public class ApplicationServiceImpl implements ApplicationService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
return applicationDao.updateApplicationStatus(applicationId, status);

View File

@@ -227,4 +227,47 @@ public class Utils {
Pattern pattern = Pattern.compile(EMAIL_REGEX);
return pattern.matcher(email).matches();
}
public static String convertObjectToJsonString(Object object) {
try {
// Check if the object is a string
if (object instanceof String) {
String str = (String) object;
// Return null if the string is null or empty
if (str != null && !str.trim().isEmpty()) {
return str; // Return the non-empty string
} else {
return null; // Return null for null or empty string
}
} else if (object != null) {
// Convert non-string objects (arrays, objects) to JSON strings
return mapper.writeValueAsString(object);
}
return null; // Return null if the object is null
} catch (JsonProcessingException e) {
log.error("Error while converting object to string: {}", e.getMessage(), e);
return null; // Return null in case of exception
}
}
public static Object getFieldValueAsObject(String fieldValue) {
ObjectMapper mapper = new ObjectMapper();
try {
// Check if the string is a valid JSON object, array, or simple string
if (fieldValue.startsWith("{")) {
// Convert to a Map (representing an object)
return mapper.readValue(fieldValue, Map.class);
} else if (fieldValue.startsWith("[")) {
// Convert to a List (representing an array)
return mapper.readValue(fieldValue, List.class);
} else {
// Return the raw string (it's a simple value)
return fieldValue;
}
} catch (JsonProcessingException e) {
log.error("Error while converting string to object: {}", e.getMessage(), e);
return fieldValue; // If there's an error, return the raw string
}
}
}

View File

@@ -899,4 +899,10 @@
</addColumn>
</changeSet>
<changeSet id="07-10-2024_2" author="Nisha Kashyap">
<modifyDataType
tableName="application_form_field"
columnName="field_value"
newDataType="TEXT"/>
</changeSet>
</databaseChangeLog>

View File

@@ -206,5 +206,8 @@ vatnumber.already.exists=VatNumber already exists.
invalid.email=Invalid email.
company.id.mandatory=Company id is mandatory.
user.already.connected.to.company=The user is already connected to this company.
call.not.started.yet = The call has not started yet. Please wait until the specified start date and time.
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.

View File

@@ -9,7 +9,7 @@ get_user_success_msg=Utente recuperato con successo.
get_user_error_msg=Si <20> verificato un errore durante il recupero dell'utente.
user.not.active=Utente non attivo. Si prega di contattare il supporto.
user.already.exist.msg=L'utente esiste gi<67> per questo codice fiscale.
validate.email=L'email è obbligatoria e deve essere nel formato corretto. Si prega di verificare e riprovare.
validate.email=L'email <EFBFBD> obbligatoria e deve essere nel formato corretto. Si prega di verificare e riprovare.
validate.password=La password e confPassword sono obbligatorie. Verifica e riprova.
# Role-related messages
role.created.success=Ruolo creato con successo.
@@ -20,7 +20,7 @@ create.role.error=Errore durante la creazione del ruolo.
update.role.error=Errore durante l'aggiornamento del ruolo.
role.fetch.success=Ruolo recuperato con successo.
delete.role.error=Errore durante l'eliminazione del ruolo.
role.id.mandatory=L'ID del ruolo è obbligatorio.
role.id.mandatory=L'ID del ruolo <EFBFBD> obbligatorio.
# Region-related messages
region.created.success=Regione creata con successo.
@@ -194,10 +194,12 @@ company.get.success=Azienda recuperata con successo.
company.not.found=Azienda non trovata.
check.vatnumber.success=Numero di partita IVA verificato con successo.
invalid.vatnumber=Numero di partita IVA non valido.
vatnumber.mandatory=Il numero di partita IVA è obbligatorio.
vatnumber.already.exists=Il numero di partita IVA esiste già.
vatnumber.mandatory=Il numero di partita IVA <EFBFBD> obbligatorio.
vatnumber.already.exists=Il numero di partita IVA esiste gi<EFBFBD>.
invalid.email=Email non valida.
company.id.mandatory=L'ID dell'azienda è obbligatorio.
user.already.connected.to.company=L'utente è già collegato a questa azienda.
company.id.mandatory=L'ID dell'azienda <EFBFBD> obbligatorio.
user.already.connected.to.company=L'utente <EFBFBD> gi<EFBFBD> collegato a questa azienda.
call.not.started.yet = La chiamata non <20> ancora iniziata. Attendere fino alla data e all'ora di inizio specificate.
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.