Merge pull request #45 from Kitzanos/develop
Sync master with develop branch(13/10/2024)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
FROM amazoncorretto:17.0.8-alpine3.17
|
FROM amazoncorretto:17.0.8-alpine3.17
|
||||||
|
ENV TZ="Europe/Rome"
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ADD /target/tendermanagement-0.0.1-SNAPSHOT.jar tendermanagement-0.0.1-SNAPSHOT.jar
|
ADD /target/tendermanagement-0.0.1-SNAPSHOT.jar tendermanagement-0.0.1-SNAPSHOT.jar
|
||||||
ENTRYPOINT ["java", "-jar","tendermanagement-0.0.1-SNAPSHOT.jar"]
|
ENTRYPOINT ["java", "-jar","tendermanagement-0.0.1-SNAPSHOT.jar"]
|
||||||
|
|||||||
34
pom.xml
34
pom.xml
@@ -94,7 +94,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.11.0</version>
|
<version>2.17.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -173,12 +173,44 @@
|
|||||||
<version>4.1.3</version>
|
<version>4.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mailgun</groupId>
|
||||||
|
<artifactId>mailgun-java</artifactId>
|
||||||
|
<version>1.0.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.santuario</groupId>
|
<groupId>org.apache.santuario</groupId>
|
||||||
<artifactId>xmlsec</artifactId>
|
<artifactId>xmlsec</artifactId>
|
||||||
<version>2.3.0</version> <!-- or latest -->
|
<version>2.3.0</version> <!-- or latest -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itextpdf</artifactId>
|
||||||
|
<version>5.5.13.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.itextpdf/itext7-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>itext7-core</artifactId>
|
||||||
|
<version>8.0.5</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.itextpdf/layout -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.itextpdf</groupId>
|
||||||
|
<artifactId>layout</artifactId>
|
||||||
|
<version>8.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class GepafinConstant {
|
|||||||
public static final String GET_REGION_SUCCESS_MSG = "get.region.success";
|
public static final String GET_REGION_SUCCESS_MSG = "get.region.success";
|
||||||
public static final String DELETE_REGION_SUCCESS_MSG = "delete.region.success";
|
public static final String DELETE_REGION_SUCCESS_MSG = "delete.region.success";
|
||||||
public static final String REGION_NOT_FOUND_MSG = "user.region.not.found";
|
public static final String REGION_NOT_FOUND_MSG = "user.region.not.found";
|
||||||
public static final String PASSWORD_DOESNT_MATCH ="password.doesnt.match";
|
public static final String PASSWORD_DOESNT_MATCH = "password.doesnt.match";
|
||||||
public static final String USER_NOT_EXIST_MSG = "user.not.exist";
|
public static final String USER_NOT_EXIST_MSG = "user.not.exist";
|
||||||
public static final String REGION_NOT_FOUND = "region.not.found";
|
public static final String REGION_NOT_FOUND = "region.not.found";
|
||||||
public static final String USER_ID_NOT_NULL_MSG = "user.id.not.null";
|
public static final String USER_ID_NOT_NULL_MSG = "user.id.not.null";
|
||||||
@@ -36,13 +36,13 @@ public class GepafinConstant {
|
|||||||
public static final String LOOK_UP_DATA_NOT_VALID_MSG = "look.up.data.not.valid";
|
public static final String LOOK_UP_DATA_NOT_VALID_MSG = "look.up.data.not.valid";
|
||||||
public static final String FILES_UPLOADED_MSG = "files.uploaded";
|
public static final String FILES_UPLOADED_MSG = "files.uploaded";
|
||||||
public static final String CALL_CREATED_SUCCESSFULLY_MSG = "call.created.successfully";
|
public static final String CALL_CREATED_SUCCESSFULLY_MSG = "call.created.successfully";
|
||||||
public static final String FILE_DELETED_SUCCESSFULLY_MSG="file.deleted.successfully";
|
public static final String FILE_DELETED_SUCCESSFULLY_MSG = "file.deleted.successfully";
|
||||||
public static final String DOCUMENT_NOT_FOUND="document.not.found";
|
public static final String DOCUMENT_NOT_FOUND = "document.not.found";
|
||||||
public static final String LOGIN_SUCCESS_MSG="login.successfully";
|
public static final String LOGIN_SUCCESS_MSG = "login.successfully";
|
||||||
public static final String PASSWORD_MIN_LEN ="pass.min.len.msg";
|
public static final String PASSWORD_MIN_LEN = "pass.min.len.msg";
|
||||||
public static final String EMAIL_ALREADY_EXISTS = "email.already.exists";
|
public static final String EMAIL_ALREADY_EXISTS = "email.already.exists";
|
||||||
public static final String DOCUMENT_ID_NOT_FOUND="document.id.not.found";
|
public static final String DOCUMENT_ID_NOT_FOUND = "document.id.not.found";
|
||||||
public static final String INVALID_DATE_MSG = "call.invalid.date";
|
public static final String INVALID_DATE_MSG = "call.invalid.date";
|
||||||
public static final String FORM_NOT_FOUND = "form.not.found";
|
public static final String FORM_NOT_FOUND = "form.not.found";
|
||||||
public static final String FORM_CREATED_SUCCESSFULLY = "form.created.successfully";
|
public static final String FORM_CREATED_SUCCESSFULLY = "form.created.successfully";
|
||||||
public static final String FORM_UPDATED_SUCCESSFULLY = "form.updated.suucessfully";
|
public static final String FORM_UPDATED_SUCCESSFULLY = "form.updated.suucessfully";
|
||||||
@@ -61,12 +61,12 @@ public class GepafinConstant {
|
|||||||
public static final String FORM_TEMPLATE_DELETED_SUCCESSFULLY = "form.template.deleted.successfully";
|
public static final String FORM_TEMPLATE_DELETED_SUCCESSFULLY = "form.template.deleted.successfully";
|
||||||
public static final String FORM_TEMPLATE_FETCHED_SUCCESSFULLY = "form.template.fetched.successfully";
|
public static final String FORM_TEMPLATE_FETCHED_SUCCESSFULLY = "form.template.fetched.successfully";
|
||||||
public static final String REQUIRED_PARAMETER_NOT_FOUND_FOR_FORM_TEMPLATE = "required.parameter.not.found.for.form.template";
|
public static final String REQUIRED_PARAMETER_NOT_FOUND_FOR_FORM_TEMPLATE = "required.parameter.not.found.for.form.template";
|
||||||
public static final String FORM_NOT_FOUND_FOR_CALL_ID="form.not.found.for.call.id";
|
public static final String FORM_NOT_FOUND_FOR_CALL_ID = "form.not.found.for.call.id";
|
||||||
public static final String STEP_1 = "STEP_1";
|
public static final String STEP_1 = "STEP_1";
|
||||||
public static final String STEP_2 = "STEP_2";
|
public static final String STEP_2 = "STEP_2";
|
||||||
public static final String VALIDATE_REQUEST = "VALIDATE_REQUEST";
|
public static final String VALIDATE_REQUEST = "VALIDATE_REQUEST";
|
||||||
public static final String CALL_UPDATE_SUCCESSFULLY_MSG = "call.update.successfully";
|
public static final String CALL_UPDATE_SUCCESSFULLY_MSG = "call.update.successfully";
|
||||||
public static final String CALL_NOT_FOUND = "call.not.found";
|
public static final String CALL_NOT_FOUND = "call.not.found";
|
||||||
public static final String CALL_FETCH_SUCCESS_MSG = "call.fetch.success";
|
public static final String CALL_FETCH_SUCCESS_MSG = "call.fetch.success";
|
||||||
|
|
||||||
public static final String EVALUATION_CRITERIA_NOT_FOUND = "evaluation.criteria.not.found";
|
public static final String EVALUATION_CRITERIA_NOT_FOUND = "evaluation.criteria.not.found";
|
||||||
@@ -74,7 +74,7 @@ public class GepafinConstant {
|
|||||||
public static final String EVALUATION_CRITERIA_FETCH_SUCCESSFULLY = "evaluation.criteria.fetch.successfully";
|
public static final String EVALUATION_CRITERIA_FETCH_SUCCESSFULLY = "evaluation.criteria.fetch.successfully";
|
||||||
public static final String EVALUATION_CRITERIA_UPDATED_SUCCESSFULLY = "evaluation.criteria.updated.successfully";
|
public static final String EVALUATION_CRITERIA_UPDATED_SUCCESSFULLY = "evaluation.criteria.updated.successfully";
|
||||||
public static final String EVALUATION_CRITERIA_DELETED_SUCCESSFULLY = "evaluation.criteria.deleted.successfully";
|
public static final String EVALUATION_CRITERIA_DELETED_SUCCESSFULLY = "evaluation.criteria.deleted.successfully";
|
||||||
public static final String SCORE_NOT_NULL_MSG="score.not.null";
|
public static final String SCORE_NOT_NULL_MSG = "score.not.null";
|
||||||
public static final String FAQ_NOT_FOUND = "faq.not.found";
|
public static final String FAQ_NOT_FOUND = "faq.not.found";
|
||||||
public static final String FAQ_CREATED_SUCCESSFULLY = "faq.created.successfully";
|
public static final String FAQ_CREATED_SUCCESSFULLY = "faq.created.successfully";
|
||||||
public static final String FAQ_FETCHED_SUCCESSFULLY = "faq.fetched.successfully";
|
public static final String FAQ_FETCHED_SUCCESSFULLY = "faq.fetched.successfully";
|
||||||
@@ -102,41 +102,41 @@ public class GepafinConstant {
|
|||||||
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 INVALID_STATUS_CHANGE_FROM_PUBLISH = "invalid.status.change.from.publish";
|
public static final String INVALID_STATUS_CHANGE_FROM_PUBLISH = "invalid.status.change.from.publish";
|
||||||
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 PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
|
public static final String PUBLISHED_CALL_NOT_UPDATE = "published.call.not.update";
|
||||||
public static final String INVALID_USER = "invalid_user";
|
public static final String INVALID_USER = "invalid_user";
|
||||||
public static final String FLOW_CREATED_SUCCESSFULLY="flow.created.successfully";
|
public static final String FLOW_CREATED_SUCCESSFULLY = "flow.created.successfully";
|
||||||
public static final String FLOW_FETCHED_SUCCESSFULLY="flow.fetched.successfully";
|
public static final String FLOW_FETCHED_SUCCESSFULLY = "flow.fetched.successfully";
|
||||||
public static final String FLOW_ALREADY_EXISTS="flow.already.exists";
|
public static final String FLOW_ALREADY_EXISTS = "flow.already.exists";
|
||||||
public static final String FLOW_REQUEST_NOT_PROPER="flow.request.not.complete";
|
public static final String FLOW_REQUEST_NOT_PROPER = "flow.request.not.complete";
|
||||||
public static final String APPLICATION_CREATED_SUCCESS_MSG = "application.created.success";
|
public static final String APPLICATION_CREATED_SUCCESS_MSG = "application.created.success";
|
||||||
public static final String APPLICATION_UPDATED_SUCCESS_MSG = "application.updated.success";
|
public static final String APPLICATION_UPDATED_SUCCESS_MSG = "application.updated.success";
|
||||||
public static final String DELETE_APPLICATION_SUCCESS_MSG = "application.deleted.success";
|
public static final String DELETE_APPLICATION_SUCCESS_MSG = "application.deleted.success";
|
||||||
public static final String GET_APPLICATION_SUCCESS_MSG = "application.get.success";
|
public static final String GET_APPLICATION_SUCCESS_MSG = "application.get.success";
|
||||||
public static final String APPLICATION_NOT_FOUND_MSG = "application.not.found";
|
public static final String APPLICATION_NOT_FOUND_MSG = "application.not.found";
|
||||||
public static final String APPLICATION_FORM_FIELD_NOT_FOUND="application.form.field.not.found";
|
public static final String APPLICATION_FORM_FIELD_NOT_FOUND = "application.form.field.not.found";
|
||||||
public static final String FORM_ID_DOES_NOT_MACTHES="Form.not.matches.to.call.initial.form";
|
public static final String FORM_ID_DOES_NOT_MACTHES = "Form.not.matches.to.call.initial.form";
|
||||||
public static final String VALIDATION_FIELD_REQUIRED = "validation.field.required";
|
public static final String VALIDATION_FIELD_REQUIRED = "validation.field.required";
|
||||||
public static final String VALIDATION_FIELD_MIN_LENGTH = "validation.field.min_length";
|
public static final String VALIDATION_FIELD_MIN_LENGTH = "validation.field.min_length";
|
||||||
public static final String VALIDATION_FIELD_MAX_LENGTH = "validation.field.max_length";
|
public static final String VALIDATION_FIELD_MAX_LENGTH = "validation.field.max_length";
|
||||||
public static final String VALIDATION_FIELD_PATTERN = "validation.field.pattern";
|
public static final String VALIDATION_FIELD_PATTERN = "validation.field.pattern";
|
||||||
public static final String VALIDATION_FIELD_NOT_NULL = "validation.field.not_null";
|
public static final String VALIDATION_FIELD_NOT_NULL = "validation.field.not_null";
|
||||||
public static final String VALIDATION_FIELD_NOT_EMPTY = "validation.field.not_empty";
|
public static final String VALIDATION_FIELD_NOT_EMPTY = "validation.field.not_empty";
|
||||||
public static final String APPLICATION_ALREADY_EXISTS="application.already.exists";
|
public static final String APPLICATION_ALREADY_EXISTS = "application.already.exists";
|
||||||
// public static final String NEXT_FORM_NOT_FOUND = "next.form.not.found";
|
// public static final String NEXT_FORM_NOT_FOUND = "next.form.not.found";
|
||||||
// public static final String PREVIOUS_FORM_NOT_FOUND = "previous.form.not.found";
|
// public static final String PREVIOUS_FORM_NOT_FOUND = "previous.form.not.found";
|
||||||
public static final String CURRENT_FORM_INCOMPLETE = "current.form.incomplete";
|
public static final String CURRENT_FORM_INCOMPLETE = "current.form.incomplete";
|
||||||
public static final String FLOW_NOT_FOUND = "flow.not.found";
|
public static final String FLOW_NOT_FOUND = "flow.not.found";
|
||||||
public static final String VALIDATION_MESSAGE = "validation.message";
|
public static final String VALIDATION_MESSAGE = "validation.message";
|
||||||
public static final String ACTION_REQUIRED = "action.required";
|
public static final String ACTION_REQUIRED = "action.required";
|
||||||
public static final String CALL_NOT_PUBLISHED="call.not.published";
|
public static final String CALL_NOT_PUBLISHED = "call.not.published";
|
||||||
public static final String APPLICATION_ALREADY_SUBMITTED="application.already.submitted";
|
public static final String APPLICATION_ALREADY_SUBMITTED = "application.already.submitted";
|
||||||
public static final String INITAL_AND_FINAL_FORM_CANNOT_NULL="initial.and.final.form.cannot.null";
|
public static final String INITAL_AND_FINAL_FORM_CANNOT_NULL = "initial.and.final.form.cannot.null";
|
||||||
public static final String APPLICATION_FORM_NOT_FOUND="application.form.not.found";
|
public static final String APPLICATION_FORM_NOT_FOUND = "application.form.not.found";
|
||||||
public static final String UPDATING_FORM_VALUE_IMPACT_ON_FLOW="updating.form.value.impact.on.flow";
|
public static final String UPDATING_FORM_VALUE_IMPACT_ON_FLOW = "updating.form.value.impact.on.flow";
|
||||||
public static final String APPLICATION_IS_INCOMPLETE_MSG = "application.is.incomplete";
|
public static final String APPLICATION_IS_INCOMPLETE_MSG = "application.is.incomplete";
|
||||||
public static final String AUTHORIZATION = "Authorization";
|
public static final String AUTHORIZATION = "Authorization";
|
||||||
public static final String CHECK_VATNUMBER_V2_NEW_URL = "https://imprese.openapi.it/advance";
|
public static final String CHECK_VATNUMBER_V2_NEW_URL = "https://imprese.openapi.it/advance";
|
||||||
public static final String VALIDATION_FIELD_CUSTOM="validation.field.custom";
|
public static final String VALIDATION_FIELD_CUSTOM = "validation.field.custom";
|
||||||
public static final String VALIDATION_CODICE_FISCALE = "validation.codice.fiscale";
|
public static final String VALIDATION_CODICE_FISCALE = "validation.codice.fiscale";
|
||||||
public static final String VALIDATION_CAP = "validation.cap";
|
public static final String VALIDATION_CAP = "validation.cap";
|
||||||
public static final String VALIDATION_IBAN = "validation.iban";
|
public static final String VALIDATION_IBAN = "validation.iban";
|
||||||
@@ -145,38 +145,70 @@ public class GepafinConstant {
|
|||||||
public static final String VALIDATION_URL = "validation.url";
|
public static final String VALIDATION_URL = "validation.url";
|
||||||
public static final String VALIDATION_MARCA_DA_BOLLO = "validation.marca.da.bollo";
|
public static final String VALIDATION_MARCA_DA_BOLLO = "validation.marca.da.bollo";
|
||||||
public static final String VALIDATION_PIVA = "validation.piva";
|
public static final String VALIDATION_PIVA = "validation.piva";
|
||||||
public static final String VALIDATION_VALID_PIVA="valid.vat.number";
|
public static final String VALIDATION_VALID_PIVA = "valid.vat.number";
|
||||||
public static final String IS_MARCA_DA_BOLLO="isMarcaDaBollo";
|
public static final String IS_MARCA_DA_BOLLO = "isMarcaDaBollo";
|
||||||
public static final String IS_URL="isUrl";
|
public static final String IS_URL = "isUrl";
|
||||||
public static final String IS_EMAIL_PEC="isEmailPEC";
|
public static final String IS_EMAIL_PEC = "isEmailPEC";
|
||||||
public static final String IS_EMAIL="isEmail";
|
public static final String IS_EMAIL = "isEmail";
|
||||||
public static final String IS_IBAN="isIBAN";
|
public static final String IS_IBAN = "isIBAN";
|
||||||
public static final String IS_CAP="isCAP";
|
public static final String IS_CAP = "isCAP";
|
||||||
public static final String IS_CODICE_FISCALE="isCodiceFiscale";
|
public static final String IS_CODICE_FISCALE = "isCodiceFiscale";
|
||||||
public static final String IS_PIVA="isPIVA";
|
public static final String IS_PIVA = "isPIVA";
|
||||||
public static final String FAILED_RETAIN_FIELD="failed.retain.field";
|
public static final String FAILED_RETAIN_FIELD = "failed.retain.field";
|
||||||
public static final String USER_ALREADY_EXIST_MSG = "user.already.exist.msg";
|
public static final String USER_ALREADY_EXIST_MSG = "user.already.exist.msg";
|
||||||
public static final String TOKEN_VALIDATE_SUCCESS_MSE = "token.validate.success";
|
public static final String TOKEN_VALIDATE_SUCCESS_MSE = "token.validate.success";
|
||||||
public static final String INVALID_REQUEST = "invalid.request";
|
public static final String INVALID_REQUEST = "invalid.request";
|
||||||
public static final String CODICE_FISCALE_EXISTS = "codice.fiscale.exists";
|
public static final String CODICE_FISCALE_EXISTS = "codice.fiscale.exists";
|
||||||
public static final String TOTAL_STEPS_NOT_BE_ZERO="total.steps.not.zero";
|
public static final String TOTAL_STEPS_NOT_BE_ZERO = "total.steps.not.zero";
|
||||||
public static final String COMPLETED_STEPS_NOT_VALID="completed.steps.not.valid";
|
public static final String COMPLETED_STEPS_NOT_VALID = "completed.steps.not.valid";
|
||||||
public static final String FIELD_ID_NOT_FOUND="field.id.not.found";
|
public static final String FIELD_ID_NOT_FOUND = "field.id.not.found";
|
||||||
public static final String VALIDATE_EMAIL = "validate.email";
|
public static final String VALIDATE_EMAIL = "validate.email";
|
||||||
public static final String ROLE_ID_MANDATORY = "role.id.mandatory";
|
public static final String ROLE_ID_MANDATORY = "role.id.mandatory";
|
||||||
public static final String VALIDATE_PASSWORD = "validate.password";
|
public static final String VALIDATE_PASSWORD = "validate.password";
|
||||||
|
|
||||||
public static final String COMPANY_CREATED_SUCCESS_MSG = "company.created.success";
|
public static final String COMPANY_CREATED_SUCCESS_MSG = "company.created.success";
|
||||||
public static final String COMPANY_UPDATED_SUCCESS_MSG = "company.updated.success";
|
public static final String COMPANY_UPDATED_SUCCESS_MSG = "company.updated.success";
|
||||||
public static final String COMPANY_DELETE_SUCCESS_MSG = "company.delete.success";
|
public static final String COMPANY_DELETE_SUCCESS_MSG = "company.delete.success";
|
||||||
public static final String COMPANY_GET_SUCCESS_MSG = "company.get.success";
|
public static final String COMPANY_GET_SUCCESS_MSG = "company.get.success";
|
||||||
public static final String COMPANY_NOT_FOUND_MSG = "company.not.found";
|
public static final String COMPANY_NOT_FOUND_MSG = "company.not.found";
|
||||||
public static final String CHECK_VATNUMBER_SUCCESS_MSG = "check.vatnumber.success";
|
public static final String CHECK_VATNUMBER_SUCCESS_MSG = "check.vatnumber.success";
|
||||||
public static final String INVALID_VATNUMBER = "invalid.vatnumber";
|
public static final String INVALID_VATNUMBER = "invalid.vatnumber";
|
||||||
public static final String VATNUMBER_MANDATORY = "vatnumber.mandatory";
|
public static final String VATNUMBER_MANDATORY = "vatnumber.mandatory";
|
||||||
public static final String VATNUMBER_ALREADY_EXISTS = "vatnumber.already.exists";
|
public static final String VATNUMBER_ALREADY_EXISTS = "vatnumber.already.exists";
|
||||||
public static final String INVALID_EMAIL = "invalid.email";
|
public static final String INVALID_EMAIL = "invalid.email";
|
||||||
public static final String UNAUTHORIZED = "UNAUTHORIZED";
|
public static final String UNAUTHORIZED = "UNAUTHORIZED";
|
||||||
public static final String COMPANY_ID_MANDATORY = "company.id.mandatory";
|
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 USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company";
|
||||||
|
public static final String YYYY_MM_DD_DASH = "yyyy-MM-dd";
|
||||||
|
public static final String YYYY_MM_DD_SLASH = "yyyy/MM/dd";
|
||||||
|
public static final String DELEGATION_TEMPLATE = "DELEGATION_TEMPLATE";
|
||||||
|
public static final String VALIDATION_ERROR_MISSING_FIRSTNAME = "validation.error.missing.firstName";
|
||||||
|
public static final String VALIDATION_ERROR_MISSING_LASTNAME = "validation.error.missing.lastName";
|
||||||
|
public static final String VALIDATION_ERROR_MISSING_CODICEFISCALE = "validation.error.missing.codiceFiscale";
|
||||||
|
public static final String DELEGATION_FILE_UPLOAD_SUCCESS = "delegation.file.upload.success";
|
||||||
|
public static final String DELEGATION_FETCH_SUCCESS = "delegation.fetch.success";
|
||||||
|
public static final String DELEGATION_TEMPLATE_GENERATION_ERROR = "delegation.template.generation.error";
|
||||||
|
public static final String VALIDATION_ERROR_FILE_EMPTY = "validation.error.file.empty";
|
||||||
|
public static final String VALIDATION_ERROR_FILE_INVALIDTYPE = "validation.error.file.invalidType";
|
||||||
|
public static final String UPLOAD_ERROR_S3 = "upload.error.s3";
|
||||||
|
|
||||||
|
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";
|
||||||
|
public static final String HH_MM_SS = "HH:mm:ss";
|
||||||
|
|
||||||
|
public static final String USER_NOT_AUTHORIZED_TO_CREATE_APPLICATION = "user.not.authorized.create.application";
|
||||||
|
public static final String APPLICATION_SUBMITTED_CANNOT_CHANGE = "application.submitted.cannot.change";
|
||||||
|
public static final String CALL_DOCUMENTS_FETCH_SUCCESS_MSG = "call.documents.fetch.success";
|
||||||
|
public static final String CALL_DOCUMENTS_NOT_FOUND_MSG = "call.documents.not.found";
|
||||||
|
public static final String PERMISSION_DENIED = "permission.denied";
|
||||||
|
public static final String SIGNED_DOCUMENT_FILE_UPLOAD_SUCCESS = "signed.document.file.upload.success";
|
||||||
|
public static final String GET_SIGNED_DOCUMENT_FILE_SUCCESS = "get.signed.document.file.success";
|
||||||
|
public static final String APPLICATION_SIGNED_DOCUMENT_NOT_FOUND = "application.signed.document.not.found";
|
||||||
|
public static final String DELETE_SIGNED_DOCUMENT_FILE_SUCCESS = "delete.signed.document.file.success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,34 +3,46 @@ package net.gepafin.tendermanagement.dao;
|
|||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.*;
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationSignedDocumentStatusEnum;
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationFormFieldRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
import net.gepafin.tendermanagement.service.CallService;
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
import net.gepafin.tendermanagement.service.DocumentService;
|
import net.gepafin.tendermanagement.service.DocumentService;
|
||||||
import net.gepafin.tendermanagement.service.FormService;
|
import net.gepafin.tendermanagement.service.FormService;
|
||||||
|
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||||
|
import net.gepafin.tendermanagement.util.MailUtil;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
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.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Predicate;
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -69,13 +81,49 @@ public class ApplicationDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FlowDataRepository flowDataRepository;
|
private FlowDataRepository flowDataRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Validator validator;
|
private Validator validator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CompanyService companyService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProtocolRepository protocolRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemEmailTemplatesService systemEmailTemplatesService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MailUtil mailUtil;
|
||||||
|
|
||||||
|
@Value("${default_System_Receiver_Email}")
|
||||||
|
private String defaultSystemReceiverEmail;
|
||||||
|
|
||||||
|
@Value("${gepafin_email}")
|
||||||
|
private String gepafinEmail;
|
||||||
|
|
||||||
|
@Value("${rinaldo_email}")
|
||||||
|
private String rinaldoEmail;
|
||||||
|
|
||||||
|
@Value("${carlo_email}")
|
||||||
|
private String carloEmail;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||||
|
|
||||||
|
@Value("${aws.s3.url.folder.signed.document}")
|
||||||
|
private String signedDocumentS3Folder;
|
||||||
|
|
||||||
|
|
||||||
public ApplicationResponseBean createApplication(ApplicationRequestBean applicationRequestBean, UserEntity userEntity, Long formId, Long applicationId) {
|
public ApplicationResponseBean createApplication(ApplicationRequestBean applicationRequestBean, UserEntity userEntity, Long formId, Long applicationId) {
|
||||||
FormEntity formEntity = formService.validateForm(formId);
|
FormEntity formEntity = formService.validateForm(formId);
|
||||||
callService.validatePublishedCall(formEntity.getCall().getId());
|
// callService.validatePublishedCall(formEntity.getCall().getId());
|
||||||
validateFormFields(applicationRequestBean,formEntity);
|
validateFormFields(applicationRequestBean,formEntity);
|
||||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) {
|
if(Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) {
|
||||||
@@ -86,6 +134,19 @@ public class ApplicationDao {
|
|||||||
createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationFormEntity,formEntity);
|
createOrUpdateMultipleFormFields(applicationRequestBean.getFormFields(), applicationFormEntity,formEntity);
|
||||||
return getApplicationById(applicationEntity.getId(),formEntity.getId());
|
return getApplicationById(applicationEntity.getId(),formEntity.getId());
|
||||||
}
|
}
|
||||||
|
public void validateDelegation(UserEntity user, CompanyEntity company) {
|
||||||
|
UserWithCompanyEntity userWithCompany = companyService.getUserWithCompanyEntity(user.getId(), company.getId());
|
||||||
|
|
||||||
|
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||||
|
.findByUserIdAndCompanyIdAndStatus(user.getId(), company.getId(),
|
||||||
|
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||||
|
|
||||||
|
if (!userWithCompany.getIsLegalRepresentant() && userCompanyDelegationEntity == null) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST,
|
||||||
|
Translator.toLocale(GepafinConstant.USER_NOT_AUTHORIZED_TO_CREATE_APPLICATION));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ApplicationFormEntity saveApplicationFormEntity(ApplicationFormEntity applicationFormEntity) {
|
public ApplicationFormEntity saveApplicationFormEntity(ApplicationFormEntity applicationFormEntity) {
|
||||||
ApplicationFormEntity applicationFormEntity1 = applicationFormRepository.save(applicationFormEntity);
|
ApplicationFormEntity applicationFormEntity1 = applicationFormRepository.save(applicationFormEntity);
|
||||||
@@ -101,6 +162,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationEntity createApplicationEntity(UserEntity user, CallEntity call, CompanyEntity companyEntity) {
|
public ApplicationEntity createApplicationEntity(UserEntity user, CallEntity call, CompanyEntity companyEntity) {
|
||||||
|
validateDelegation(user,companyEntity);
|
||||||
ApplicationEntity entity = new ApplicationEntity();
|
ApplicationEntity entity = new ApplicationEntity();
|
||||||
entity.setUserId(user.getId());
|
entity.setUserId(user.getId());
|
||||||
entity.setCompany(companyEntity);
|
entity.setCompany(companyEntity);
|
||||||
@@ -260,6 +322,9 @@ public class ApplicationDao {
|
|||||||
responseBean.setComments(applicationEntity.getComments());
|
responseBean.setComments(applicationEntity.getComments());
|
||||||
responseBean.setCompanyId(applicationEntity.getCompany().getId());
|
responseBean.setCompanyId(applicationEntity.getCompany().getId());
|
||||||
responseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
responseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
||||||
|
if(applicationEntity.getProtocol() != null) {
|
||||||
|
responseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
|
||||||
|
}
|
||||||
return responseBean;
|
return responseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +344,9 @@ public class ApplicationDao {
|
|||||||
response.setCallId(entity.getCall().getId());
|
response.setCallId(entity.getCall().getId());
|
||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
if(entity.getProtocol() != null) {
|
||||||
|
response.setProtocolNumber(entity.getProtocol().getProtocolNumber());
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,9 +391,13 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils.setIfUpdated(applicationFormFieldEntity::getFieldId, applicationFormFieldEntity::setFieldId, applicationFormFieldRequestBean.getFieldId());
|
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);
|
return applicationFormFieldRepository.save(applicationFormFieldEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,10 +405,15 @@ public class ApplicationDao {
|
|||||||
List<Long> documentIds=null;
|
List<Long> documentIds=null;
|
||||||
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
List<ContentResponseBean> contentResponseBeans=Utils.convertJsonStringToList(formEntity.getContent(),ContentResponseBean.class);
|
||||||
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
for (ContentResponseBean contentResponseBean:contentResponseBeans){
|
||||||
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))){
|
if(Boolean.TRUE.equals(contentResponseBean.getName().equals("fileupload"))) {
|
||||||
if(contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
if (contentResponseBean.getId().equals(applicationFormFieldRequestBean.getFieldId())) {
|
||||||
String documentId = applicationFormFieldRequestBean.getFieldValue();
|
Object fieldValueObject = applicationFormFieldRequestBean.getFieldValue();
|
||||||
documentIds = validateDocumentIds(documentId);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -377,7 +454,9 @@ public class ApplicationDao {
|
|||||||
ApplicationFormFieldResponseBean applicationFormFieldResponseBean = new ApplicationFormFieldResponseBean();
|
ApplicationFormFieldResponseBean applicationFormFieldResponseBean = new ApplicationFormFieldResponseBean();
|
||||||
applicationFormFieldResponseBean.setApplicationFormId(applicationFormId);
|
applicationFormFieldResponseBean.setApplicationFormId(applicationFormId);
|
||||||
applicationFormFieldResponseBean.setFieldId(applicationFormFieldEntity.getFieldId());
|
applicationFormFieldResponseBean.setFieldId(applicationFormFieldEntity.getFieldId());
|
||||||
applicationFormFieldResponseBean.setFieldValue(applicationFormFieldEntity.getFieldValue());
|
if(applicationFormFieldEntity.getFieldValue() != null) {
|
||||||
|
applicationFormFieldResponseBean.setFieldValue(Utils.getFieldValueAsObject(applicationFormFieldEntity.getFieldValue()));
|
||||||
|
}
|
||||||
applicationFormFieldResponseBean.setId(applicationFormFieldEntity.getId());
|
applicationFormFieldResponseBean.setId(applicationFormFieldEntity.getId());
|
||||||
applicationFormFieldResponseBean.setCreatedDate(applicationFormFieldEntity.getCreatedDate());
|
applicationFormFieldResponseBean.setCreatedDate(applicationFormFieldEntity.getCreatedDate());
|
||||||
applicationFormFieldResponseBean.setUpdatedDate(applicationFormFieldEntity.getUpdatedDate());
|
applicationFormFieldResponseBean.setUpdatedDate(applicationFormFieldEntity.getUpdatedDate());
|
||||||
@@ -447,7 +526,7 @@ public class ApplicationDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationGetResponseBean createApplicationGetResponseBean(ApplicationEntity applicationEntity, List<FormEntity> formEntities, List<FormApplicationResponse> formApplicationResponses) {
|
private ApplicationGetResponseBean createApplicationGetResponseBean(ApplicationEntity applicationEntity, List<FormEntity> formEntities, List<FormApplicationResponse> formApplicationResponses) {
|
||||||
ApplicationGetResponseBean applicationGetResponseBean =createApplicationGetResponseBean(applicationEntity);
|
ApplicationGetResponseBean applicationGetResponseBean = createApplicationGetResponseBean(applicationEntity);
|
||||||
applicationGetResponseBean.setForm(formApplicationResponses);
|
applicationGetResponseBean.setForm(formApplicationResponses);
|
||||||
return applicationGetResponseBean;
|
return applicationGetResponseBean;
|
||||||
}
|
}
|
||||||
@@ -461,6 +540,9 @@ public class ApplicationDao {
|
|||||||
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
|
applicationGetResponseBean.setCallId(applicationEntity.getCall().getId());
|
||||||
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getName());
|
applicationGetResponseBean.setCallTitle(applicationEntity.getCall().getName());
|
||||||
applicationGetResponseBean.setCompanyId(applicationEntity.getCompany().getId());
|
applicationGetResponseBean.setCompanyId(applicationEntity.getCompany().getId());
|
||||||
|
if(applicationEntity.getProtocol() != null) {
|
||||||
|
applicationGetResponseBean.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
|
||||||
|
}
|
||||||
applicationGetResponseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
applicationGetResponseBean.setCompanyName(applicationEntity.getCompany().getCompanyName());
|
||||||
return applicationGetResponseBean;
|
return applicationGetResponseBean;
|
||||||
}
|
}
|
||||||
@@ -477,25 +559,32 @@ public class ApplicationDao {
|
|||||||
public ApplicationResponse createApplicationByCallId(CompanyEntity companyEntity,
|
public ApplicationResponse createApplicationByCallId(CompanyEntity companyEntity,
|
||||||
ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) {
|
ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) {
|
||||||
CallEntity call = callService.validateCall(callId);
|
CallEntity call = callService.validateCall(callId);
|
||||||
call = callService.validatePublishedCall(call.getId());
|
// call = callService.validatePublishedCall(call.getId());
|
||||||
checkIfApplicationExists(call, companyEntity);
|
checkIfApplicationExists(call, companyEntity, userEntity);
|
||||||
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, companyEntity);
|
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, companyEntity);
|
||||||
applicationEntity.setComments(applicationRequest.getComments());
|
applicationEntity.setComments(applicationRequest.getComments());
|
||||||
applicationEntity = saveApplicationEntity(applicationEntity);
|
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||||
ApplicationResponse applicationResponse = getApplicationResponse(applicationEntity);
|
ApplicationResponse applicationResponse = getApplicationResponse(applicationEntity);
|
||||||
return applicationResponse;
|
return applicationResponse;
|
||||||
}
|
}
|
||||||
public void checkIfApplicationExists(CallEntity call, CompanyEntity companyEntity){
|
public void checkIfApplicationExists(CallEntity call, CompanyEntity companyEntity, UserEntity userEntity){
|
||||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByCompanyIdAndCallIdAndIsDeletedFalse(companyEntity.getId(),call.getId());
|
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), companyEntity.getId(),call.getId());
|
||||||
if(applicationEntity.isPresent()){
|
if(applicationEntity.isPresent()){
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) {
|
public ApplicationResponse updateApplicationStatus(UserEntity userEntity, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
if (ApplicationStatusTypeEnum.SUBMIT.getValue().equals(applicationEntity.getStatus())) {
|
||||||
|
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_SUBMITTED_CANNOT_CHANGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) {
|
if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) {
|
||||||
|
callService.validatePublishedCall(applicationEntity.getCall().getId());
|
||||||
// CallEntity callEntity = applicationEntity.getCall();
|
// CallEntity callEntity = applicationEntity.getCall();
|
||||||
// Long initialFormId = callEntity.getInitialForm();
|
// Long initialFormId = callEntity.getInitialForm();
|
||||||
// Long finalFormId = callEntity.getFinalForm();
|
// Long finalFormId = callEntity.getFinalForm();
|
||||||
@@ -513,15 +602,23 @@ public class ApplicationDao {
|
|||||||
if (totalSteps.intValue() != completedSteps) {
|
if (totalSteps.intValue() != completedSteps) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
|
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.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
|
||||||
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
applicationEntity.setSubmissionDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
sendMailToUserAndCompany(userEntity, applicationEntity);
|
||||||
|
sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity);
|
||||||
} else {
|
} else {
|
||||||
applicationEntity.setStatus(status.getValue());
|
applicationEntity.setStatus(status.getValue());
|
||||||
}
|
}
|
||||||
saveApplicationEntity(applicationEntity);
|
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||||
|
|
||||||
|
return getApplicationResponse(applicationEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer calculateProgress(Long totalSteps, Long completedSteps) {
|
public Integer calculateProgress(Long totalSteps, Long completedSteps) {
|
||||||
if (FieldValidator.isNullOrZero(totalSteps)) {
|
if (FieldValidator.isNullOrZero(totalSteps)) {
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.TOTAL_STEPS_NOT_BE_ZERO));
|
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.TOTAL_STEPS_NOT_BE_ZERO));
|
||||||
}
|
}
|
||||||
@@ -594,4 +691,154 @@ 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;
|
||||||
|
}
|
||||||
|
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||||
|
CallEntity call =applicationEntity.getCall();
|
||||||
|
CompanyEntity company = applicationEntity.getCompany();
|
||||||
|
ProtocolEntity protocol = applicationEntity.getProtocol();
|
||||||
|
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||||
|
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_USER_AND_COMPANY,
|
||||||
|
call, null);
|
||||||
|
|
||||||
|
// Create the map for subject placeholders
|
||||||
|
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||||
|
subjectPlaceholders.put("{{call_name}}", call.getName());
|
||||||
|
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||||
|
|
||||||
|
// Create the map for body placeholders
|
||||||
|
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||||
|
bodyPlaceholders.put("{{call_name}}", call.getName());
|
||||||
|
bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString());
|
||||||
|
bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.YYYY_MM_DD_SLASH));
|
||||||
|
bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS));
|
||||||
|
|
||||||
|
// Replace placeholders in the subject and body
|
||||||
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||||
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||||
|
|
||||||
|
String email = userEntity.getEmail();
|
||||||
|
if (userEntity.getBeneficiary() != null) {
|
||||||
|
email = userEntity.getBeneficiary().getEmail();
|
||||||
|
}
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(email), null);
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(applicationEntity.getCompany().getEmail()), null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMailTodefaultSystemAndGepafin(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||||
|
CallEntity call = applicationEntity.getCall();
|
||||||
|
CompanyEntity company = applicationEntity.getCompany();
|
||||||
|
ProtocolEntity protocol = applicationEntity.getProtocol();
|
||||||
|
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||||
|
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_GEPAFIN,
|
||||||
|
call, null);
|
||||||
|
|
||||||
|
// Create the map for subject placeholders
|
||||||
|
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||||
|
subjectPlaceholders.put("{{call_name}}", call.getName());
|
||||||
|
subjectPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||||
|
|
||||||
|
// Create the map for body placeholders
|
||||||
|
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||||
|
bodyPlaceholders.put("{{call_name}}", call.getName());
|
||||||
|
bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString());
|
||||||
|
bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.YYYY_MM_DD_SLASH));
|
||||||
|
bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS));
|
||||||
|
|
||||||
|
// Replace placeholders in the subject and body
|
||||||
|
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||||
|
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||||
|
|
||||||
|
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null);
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null);
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null);
|
||||||
|
mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
|
||||||
|
|
||||||
|
}
|
||||||
|
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId,
|
||||||
|
MultipartFile file) {
|
||||||
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||||
|
validateFileType(file);
|
||||||
|
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||||
|
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||||
|
if (applicationSignedDocument != null) {
|
||||||
|
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
||||||
|
applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||||
|
}
|
||||||
|
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = amazonS3Service.uploadFileOnAmazonS3(signedDocumentS3Folder,
|
||||||
|
file);
|
||||||
|
applicationSignedDocument = new ApplicationSignedDocumentEntity();
|
||||||
|
applicationSignedDocument.setApplication(applicationEntity);
|
||||||
|
applicationSignedDocument.setFileName(uploadFileOnAmazonS3.getFileName());
|
||||||
|
applicationSignedDocument.setFilePath(uploadFileOnAmazonS3.getFilePath());
|
||||||
|
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||||
|
applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||||
|
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationSignedDocumentResponse convertApplicationSignedDocumentToApplicationSignedDocumentResponse(
|
||||||
|
ApplicationSignedDocumentEntity applicationSignedDocument) {
|
||||||
|
ApplicationSignedDocumentResponse applicationSignedDocumentResponse = new ApplicationSignedDocumentResponse();
|
||||||
|
applicationSignedDocumentResponse.setId(applicationSignedDocument.getId());
|
||||||
|
applicationSignedDocumentResponse.setApplicationId(applicationSignedDocument.getApplication().getId());
|
||||||
|
applicationSignedDocumentResponse.setFileName(applicationSignedDocument.getFileName());
|
||||||
|
applicationSignedDocumentResponse.setFilePath(applicationSignedDocument.getFilePath());
|
||||||
|
applicationSignedDocumentResponse
|
||||||
|
.setStatus(ApplicationSignedDocumentStatusEnum.valueOf(applicationSignedDocument.getStatus()));
|
||||||
|
applicationSignedDocumentResponse.setCreatedDate(applicationSignedDocument.getCreatedDate());
|
||||||
|
applicationSignedDocumentResponse.setUpdatedDate(applicationSignedDocument.getUpdatedDate());
|
||||||
|
return applicationSignedDocumentResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateFileType(MultipartFile file) {
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_EMPTY));
|
||||||
|
}
|
||||||
|
String filename = file.getOriginalFilename();
|
||||||
|
if (filename == null || !filename.endsWith(".p7m")) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_INVALIDTYPE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||||
|
|
||||||
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||||
|
|
||||||
|
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||||
|
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||||
|
if(applicationSignedDocument == null) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.APPLICATION_SIGNED_DOCUMENT_NOT_FOUND));
|
||||||
|
}
|
||||||
|
return convertApplicationSignedDocumentToApplicationSignedDocumentResponse(applicationSignedDocument);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||||
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
|
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||||
|
|
||||||
|
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository
|
||||||
|
.findByApplicationIdAndStatus(applicationId, ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||||
|
if(applicationSignedDocument == null) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.APPLICATION_SIGNED_DOCUMENT_NOT_FOUND));
|
||||||
|
}
|
||||||
|
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.INACTIVE.getValue());
|
||||||
|
applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,32 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.*;
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
import net.gepafin.tendermanagement.service.*;
|
import net.gepafin.tendermanagement.service.*;
|
||||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
import org.h2.util.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -84,6 +97,10 @@ public class CallDao {
|
|||||||
private FlowDao flowDao;
|
private FlowDao flowDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FormDao formDao;
|
private FormDao formDao;
|
||||||
|
@Value("${aws.s3.url.folder}")
|
||||||
|
private String s3Folder;
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
||||||
UserEntity userEntity = userService.validateUser(userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
@@ -100,6 +117,35 @@ public class CallDao {
|
|||||||
return createCallResponseBean;
|
return createCallResponseBean;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public byte[] downloadCallDocumentsAsZip(Long callId) {
|
||||||
|
List<DocumentEntity> documents = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callId, DocumentSourceTypeEnum.CALL.getValue(),DocumentTypeEnum.DOCUMENT.getValue());
|
||||||
|
if (documents.isEmpty()) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||||
|
}
|
||||||
|
|
||||||
|
try (ByteArrayOutputStream zipOutputStream = new ByteArrayOutputStream();
|
||||||
|
ZipOutputStream zos = new ZipOutputStream(zipOutputStream)) {
|
||||||
|
|
||||||
|
for (DocumentEntity document : documents) {
|
||||||
|
try (InputStream fileInputStream = amazonS3Service.getFile(s3Folder, document.getFileName())) {
|
||||||
|
ZipEntry zipEntry = new ZipEntry(document.getFileName());
|
||||||
|
zos.putNextEntry(zipEntry);
|
||||||
|
IOUtils.copy(fileInputStream, zos);
|
||||||
|
zos.closeEntry();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Error downloading or adding document to ZIP: " + document.getFileName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zos.finish();
|
||||||
|
return zipOutputStream.toByteArray();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Error while creating ZIP file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CallEntity convertToCallEntity(CreateCallRequestStep1 createCallRequest) {
|
public CallEntity convertToCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||||
CallEntity callEntity = new CallEntity();
|
CallEntity callEntity = new CallEntity();
|
||||||
@@ -130,7 +176,7 @@ public class CallDao {
|
|||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||||
}
|
}
|
||||||
callEntity.setAmountMin(createCallRequest.getAmountMin());
|
callEntity.setAmountMin(createCallRequest.getAmountMin());
|
||||||
if(createCallRequest.getEmail()==null || Boolean.FALSE.equals(Utils.isValidEmail(createCallRequest.getEmail()))){
|
if(createCallRequest.getEmail()!=null && Boolean.FALSE.equals(Utils.isValidEmail(createCallRequest.getEmail()))){
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.VALIDATION_EMAIL,createCallRequest.getEmail()));
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.VALIDATION_EMAIL,createCallRequest.getEmail()));
|
||||||
}
|
}
|
||||||
callEntity.setEmail(createCallRequest.getEmail());
|
callEntity.setEmail(createCallRequest.getEmail());
|
||||||
@@ -478,7 +524,7 @@ public class CallDao {
|
|||||||
if (updateCallRequest.getAmountMin() != null && updateCallRequest.getAmountMin().compareTo(BigDecimal.ZERO) < 0) {
|
if (updateCallRequest.getAmountMin() != null && updateCallRequest.getAmountMin().compareTo(BigDecimal.ZERO) < 0) {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||||
}
|
}
|
||||||
if(updateCallRequest.getEmail()==null || Boolean.FALSE.equals(Utils.isValidEmail(updateCallRequest.getEmail()))){
|
if(updateCallRequest.getEmail()!=null && Boolean.FALSE.equals(Utils.isValidEmail(updateCallRequest.getEmail()))){
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.VALIDATION_EMAIL,updateCallRequest.getEmail()));
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.VALIDATION_EMAIL,updateCallRequest.getEmail()));
|
||||||
}
|
}
|
||||||
setIfUpdated(callEntity::getAmountMin, callEntity::setAmountMin, updateCallRequest.getAmountMin());
|
setIfUpdated(callEntity::getAmountMin, callEntity::setAmountMin, updateCallRequest.getAmountMin());
|
||||||
@@ -673,6 +719,25 @@ public class CallDao {
|
|||||||
Status.NOT_FOUND,
|
Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED));
|
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;
|
return callEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,12 @@ import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
|||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.util.Utils;
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CompanyDao {
|
public class CompanyDao {
|
||||||
|
|
||||||
@@ -33,24 +36,26 @@ public class CompanyDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserWithCompanyRepository userWithCompanyRepository;
|
private UserWithCompanyRepository userWithCompanyRepository;
|
||||||
|
|
||||||
|
|
||||||
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||||
CompanyEntity existingCompany = companyRepository.findByVatNumber(companyRequest.getVatNumber());
|
CompanyEntity existingCompany = companyRepository.findByVatNumber(companyRequest.getVatNumber());
|
||||||
|
UserWithCompanyEntity userWithCompanyEntity = null;
|
||||||
if (existingCompany != null) {
|
if (existingCompany != null) {
|
||||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyId(userEntity.getId(), existingCompany.getId())
|
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyId(userEntity.getId(), existingCompany.getId())
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
if (existingRelation == null) {
|
if (existingRelation == null) {
|
||||||
createUserWithCompanyRelation(userEntity, existingCompany);
|
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, existingCompany, companyRequest.getIsLegalRepresentant());
|
||||||
} else {
|
} else {
|
||||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.USER_ALREADY_CONNECTED_TO_COMPANY));
|
Translator.toLocale(GepafinConstant.USER_ALREADY_CONNECTED_TO_COMPANY));
|
||||||
}
|
}
|
||||||
return convertCompanyEntityToCompanyResponse(existingCompany);
|
return convertCompanyEntityToCompanyResponse(existingCompany, userWithCompanyEntity);
|
||||||
} else {
|
} else {
|
||||||
validateCompany(companyRequest);
|
validateCompany(companyRequest);
|
||||||
CompanyEntity companyEntity = convertCompanyRequestToCompanyEntity(companyRequest);
|
CompanyEntity companyEntity = convertCompanyRequestToCompanyEntity(companyRequest);
|
||||||
companyRepository.save(companyEntity);
|
companyRepository.save(companyEntity);
|
||||||
createUserWithCompanyRelation(userEntity, companyEntity);
|
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant());
|
||||||
return convertCompanyEntityToCompanyResponse(companyEntity);
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,13 +77,14 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserWithCompanyEntity createUserWithCompanyRelation(UserEntity userEntity, CompanyEntity companyEntity) {
|
private UserWithCompanyEntity createUserWithCompanyRelation(UserEntity userEntity, CompanyEntity companyEntity, Boolean isLegalRepresentant) {
|
||||||
UserWithCompanyEntity userWithCompanyEntity = new UserWithCompanyEntity();
|
UserWithCompanyEntity userWithCompanyEntity = new UserWithCompanyEntity();
|
||||||
if (userEntity.getBeneficiary() != null) {
|
if (userEntity.getBeneficiary() != null) {
|
||||||
userWithCompanyEntity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
userWithCompanyEntity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||||
}
|
}
|
||||||
userWithCompanyEntity.setCompanyId(companyEntity.getId());
|
userWithCompanyEntity.setCompanyId(companyEntity.getId());
|
||||||
userWithCompanyEntity.setUserId(userEntity.getId());
|
userWithCompanyEntity.setUserId(userEntity.getId());
|
||||||
|
userWithCompanyEntity.setIsLegalRepresentant(isLegalRepresentant);
|
||||||
return userWithCompanyRepository.save(userWithCompanyEntity);
|
return userWithCompanyRepository.save(userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,10 +103,12 @@ public class CompanyDao {
|
|||||||
entity.setEmail(request.getEmail());
|
entity.setEmail(request.getEmail());
|
||||||
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
||||||
entity.setAnnualRevenue(request.getAnnualRevenue());
|
entity.setAnnualRevenue(request.getAnnualRevenue());
|
||||||
|
entity.setContactName(request.getContactName());
|
||||||
|
entity.setContactEmail(request.getContactEmail());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompanyResponse convertCompanyEntityToCompanyResponse(CompanyEntity entity) {
|
private CompanyResponse convertCompanyEntityToCompanyResponse(CompanyEntity entity, UserWithCompanyEntity userWithCompanyEntity) {
|
||||||
CompanyResponse response = new CompanyResponse();
|
CompanyResponse response = new CompanyResponse();
|
||||||
response.setId(entity.getId());
|
response.setId(entity.getId());
|
||||||
response.setCompanyName(entity.getCompanyName());
|
response.setCompanyName(entity.getCompanyName());
|
||||||
@@ -116,33 +124,44 @@ public class CompanyDao {
|
|||||||
response.setEmail(entity.getEmail());
|
response.setEmail(entity.getEmail());
|
||||||
response.setNumberOfEmployees(entity.getNumberOfEmployees());
|
response.setNumberOfEmployees(entity.getNumberOfEmployees());
|
||||||
response.setAnnualRevenue(entity.getAnnualRevenue());
|
response.setAnnualRevenue(entity.getAnnualRevenue());
|
||||||
|
if(userWithCompanyEntity!=null) {
|
||||||
|
response.setIsLegalRepresentant(userWithCompanyEntity.getIsLegalRepresentant());
|
||||||
|
}
|
||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
response.setContactName(entity.getContactName());
|
||||||
|
response.setContactEmail(entity.getContactEmail());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompanyResponse updateCompany(UserEntity userEntity, Long companyId, CompanyRequest companyRequest) {
|
public CompanyResponse updateCompany(UserEntity userEntity, Long companyId, CompanyRequest companyRequest) {
|
||||||
CompanyEntity companyEntity = validateCompany(companyId);
|
CompanyEntity companyEntity = validateCompany(companyId);
|
||||||
Utils.setIfUpdated(companyEntity::getCompanyName, companyEntity::setCompanyName,
|
setIfUpdated(companyEntity::getCompanyName, companyEntity::setCompanyName,
|
||||||
companyRequest.getCompanyName());
|
companyRequest.getCompanyName());
|
||||||
Utils.setIfUpdated(companyEntity::getVatNumber, companyEntity::setVatNumber, companyRequest.getVatNumber());
|
setIfUpdated(companyEntity::getVatNumber, companyEntity::setVatNumber, companyRequest.getVatNumber());
|
||||||
Utils.setIfUpdated(companyEntity::getCodiceFiscale, companyEntity::setCodiceFiscale,
|
setIfUpdated(companyEntity::getCodiceFiscale, companyEntity::setCodiceFiscale,
|
||||||
companyRequest.getCodiceFiscale());
|
companyRequest.getCodiceFiscale());
|
||||||
Utils.setIfUpdated(companyEntity::getAddress, companyEntity::setAddress, companyRequest.getAddress());
|
setIfUpdated(companyEntity::getAddress, companyEntity::setAddress, companyRequest.getAddress());
|
||||||
Utils.setIfUpdated(companyEntity::getPhoneNumber, companyEntity::setPhoneNumber,
|
setIfUpdated(companyEntity::getPhoneNumber, companyEntity::setPhoneNumber,
|
||||||
companyRequest.getPhoneNumber());
|
companyRequest.getPhoneNumber());
|
||||||
Utils.setIfUpdated(companyEntity::getCity, companyEntity::setCity, companyRequest.getCity());
|
setIfUpdated(companyEntity::getCity, companyEntity::setCity, companyRequest.getCity());
|
||||||
Utils.setIfUpdated(companyEntity::getProvince, companyEntity::setProvince, companyRequest.getProvince());
|
setIfUpdated(companyEntity::getProvince, companyEntity::setProvince, companyRequest.getProvince());
|
||||||
Utils.setIfUpdated(companyEntity::getCap, companyEntity::setCap, companyRequest.getCap());
|
setIfUpdated(companyEntity::getCap, companyEntity::setCap, companyRequest.getCap());
|
||||||
Utils.setIfUpdated(companyEntity::getCountry, companyEntity::setCountry, companyRequest.getCountry());
|
setIfUpdated(companyEntity::getCountry, companyEntity::setCountry, companyRequest.getCountry());
|
||||||
Utils.setIfUpdated(companyEntity::getPec, companyEntity::setPec, companyRequest.getPec());
|
setIfUpdated(companyEntity::getPec, companyEntity::setPec, companyRequest.getPec());
|
||||||
Utils.setIfUpdated(companyEntity::getEmail, companyEntity::setEmail, companyRequest.getEmail());
|
setIfUpdated(companyEntity::getEmail, companyEntity::setEmail, companyRequest.getEmail());
|
||||||
Utils.setIfUpdated(companyEntity::getNumberOfEmployees, companyEntity::setNumberOfEmployees,
|
setIfUpdated(companyEntity::getNumberOfEmployees, companyEntity::setNumberOfEmployees,
|
||||||
companyRequest.getNumberOfEmployees());
|
companyRequest.getNumberOfEmployees());
|
||||||
Utils.setIfUpdated(companyEntity::getAnnualRevenue, companyEntity::setAnnualRevenue,
|
setIfUpdated(companyEntity::getAnnualRevenue, companyEntity::setAnnualRevenue,
|
||||||
companyRequest.getAnnualRevenue());
|
companyRequest.getAnnualRevenue());
|
||||||
|
setIfUpdated(companyEntity::getContactName,companyEntity::setContactName,companyRequest.getContactName());
|
||||||
|
setIfUpdated(companyEntity::getContactEmail,companyEntity::setContactEmail,companyRequest.getContactEmail());
|
||||||
companyRepository.save(companyEntity);
|
companyRepository.save(companyEntity);
|
||||||
return convertCompanyEntityToCompanyResponse(companyEntity);
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
Utils.setIfUpdated(userWithCompanyEntity::getIsLegalRepresentant, userWithCompanyEntity::setIsLegalRepresentant,
|
||||||
|
companyRequest.getIsLegalRepresentant());
|
||||||
|
userWithCompanyRepository.save(userWithCompanyEntity);
|
||||||
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompanyEntity validateCompany(Long companyId) {
|
public CompanyEntity validateCompany(Long companyId) {
|
||||||
@@ -151,7 +170,8 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompanyResponse getCompany(UserEntity userEntity, Long companyId) {
|
public CompanyResponse getCompany(UserEntity userEntity, Long companyId) {
|
||||||
return convertCompanyEntityToCompanyResponse(validateCompany(companyId));
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
return convertCompanyEntityToCompanyResponse(validateCompany(companyId), userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteCompany(UserEntity userEntity, Long companyId) {
|
public void deleteCompany(UserEntity userEntity, Long companyId) {
|
||||||
@@ -164,12 +184,20 @@ public class CompanyDao {
|
|||||||
UserEntity userEntity = userService.validateUser(userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
List<Long> companyIds = userWithCompanyRepository.findCompanyIdByUserId(userEntity.getId());
|
List<Long> companyIds = userWithCompanyRepository.findCompanyIdByUserId(userEntity.getId());
|
||||||
List<CompanyEntity> list = companyRepository.findByIdIn(companyIds);
|
List<CompanyEntity> list = companyRepository.findByIdIn(companyIds);
|
||||||
return list.stream().map(this::convertCompanyEntityToCompanyResponse).toList();
|
return list.stream().map(companyEntity->{
|
||||||
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyEntity.getId());
|
||||||
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
||||||
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, companyId).orElseThrow(() -> new CustomValidationException(Status.UNAUTHORIZED,
|
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, companyId).orElseThrow(() -> new ForbiddenAccessException(Status.FORBIDDEN,
|
||||||
Translator.toLocale(GepafinConstant.UNAUTHORIZED)));
|
Translator.toLocale(GepafinConstant.PERMISSION_DENIED)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserWithCompanyEntity getUserWithCompany(Long userId, Long compnayId) {
|
||||||
|
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, compnayId).orElseThrow(
|
||||||
|
() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_COMPANY_RELATION_NOT_FOUND)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,256 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.UserCompanyDelegationRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DelegationDao {
|
||||||
|
|
||||||
|
private static final String DEFAULT_PLACEHOLDER = "____________________";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CompanyDao companyDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AmazonS3Service amazonS3Service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DocumentRepository documentRepository;
|
||||||
|
|
||||||
|
@Value("${aws.s3.url.folder.delegation}")
|
||||||
|
private String s3Folder;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserCompanyDelegationRepository userCompanyDelegationRepository;
|
||||||
|
|
||||||
|
|
||||||
|
public ByteArrayOutputStream generateDocument(Map<String, String> placeholders, String templateName) {
|
||||||
|
try {
|
||||||
|
InputStream templateStream = amazonS3Service.getFile(s3Folder ,templateName);
|
||||||
|
XWPFDocument doc = loadTemplate(templateStream);
|
||||||
|
replacePlaceholders(doc, placeholders);
|
||||||
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
doc.write(byteArrayOutputStream);
|
||||||
|
return byteArrayOutputStream;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.DELEGATION_TEMPLATE_GENERATION_ERROR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void replacePlaceholders(XWPFDocument doc, Map<String, String> placeholders) {
|
||||||
|
doc.getParagraphs().forEach(paragraph -> {
|
||||||
|
placeholders.forEach((placeholder, value) -> {
|
||||||
|
if (paragraph.getText().contains(placeholder)) {
|
||||||
|
String updatedText = paragraph.getText().replace(placeholder, value);
|
||||||
|
paragraph.getRuns().forEach(run -> run.setText("", 0)); // Clear the existing text
|
||||||
|
paragraph.createRun().setText(updatedText); // Insert updated text
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public XWPFDocument loadTemplate(InputStream templateStream) throws IOException {
|
||||||
|
return new XWPFDocument(templateStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteArrayOutputStream downloadCompanyDelegation(UserEntity userEntity, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
|
Map<String, String> placeholders = getDefaultPlaceholders();
|
||||||
|
UserResponseBean user = userService.getUserById(userEntity.getId());
|
||||||
|
CompanyEntity companyEntity = companyDao.validateCompany(companyId);
|
||||||
|
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
updatePlaceholdersForDelegation(user, companyEntity, placeholders, companyDelegationRequest);
|
||||||
|
DocumentEntity documentEntity = documentRepository.findBySource(GepafinConstant.DELEGATION_TEMPLATE).get(0);
|
||||||
|
return generateDocument(placeholders, documentEntity.getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> updatePlaceholdersForDelegation(UserResponseBean user, CompanyEntity companyEntity,
|
||||||
|
Map<String, String> placeholders, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
|
validateMandatoryFields(companyDelegationRequest);
|
||||||
|
addIfNotEmpty(placeholders, "{{company_first_name}}", companyDelegationRequest.getFirstName());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_last_name}}", companyDelegationRequest.getLastName());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_codice_fiscale}}", companyDelegationRequest.getCodiceFiscale());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_name}}", companyEntity.getCompanyName());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_city}}", companyEntity.getCity());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_address}}", companyEntity.getAddress());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_province}}", companyEntity.getProvince());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_cap}}", companyEntity.getCap());
|
||||||
|
addIfNotEmpty(placeholders, "{{company_vat_number}}", companyEntity.getVatNumber());
|
||||||
|
|
||||||
|
addIfNotEmpty(placeholders, "{{user_first_name}}", user.getFirstName());
|
||||||
|
addIfNotEmpty(placeholders, "{{user_last_name}}", user.getLastName());
|
||||||
|
addIfNotNull(placeholders, "{{user_date_of_birth}}", user.getDateOfBirth(),
|
||||||
|
date -> DateTimeUtil.formatLocalDateTime(date, GepafinConstant.YYYY_MM_DD_SLASH));
|
||||||
|
addIfNotEmpty(placeholders, "{{user_codice_fiscale}}", user.getCodiceFiscale());
|
||||||
|
|
||||||
|
return placeholders;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> getDefaultPlaceholders() {
|
||||||
|
Map<String, String> placeholders = new HashMap<>();
|
||||||
|
placeholders.put("{{company_first_name}}", "");
|
||||||
|
placeholders.put("{{company_last_name}}", "");
|
||||||
|
placeholders.put("{{company_codice_fiscale}}", "");
|
||||||
|
placeholders.put("{{company_name}}", "");
|
||||||
|
placeholders.put("{{company_city}}", "");
|
||||||
|
placeholders.put("{{company_address}}", "");
|
||||||
|
placeholders.put("{{company_province}}", "");
|
||||||
|
placeholders.put("{{company_cap}}", "");
|
||||||
|
placeholders.put("{{company_vat_number}}", "");
|
||||||
|
|
||||||
|
placeholders.put("{{user_first_name}}", "");
|
||||||
|
placeholders.put("{{user_last_name}}", "");
|
||||||
|
placeholders.put("{{user_date_of_birth}}", "");
|
||||||
|
placeholders.put("{{user_codice_fiscale}}", "");
|
||||||
|
return placeholders;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMandatoryFields(CompanyDelegationRequest companyDelegationRequest) {
|
||||||
|
if (StringUtils.isAllEmpty(companyDelegationRequest.getFirstName())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_MISSING_FIRSTNAME));
|
||||||
|
}
|
||||||
|
if (StringUtils.isAllEmpty(companyDelegationRequest.getLastName())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_MISSING_LASTNAME));
|
||||||
|
}
|
||||||
|
if (StringUtils.isAllEmpty(companyDelegationRequest.getCodiceFiscale())) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_MISSING_CODICEFISCALE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIfNotEmpty(Map<String, String> placeholders, String key, String value) {
|
||||||
|
if (Boolean.FALSE.equals(StringUtils.isAllEmpty(value))) {
|
||||||
|
placeholders.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> void addIfNotNull(Map<String, String> placeholders, String key, T value, Function<T, String> formatter) {
|
||||||
|
if (value != null) {
|
||||||
|
placeholders.put(key, formatter.apply(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CompanyDelegationResponse uploadCompanyDelegation(UserEntity userEntity, Long companyId, MultipartFile file) {
|
||||||
|
companyDao.validateCompany(companyId);
|
||||||
|
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
validateFileType(file);
|
||||||
|
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||||
|
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||||
|
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||||
|
if (userCompanyDelegationEntity != null) {
|
||||||
|
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||||
|
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||||
|
}
|
||||||
|
UploadFileOnAmazonS3 uploadFileOnAmazonS3 = uploadFileOnAmazonS3(file);
|
||||||
|
userCompanyDelegationEntity = new UserCompanyDelegationEntity();
|
||||||
|
userCompanyDelegationEntity.setCompanyId(companyId);
|
||||||
|
userCompanyDelegationEntity.setUserId(userEntity.getId());
|
||||||
|
if (userEntity.getBeneficiary() != null) {
|
||||||
|
userCompanyDelegationEntity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||||
|
}
|
||||||
|
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||||
|
userCompanyDelegationEntity.setFileName(uploadFileOnAmazonS3.fileName());
|
||||||
|
userCompanyDelegationEntity.setFilePath(uploadFileOnAmazonS3.filepath());
|
||||||
|
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||||
|
return convertUserCompanyDelegationToCompanyDelegationResponse(userCompanyDelegationEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompanyDelegationResponse convertUserCompanyDelegationToCompanyDelegationResponse(
|
||||||
|
UserCompanyDelegationEntity userCompanyDelegationEntity) {
|
||||||
|
return Utils.convertSourceObjectToDestinationObject(userCompanyDelegationEntity, CompanyDelegationResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private UploadFileOnAmazonS3 uploadFileOnAmazonS3(MultipartFile file){
|
||||||
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
|
String fileName = org.springframework.util.StringUtils.cleanPath(file.getOriginalFilename());
|
||||||
|
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
|
firstNameContain+=Utils.randomKey(5);
|
||||||
|
fileName = (firstNameContain + "." + extension);
|
||||||
|
try {
|
||||||
|
String filepath = amazonS3Service.upload(fileName, s3Folder, file);
|
||||||
|
return new UploadFileOnAmazonS3(fileName, filepath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private record UploadFileOnAmazonS3(String fileName, String filepath) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateFileType(MultipartFile file) {
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_EMPTY));
|
||||||
|
}
|
||||||
|
String filename = file.getOriginalFilename();
|
||||||
|
if (filename == null || !filename.endsWith(".p7m")) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.VALIDATION_ERROR_FILE_INVALIDTYPE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompanyDelegationResponse getCompanyDelegation(UserEntity userEntity, Long companyId) {
|
||||||
|
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||||
|
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||||
|
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||||
|
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
if(userCompanyDelegationEntity == null) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.DELEGATION_NOT_FOUND));
|
||||||
|
}
|
||||||
|
return convertUserCompanyDelegationToCompanyDelegationResponse(userCompanyDelegationEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteCompanyDelegation(UserEntity userEntity, Long companyId) {
|
||||||
|
UserCompanyDelegationEntity userCompanyDelegationEntity = userCompanyDelegationRepository
|
||||||
|
.findByUserIdAndCompanyIdAndStatus(userEntity.getId(), companyId,
|
||||||
|
UserCompanyDelegationStatusEnum.ACTIVE.getValue());
|
||||||
|
companyDao.getUserWithCompany(userEntity.getId(), companyId);
|
||||||
|
if(userCompanyDelegationEntity == null) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
Translator.toLocale(GepafinConstant.DELEGATION_NOT_FOUND));
|
||||||
|
}
|
||||||
|
userCompanyDelegationEntity.setStatus(UserCompanyDelegationStatusEnum.INACTIVE.getValue());
|
||||||
|
userCompanyDelegationRepository.save(userCompanyDelegationEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
|
|||||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -41,6 +42,9 @@ public class DocumentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CallService callService;
|
private CallService callService;
|
||||||
|
|
||||||
|
@Value("${aws.s3.url.folder}")
|
||||||
|
private String s3Folder;
|
||||||
|
|
||||||
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long sourceId, DocumentSourceTypeEnum sourceType, DocumentTypeEnum fileType) {
|
||||||
List<DocumentEntity> documentEntities = new ArrayList<>();
|
List<DocumentEntity> documentEntities = new ArrayList<>();
|
||||||
Long source = resolveSourceId(sourceId, sourceType);
|
Long source = resolveSourceId(sourceId, sourceType);
|
||||||
@@ -81,7 +85,7 @@ public class DocumentDao {
|
|||||||
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
|
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
|
||||||
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
fileName = (firstNameContain + "." + extension);
|
fileName = (firstNameContain + "." + extension);
|
||||||
String filepath = amazonS3Service.upload(fileName, file);
|
String filepath = amazonS3Service.upload(fileName, s3Folder, file);
|
||||||
uploadFileOnAmazonS3 result = new uploadFileOnAmazonS3(fileName, filepath);
|
uploadFileOnAmazonS3 result = new uploadFileOnAmazonS3(fileName, filepath);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -99,7 +103,7 @@ public class DocumentDao {
|
|||||||
|
|
||||||
private DocumentEntity deleteFileOnAmazonS3(String fileName) {
|
private DocumentEntity deleteFileOnAmazonS3(String fileName) {
|
||||||
try {
|
try {
|
||||||
amazonS3Service.delete(fileName);
|
amazonS3Service.delete(s3Folder, fileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||||
import net.gepafin.tendermanagement.repositories.*;
|
import net.gepafin.tendermanagement.repositories.*;
|
||||||
@@ -174,81 +175,83 @@ public class FlowFormDao {
|
|||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
|
||||||
// // Retrieve the flow edges for the previous forms
|
|
||||||
// List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
|
||||||
// currentFormEntity.getId(), applicationEntity.getCall().getId());
|
|
||||||
//
|
|
||||||
// if (flowEdgesList.isEmpty()) {
|
|
||||||
// return null;
|
|
||||||
//// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
|
||||||
//// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // If only one edge exists, return the source form ID
|
|
||||||
// if (flowEdgesList.size() == 1) {
|
|
||||||
// return flowEdgesList.get(0).getSourceId();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // For multiple edges, find the previous form based on the chosen value
|
|
||||||
// List<Long> previousFormIds = flowEdgesList.stream()
|
|
||||||
// .map(FlowEdgesEntity::getSourceId)
|
|
||||||
// .toList();
|
|
||||||
//
|
|
||||||
// // Fetch the flow data based on previous form IDs
|
|
||||||
// List<FlowDataEntity> flowDataList = flowDataRepository.findByFormIdInAndCallId(
|
|
||||||
// previousFormIds, applicationEntity.getCall().getId());
|
|
||||||
//
|
|
||||||
// List<String> chosenValues = flowDataList.stream()
|
|
||||||
// .map(FlowDataEntity::getChoosenValue)
|
|
||||||
// .toList();
|
|
||||||
//
|
|
||||||
// // Fetch the previous forms based on the chosen field values
|
|
||||||
// Set<FormEntity> formList = applicationFormFieldRepository
|
|
||||||
// .findByFieldValueInAndApplicationFormApplicationId(chosenValues, applicationEntity.getId()).stream()
|
|
||||||
// .map(fieldEntity -> fieldEntity.getApplicationForm().getForm())
|
|
||||||
// .collect(Collectors.toSet());
|
|
||||||
//
|
|
||||||
// // Find next form IDs recursively for all forms in the formList
|
|
||||||
// List<Long> fieldIds = formList.stream()
|
|
||||||
// .map(formEntity -> getNextForm(formEntity, applicationEntity))
|
|
||||||
// .toList();
|
|
||||||
//
|
|
||||||
// // Return the first matching previous form ID that corresponds to a next form
|
|
||||||
// return previousFormIds.stream()
|
|
||||||
// .filter(fieldIds::contains)
|
|
||||||
// .findFirst().orElse(null);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
// Retrieve the flow edges for the previous forms
|
||||||
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
||||||
|
currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
|
||||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
if (flowEdgesList.isEmpty()) {
|
||||||
currentFormEntity.getId(), applicationEntity.getCall().getId());
|
return null;
|
||||||
|
|
||||||
if (flowEdgesList.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
// // If only one edge exists, return the source form ID
|
// If only one edge exists, return the source form ID
|
||||||
// if (flowEdgesList.size() == 1) {
|
if (flowEdgesList.size() == 1) {
|
||||||
// return flowEdgesList.get(0).getSourceId();
|
return flowEdgesList.get(0).getSourceId();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// For multiple edges, find the previous form based on the chosen value
|
// For multiple edges, find the previous form based on the chosen value
|
||||||
List<Long> previousFormIds = flowEdgesList.stream()
|
List<Long> previousFormIds = flowEdgesList.stream()
|
||||||
.map(FlowEdgesEntity::getSourceId)
|
.map(FlowEdgesEntity::getSourceId)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
List<ApplicationFormEntity> applicationFormEntities=applicationFormRepository.findByFormIdInAndApplicationId(previousFormIds,applicationEntity.getId());
|
// Fetch the flow data based on previous form IDs
|
||||||
|
List<FlowDataEntity> flowDataList = flowDataRepository.findByFormIdInAndCallId(
|
||||||
|
previousFormIds, applicationEntity.getCall().getId());
|
||||||
|
|
||||||
applicationFormEntities.sort(Comparator.comparing(ApplicationFormEntity::getCreatedDate).reversed());
|
List<String> chosenValues = flowDataList.stream()
|
||||||
|
.map(FlowDataEntity::getChoosenValue)
|
||||||
|
.toList();
|
||||||
|
|
||||||
return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId();
|
// Fetch the previous forms based on the chosen field values
|
||||||
|
Set<FormEntity> formList = applicationFormFieldRepository
|
||||||
|
.findByFieldValueInAndApplicationFormApplicationId(chosenValues, applicationEntity.getId()).stream()
|
||||||
|
.map(fieldEntity -> fieldEntity.getApplicationForm().getForm())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// Find next form IDs recursively for all forms in the formList
|
||||||
|
List<Long> fieldIds = formList.stream()
|
||||||
|
.map(formEntity -> getNextForm(formEntity, applicationEntity))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
// Return the first matching previous form ID that corresponds to a next form
|
||||||
|
return previousFormIds.stream()
|
||||||
|
.filter(fieldIds::contains)
|
||||||
|
.findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
public NextOrPreviousFormResponse getnextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
|
||||||
FormActionEnum action) {
|
// public Long getPreviousForm(FormEntity currentFormEntity, ApplicationEntity applicationEntity) {
|
||||||
|
//
|
||||||
|
// List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByTargetIdAndCallId(
|
||||||
|
// currentFormEntity.getId(), applicationEntity.getCall().getId());
|
||||||
|
//
|
||||||
|
// if (flowEdgesList.isEmpty()) {
|
||||||
|
// return null;
|
||||||
|
//// throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||||
|
//// Translator.toLocale(GepafinConstant.PREVIOUS_FORM_NOT_FOUND));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // // If only one edge exists, return the source form ID
|
||||||
|
// // if (flowEdgesList.size() == 1) {
|
||||||
|
// // return flowEdgesList.get(0).getSourceId();
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// // For multiple edges, find the previous form based on the chosen value
|
||||||
|
// List<Long> previousFormIds = flowEdgesList.stream()
|
||||||
|
// .map(FlowEdgesEntity::getSourceId)
|
||||||
|
// .toList();
|
||||||
|
// if (previousFormIds.size() == 1) {
|
||||||
|
// return previousFormIds.get(0);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<ApplicationFormEntity> applicationFormEntities=applicationFormRepository.findByFormIdInAndApplicationId(previousFormIds,applicationEntity.getId());
|
||||||
|
// applicationFormEntities.sort(Comparator.comparing(ApplicationFormEntity::getCreatedDate).reversed());
|
||||||
|
//
|
||||||
|
// return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId();
|
||||||
|
// }
|
||||||
|
public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
|
||||||
|
FormActionEnum action) {
|
||||||
Long calculatedFormId = null;
|
Long calculatedFormId = null;
|
||||||
FormEntity formEntity = null;
|
FormEntity formEntity = null;
|
||||||
if (formId == null) {
|
if (formId == null) {
|
||||||
@@ -299,11 +302,14 @@ public class FlowFormDao {
|
|||||||
|
|
||||||
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
List<FlowEdgesEntity> flowEdgesList = flowEdgesRepository.findByCallId(applicationEntity.getCall().getId());
|
||||||
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
Long totalFormSteps = calculateTotalSteps(flowEdgesList);
|
||||||
Long currentStep = calculateCurrentStep(formEntity);
|
Long currentStep = calculateCurrentStep(flowEdgesList, formEntity);
|
||||||
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
nextOrPreviousFormResponse.setTotalFormSteps(totalFormSteps);
|
||||||
completedSteps = getCompletedSteps(applicationEntity);
|
completedSteps = getCompletedSteps(applicationEntity);
|
||||||
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
|
nextOrPreviousFormResponse.setCompletedSteps(Long.valueOf(completedSteps));
|
||||||
nextOrPreviousFormResponse.setCurrentStep(currentStep);
|
nextOrPreviousFormResponse.setCurrentStep(currentStep);
|
||||||
|
if(applicationEntity.getProtocol() != null) {
|
||||||
|
nextOrPreviousFormResponse.setProtocolNumber(applicationEntity.getProtocol().getProtocolNumber());
|
||||||
|
}
|
||||||
return nextOrPreviousFormResponse;
|
return nextOrPreviousFormResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,11 +327,11 @@ public class FlowFormDao {
|
|||||||
return completedSteps;
|
return completedSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long calculateCurrentStep(FormEntity formEntity) {
|
public Long calculateCurrentStep(List<FlowEdgesEntity> flowEdgesList, FormEntity formEntity) {
|
||||||
Long currentStep = 2l;
|
Long currentStep = 2l;
|
||||||
if (formEntity.getId().equals(formEntity.getCall().getInitialForm())) {
|
if (formEntity.getId().equals(formEntity.getCall().getInitialForm())) {
|
||||||
currentStep = 1l;
|
currentStep = 1l;
|
||||||
} else if (formEntity.getId().equals(formEntity.getCall().getFinalForm())) {
|
} else if (flowEdgesList.size()>1 && formEntity.getId().equals(formEntity.getCall().getFinalForm())) {
|
||||||
currentStep = 3l;
|
currentStep = 3l;
|
||||||
}
|
}
|
||||||
return currentStep;
|
return currentStep;
|
||||||
@@ -341,13 +347,21 @@ public class FlowFormDao {
|
|||||||
|
|
||||||
private Long getDefaultForm(ApplicationEntity applicationEntity) {
|
private Long getDefaultForm(ApplicationEntity applicationEntity) {
|
||||||
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationIdOrderByCreatedDateAsc(applicationEntity.getId());
|
List<ApplicationFormEntity> applicationFormList = applicationFormRepository.findByApplicationIdOrderByCreatedDateAsc(applicationEntity.getId());
|
||||||
if(applicationFormList.isEmpty()) {
|
if (applicationFormList.isEmpty()) {
|
||||||
return applicationEntity.getCall().getInitialForm();
|
return applicationEntity.getCall().getInitialForm();
|
||||||
}
|
}
|
||||||
if(applicationFormList.get(applicationFormList.size()-1).getForm().getId().equals(applicationEntity.getCall().getFinalForm())) {
|
if (applicationFormList.get(applicationFormList.size() - 1).getForm().getId().equals(applicationEntity.getCall().getFinalForm())) {
|
||||||
return applicationEntity.getCall().getInitialForm();
|
return applicationEntity.getCall().getInitialForm();
|
||||||
}
|
}
|
||||||
return getNextForm(applicationFormList.get(applicationFormList.size()-1).getForm(), applicationEntity);
|
FormEntity currentFormEntity = applicationFormList.get(applicationFormList.size() - 1).getForm();
|
||||||
|
|
||||||
|
for (ApplicationFormEntity applicationFormEntity : applicationFormList) {
|
||||||
|
Boolean isCompleted = formDao.validateCompletedSteps(applicationFormFieldRepository.findByApplicationFormId(applicationFormEntity.getId()), applicationEntity, applicationFormEntity.getForm());
|
||||||
|
if (Boolean.FALSE.equals(isCompleted)) {
|
||||||
|
return applicationFormEntity.getForm().getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return getNextForm(currentFormEntity, applicationEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -205,12 +206,14 @@ public class FormDao {
|
|||||||
public void validateFormField(List<ApplicationFormFieldRequestBean> applicationFormFieldRequestList, ApplicationEntity applicationEntity, FormEntity formEntity) {
|
public void validateFormField(List<ApplicationFormFieldRequestBean> applicationFormFieldRequestList, ApplicationEntity applicationEntity, FormEntity formEntity) {
|
||||||
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
||||||
for(ApplicationFormFieldRequestBean applicationFormFieldRequestBean:applicationFormFieldRequestList) {
|
for(ApplicationFormFieldRequestBean applicationFormFieldRequestBean:applicationFormFieldRequestList) {
|
||||||
if(applicationFormFieldRequestBean.getFieldValue()==null || applicationFormFieldRequestBean.getFieldValue().isEmpty())
|
if(applicationFormFieldRequestBean.getFieldValue()==null )
|
||||||
continue;
|
continue;
|
||||||
formFieldMap.put(applicationFormFieldRequestBean.getFieldId(),applicationFormFieldRequestBean.getFieldValue());
|
if (applicationFormFieldRequestBean.getFieldValue() != null ) {
|
||||||
}
|
Object fieldValue = applicationFormFieldRequestBean.getFieldValue();
|
||||||
|
checkObjectData(applicationFormFieldRequestBean.getFieldId(), fieldValue, formFieldMap);
|
||||||
|
}}
|
||||||
|
|
||||||
FormResponseBean formResponseBean = convertFormEntityToFormResponseBean(formEntity);
|
FormResponseBean formResponseBean = convertFormEntityToFormResponseBean(formEntity);
|
||||||
ApplicationFormEntity applicationFormEntity=applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(),formEntity.getId());
|
ApplicationFormEntity applicationFormEntity=applicationFormRepository.findByApplicationIdAndFormId(applicationEntity.getId(),formEntity.getId());
|
||||||
Boolean isApplicationFormExist= getApplicationFormExist(applicationFormEntity);
|
Boolean isApplicationFormExist= getApplicationFormExist(applicationFormEntity);
|
||||||
FieldValidator validator = FieldValidator.create();
|
FieldValidator validator = FieldValidator.create();
|
||||||
@@ -238,6 +241,28 @@ public class FormDao {
|
|||||||
validator.validate();
|
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) {
|
private Boolean getApplicationFormExist(ApplicationFormEntity applicationFormEntity) {
|
||||||
if(applicationFormEntity !=null) {
|
if(applicationFormEntity !=null) {
|
||||||
return true;
|
return true;
|
||||||
@@ -249,7 +274,7 @@ public class FormDao {
|
|||||||
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
Map<String, Object> formFieldMap = new LinkedHashMap<String, Object>();
|
||||||
for(ApplicationFormFieldEntity applicationFormFieldEntity:applicationFormFieldEntityList) {
|
for(ApplicationFormFieldEntity applicationFormFieldEntity:applicationFormFieldEntityList) {
|
||||||
formFieldMap.put(applicationFormFieldEntity.getFieldId(),applicationFormFieldEntity.getFieldValue());
|
formFieldMap.put(applicationFormFieldEntity.getFieldId(),applicationFormFieldEntity.getFieldValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
FormResponseBean formResponseBean = convertFormEntityToFormResponseBean(formEntity);
|
FormResponseBean formResponseBean = convertFormEntityToFormResponseBean(formEntity);
|
||||||
FieldValidator validator = FieldValidator.create();
|
FieldValidator validator = FieldValidator.create();
|
||||||
|
|||||||
619
src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java
Normal file
619
src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java
Normal file
@@ -0,0 +1,619 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.itextpdf.kernel.colors.ColorConstants;
|
||||||
|
import com.itextpdf.kernel.colors.DeviceRgb;
|
||||||
|
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
|
||||||
|
import com.itextpdf.layout.properties.UnitValue;
|
||||||
|
import com.itextpdf.layout.renderer.CellRenderer;
|
||||||
|
import com.itextpdf.layout.renderer.DrawContext;
|
||||||
|
import com.itextpdf.text.*;
|
||||||
|
import com.itextpdf.text.Element;
|
||||||
|
import com.itextpdf.text.Font;
|
||||||
|
import com.itextpdf.text.Image;
|
||||||
|
import com.itextpdf.text.Rectangle;
|
||||||
|
import com.itextpdf.text.pdf.*;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.*;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CustomPageEvent;
|
||||||
|
import net.gepafin.tendermanagement.model.request.FieldLabelValuePairRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.*;
|
||||||
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
|
import net.gepafin.tendermanagement.service.CallService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
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.stereotype.Component;
|
||||||
|
import com.itextpdf.layout.element.Table;
|
||||||
|
import com.itextpdf.layout.element.Cell;
|
||||||
|
//import com.itextpdf.layout.element.
|
||||||
|
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class PdfDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallService callService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ApplicationDao applicationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] generatePdf(HttpServletRequest request,Long applicationId) {
|
||||||
|
try {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
ApplicationEntity applicationEntity = applicationDao.validateApplication(applicationId);
|
||||||
|
validator.validateUserWithCompany(request, applicationEntity.getCompany().getId());
|
||||||
|
CallEntity call=callService.validateCall(applicationEntity.getCall().getId());
|
||||||
|
|
||||||
|
// Create a byte stream to hold the PDF
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
float leftMargin = 50f; // Adjust this for the left margin
|
||||||
|
|
||||||
|
Document document = new Document(PageSize.A4, leftMargin, 36f, 50f, 35);
|
||||||
|
PdfWriter writer = PdfWriter.getInstance(document, out);
|
||||||
|
// CustomPageEvent pageEvent = new CustomPageEvent(call.getName(), 0);
|
||||||
|
// writer.setPageEvent(pageEvent);
|
||||||
|
document.open();
|
||||||
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
|
addLogo(document, "https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/logo.jpg"); // Add your image path here
|
||||||
|
|
||||||
|
|
||||||
|
BaseColor customColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
|
||||||
|
// Define fonts and styles
|
||||||
|
BaseColor greenColor = new BaseColor(0, 128, 0); // Adjust RGB values as needed
|
||||||
|
BaseColor darkGreenColor = new BaseColor(1, 50, 32); // Adjust RGB values as needed
|
||||||
|
Font titleFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, customColor);
|
||||||
|
Font sectionFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12,darkGreenColor);
|
||||||
|
Font labelFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12,new BaseColor(113,121,126)); // Light grey);
|
||||||
|
Font smallFont = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8,new BaseColor(105, 105, 105));
|
||||||
|
Font valueFont=FontFactory.getFont(FontFactory.HELVETICA_BOLD,10,new BaseColor(178, 190, 181));
|
||||||
|
Paragraph title = new Paragraph(call.getName(), titleFont);
|
||||||
|
title.setAlignment(Element.ALIGN_LEFT);
|
||||||
|
document.add(title);
|
||||||
|
|
||||||
|
BaseColor greyColor=new BaseColor(178, 190, 181); // Very light grey color
|
||||||
|
addColoredLines(writer,document,greyColor);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
// Application ID section (Centered)
|
||||||
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
|
Paragraph appId = new Paragraph("ID domanda :" +"XX00");
|
||||||
|
appId.setAlignment(Element.ALIGN_RIGHT);
|
||||||
|
document.add(appId);
|
||||||
|
|
||||||
|
if(applicationEntity.getProtocol()!=null) {
|
||||||
|
appId = new Paragraph("ID domanda :"+String.valueOf(applicationEntity.getProtocol().getProtocolNumber()), valueFont);
|
||||||
|
appId.setAlignment(Element.ALIGN_RIGHT);
|
||||||
|
document.add(appId);
|
||||||
|
}
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
addColoredLines(writer,document,greenColor);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
document.add(new Paragraph("\n")); // Add line break
|
||||||
|
// String companyName= companyEntity.getCompanyName();
|
||||||
|
// String vatNumber=companyEntity.getVatNumber();
|
||||||
|
// String address=companyEntity.getAddress();
|
||||||
|
// // Section: Dati Anagrafici Azienda
|
||||||
|
// document.add(new Paragraph("Dati Anagrafici Azienda", sectionFont));
|
||||||
|
// addLabelValuePair(document, "Codice ATECO", "SEZIONE C “ATTIVITÀ MANUFATTURIERE”", regularFont);
|
||||||
|
// addLabelValuePair(document, "Ragione Sociale", companyName, regularFont);
|
||||||
|
// addLabelValuePair(document, "Partita IVA", vatNumber, regularFont);
|
||||||
|
// addLabelValuePair(document, "Indirizzo sede Legale", address, regularFont);
|
||||||
|
//
|
||||||
|
// document.add(new Paragraph("\n")); // Add line break
|
||||||
|
//
|
||||||
|
// // Section: Domanda presentata da
|
||||||
|
// document.add(new Paragraph("Domanda presentata da:", sectionFont));
|
||||||
|
// addLabelValuePair(document, "Nome e cognome", userEntity.getBeneficiary().getFirstName()+" "+userEntity.getBeneficiary().getLastName(), regularFont);
|
||||||
|
// addLabelValuePair(document, "Codice fiscale", userEntity.getBeneficiary().getCodiceFiscale(), regularFont);
|
||||||
|
// addLabelValuePair(document, "Telefono", userEntity.getBeneficiary().getPhoneNumber(), regularFont);
|
||||||
|
// addLabelValuePair(document, "Email", userEntity.getBeneficiary().getEmail(), regularFont);
|
||||||
|
// addLabelValuePair(document, "Con il titolo di", "Rappresentante legale", regularFont);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
ApplicationGetResponseBean applicationGetResponseBean=applicationDao.getApplicationByFormId(applicationId,null, userEntity);
|
||||||
|
for(FormApplicationResponse formApplicationResponse: applicationGetResponseBean.getForm()) {
|
||||||
|
document.add(new Paragraph(formApplicationResponse.getLabel(),sectionFont));
|
||||||
|
document.add(new Paragraph(" ")); // Add line break
|
||||||
|
List<FieldLabelValuePairRequest> fieldLabelValuePairRequests = getFormFieldsToLabels(formApplicationResponse);
|
||||||
|
for (FieldLabelValuePairRequest pair : fieldLabelValuePairRequests) {
|
||||||
|
String label = pair.getLabel();
|
||||||
|
Object value = pair.getValue();
|
||||||
|
Integer pages=0;
|
||||||
|
pages=addLabelValuePair(writer,document, label, value, labelFont,valueFont,call.getName(),pages);
|
||||||
|
if(pages !=0 ){
|
||||||
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addColoredLines(writer,document,greenColor);
|
||||||
|
document.add(new Paragraph(" ")); // Add line break
|
||||||
|
}
|
||||||
|
document.add(new Paragraph("\n")); // Add line break
|
||||||
|
Font boldSmallFont = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD,new BaseColor(105, 105, 105));
|
||||||
|
|
||||||
|
// Adding the "Documenti Allegati" section title
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
|
document.newPage();
|
||||||
|
// pageEvent.setTotalPages(writer.getPageNumber());
|
||||||
|
document.add(new Paragraph("Documenti Allegati", sectionFont));
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 1. Autocertificazione possesso Requisiti
|
||||||
|
Paragraph p1 = new Paragraph();
|
||||||
|
p1.add(new Chunk("1. ", boldSmallFont));
|
||||||
|
p1.add(new Chunk("Autocertificazione possesso Requisiti ", boldSmallFont));
|
||||||
|
p1.add(new Chunk("ai sensi degli artt. 46 e 47 del DPR 445/2000", smallFont));
|
||||||
|
document.add(p1);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 2. Informativa Privacy relativa al trattamento dei dati personali
|
||||||
|
Paragraph p2 = new Paragraph();
|
||||||
|
p2.add(new Chunk("2. ", boldSmallFont));
|
||||||
|
p2.add(new Chunk("Informativa Privacy relativa al trattamento dei dati personali", boldSmallFont));
|
||||||
|
document.add(p2);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 3. Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari
|
||||||
|
Paragraph p3 = new Paragraph();
|
||||||
|
p3.add(new Chunk("3. ", boldSmallFont));
|
||||||
|
p3.add(new Chunk("Dati richiesti per la valutazione dell’adeguatezza dei flussi finanziari prospettici come da tabella di cui all’Appendice 9", boldSmallFont));
|
||||||
|
document.add(p3);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 4. Rilevazione Centrale dei Rischi
|
||||||
|
Paragraph p4 = new Paragraph();
|
||||||
|
p4.add(new Chunk("4. ", boldSmallFont));
|
||||||
|
p4.add(new Chunk("Rilevazione Centrale dei Rischi riferita agli ultimi 36 mesi disponibili alla data di presentazione della Domanda", boldSmallFont));
|
||||||
|
document.add(p4);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 5. Schema di presentazione dei dati di bilancio
|
||||||
|
Paragraph p5 = new Paragraph();
|
||||||
|
p5.add(new Chunk("5. ", boldSmallFont));
|
||||||
|
p5.add(new Chunk("Schema di presentazione dei dati di bilancio", boldSmallFont));
|
||||||
|
document.add(p5);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 6. Dettagli bilanci in forma abbreviata
|
||||||
|
Paragraph p6 = new Paragraph();
|
||||||
|
p6.add(new Chunk("6. ", boldSmallFont));
|
||||||
|
p6.add(new Chunk("Dettagli bilanci in forma abbreviata", boldSmallFont));
|
||||||
|
document.add(p6);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
|
||||||
|
// 7. Relazione aziendale illustrativa
|
||||||
|
Paragraph p7 = new Paragraph();
|
||||||
|
p7.add(new Chunk("7. ", boldSmallFont));
|
||||||
|
p7.add(new Chunk("Relazione aziendale illustrativa", boldSmallFont));
|
||||||
|
document.add(p7);
|
||||||
|
document.add(new Paragraph(" "));
|
||||||
|
|
||||||
|
addColoredLines(writer,document,greenColor);
|
||||||
|
|
||||||
|
// System.out.println(writer.getPageSize());
|
||||||
|
// System.out.println(document.getPageSize());
|
||||||
|
// System.out.println(document.getPageNumber());
|
||||||
|
// System.out.println(writer.getPageNumber());
|
||||||
|
// document.setPageCount(100);
|
||||||
|
// document.setPageCount(writer.getPageNumber());
|
||||||
|
// System.out.println(document.getPageNumber());
|
||||||
|
|
||||||
|
// Close the document
|
||||||
|
document.close();
|
||||||
|
|
||||||
|
// Convert to byte array for response
|
||||||
|
byte[] pdfBytes =PdfPageNumberInserter.addPageNumbers(out.toByteArray());
|
||||||
|
|
||||||
|
return pdfBytes;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer addLabelValuePair(PdfWriter writer,Document document, String label, Object value, Font labelFont,Font valueFont,String title,Integer totalPages) throws DocumentException {
|
||||||
|
// Add label
|
||||||
|
Paragraph labelParagraph = new Paragraph(label, labelFont);
|
||||||
|
document.add(labelParagraph);
|
||||||
|
float leftMargin = 20f;
|
||||||
|
|
||||||
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
|
// Setting the color and width of the line
|
||||||
|
float lineWidth = 1.0f; // Thickness of the line
|
||||||
|
canvas.setLineWidth(lineWidth);
|
||||||
|
|
||||||
|
// Get the current vertical position in the document
|
||||||
|
float yPos = writer.getVerticalPosition(true) - 10f; // Adjust this to move line slightly below current content
|
||||||
|
|
||||||
|
// Define start and end points for the line (relative to the page size and margins)
|
||||||
|
|
||||||
|
if (yPos <= 140) {
|
||||||
|
// If xEnd is less than or equal to 200, generate a new page
|
||||||
|
|
||||||
|
totalPages++;
|
||||||
|
document.newPage();
|
||||||
|
} // Add a gap between the label and value
|
||||||
|
document.add(new Paragraph(" ")); // Adding an empty paragraph for spacing
|
||||||
|
// Create value cell with rounded corners
|
||||||
|
PdfPTable valueTable = new PdfPTable(1);
|
||||||
|
valueTable.setWidthPercentage(100);
|
||||||
|
if (value instanceof List<?>) {
|
||||||
|
// Further check if the list contains Strings
|
||||||
|
List<?> list = (List<?>) value;
|
||||||
|
if (!list.isEmpty() && list.get(0) instanceof String) {
|
||||||
|
// Cast to List<String>
|
||||||
|
List<String> values = (List<String>) value;
|
||||||
|
|
||||||
|
// Loop through the list of strings and create a cell for each string
|
||||||
|
for (String item : values) {
|
||||||
|
PdfPCell valueCell = new PdfPCell(new Phrase(item, valueFont));
|
||||||
|
valueCell.setPadding(5f); // Increase padding for better spacing
|
||||||
|
valueCell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||||
|
valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||||
|
valueCell.setMinimumHeight(30f);
|
||||||
|
valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||||
|
|
||||||
|
// Add the cell to the table
|
||||||
|
valueTable.addCell(valueCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, add the table to the document
|
||||||
|
document.add(valueTable);
|
||||||
|
} else {
|
||||||
|
boolean containsThreeValues = false; // Variable to track if any map contains three keys
|
||||||
|
List<Map<String, Object>> dataList = (List<Map<String, Object>>) value; // Cast Object to List of Maps
|
||||||
|
for (Map<String, Object> entry : dataList) {
|
||||||
|
if (entry.size() == 3) { // Check if the current map has three keys
|
||||||
|
containsThreeValues = true; // If found, set the variable to true
|
||||||
|
break; // No need to check further, exit loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<Map<String, String>> extractedData = new ArrayList<>(); // To hold extracted data
|
||||||
|
for (Map<String, Object> entry : dataList) {
|
||||||
|
Map<String, String> extractedMap = new HashMap<>(); // To hold the current extracted row of data
|
||||||
|
|
||||||
|
List<String> keys = new ArrayList<>(entry.keySet()); // Get all keys in the current map
|
||||||
|
|
||||||
|
// Handle based on the number of keys in the map
|
||||||
|
if (Boolean.FALSE.equals(containsThreeValues) && keys.size() == 2) {
|
||||||
|
// Treat the first key as the "key" and second key as the "value"
|
||||||
|
String heading = (String) entry.get(keys.get(0)); // Get value of first key
|
||||||
|
String value1 = (String) entry.get(keys.get(1)); // Get value of second key
|
||||||
|
extractedMap.put(heading,value1); // Store the first key's value as "heading"
|
||||||
|
} if (Boolean.TRUE.equals(containsThreeValues) ) {
|
||||||
|
String amount="";
|
||||||
|
// Treat the first as number, second as description, third as amount
|
||||||
|
if(keys.size()==3){
|
||||||
|
amount = (String) entry.get(keys.get(2)); // Third key's value
|
||||||
|
}
|
||||||
|
String number = (String) entry.get(keys.get(0)); // First key's value
|
||||||
|
String description = (String) entry.get(keys.get(1)); // Second key's value
|
||||||
|
|
||||||
|
// Store the combined result as a value in the map, with a suitable key
|
||||||
|
String combinedValue = number + "; " + description + "; " + amount; // Concatenate them as a single value
|
||||||
|
extractedMap.put("combined", combinedValue); // Store as a single entry, key as "combined"
|
||||||
|
}
|
||||||
|
|
||||||
|
extractedData.add(extractedMap); // Add each extracted map to the list
|
||||||
|
}
|
||||||
|
document=createPdfTable(extractedData,document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PdfPCell valueCell = new PdfPCell(new Phrase(String.valueOf(value), valueFont));
|
||||||
|
valueCell.setPadding(5f); // Increase padding for better spacing
|
||||||
|
valueCell.setPaddingLeft(leftMargin); // Increase left margin for value
|
||||||
|
valueCell.setBorder(Rectangle.NO_BORDER); // Remove border for value cell
|
||||||
|
valueCell.setMinimumHeight(30f);
|
||||||
|
valueCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
valueCell.setCellEvent(new RoundedCorners()); // Apply rounded corners
|
||||||
|
|
||||||
|
valueTable.addCell(valueCell);
|
||||||
|
document.add(valueTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.add(new Paragraph("\n")); // Add line break after each value
|
||||||
|
return totalPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException { // Create a PdfPTable with 2 columns
|
||||||
|
PdfPTable table = new PdfPTable(2); // Initial assumption for 2 columns
|
||||||
|
table.setWidthPercentage(100); // Set table width to 100%
|
||||||
|
Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text
|
||||||
|
boolean combinedHeaderAdded = false; // Flag to track if headers for combined have been added
|
||||||
|
float rowHeight = 50f; // Example row height, adjust as necessary
|
||||||
|
float maxTableHeight = 700f; // Maximum height of the table before a page break
|
||||||
|
int rowCount = 0; // Counter for rows
|
||||||
|
|
||||||
|
|
||||||
|
// Add table header
|
||||||
|
// Populate the table with extracted data and style rows
|
||||||
|
for (Map<String, String> row : extractedData) {
|
||||||
|
for (Map.Entry<String, String> entry : row.entrySet()) {
|
||||||
|
String key = entry.getKey(); // This will give you the key
|
||||||
|
String value = entry.getValue(); // This will give you the value
|
||||||
|
|
||||||
|
// Check if the current entry is for the combined section
|
||||||
|
if ("combined".equals(key)) {
|
||||||
|
// Ensure the combined header is added only once
|
||||||
|
if (!combinedHeaderAdded) {
|
||||||
|
// Create a new table for combined entries
|
||||||
|
table = new PdfPTable(3); // 3 columns for combined entries
|
||||||
|
|
||||||
|
PdfPCell headerCell1 = new PdfPCell(new Phrase("Number"));
|
||||||
|
headerCell1.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell1.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
table.addCell(headerCell1);
|
||||||
|
|
||||||
|
PdfPCell headerCell2 = new PdfPCell(new Phrase("Details"));
|
||||||
|
headerCell2.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell2.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
table.addCell(headerCell2);
|
||||||
|
|
||||||
|
PdfPCell headerCell3 = new PdfPCell(new Phrase("Amount"));
|
||||||
|
headerCell3.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell3.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
table.addCell(headerCell3);
|
||||||
|
|
||||||
|
combinedHeaderAdded = true; // Mark header as added
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split the value for "combined" into separate parts
|
||||||
|
String[] combinedValues = value.split("; ");
|
||||||
|
|
||||||
|
// Check if we have 3 parts (number, description, amount)
|
||||||
|
String number = combinedValues[0]; // 1st part (number)
|
||||||
|
String description = combinedValues[1]; // 2nd part (description)
|
||||||
|
String amount = "";
|
||||||
|
if (combinedValues.length == 3) {
|
||||||
|
amount = combinedValues[2]; // 3rd part (amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create PDF cells using the split values
|
||||||
|
PdfPCell cellNumber = new PdfPCell(new Phrase(number, textFont)); // Cell for number
|
||||||
|
PdfPCell cellDescription = new PdfPCell(new Phrase(description, textFont)); // Cell for description
|
||||||
|
PdfPCell cellAmount = new PdfPCell(new Phrase(amount, textFont)); // Cell for amount
|
||||||
|
|
||||||
|
// Set row background color for combined values
|
||||||
|
cellNumber.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for combined rows
|
||||||
|
cellDescription.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||||
|
cellAmount.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||||
|
|
||||||
|
// Set cell height and add rounded borders
|
||||||
|
// cellNumber.setFixedHeight(rowHeight);
|
||||||
|
// cellDescription.setFixedHeight(rowHeight);
|
||||||
|
// cellAmount.setFixedHeight(rowHeight);
|
||||||
|
|
||||||
|
cellNumber.setMinimumHeight(20f); // Set minimum height for better appearance
|
||||||
|
cellDescription.setMinimumHeight(20f); // Set minimum height for better appearance
|
||||||
|
cellAmount.setMinimumHeight(20f); // Set minimum height for better appearance
|
||||||
|
|
||||||
|
cellNumber.setPadding(7f);
|
||||||
|
cellDescription.setPadding(7f);
|
||||||
|
cellAmount.setPadding(7f);
|
||||||
|
|
||||||
|
// Add the cells to the table only once
|
||||||
|
table.addCell(cellNumber);
|
||||||
|
table.addCell(cellDescription);
|
||||||
|
table.addCell(cellAmount);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!combinedHeaderAdded) {
|
||||||
|
// Create a new table for combined entries
|
||||||
|
table= new PdfPTable(2); // 3 columns for combined entries
|
||||||
|
table.setWidthPercentage(100);
|
||||||
|
|
||||||
|
PdfPCell headerCell1 = new PdfPCell(new Phrase("Details"));
|
||||||
|
headerCell1.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell1.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
table.addCell(headerCell1);
|
||||||
|
|
||||||
|
PdfPCell headerCell2 = new PdfPCell(new Phrase("Amount"));
|
||||||
|
headerCell2.setHorizontalAlignment(Element.ALIGN_CENTER); // Center align
|
||||||
|
headerCell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
||||||
|
headerCell2.setBackgroundColor(new BaseColor(178, 190, 181)); // Light gray background for header
|
||||||
|
table.addCell(headerCell2);
|
||||||
|
combinedHeaderAdded=true;
|
||||||
|
}
|
||||||
|
// Add cells for regular key-value pairs without headers
|
||||||
|
PdfPCell cellKey = new PdfPCell(new Phrase(key, textFont));
|
||||||
|
PdfPCell cellValue = new PdfPCell(new Phrase(value, textFont));
|
||||||
|
|
||||||
|
// Set background color for both cells
|
||||||
|
cellKey.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for other rows
|
||||||
|
cellValue.setBackgroundColor(new BaseColor(239, 243, 248));
|
||||||
|
|
||||||
|
cellKey.setPadding(7f);
|
||||||
|
cellValue.setPadding(7f);
|
||||||
|
// Set cell height and add rounded borders
|
||||||
|
cellKey.setFixedHeight(rowHeight);
|
||||||
|
cellValue.setFixedHeight(rowHeight);
|
||||||
|
|
||||||
|
// Add the cells to the table
|
||||||
|
table.addCell(cellKey);
|
||||||
|
table.addCell(cellValue);
|
||||||
|
}
|
||||||
|
if (table.getTotalHeight() + rowHeight > maxTableHeight) {
|
||||||
|
// Start a new page if needed
|
||||||
|
document.add(table);
|
||||||
|
table = new PdfPTable(2); // Reset table for new page
|
||||||
|
table.setWidthPercentage(100); // Reset width percentage
|
||||||
|
combinedHeaderAdded = false; // Reset header flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.add(table); // Add the last table before returning
|
||||||
|
|
||||||
|
|
||||||
|
// Check if adding a new row would exceed the maximum height
|
||||||
|
// Return the populated table
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean) {
|
||||||
|
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();
|
||||||
|
|
||||||
|
// Iterate through each form in the application response
|
||||||
|
|
||||||
|
List<ApplicationFormFieldResponseBean> formFields = responseBean.getFormFields();
|
||||||
|
List<ContentResponseBean> contents = responseBean.getContent();
|
||||||
|
|
||||||
|
// Iterate through each formField in the current form
|
||||||
|
for (ApplicationFormFieldResponseBean formField : formFields) {
|
||||||
|
String fieldId = formField.getFieldId();
|
||||||
|
Object fieldValue = formField.getFieldValue();
|
||||||
|
|
||||||
|
// Find the content in the form that matches the fieldId
|
||||||
|
Optional<ContentResponseBean> matchingContent = contents.stream()
|
||||||
|
.filter(content -> content.getId().equals(fieldId))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
|
||||||
|
// If the content with the matching fieldId is found, create a label-value pair
|
||||||
|
if (matchingContent.isPresent()) {
|
||||||
|
String name = matchingContent.get().getName();
|
||||||
|
if (name.equals("fileupload")) {
|
||||||
|
|
||||||
|
// Step 1: Check if fieldValue is an instance of List<DocumentResponseBean>
|
||||||
|
if (fieldValue instanceof List<?> && ((List<?>) fieldValue).stream().allMatch(item -> item instanceof DocumentResponseBean)) {
|
||||||
|
// Step 2: Safely cast to List<DocumentResponseBean>
|
||||||
|
List<DocumentResponseBean> documentList = (List<DocumentResponseBean>) fieldValue;
|
||||||
|
|
||||||
|
// Step 3: Extract names from the document list
|
||||||
|
List<String> names = documentList.stream()
|
||||||
|
.map(DocumentResponseBean::getName) // Extract the name from each DocumentResponseBean
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
fieldValue=names;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(name.equals("checkboxes")) {
|
||||||
|
List<String> check = (List<String>) fieldValue;
|
||||||
|
List<SettingResponseBean> settingResponseBeans = matchingContent.get().getSettings();
|
||||||
|
for (SettingResponseBean settingResponseBean : settingResponseBeans) {
|
||||||
|
// Initialize a list to hold matched labels for each SettingResponseBean
|
||||||
|
List<String> matchedLabels = new ArrayList<>();
|
||||||
|
if (settingResponseBean.getValue() instanceof List<?>) {
|
||||||
|
|
||||||
|
List<?> valueList = (List<?>) settingResponseBean.getValue();
|
||||||
|
if (!valueList.isEmpty() && valueList.get(0) instanceof Map<?, ?>) {
|
||||||
|
// Cast to List<Map<String, String>>
|
||||||
|
List<Map<String, String>> options = (List<Map<String, String>>) valueList;
|
||||||
|
for (Map<String, String> field : options) {
|
||||||
|
for (String val : check) {
|
||||||
|
String name1=field.get("name");
|
||||||
|
if (val.equals(name1)) { // Check if the key exists in the current field map
|
||||||
|
String label = field.get("label"); // Extract the label
|
||||||
|
if (field != null) { // Check if the value is not null
|
||||||
|
matchedLabels.add(label); // Add the value to the matchedValues list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldValue = matchedLabels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String label = matchingContent.get().getLabel();
|
||||||
|
// Add the label-value pair to the list
|
||||||
|
if (fieldValue != null && !fieldValue.toString().trim().isEmpty()) {
|
||||||
|
fieldValue = findLabelInOptions(matchingContent.get().getSettings(), fieldValue);
|
||||||
|
labelValuePairs.add(new FieldLabelValuePairRequest(label, fieldValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return labelValuePairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object findLabelInOptions(List<SettingResponseBean> settings, Object valueToFind) {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (valueToFind instanceof String) {
|
||||||
|
String searchValue = (String) valueToFind;
|
||||||
|
for (SettingResponseBean setting : settings) {
|
||||||
|
Object value = setting.getValue();
|
||||||
|
if (value instanceof List) {
|
||||||
|
List<?> options = (List<?>) value;
|
||||||
|
for (Object option : options) {
|
||||||
|
JsonNode optionNode = objectMapper.convertValue(option, JsonNode.class);
|
||||||
|
if (optionNode.get("name").asText().equals(searchValue)) {
|
||||||
|
return optionNode.get("label").asText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return valueToFind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogo(Document document, String logoPath) throws Exception {
|
||||||
|
Image logo = Image.getInstance(logoPath);
|
||||||
|
logo.scaleToFit(document.getPageSize().getWidth() - document.leftMargin() - document.rightMargin(), // Fit to document width
|
||||||
|
document.getPageSize().getHeight() / 4); // Adjust the height as needed (1/4th of the page height)
|
||||||
|
logo.setAlignment(Image.ALIGN_CENTER); // Align logo to center
|
||||||
|
document.add(logo);
|
||||||
|
|
||||||
|
// Add some space after logo
|
||||||
|
document.add(new Paragraph("\n")); // Adding space after the logo
|
||||||
|
}
|
||||||
|
public void addColoredLines(PdfWriter writer, Document document, BaseColor color){
|
||||||
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
|
// Setting the color and width of the line
|
||||||
|
canvas.setColorStroke(color);
|
||||||
|
float lineWidth = 1.0f; // Thickness of the line
|
||||||
|
canvas.setLineWidth(lineWidth);
|
||||||
|
|
||||||
|
// Get the current vertical position in the document
|
||||||
|
float yPos = writer.getVerticalPosition(true) - 10f; // Adjust this to move line slightly below current content
|
||||||
|
|
||||||
|
// Define start and end points for the line (relative to the page size and margins)
|
||||||
|
float xStart = document.leftMargin(); // Start from the left margin
|
||||||
|
float xEnd = document.getPageSize().getWidth() - document.rightMargin(); // End at the right margin
|
||||||
|
|
||||||
|
// Draw the line at the current Y position
|
||||||
|
canvas.moveTo(xStart, yPos); // Move to the starting point
|
||||||
|
canvas.lineTo(xEnd, yPos); // Draw the line to the end point
|
||||||
|
canvas.stroke(); // Apply the stroke (line)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
import com.itextpdf.text.BaseColor;
|
||||||
|
import com.itextpdf.text.DocumentException;
|
||||||
|
import com.itextpdf.text.Font;
|
||||||
|
import com.itextpdf.text.FontFactory;
|
||||||
|
import com.itextpdf.text.pdf.BaseFont;
|
||||||
|
import com.itextpdf.text.pdf.PdfReader;
|
||||||
|
import com.itextpdf.text.pdf.PdfStamper;
|
||||||
|
import com.itextpdf.text.pdf.PdfContentByte;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class PdfPageNumberInserter {
|
||||||
|
|
||||||
|
public static byte[] addPageNumbers(byte[] pdfData) throws IOException, DocumentException {
|
||||||
|
PdfReader reader = new PdfReader(pdfData); // Read the generated PDF
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
BaseColor darkGreenColor = new BaseColor(1, 50, 32); // Adjust RGB values as needed
|
||||||
|
Font baseFont = FontFactory.getFont(FontFactory.HELVETICA, 4,darkGreenColor);
|
||||||
|
BaseFont font = baseFont.getBaseFont();
|
||||||
|
|
||||||
|
// PdfStamper allows us to modify the existing PDF
|
||||||
|
PdfStamper stamper = new PdfStamper(reader, outputStream);
|
||||||
|
int totalPages = reader.getNumberOfPages();
|
||||||
|
|
||||||
|
// Set the font for page numbers
|
||||||
|
|
||||||
|
for (int i = 1; i <= totalPages; i++) {
|
||||||
|
// Get the content of the current page
|
||||||
|
PdfContentByte over = stamper.getOverContent(i);
|
||||||
|
over.beginText();
|
||||||
|
over.setFontAndSize(font, 12);
|
||||||
|
|
||||||
|
// Add the page number at the bottom center of the page
|
||||||
|
over.showTextAligned(PdfContentByte.ALIGN_CENTER, "Page " + i + " of " + totalPages, 300, 30, 0);
|
||||||
|
|
||||||
|
over.endText();
|
||||||
|
}
|
||||||
|
|
||||||
|
stamper.close();
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
return outputStream.toByteArray(); // Return the modified PDF with page numbers
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import com.itextpdf.text.BaseColor;
|
||||||
|
import com.itextpdf.text.Rectangle;
|
||||||
|
import com.itextpdf.text.pdf.PdfContentByte;
|
||||||
|
import com.itextpdf.text.pdf.PdfPCell;
|
||||||
|
import com.itextpdf.text.pdf.PdfPCellEvent;
|
||||||
|
import com.itextpdf.text.pdf.PdfPTable;
|
||||||
|
|
||||||
|
public class RoundedCorners implements PdfPCellEvent {
|
||||||
|
@Override
|
||||||
|
public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvas) {
|
||||||
|
// Retrieve the canvas for drawing the background and border
|
||||||
|
PdfContentByte cbBackground = canvas[PdfPTable.BACKGROUNDCANVAS];
|
||||||
|
PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
|
||||||
|
|
||||||
|
cbBackground.saveState();
|
||||||
|
cb.saveState();
|
||||||
|
|
||||||
|
// Define the rounded rectangle radius and padding
|
||||||
|
float radius = 10f;
|
||||||
|
float padding = 2f; // Small padding to avoid overlap
|
||||||
|
|
||||||
|
// Get position values with adjusted height and width
|
||||||
|
float x = position.getLeft() + padding;
|
||||||
|
float y = position.getBottom() + padding;
|
||||||
|
float width = position.getWidth() - 2 * padding;
|
||||||
|
float height = position.getHeight() - 2 * padding;
|
||||||
|
|
||||||
|
// Fill the rounded rectangle with lighter grey
|
||||||
|
cbBackground.setColorFill(new BaseColor(239, 243, 248)); // Very light grey color
|
||||||
|
cbBackground.roundRectangle(x, y, width, height, radius);
|
||||||
|
cbBackground.fill(); // Fill the background
|
||||||
|
|
||||||
|
// Set the border stroke to thin and draw the rounded rectangle with dark grey color
|
||||||
|
cb.setLineWidth(0.5f); // Thin border width
|
||||||
|
cb.setColorStroke(new BaseColor(105, 105, 105)); // Dark grey border
|
||||||
|
cb.roundRectangle(x, y, width, height, radius);
|
||||||
|
cb.stroke(); // Draw the border
|
||||||
|
|
||||||
|
// Restore the canvas states
|
||||||
|
cbBackground.restoreState();
|
||||||
|
cb.restoreState();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||||
|
import net.gepafin.tendermanagement.repositories.SystemEmailTemplatesRespository;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SystemEmailTemplatesDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemEmailTemplatesRespository systemEmailTemplatesRespository;
|
||||||
|
|
||||||
|
@Value("${fe.base.url}")
|
||||||
|
private String feBaseUrl;
|
||||||
|
|
||||||
|
|
||||||
|
public SystemEmailTemplateResponse retrieveTemplate(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language) {
|
||||||
|
SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity = null;
|
||||||
|
if(call != null){
|
||||||
|
// dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
||||||
|
// .findByTypeAndCallId(type.getValue(), call.getId());
|
||||||
|
}
|
||||||
|
if(dbSystemEmailTemplatesEntity == null){
|
||||||
|
dbSystemEmailTemplatesEntity = systemEmailTemplatesRespository
|
||||||
|
.findByType(type.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemEmailTemplateResponse systemEmailTemplateResponse = replaceHtmlContant(dbSystemEmailTemplatesEntity, call, language, Boolean.TRUE);
|
||||||
|
return systemEmailTemplateResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SystemEmailTemplateResponse replaceHtmlContant(SystemEmailTemplatesEntity dbSystemEmailTemplatesEntity,
|
||||||
|
CallEntity call, Locale language1, Boolean isDefaultReplace) {
|
||||||
|
String language = null;
|
||||||
|
String htmlContent = dbSystemEmailTemplatesEntity.getHtmlContent();
|
||||||
|
String subject = dbSystemEmailTemplatesEntity.getSubject();
|
||||||
|
|
||||||
|
if (language1 == null) {
|
||||||
|
// language = getLanguage(LocaleContextHolder.getLocale());
|
||||||
|
language="italian";
|
||||||
|
}else{
|
||||||
|
language="italian";
|
||||||
|
}
|
||||||
|
Map<String, String> languageMap = new HashMap<>();
|
||||||
|
String jsonContent = dbSystemEmailTemplatesEntity.getJson();
|
||||||
|
if (Boolean.FALSE.equals(StringUtils.isEmpty(jsonContent))) {
|
||||||
|
Map<String, Map<String, String>> jsonMap = Utils.parseJsonContent(jsonContent);
|
||||||
|
if (jsonMap != null && jsonMap.containsKey(language)) {
|
||||||
|
languageMap = jsonMap.get(language);
|
||||||
|
htmlContent = replacePlaceholders(htmlContent, languageMap);
|
||||||
|
subject = replaceSubjectPlaceholders(subject, languageMap);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Boolean.TRUE.equals(StringUtils.isEmpty(subject))){
|
||||||
|
subject = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
htmlContent = replacePlatformLinkPlaceholder(call, htmlContent, languageMap);
|
||||||
|
SystemEmailTemplateResponse systemEmailTemplateResponse = new SystemEmailTemplateResponse();
|
||||||
|
systemEmailTemplateResponse.setHtmlContent(htmlContent);
|
||||||
|
systemEmailTemplateResponse.setSubject(subject);
|
||||||
|
systemEmailTemplateResponse.setJsonMap(languageMap);
|
||||||
|
return systemEmailTemplateResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// private String getLanguage(Locale locale) {
|
||||||
|
// return switch (locale.getLanguage()) {
|
||||||
|
// case "en" -> "english";
|
||||||
|
// case "it" -> "italian";
|
||||||
|
// default -> "italian";
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
private String replacePlaceholders(String htmlContent, Map<String, String> languageMap) {
|
||||||
|
for (Map.Entry<String, String> entry : languageMap.entrySet()) {
|
||||||
|
htmlContent = htmlContent.replace("{{" + entry.getKey() + "}}", entry.getValue());
|
||||||
|
}
|
||||||
|
return htmlContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String replaceSubjectPlaceholders(String subject, Map<String, String> languageMap) {
|
||||||
|
if(languageMap.containsKey("subject") && subject != null){
|
||||||
|
String value = languageMap.get("subject");
|
||||||
|
subject = subject.replace("{{subject}}", value);
|
||||||
|
return subject;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
private String replacePlatformLinkPlaceholder(CallEntity call, String htmlContent,
|
||||||
|
Map<String, String> languageMap) {
|
||||||
|
String platformLink = feBaseUrl;
|
||||||
|
|
||||||
|
// if(hubEntity != null && Boolean.FALSE.equals(isEmpty(hubEntity.getDomainName()))){
|
||||||
|
// platformLink = hubEntity.getDomainName();
|
||||||
|
// }
|
||||||
|
htmlContent = htmlContent.replace("{{platform_link}}", platformLink);
|
||||||
|
return htmlContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -83,6 +83,12 @@ public class UserDao {
|
|||||||
beneficiaryEntity.setLastName(userReq.getLastName());
|
beneficiaryEntity.setLastName(userReq.getLastName());
|
||||||
beneficiaryEntity.setOrganization(userReq.getOrganization());
|
beneficiaryEntity.setOrganization(userReq.getOrganization());
|
||||||
beneficiaryEntity.setPhoneNumber(userReq.getPhoneNumber());
|
beneficiaryEntity.setPhoneNumber(userReq.getPhoneNumber());
|
||||||
|
beneficiaryEntity.setPrivacy(userReq.getPrivacy());
|
||||||
|
beneficiaryEntity.setTerms(userReq.getTerms());
|
||||||
|
beneficiaryEntity.setOffers(userReq.getOffers());
|
||||||
|
beneficiaryEntity.setMarketing(userReq.getMarketing());
|
||||||
|
beneficiaryEntity.setThirdParty(userReq.getThirdParty());
|
||||||
|
beneficiaryEntity.setEmailPec(userReq.getEmailPec());
|
||||||
beneficiaryEntity =beneficiaryRepository.save(beneficiaryEntity);
|
beneficiaryEntity =beneficiaryRepository.save(beneficiaryEntity);
|
||||||
}
|
}
|
||||||
return beneficiaryEntity;
|
return beneficiaryEntity;
|
||||||
@@ -148,10 +154,16 @@ public class UserDao {
|
|||||||
setIfUpdated(userEntity::getOrganization, userEntity::setOrganization, userReq.getOrganization());
|
setIfUpdated(userEntity::getOrganization, userEntity::setOrganization, userReq.getOrganization());
|
||||||
setIfUpdated(userEntity::getAddress, userEntity::setAddress, userReq.getAddress());
|
setIfUpdated(userEntity::getAddress, userEntity::setAddress, userReq.getAddress());
|
||||||
setIfUpdated(userEntity::getPhoneNumber, userEntity::setPhoneNumber, userReq.getPhoneNumber());
|
setIfUpdated(userEntity::getPhoneNumber, userEntity::setPhoneNumber, userReq.getPhoneNumber());
|
||||||
|
setIfUpdated(userEntity::getDateOfBirth, userEntity::setDateOfBirth, userReq.getDateOfBirth());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getCodiceFiscale, userEntity.getBeneficiary()::setCodiceFiscale, userReq.getCodiceFiscale());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getMarketing, userEntity.getBeneficiary()::setMarketing, userReq.getMarketing());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getOffers, userEntity.getBeneficiary()::setOffers, userReq.getOffers());
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getThirdParty, userEntity.getBeneficiary()::setThirdParty, userReq.getThirdParty());
|
||||||
if (userReq.getRoleId() != null) {
|
if (userReq.getRoleId() != null) {
|
||||||
RoleEntity roleEntity = roleDao.validateRole(userReq.getRoleId());
|
RoleEntity roleEntity = roleDao.validateRole(userReq.getRoleId());
|
||||||
setIfUpdated(userEntity::getRoleEntity, userEntity::setRoleEntity, roleEntity);
|
setIfUpdated(userEntity::getRoleEntity, userEntity::setRoleEntity, roleEntity);
|
||||||
}
|
}
|
||||||
|
setIfUpdated(userEntity.getBeneficiary()::getEmailPec, userEntity.getBeneficiary()::setEmailPec, userReq.getEmailPec());
|
||||||
userEntity = userRepository.save(userEntity);
|
userEntity = userRepository.save(userEntity);
|
||||||
log.info("User updated with ID: {}", userEntity.getId());
|
log.info("User updated with ID: {}", userEntity.getId());
|
||||||
return convertUserEntityToUserResponse(userEntity);
|
return convertUserEntityToUserResponse(userEntity);
|
||||||
@@ -167,6 +179,7 @@ public class UserDao {
|
|||||||
userEntity.setStatus(UserStatusEnum.ACTIVE.getValue());
|
userEntity.setStatus(UserStatusEnum.ACTIVE.getValue());
|
||||||
userEntity.setBeneficiary(beneficiary);
|
userEntity.setBeneficiary(beneficiary);
|
||||||
if (Boolean.FALSE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()))) {
|
if (Boolean.FALSE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(roleEntity.getRoleType()))) {
|
||||||
|
|
||||||
userEntity.setFirstName(userReq.getFirstName());
|
userEntity.setFirstName(userReq.getFirstName());
|
||||||
userEntity.setLastName(userReq.getLastName());
|
userEntity.setLastName(userReq.getLastName());
|
||||||
userEntity.setOrganization(userReq.getOrganization());
|
userEntity.setOrganization(userReq.getOrganization());
|
||||||
@@ -216,6 +229,12 @@ public class UserDao {
|
|||||||
userResponseBean.setCountry(userEntity.getBeneficiary().getCountry());
|
userResponseBean.setCountry(userEntity.getBeneficiary().getCountry());
|
||||||
userResponseBean.setCodiceFiscale(userEntity.getBeneficiary().getCodiceFiscale());
|
userResponseBean.setCodiceFiscale(userEntity.getBeneficiary().getCodiceFiscale());
|
||||||
userResponseBean.setDateOfBirth(userEntity.getBeneficiary().getDateOfBirth());
|
userResponseBean.setDateOfBirth(userEntity.getBeneficiary().getDateOfBirth());
|
||||||
|
userResponseBean.setPrivacy(userEntity.getBeneficiary().getPrivacy());
|
||||||
|
userResponseBean.setTerms(userEntity.getBeneficiary().getTerms());
|
||||||
|
userResponseBean.setOffers(userEntity.getBeneficiary().getOffers());
|
||||||
|
userResponseBean.setMarketing(userEntity.getBeneficiary().getMarketing());
|
||||||
|
userResponseBean.setThirdParty(userEntity.getBeneficiary().getThirdParty());
|
||||||
|
userResponseBean.setEmailPec(userEntity.getBeneficiary().getEmailPec());
|
||||||
}
|
}
|
||||||
return userResponseBean;
|
return userResponseBean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,7 @@ public class ApplicationEntity extends BaseEntity {
|
|||||||
@Column(name="IS_DELETED")
|
@Column(name="IS_DELETED")
|
||||||
private Boolean isDeleted;
|
private Boolean isDeleted;
|
||||||
|
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "PROTOCOL_NUMBER")
|
||||||
|
private ProtocolEntity protocol;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "application_signed_document")
|
||||||
|
public class ApplicationSignedDocumentEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "APPLICATION_ID")
|
||||||
|
private ApplicationEntity application;
|
||||||
|
|
||||||
|
@Column(name = "FILE_NAME")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Column(name = "FILE_PATH")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
@Column(name="STATUS")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -44,4 +44,21 @@ public class BeneficiaryEntity extends BaseEntity {
|
|||||||
@Column(name = "DATE_OF_BIRTH")
|
@Column(name = "DATE_OF_BIRTH")
|
||||||
private LocalDateTime dateOfBirth;
|
private LocalDateTime dateOfBirth;
|
||||||
|
|
||||||
|
@Column(name = "PRIVACY")
|
||||||
|
private Boolean privacy;
|
||||||
|
|
||||||
|
@Column(name = "TERMS")
|
||||||
|
private Boolean terms;
|
||||||
|
|
||||||
|
@Column(name = "MARKETING")
|
||||||
|
private Boolean marketing;
|
||||||
|
|
||||||
|
@Column(name = "OFFERS")
|
||||||
|
private Boolean offers;
|
||||||
|
|
||||||
|
@Column(name = "THIRD_PARTY")
|
||||||
|
private Boolean thirdParty;
|
||||||
|
|
||||||
|
@Column(name = "EMAIL_PEC")
|
||||||
|
private String emailPec;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,10 @@ public class CompanyEntity extends BaseEntity{
|
|||||||
|
|
||||||
@Column(name = "ANNUAL_REVENUE")
|
@Column(name = "ANNUAL_REVENUE")
|
||||||
private BigDecimal annualRevenue;
|
private BigDecimal annualRevenue;
|
||||||
|
|
||||||
|
@Column(name = "CONTACT_NAME")
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
|
@Column(name = "CONTACT_EMAIL")
|
||||||
|
private String contactEmail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "system_email_template")
|
||||||
|
@Data
|
||||||
|
public class SystemEmailTemplatesEntity extends BaseEntity {
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "TEMPLATE_NAME")
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
|
@Column(name = "TYPE")
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
@Column(name = "HTML_CONTENT", columnDefinition = "TEXT")
|
||||||
|
private String htmlContent;
|
||||||
|
|
||||||
|
@Column(name = "SUBJECT")
|
||||||
|
private String subject;
|
||||||
|
|
||||||
|
@Column(name = "JSON", columnDefinition = "TEXT")
|
||||||
|
private String json;
|
||||||
|
|
||||||
|
@Column(name = "SYSTEM")
|
||||||
|
private Boolean system;
|
||||||
|
|
||||||
|
@Column(name ="IS_DELETED", nullable = false)
|
||||||
|
private Boolean isDeleted = false;
|
||||||
|
|
||||||
|
public enum SystemEmailTemplatesEntityTypeEnum {
|
||||||
|
|
||||||
|
APPLICATION_SUBMISSION_TO_USER_AND_COMPANY("APPLICATION_SUBMISSION_TO_USER_AND_COMPANY"),
|
||||||
|
APPLICATION_SUBMISSION_TO_GEPAFIN("APPLICATION_SUBMISSION_TO_GEPAFIN");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
SystemEmailTemplatesEntityTypeEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package net.gepafin.tendermanagement.entities;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
@Table(name = "user_company_delegation")
|
||||||
|
public class UserCompanyDelegationEntity extends BaseEntity{
|
||||||
|
|
||||||
|
@Column(name="USER_ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Column(name="COMPANY_ID")
|
||||||
|
private Long companyId;
|
||||||
|
|
||||||
|
@Column(name = "BENEFICIARY_ID")
|
||||||
|
private Long beneficiaryId;
|
||||||
|
|
||||||
|
@Column(name = "FILE_NAME")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
@Column(name = "FILE_PATH")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
@Column(name="STATUS")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,4 +19,7 @@ public class UserWithCompanyEntity extends BaseEntity{
|
|||||||
@Column(name = "COMPANY_ID")
|
@Column(name = "COMPANY_ID")
|
||||||
Long companyId;
|
Long companyId;
|
||||||
|
|
||||||
|
@Column(name = "IS_LEGAL_REPRESENTANT")
|
||||||
|
private Boolean isLegalRepresentant;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum ApplicationSignedDocumentStatusEnum {
|
||||||
|
ACTIVE("ACTIVE"), INACTIVE("INACTIVE");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
ApplicationSignedDocumentStatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package net.gepafin.tendermanagement.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
public enum UserCompanyDelegationStatusEnum {
|
||||||
|
ACTIVE("ACTIVE"), INACTIVE("INACTIVE");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
UserCompanyDelegationStatusEnum(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,6 @@ public class ApplicationFormFieldRequestBean {
|
|||||||
|
|
||||||
private String fieldId;
|
private String fieldId;
|
||||||
|
|
||||||
private String fieldValue;
|
private Object fieldValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CompanyDelegationRequest {
|
||||||
|
|
||||||
|
private String firstName;
|
||||||
|
|
||||||
|
private String lastName;
|
||||||
|
|
||||||
|
private String codiceFiscale;
|
||||||
|
}
|
||||||
@@ -20,5 +20,7 @@ public class CompanyRequest {
|
|||||||
private String email;
|
private String email;
|
||||||
private String numberOfEmployees;
|
private String numberOfEmployees;
|
||||||
private BigDecimal annualRevenue;
|
private BigDecimal annualRevenue;
|
||||||
|
private Boolean isLegalRepresentant;
|
||||||
|
private String contactName;
|
||||||
|
private String contactEmail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import com.itextpdf.text.*;
|
||||||
|
import com.itextpdf.text.pdf.ColumnText;
|
||||||
|
import com.itextpdf.text.pdf.PdfContentByte;
|
||||||
|
import com.itextpdf.text.pdf.PdfPageEventHelper;
|
||||||
|
import com.itextpdf.text.pdf.PdfWriter;
|
||||||
|
|
||||||
|
public class CustomPageEvent extends PdfPageEventHelper {
|
||||||
|
private String title;
|
||||||
|
private int totalPages;
|
||||||
|
|
||||||
|
public CustomPageEvent(String title, int totalPages) {
|
||||||
|
this.title = title;
|
||||||
|
this.totalPages = totalPages;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEndPage(PdfWriter writer, Document document) {
|
||||||
|
PdfContentByte canvas = writer.getDirectContent();
|
||||||
|
|
||||||
|
// Header - Add a title to each page at the top
|
||||||
|
if (writer.getPageNumber() > 1) {
|
||||||
|
Font headerFont = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD, new BaseColor(113, 121, 126)); // Gray color for header
|
||||||
|
ColumnText.showTextAligned(
|
||||||
|
canvas,
|
||||||
|
Element.ALIGN_LEFT,
|
||||||
|
new Phrase(title, headerFont),
|
||||||
|
document.leftMargin(), // Use left margin to align fully to the left
|
||||||
|
document.getPageSize().getHeight() - 30, // Positioning header near top
|
||||||
|
0 // No rotation
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Footer - Add page number at the bottom
|
||||||
|
String footerText = String.format("Page %d of %d", writer.getPageNumber(), totalPages);
|
||||||
|
|
||||||
|
// Set font for the footer
|
||||||
|
Font footerFont = new Font(Font.FontFamily.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK);
|
||||||
|
|
||||||
|
// Positioning footer near bottom
|
||||||
|
ColumnText.showTextAligned(writer.getDirectContent(),
|
||||||
|
Element.ALIGN_LEFT,
|
||||||
|
new Phrase(footerText, footerFont),
|
||||||
|
(document.right() + document.left()) / 2,
|
||||||
|
document.bottomMargin() - 10, // Positioning footer near bottom
|
||||||
|
0);
|
||||||
|
|
||||||
|
// Draw a yellow line below header
|
||||||
|
if (writer.getPageNumber() > 1) {
|
||||||
|
canvas.setLineWidth(1.5f);
|
||||||
|
canvas.setColorStroke(new BaseColor(255, 219, 88)); // Yellow color
|
||||||
|
float yPos = document.getPageSize().getHeight() - 50f; // Position for the line below header
|
||||||
|
canvas.moveTo(0, yPos);
|
||||||
|
canvas.lineTo(document.getPageSize().getWidth(), yPos);
|
||||||
|
canvas.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw another line 50 points above the bottom of the document
|
||||||
|
canvas.setLineWidth(1.5f);
|
||||||
|
canvas.setColorStroke(new BaseColor(255, 219, 88)); // Yellow color
|
||||||
|
float lineYPos = document.bottomMargin() + 25f; // Position for the line above the bottom margin
|
||||||
|
canvas.moveTo(0, lineYPos);
|
||||||
|
canvas.lineTo(document.getPageSize().getWidth(), lineYPos);
|
||||||
|
canvas.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPages(int totalPages) {
|
||||||
|
this.totalPages = totalPages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FieldLabelValuePairRequest {
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
private Object value;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -4,6 +4,8 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class UpdateUserReq {
|
public class UpdateUserReq {
|
||||||
@@ -17,4 +19,11 @@ public class UpdateUserReq {
|
|||||||
private String city;
|
private String city;
|
||||||
private UserStatusEnum status;
|
private UserStatusEnum status;
|
||||||
private String country;
|
private String country;
|
||||||
|
private String codiceFiscale;
|
||||||
|
private LocalDateTime dateOfBirth;
|
||||||
|
private Boolean marketing;
|
||||||
|
private Boolean offers;
|
||||||
|
private Boolean thirdParty;
|
||||||
|
|
||||||
|
private String emailPec;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,5 +31,12 @@ public class UserReq {
|
|||||||
private String codiceFiscale;
|
private String codiceFiscale;
|
||||||
|
|
||||||
private LocalDateTime dateOfBirth;
|
private LocalDateTime dateOfBirth;
|
||||||
|
private Boolean privacy;
|
||||||
|
private Boolean terms;
|
||||||
|
|
||||||
|
private Boolean marketing;
|
||||||
|
private Boolean offers;
|
||||||
|
private Boolean thirdParty;
|
||||||
|
|
||||||
|
private String emailPec;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public class ApplicationGetResponseBean {
|
|||||||
|
|
||||||
private String companyName;
|
private String companyName;
|
||||||
|
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
private List<FormApplicationResponse> form;
|
private List<FormApplicationResponse> form;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ public class ApplicationResponse{
|
|||||||
|
|
||||||
private String companyName;
|
private String companyName;
|
||||||
|
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ public class ApplicationResponseBean extends BaseBean {
|
|||||||
|
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
private List<ApplicationFormFieldResponseBean> formFields;
|
private List<ApplicationFormFieldResponseBean> formFields;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.enums.ApplicationSignedDocumentStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApplicationSignedDocumentResponse extends BaseBean{
|
||||||
|
|
||||||
|
private Long applicationId;
|
||||||
|
private String fileName;
|
||||||
|
private String filePath;
|
||||||
|
private ApplicationSignedDocumentStatusEnum status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.entities.BaseEntity;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserCompanyDelegationStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CompanyDelegationResponse extends BaseBean{
|
||||||
|
private Long userId;
|
||||||
|
private Long companyId;
|
||||||
|
private Long beneficiaryId;
|
||||||
|
private String fileName;
|
||||||
|
private String filePath;
|
||||||
|
private UserCompanyDelegationStatusEnum status;
|
||||||
|
}
|
||||||
@@ -21,5 +21,7 @@ public class CompanyResponse extends BaseBean{
|
|||||||
private String email;
|
private String email;
|
||||||
private String numberOfEmployees;
|
private String numberOfEmployees;
|
||||||
private BigDecimal annualRevenue;
|
private BigDecimal annualRevenue;
|
||||||
|
private Boolean isLegalRepresentant;
|
||||||
|
private String contactName;
|
||||||
|
private String contactEmail;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ public class LoginResponse {
|
|||||||
|
|
||||||
private LocalDateTime dateOfBirth;
|
private LocalDateTime dateOfBirth;
|
||||||
|
|
||||||
|
private Boolean privacy;
|
||||||
|
|
||||||
|
private Boolean terms;
|
||||||
|
|
||||||
|
private Boolean marketing;
|
||||||
|
|
||||||
|
private Boolean offers;
|
||||||
|
|
||||||
|
private Boolean thirdParty;
|
||||||
|
|
||||||
|
private String emailPec;
|
||||||
|
|
||||||
private LocalDateTime createdDate;
|
private LocalDateTime createdDate;
|
||||||
|
|
||||||
private LocalDateTime updatedDate;
|
private LocalDateTime updatedDate;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public class NextOrPreviousFormResponse {
|
|||||||
|
|
||||||
private String companyName;
|
private String companyName;
|
||||||
|
|
||||||
|
private Long protocolNumber;
|
||||||
|
|
||||||
private ApplicationStatusTypeEnum applicationStatus;
|
private ApplicationStatusTypeEnum applicationStatus;
|
||||||
|
|
||||||
private FormApplicationResponse applicationFormResponse;
|
private FormApplicationResponse applicationFormResponse;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SystemEmailTemplateResponse {
|
||||||
|
|
||||||
|
String htmlContent;
|
||||||
|
|
||||||
|
String subject;
|
||||||
|
|
||||||
|
Map<String, String> jsonMap;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class UploadFileOnAmazonS3Response {
|
||||||
|
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,4 +39,12 @@ public class UserResponseBean extends BaseBean {
|
|||||||
private LocalDateTime dateOfBirth;
|
private LocalDateTime dateOfBirth;
|
||||||
|
|
||||||
private List<CompanyResponse> companies;
|
private List<CompanyResponse> companies;
|
||||||
|
private Boolean privacy;
|
||||||
|
private Boolean terms;
|
||||||
|
|
||||||
|
private Boolean marketing;
|
||||||
|
private Boolean offers;
|
||||||
|
private Boolean thirdParty;
|
||||||
|
|
||||||
|
private String emailPec;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.repositories;
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@@ -25,7 +24,7 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
|
|
||||||
public Optional<ApplicationEntity> findByIdAndUserIdAndIsDeletedFalse(Long id,Long userId);
|
public Optional<ApplicationEntity> findByIdAndUserIdAndIsDeletedFalse(Long id,Long userId);
|
||||||
|
|
||||||
Optional<ApplicationEntity> findByCompanyIdAndCallIdAndIsDeletedFalse(Long companyId, Long callId);
|
Optional<ApplicationEntity> findByUserIdAndCompanyIdAndCallIdAndIsDeletedFalse(Long userId, Long companyId, Long callId);
|
||||||
|
|
||||||
public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId,
|
public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId,
|
||||||
Long callId);
|
Long callId);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.ApplicationSignedDocumentEntity;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ApplicationSignedDocumentRepository extends JpaRepository<ApplicationSignedDocumentEntity, Long> {
|
||||||
|
|
||||||
|
ApplicationSignedDocumentEntity findByApplicationIdAndStatus(Long applicationId, String status);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -19,5 +19,8 @@ public interface DocumentRepository extends JpaRepository<DocumentEntity, Long>
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity;
|
||||||
|
|
||||||
|
public interface SystemEmailTemplatesRespository extends JpaRepository<SystemEmailTemplatesEntity, Long> {
|
||||||
|
|
||||||
|
// @Query("select s from SystemEmailTemplatesEntity s where s.type=:type and s.call.id=:callId and s.isDeleted =false and s.system = false")
|
||||||
|
// SystemEmailTemplatesEntity findByTypeAndCallId(@Param("type") String type, @Param("callId") Long callId);
|
||||||
|
|
||||||
|
@Query("select s from SystemEmailTemplatesEntity s where s.type=:type and s.isDeleted =false and s.system = true")
|
||||||
|
SystemEmailTemplatesEntity findByType(@Param("type") String type);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.gepafin.tendermanagement.repositories;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserCompanyDelegationEntity;
|
||||||
|
|
||||||
|
public interface UserCompanyDelegationRepository extends JpaRepository<UserCompanyDelegationEntity, Long> {
|
||||||
|
|
||||||
|
UserCompanyDelegationEntity findByUserIdAndCompanyIdAndStatus(Long userId, Long companyId, String status);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,15 +3,19 @@ package net.gepafin.tendermanagement.service;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public interface AmazonS3Service {
|
public interface AmazonS3Service {
|
||||||
|
|
||||||
public String upload(String fileName, MultipartFile file) throws IOException;
|
public String upload(String fileName, String s3Folder, MultipartFile file) throws IOException;
|
||||||
|
|
||||||
public Boolean delete(String fileName);
|
public Boolean delete(String s3Folder, String fileName);
|
||||||
|
|
||||||
InputStream getFile(String filePath) throws IOException;
|
InputStream getFile(String s3Folder, String filePath) throws IOException;
|
||||||
|
|
||||||
|
public UploadFileOnAmazonS3Response uploadFileOnAmazonS3(String s3Folder, MultipartFile file);
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,13 @@ import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
|||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
public interface ApplicationService {
|
public interface ApplicationService {
|
||||||
|
|
||||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean,Long applicationId, Long formId);
|
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean,Long applicationId, Long formId);
|
||||||
@@ -29,6 +32,12 @@ public interface ApplicationService {
|
|||||||
|
|
||||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action);
|
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action);
|
||||||
|
|
||||||
public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status);
|
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status);
|
||||||
|
|
||||||
|
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file);
|
||||||
|
|
||||||
|
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId);
|
||||||
|
|
||||||
|
public void deleteSignedDocument(HttpServletRequest request, Long applicationId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ public interface CallService {
|
|||||||
CallEntity validateCall(Long callId);
|
CallEntity validateCall(Long callId);
|
||||||
|
|
||||||
CallEntity validatePublishedCall(Long callId);
|
CallEntity validatePublishedCall(Long callId);
|
||||||
|
byte[] downloadCallDocumentsAsZip(Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package net.gepafin.tendermanagement.service;
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||||
|
|
||||||
public interface CompanyService {
|
public interface CompanyService {
|
||||||
@@ -27,4 +32,14 @@ public interface CompanyService {
|
|||||||
|
|
||||||
UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId);
|
UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId);
|
||||||
|
|
||||||
|
ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest);
|
||||||
|
|
||||||
|
CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file);
|
||||||
|
|
||||||
|
CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId);
|
||||||
|
|
||||||
|
void deleteCompanyDelegation(HttpServletRequest request, Long companyId);
|
||||||
|
UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
|
||||||
|
public interface PdfService {
|
||||||
|
|
||||||
|
public byte[] generatePdf(HttpServletRequest request, Long applicationId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||||
|
|
||||||
|
public interface SystemEmailTemplatesService {
|
||||||
|
|
||||||
|
SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,16 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
|
|
||||||
import com.amazonaws.services.s3.AmazonS3;
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
import com.amazonaws.services.s3.model.*;
|
import com.amazonaws.services.s3.model.*;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.model.response.UploadFileOnAmazonS3Response;
|
||||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||||
|
import net.gepafin.tendermanagement.util.Utils;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
@@ -29,18 +38,16 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
@Value("${aws.s3.bucket.name}")
|
@Value("${aws.s3.bucket.name}")
|
||||||
private String bucketName;
|
private String bucketName;
|
||||||
|
|
||||||
@Value("${aws.s3.url.folder}")
|
|
||||||
private String s3Folder;
|
|
||||||
|
|
||||||
@Value("${aws.s3.url}")
|
@Value("${aws.s3.url}")
|
||||||
private String s3Url;
|
private String s3Url;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String upload(String fileName,
|
public String upload(String fileName, String s3Folder,
|
||||||
MultipartFile file) throws IOException {
|
MultipartFile file) throws IOException {
|
||||||
|
|
||||||
String path = bucketName+"/"+s3Folder;
|
// String path = bucketName+"/"+s3Folder;
|
||||||
|
String path = s3Folder +"/"+fileName;
|
||||||
|
|
||||||
InputStream inputStream = file.getInputStream();
|
InputStream inputStream = file.getInputStream();
|
||||||
|
|
||||||
@@ -57,15 +64,15 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(Boolean.FALSE.equals(isTestProfileActivated())) {
|
if(Boolean.FALSE.equals(isTestProfileActivated())) {
|
||||||
amazonS3.putObject(path, fileName, inputStream, objectMetadata);
|
amazonS3.putObject(bucketName, path, inputStream, objectMetadata);
|
||||||
}
|
}
|
||||||
return s3Url + s3Folder +"/"+ fileName;
|
return s3Url + s3Folder +"/"+ fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean delete(String fileName) {
|
public Boolean delete(String s3Folder, String fileName) {
|
||||||
|
String path = s3Folder +"/"+fileName;
|
||||||
final DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucketName, fileName);
|
final DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucketName, path);
|
||||||
if(Boolean.FALSE.equals(isTestProfileActivated())) {
|
if(Boolean.FALSE.equals(isTestProfileActivated())) {
|
||||||
amazonS3.deleteObject(deleteObjectRequest);
|
amazonS3.deleteObject(deleteObjectRequest);
|
||||||
}
|
}
|
||||||
@@ -78,14 +85,30 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getFile(String filePath) throws IOException {
|
public InputStream getFile(String s3Folder, String filePath) throws IOException {
|
||||||
try {
|
try {
|
||||||
String path = bucketName+ s3Folder +"/";
|
String path = s3Folder +"/"+filePath;
|
||||||
GetObjectRequest getObjectRequest = new GetObjectRequest(path, filePath);
|
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, path);
|
||||||
S3Object s3Object = amazonS3.getObject(getObjectRequest);
|
S3Object s3Object = amazonS3.getObject(getObjectRequest);
|
||||||
return s3Object.getObjectContent();
|
return s3Object.getObjectContent();
|
||||||
} catch (AmazonS3Exception e) {
|
} catch (AmazonS3Exception e) {
|
||||||
throw new IOException("Error getting file from Amazon S3", e);
|
throw new IOException("Error getting file from Amazon S3", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UploadFileOnAmazonS3Response uploadFileOnAmazonS3(String s3Folder, MultipartFile file) {
|
||||||
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
|
String fileName = org.springframework.util.StringUtils.cleanPath(file.getOriginalFilename());
|
||||||
|
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
|
firstNameContain+=Utils.randomKey(5);
|
||||||
|
fileName = (firstNameContain + "." + extension);
|
||||||
|
try {
|
||||||
|
String filepath = upload(fileName, s3Folder, file);
|
||||||
|
return UploadFileOnAmazonS3Response.builder().fileName(fileName).filePath(filepath).build();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
Translator.toLocale(GepafinConstant.UPLOAD_ERROR_S3));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,12 +13,14 @@ import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
|||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -64,7 +66,7 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
||||||
UserEntity userEntity = validator.validateUser(request);
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
CompanyEntity companyEntity = validator.validateUSerWithCompany(request, companyId);
|
CompanyEntity companyEntity = validator.validateUserWithCompany(request, companyId);
|
||||||
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
return applicationDao.createApplicationByCallId(companyEntity, applicationRequest, callId, userEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,12 +74,14 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
|
||||||
FormActionEnum action) {
|
FormActionEnum action) {
|
||||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||||
return flowFormDao.getnextOrPreviousForm(applicationEntity, formId, action);
|
return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
applicationDao.updateApplicationStatus(applicationId, status);
|
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
return applicationDao.updateApplicationStatus(userEntity, applicationId, status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +90,26 @@ public class ApplicationServiceImpl implements ApplicationService {
|
|||||||
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId) {
|
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId) {
|
||||||
UserEntity userEntity = validator.validateUser(request);
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
if (companyId != null) {
|
if (companyId != null) {
|
||||||
validator.validateUSerWithCompany(request, companyId);
|
validator.validateUserWithCompany(request, companyId);
|
||||||
}
|
}
|
||||||
return applicationDao.getAllApplications(userEntity, callId, companyId);
|
return applicationDao.getAllApplications(userEntity, callId, companyId);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) {
|
||||||
|
return applicationDao.uploadSignedDocument(request, applicationId, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public ApplicationSignedDocumentResponse getSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||||
|
return applicationDao.getSignedDocument(request, applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteSignedDocument(HttpServletRequest request, Long applicationId) {
|
||||||
|
applicationDao.deleteSignedDocument(request, applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,12 @@ public class AuthenticationService {
|
|||||||
loginResponse.setCity(user.getBeneficiary().getCity());
|
loginResponse.setCity(user.getBeneficiary().getCity());
|
||||||
loginResponse.setCodiceFiscale(user.getBeneficiary().getCodiceFiscale());
|
loginResponse.setCodiceFiscale(user.getBeneficiary().getCodiceFiscale());
|
||||||
loginResponse.setDateOfBirth(user.getBeneficiary().getDateOfBirth());
|
loginResponse.setDateOfBirth(user.getBeneficiary().getDateOfBirth());
|
||||||
|
loginResponse.setPrivacy(user.getBeneficiary().getPrivacy());
|
||||||
|
loginResponse.setMarketing(user.getBeneficiary().getMarketing());
|
||||||
|
loginResponse.setOffers(user.getBeneficiary().getOffers());
|
||||||
|
loginResponse.setTerms(user.getBeneficiary().getTerms());
|
||||||
|
loginResponse.setThirdParty(user.getBeneficiary().getThirdParty());
|
||||||
|
loginResponse.setEmailPec(user.getBeneficiary().getEmailPec());
|
||||||
}
|
}
|
||||||
|
|
||||||
return loginResponse;
|
return loginResponse;
|
||||||
|
|||||||
@@ -92,4 +92,9 @@ public class CallServiceImpl implements CallService {
|
|||||||
public CallEntity validatePublishedCall(Long callId) {
|
public CallEntity validatePublishedCall(Long callId) {
|
||||||
return callDao.validatePublishedCall(callId);
|
return callDao.validatePublishedCall(callId);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public byte[] downloadCallDocumentsAsZip(Long callId) {
|
||||||
|
return callDao.downloadCallDocumentsAsZip(callId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.dao.CompanyDao;
|
import net.gepafin.tendermanagement.dao.CompanyDao;
|
||||||
|
import net.gepafin.tendermanagement.dao.DelegationDao;
|
||||||
import net.gepafin.tendermanagement.dao.VatCheckDao;
|
import net.gepafin.tendermanagement.dao.VatCheckDao;
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
import net.gepafin.tendermanagement.util.Validator;
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
@@ -30,6 +35,9 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private VatCheckDao vatCheckDao;
|
private VatCheckDao vatCheckDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DelegationDao delegationDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CompanyResponse createCompany(HttpServletRequest request, CompanyRequest companyRequest) {
|
public CompanyResponse createCompany(HttpServletRequest request, CompanyRequest companyRequest) {
|
||||||
@@ -61,7 +69,7 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<CompanyResponse> getCompanyByUserId(HttpServletRequest request, Long userId) {
|
public List<CompanyResponse> getCompanyByUserId(HttpServletRequest request, Long userId) {
|
||||||
UserEntity userEntity = validator.validateUser(request);
|
validator.validateUser(request);
|
||||||
return companyDao.getCompanyByUserId(userId);
|
return companyDao.getCompanyByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,4 +88,34 @@ public class CompanyServiceImpl implements CompanyService {
|
|||||||
return companyDao.validateUserWithCompny(userId, companyId);
|
return companyDao.validateUserWithCompny(userId, companyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public ByteArrayOutputStream downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
return delegationDao.downloadCompanyDelegation(userEntity, companyId, companyDelegationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public CompanyDelegationResponse uploadCompanyDelegation(HttpServletRequest request, Long companyId, MultipartFile file) {
|
||||||
|
UserEntity userEntity = validator.validateUser(request);
|
||||||
|
validator.validateUserWithCompany(request, companyId);
|
||||||
|
return delegationDao.uploadCompanyDelegation(userEntity, companyId, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public CompanyDelegationResponse getCompanyDelegation(HttpServletRequest request, Long companyId) {
|
||||||
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
return delegationDao.getCompanyDelegation(userEntity, companyId);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteCompanyDelegation(HttpServletRequest request, Long companyId) {
|
||||||
|
UserEntity userEntity =validator.validateUser(request);
|
||||||
|
delegationDao.deleteCompanyDelegation(userEntity, companyId);
|
||||||
|
}
|
||||||
|
public UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId){
|
||||||
|
return companyDao.getUserWithCompany(userId,companyId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.PdfDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.service.PdfService;
|
||||||
|
import net.gepafin.tendermanagement.util.Validator;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PdfServiceImpl implements PdfService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PdfDao pdfDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Validator validator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] generatePdf(HttpServletRequest request, Long applicationId) {
|
||||||
|
return pdfDao.generatePdf(request, applicationId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.dao.SystemEmailTemplatesDao;
|
||||||
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.SystemEmailTemplatesEntity.SystemEmailTemplatesEntityTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.response.SystemEmailTemplateResponse;
|
||||||
|
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SystemEmailTemplatesServiceImpl implements SystemEmailTemplatesService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SystemEmailTemplatesDao systemEmailTemplatesDao;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SystemEmailTemplateResponse retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum type, CallEntity call, Locale language) {
|
||||||
|
return systemEmailTemplatesDao.retrieveTemplate(type, call, language);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,13 +1,9 @@
|
|||||||
package net.gepafin.tendermanagement.util;
|
package net.gepafin.tendermanagement.util;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@@ -86,4 +82,30 @@ public class DateTimeUtil {
|
|||||||
// If all parsing attempts fail, throw an exception
|
// If all parsing attempts fail, throw an exception
|
||||||
throw new CustomValidationException(Status.BAD_REQUEST,"Failed to parse time: " + timeString);
|
throw new CustomValidationException(Status.BAD_REQUEST,"Failed to parse time: " + timeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatLocalDateTime(LocalDateTime dateTime, String pattern) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||||
|
return dateTime.format(formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocalDateTime parseStringToLocalDateTime(String dateTimeStr, String pattern) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||||
|
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String parseLocalTimeToString(LocalTime time, String format) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||||
|
return time.format(formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method 2: Convert String and format to LocalTime
|
||||||
|
public static LocalTime parseStringToLocalTime(String timeString, String format) {
|
||||||
|
try {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||||
|
return LocalTime.parse(timeString, formatter);
|
||||||
|
} catch (DateTimeParseException e) {
|
||||||
|
System.out.println("Invalid time format: " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package net.gepafin.tendermanagement.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import com.mailgun.api.v3.MailgunMessagesApi;
|
||||||
|
import com.mailgun.client.MailgunClient;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MailUtil {
|
||||||
|
|
||||||
|
@Value("${apiKey}")
|
||||||
|
private String apiKeyValue;
|
||||||
|
|
||||||
|
@Value("${mailGun_user}")
|
||||||
|
private String mailGunUser;
|
||||||
|
|
||||||
|
@Value("${mailGun_apiKey}")
|
||||||
|
private String mailGunApiKey;
|
||||||
|
|
||||||
|
@Value("${mailGun_domainName}")
|
||||||
|
private String mailGunDomainName;
|
||||||
|
|
||||||
|
@Value("${mailGun_base_url}")
|
||||||
|
private String mailGunBaseUrl;
|
||||||
|
|
||||||
|
@Value("${isMailSendingEnabled}")
|
||||||
|
private String isEmailSendingEnabled;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
public Boolean isTestProfileActivated() {
|
||||||
|
String[] activeProfiles = environment.getActiveProfiles();
|
||||||
|
return Arrays.stream(activeProfiles).anyMatch("test"::equals);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMailByMailGunAPI(List<String> recipents, List<String> CC, List<String> BCC, String subject,
|
||||||
|
String body, String replyTo) {
|
||||||
|
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(mailGunBaseUrl, mailGunApiKey)
|
||||||
|
.createApi(MailgunMessagesApi.class);
|
||||||
|
|
||||||
|
String mailFrom = mailGunUser;
|
||||||
|
|
||||||
|
com.mailgun.model.message.Message.MessageBuilder temp = com.mailgun.model.message.Message.builder()
|
||||||
|
.replyTo(replyTo).from(mailFrom).to(recipents).subject(subject).html(body);
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(CC))) {
|
||||||
|
temp.cc(CC);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(CollectionUtils.isEmpty(BCC))) {
|
||||||
|
temp.bcc(BCC);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Boolean.FALSE.equals(isTestProfileActivated())) {
|
||||||
|
com.mailgun.model.message.Message message = temp.build();
|
||||||
|
mailgunMessagesApi.sendMessage(mailGunDomainName, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendByMailGun(String subject, String body, List<String> receiverEmails, String replyTo) {
|
||||||
|
sendMailByMailGunAPI(receiverEmails, null, null, subject, body, replyTo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import java.lang.reflect.Type;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -227,4 +228,79 @@ public class Utils {
|
|||||||
Pattern pattern = Pattern.compile(EMAIL_REGEX);
|
Pattern pattern = Pattern.compile(EMAIL_REGEX);
|
||||||
return pattern.matcher(email).matches();
|
return pattern.matcher(email).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String randomKey(Integer range) {
|
||||||
|
String data = String.valueOf(System.currentTimeMillis());
|
||||||
|
return data.substring(data.length() - range);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, Map<String, String>> parseJsonContent(String jsonContent) {
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
return mapper.readValue(jsonContent, HashMap.class);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error(exception.getMessage());
|
||||||
|
}
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility method to replace placeholders with their values, handling nulls
|
||||||
|
public static String replacePlaceholders(String text, Map<String, String> placeholders) {
|
||||||
|
if (text == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, String> entry : placeholders.entrySet()) {
|
||||||
|
text = replaceNull(text, entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to safely replace nulls with an empty string or a default value
|
||||||
|
private static String replaceNull(String text, String target, String replacement) {
|
||||||
|
return text.replace(target, replacement != null ? replacement : "");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.gepafin.tendermanagement.entities.UserEntity;
|
|||||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.UnauthorizedAccessException;
|
import net.gepafin.tendermanagement.web.rest.api.errors.UnauthorizedAccessException;
|
||||||
|
|
||||||
@@ -37,8 +38,7 @@ public class Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity validateUser(HttpServletRequest request) {
|
public UserEntity validateUser(HttpServletRequest request) {
|
||||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
return userService.validateUser(getUserIdFromToken(request));
|
||||||
return userService.validateUser(Long.parseLong(userInfo.get("userId").toString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkIsSuperAdmin() {
|
public Boolean checkIsSuperAdmin() {
|
||||||
@@ -61,7 +61,7 @@ public class Validator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompanyEntity validateUSerWithCompany(HttpServletRequest request, Long companyId) {
|
public CompanyEntity validateUserWithCompany(HttpServletRequest request, Long companyId) {
|
||||||
if (checkIsSuperAdmin()) {
|
if (checkIsSuperAdmin()) {
|
||||||
return companyService.validateCompany(companyId);
|
return companyService.validateCompany(companyId);
|
||||||
}
|
}
|
||||||
@@ -87,4 +87,17 @@ public class Validator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserEntity validateUserId(HttpServletRequest request, Long userId) {
|
||||||
|
UserEntity user = validateUser(request);
|
||||||
|
if(user.getRoleEntity().getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()) && Boolean.FALSE.equals(user.getId().equals(userId))) {
|
||||||
|
throw new ForbiddenAccessException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||||
|
}
|
||||||
|
return userService.validateUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Long getUserIdFromToken(HttpServletRequest request) {
|
||||||
|
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||||
|
return Long.parseLong(userInfo.get("userId").toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.springframework.http.MediaType;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -21,6 +22,8 @@ import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
|||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
@@ -127,10 +130,62 @@ public interface ApplicationApi {
|
|||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@PutMapping(value = "/{applicationId}/status", produces = { "application/json" })
|
@PutMapping(value = "/{applicationId}/status", produces = { "application/json" })
|
||||||
ResponseEntity<Response<Void>> updateApplicationStatus(HttpServletRequest request,
|
ResponseEntity<Response<ApplicationResponse>> updateApplicationStatus(HttpServletRequest request,
|
||||||
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId,
|
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationStatusTypeEnum status);
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationStatusTypeEnum status);
|
||||||
|
|
||||||
|
@Operation(summary = "API to generate PDF for an application",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/pdf")),
|
||||||
|
@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 = "/{applicationId}/download-pdf",
|
||||||
|
produces = { "application/pdf" })
|
||||||
|
public ResponseEntity<byte[]> generateApplicationPdf(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@Parameter(description = "The application id", required = true)
|
||||||
|
@PathVariable(value = "applicationId", required = true) Long applicationId);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to upload signed document (only p7m file format is supported)", 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 = "{applicationId}/signedDocument/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
ResponseEntity<Response<ApplicationSignedDocumentResponse>> uploadSignedDocument(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId,
|
||||||
|
@Parameter(description = "The signed document", required = true) @RequestParam("file") MultipartFile file);
|
||||||
|
|
||||||
|
|
||||||
|
@Operation(summary = "Api to get signed document", 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 = "{applicationId}/signedDocument", produces = "application/json")
|
||||||
|
ResponseEntity<Response<ApplicationSignedDocumentResponse>> getSignedDocument(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to delete signed document", 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 = "{applicationId}/signedDocument", produces = "application/json")
|
||||||
|
ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The applicationId id", required = true) @PathVariable("applicationId") Long applicationId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,4 +134,19 @@ public interface CallApi {
|
|||||||
public ResponseEntity<Response<CallResponse>> updateCallStatus(HttpServletRequest request,
|
public ResponseEntity<Response<CallResponse>> updateCallStatus(HttpServletRequest request,
|
||||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
||||||
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) CallStatusEnum status);
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) CallStatusEnum status);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to download call documents as a ZIP file",
|
||||||
|
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 = "/{callId}/documents/zip")
|
||||||
|
ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest httpServletRequest,
|
||||||
|
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -19,7 +20,9 @@ import io.swagger.v3.oas.annotations.media.Content;
|
|||||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
@@ -81,7 +84,7 @@ public interface CompanyApi {
|
|||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||||
@GetMapping(value = "/user/{userId}", produces = { "application/json" })
|
@GetMapping(value = "/user/{userId}", produces = { "application/json" })
|
||||||
ResponseEntity<Response<List<CompanyResponse>>> getCompanyByUserId(HttpServletRequest request,
|
ResponseEntity<Response<List<CompanyResponse>>> getCompanyByUserId(HttpServletRequest request,
|
||||||
@Parameter(description = "The company id", required = true) @PathVariable("userId") Long userId);
|
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId);
|
||||||
|
|
||||||
@Operation(summary = "Api to check vatNumber", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
@Operation(summary = "Api to check vatNumber", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@@ -94,4 +97,50 @@ public interface CompanyApi {
|
|||||||
ResponseEntity<Response<Map<String,Object>>> checkVatNumber(HttpServletRequest request,
|
ResponseEntity<Response<Map<String,Object>>> checkVatNumber(HttpServletRequest request,
|
||||||
@Parameter(description = "The vatNumber of company", required = true) @RequestParam("vatNumber") String vatNumber);
|
@Parameter(description = "The vatNumber of company", required = true) @RequestParam("vatNumber") String vatNumber);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to download company delegation template", 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 = "{companyId}/delegation/download", produces = { "application/json" })
|
||||||
|
ResponseEntity<byte[]> downloadCompanyDelegation(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId,
|
||||||
|
@Parameter(description = "Company delegation request object", required = true) @RequestBody CompanyDelegationRequest companyDelegationRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to upload company delegation (only p7m file format is supported)", 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 = "{companyId}/delegation/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
ResponseEntity<Response<CompanyDelegationResponse>> uploadCompanyDelegation(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId,
|
||||||
|
@Parameter(description = "The company delegation", required = true) @RequestParam("file") MultipartFile file);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to get company delegation", 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 = "{companyId}/delegation", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to delete company delegation", 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 = "{companyId}/delegation", produces = { "application/json" })
|
||||||
|
ResponseEntity<Response<Void>> deleteCompanyDelegation(HttpServletRequest request,
|
||||||
|
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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 net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
@Validated
|
||||||
|
public interface PdfApi {
|
||||||
|
|
||||||
|
@Operation(summary = "API to generate PDF for an application",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/pdf")),
|
||||||
|
@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 = "/{applicationId}/generate-pdf",
|
||||||
|
produces = { "application/pdf" })
|
||||||
|
public ResponseEntity<byte[]> generateApplicationPdf(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@Parameter(description = "The application id", required = true)
|
||||||
|
@PathVariable(value = "applicationId", required = true) Long applicationId);
|
||||||
|
}
|
||||||
@@ -221,6 +221,12 @@ public interface UserApi {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("favicon.ico")
|
||||||
|
@ResponseBody
|
||||||
|
void returnNoFavicon();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,22 @@ import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
|||||||
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationGetResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
import net.gepafin.tendermanagement.model.response.ApplicationResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.response.ApplicationSignedDocumentResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
import net.gepafin.tendermanagement.model.response.NextOrPreviousFormResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||||
|
import net.gepafin.tendermanagement.service.PdfService;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.ApplicationApi;
|
import net.gepafin.tendermanagement.web.rest.api.ApplicationApi;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,17 +40,21 @@ public class ApplicationApiController implements ApplicationApi {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationService applicationService;
|
private ApplicationService applicationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PdfService pdfService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<ApplicationResponseBean>> createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean,Long applicationId, Long formId) {
|
public ResponseEntity<Response<ApplicationResponseBean>> createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long applicationId, Long formId) {
|
||||||
ApplicationResponseBean applicationResponseBean= applicationService.createApplication(request,applicationRequestBean,applicationId,formId);
|
ApplicationResponseBean applicationResponseBean = applicationService.createApplication(request, applicationRequestBean, applicationId, formId);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG))); }
|
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<ApplicationGetResponseBean>> getApplicationByFormId(HttpServletRequest request
|
public ResponseEntity<Response<ApplicationGetResponseBean>> getApplicationByFormId(HttpServletRequest request
|
||||||
, Long applicationId,Long formId) {
|
, Long applicationId, Long formId) {
|
||||||
log.info("Get Application by ID - Application ID: {}", applicationId);
|
log.info("Get Application by ID - Application ID: {}", applicationId);
|
||||||
ApplicationGetResponseBean application = applicationService.getApplicationByFormId(request,applicationId,formId);
|
ApplicationGetResponseBean application = applicationService.getApplicationByFormId(request, applicationId, formId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(application, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
@@ -54,39 +63,83 @@ public class ApplicationApiController implements ApplicationApi {
|
|||||||
public ResponseEntity<Response<Void>> deleteApplication(HttpServletRequest request,
|
public ResponseEntity<Response<Void>> deleteApplication(HttpServletRequest request,
|
||||||
Long applicationId) {
|
Long applicationId) {
|
||||||
log.info("Delete Application - Application ID: {}", applicationId);
|
log.info("Delete Application - Application ID: {}", applicationId);
|
||||||
applicationService.deleteApplication(request,applicationId);
|
applicationService.deleteApplication(request, applicationId);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
public ResponseEntity<Response<ApplicationResponse>> createApplicationByCallId(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId) {
|
||||||
ApplicationResponse applicationResponseBean=applicationService.createApplication(request, companyId, applicationRequest, callId);
|
ApplicationResponse applicationResponseBean = applicationService.createApplication(request, companyId, applicationRequest, callId);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG)));
|
.body(new Response<>(applicationResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_CREATED_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request,Long callId,Long companyId) {
|
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId) {
|
||||||
List<ApplicationResponse> applications = applicationService.getAllApplications(request,callId,companyId);
|
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId);
|
||||||
log.info("Get All Applications");
|
log.info("Get All Applications");
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request,Long applicationId,
|
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request, Long applicationId,
|
||||||
Long formId, FormActionEnum action) {
|
Long formId, FormActionEnum action) {
|
||||||
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId, formId, action);
|
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId, formId, action);
|
||||||
log.info("Get Next Or Previous Form ");
|
log.info("Get Next Or Previous Form ");
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<Void>> updateApplicationStatus(HttpServletRequest request, Long applicationId,
|
public ResponseEntity<Response<ApplicationResponse>> updateApplicationStatus(HttpServletRequest request, Long applicationId,
|
||||||
ApplicationStatusTypeEnum status) {
|
ApplicationStatusTypeEnum status) {
|
||||||
applicationService.updateApplicationStatus(request, applicationId, status);
|
ApplicationResponse applicationResponse = applicationService.updateApplicationStatus(request, applicationId, status);
|
||||||
return ResponseEntity.status(HttpStatus.OK)
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> generateApplicationPdf(HttpServletRequest request, Long applicationId) {
|
||||||
|
byte[] pdfBytes = pdfService.generatePdf(request, applicationId);
|
||||||
|
|
||||||
|
// Prepare headers for downloading the PDF
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Content-Disposition", "attachment; filename=bando-preview.pdf");
|
||||||
|
|
||||||
|
// Return the PDF as a response
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.headers(headers)
|
||||||
|
.contentType(MediaType.APPLICATION_PDF)
|
||||||
|
.body(pdfBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<ApplicationSignedDocumentResponse>> uploadSignedDocument(HttpServletRequest request,
|
||||||
|
Long applicationId, MultipartFile file) {
|
||||||
|
log.info("upload signed document applicationId: {}", applicationId);
|
||||||
|
ApplicationSignedDocumentResponse response = applicationService.uploadSignedDocument(request, applicationId, file);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.SIGNED_DOCUMENT_FILE_UPLOAD_SUCCESS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<ApplicationSignedDocumentResponse>> getSignedDocument(HttpServletRequest request,
|
||||||
|
Long applicationId) {
|
||||||
|
ApplicationSignedDocumentResponse response = applicationService.getSignedDocument(request, applicationId);
|
||||||
|
log.info("get signed document applicationId: {}", applicationId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_SIGNED_DOCUMENT_FILE_SUCCESS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> deleteSignedDocument(HttpServletRequest request,
|
||||||
|
Long applicationId) {
|
||||||
|
applicationService.deleteSignedDocument(request, applicationId);
|
||||||
|
log.info("delete signed document applicationId: {}", applicationId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_SIGNED_DOCUMENT_FILE_SUCCESS)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -84,4 +86,22 @@ public class CallApiController implements CallApi {
|
|||||||
CallResponse updateCall = callService.updateCallStatus(request, callId, status);
|
CallResponse updateCall = callService.updateCallStatus(request, callId, status);
|
||||||
return ResponseEntity.ok(new Response<>(updateCall, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_CALL_STATUS_SUCCESS_MSG)));
|
return ResponseEntity.ok(new Response<>(updateCall, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_CALL_STATUS_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> downloadCallDocumentsAsZip(HttpServletRequest request, Long callId) {
|
||||||
|
byte[] zipFile = callService.downloadCallDocumentsAsZip(callId);
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
headers.setContentDispositionFormData("attachment", "documents.zip");
|
||||||
|
|
||||||
|
if (zipFile == null || zipFile.length == 0) {
|
||||||
|
String notFoundMessage = Translator.toLocale(GepafinConstant.CALL_DOCUMENTS_NOT_FOUND_MSG);
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(notFoundMessage.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(zipFile, headers, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,26 @@
|
|||||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.model.request.CompanyDelegationRequest;
|
||||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.CompanyDelegationResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.service.CompanyService;
|
import net.gepafin.tendermanagement.service.CompanyService;
|
||||||
@@ -86,4 +92,40 @@ public class CompanyApiController implements CompanyApi{
|
|||||||
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.CHECK_VATNUMBER_SUCCESS_MSG)));
|
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.CHECK_VATNUMBER_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> downloadCompanyDelegation(HttpServletRequest request, Long companyId, CompanyDelegationRequest companyDelegationRequest) {
|
||||||
|
log.info("download company delegation with companyId: {}", companyId);
|
||||||
|
ByteArrayOutputStream data = companyService.downloadCompanyDelegation(request, companyId, companyDelegationRequest);
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
headers.setContentDispositionFormData("attachment", "delegation-template.docx");
|
||||||
|
|
||||||
|
return new ResponseEntity<>(data.toByteArray(), headers, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<CompanyDelegationResponse>> uploadCompanyDelegation(HttpServletRequest request, Long companyId,
|
||||||
|
MultipartFile file) {
|
||||||
|
log.info("upload company delegation with companyId: {}", companyId);
|
||||||
|
CompanyDelegationResponse companyDelegationResponse = companyService.uploadCompanyDelegation(request, companyId, file);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(companyDelegationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_FILE_UPLOAD_SUCCESS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<CompanyDelegationResponse>> getCompanyDelegation(HttpServletRequest request,
|
||||||
|
Long companyId) {
|
||||||
|
log.info("get company delegation with companyId: {}", companyId);
|
||||||
|
CompanyDelegationResponse companyDelegationResponse = companyService.getCompanyDelegation(request, companyId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(companyDelegationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_FETCH_SUCCESS)));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> deleteCompanyDelegation(HttpServletRequest request,
|
||||||
|
Long companyId) {
|
||||||
|
log.info("delete company delegation with companyId: {}", companyId);
|
||||||
|
companyService.deleteCompanyDelegation(request, companyId);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_DELETE_SUCCESS)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import com.itextpdf.text.*;
|
||||||
|
import com.itextpdf.text.pdf.*;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.RoundedCorners;
|
||||||
|
import net.gepafin.tendermanagement.service.PdfService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.PdfApi;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class PdfController implements PdfApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PdfService pdfService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<byte[]> generateApplicationPdf(HttpServletRequest request, Long applicationId) {
|
||||||
|
byte[] pdfBytes =pdfService.generatePdf(request,applicationId);
|
||||||
|
|
||||||
|
// Prepare headers for downloading the PDF
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Content-Disposition", "attachment; filename=bando-preview.pdf");
|
||||||
|
|
||||||
|
// Return the PDF as a response
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.headers(headers)
|
||||||
|
.contentType(MediaType.APPLICATION_PDF)
|
||||||
|
.body(pdfBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -140,4 +140,10 @@ public class UserApiController implements UserApi {
|
|||||||
return ResponseEntity.ok(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.TOKEN_VALIDATE_SUCCESS_MSE)));
|
return ResponseEntity.ok(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.TOKEN_VALIDATE_SUCCESS_MSE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void returnNoFavicon() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,6 @@ spring.datasource.driver-class-name=org.postgresql.Driver
|
|||||||
|
|
||||||
# JPA Configuration
|
# JPA Configuration
|
||||||
spring.h2.console.enabled=true
|
spring.h2.console.enabled=true
|
||||||
base-url=https://api-dev-gepafin.memento.credit
|
|
||||||
|
|
||||||
isVatCheckGloballyDisabled = false
|
isVatCheckGloballyDisabled = false
|
||||||
|
isMailSendingEnabled = true
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ fe.base.url=https://bandi.gepafin.it
|
|||||||
#SPID configuration
|
#SPID configuration
|
||||||
spid.ipd.base.url=https://login.regione.umbria.it
|
spid.ipd.base.url=https://login.regione.umbria.it
|
||||||
active.profile.folder=production
|
active.profile.folder=production
|
||||||
|
isMailSendingEnabled = true
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
spring.application.name=tendermanagement
|
spring.application.name=tendermanagement
|
||||||
|
|
||||||
# Multipart Configuration
|
# Multipart Configuration
|
||||||
spring.servlet.multipart.max-file-size=50MB
|
spring.servlet.multipart.max-file-size=15MB
|
||||||
spring.servlet.multipart.max-request-size=50MB
|
spring.servlet.multipart.max-request-size=15MB
|
||||||
|
|
||||||
spring.profiles.active=testing
|
spring.profiles.active=testing
|
||||||
|
|
||||||
@@ -31,20 +31,37 @@ aws.s3.region=eu-west-1
|
|||||||
aws.s3.bucket.name=mementoresources
|
aws.s3.bucket.name=mementoresources
|
||||||
aws.s3.url = https://mementoresources.s3.eu-west-1.amazonaws.com/
|
aws.s3.url = https://mementoresources.s3.eu-west-1.amazonaws.com/
|
||||||
aws.s3.url.folder=gepafin
|
aws.s3.url.folder=gepafin
|
||||||
|
aws.s3.url.folder.delegation=gepafin/delegation
|
||||||
|
aws.s3.url.folder.signed.document=gepafin/signed-document
|
||||||
# JWT configuration
|
# JWT configuration
|
||||||
# Ensure these values match your expectations
|
# Ensure these values match your expectations
|
||||||
security.authentication.jwt.secret=my-secret-token-to-change-in-prod-environment-your-super-secure-randomly-generated-key
|
security.authentication.jwt.secret=my-secret-token-to-change-in-prod-environment-your-super-secure-randomly-generated-key
|
||||||
security.authentication.jwt.token-validity-in-seconds=86400
|
security.authentication.jwt.token-validity-in-seconds=86400
|
||||||
base-url=https://api-dev-gepafin.memento.credit
|
|
||||||
|
|
||||||
|
# Default system base URLs
|
||||||
|
base-url=https://api-dev-gepafin.memento.credit
|
||||||
|
fe.base.url=https://bandi-staging.memento.credit
|
||||||
|
|
||||||
spring.main.allow-circular-references=true
|
spring.main.allow-circular-references=true
|
||||||
|
|
||||||
isVatCheckGloballyDisabled = true
|
isVatCheckGloballyDisabled = true
|
||||||
vatCheckNewToken: 66026bd891a51044e90e08c4
|
vatCheckNewToken: 66026bd891a51044e90e08c4
|
||||||
fe.base.url=http://gepafin-staging-fe.s3-website.eu-central-1.amazonaws.com
|
|
||||||
|
|
||||||
#SPID configuration
|
#SPID configuration
|
||||||
spid.ipd.base.url=https://federatest.umbriadigitale.it
|
spid.ipd.base.url=https://federatest.umbriadigitale.it
|
||||||
active.profile.folder=dev
|
active.profile.folder=dev
|
||||||
|
|
||||||
|
# MailGun API Key
|
||||||
|
mailGun_apiKey= 398e3dea1911fe941af261906ec99362-07e2c238-8094421f
|
||||||
|
mailGun_user=comunicazione@paghiamoci.ai
|
||||||
|
mailGun_domainName=paghiamoci.ai
|
||||||
|
mailGun_base_url=https://api.eu.mailgun.net/
|
||||||
|
# SendinBlue API key
|
||||||
|
apiKey=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
|
||||||
|
#senderEmail=mailer@bflows.net
|
||||||
|
isMailSendingEnabled = false
|
||||||
|
default_System_Receiver_Email=attivazione@bflows.net
|
||||||
|
gepafin_email=bandi@pec.gepafin.it
|
||||||
|
rinaldo_email=rinaldo.bonazzo@bflows.net
|
||||||
|
carlo_email=carlo.mancosu@bflows.net
|
||||||
|
|
||||||
|
|||||||
@@ -710,6 +710,35 @@
|
|||||||
<sqlFile dbms="postgresql"
|
<sqlFile dbms="postgresql"
|
||||||
path="classpath:db/dump/updated_form_field_data_16-09-2024.sql" />
|
path="classpath:db/dump/updated_form_field_data_16-09-2024.sql" />
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
<changeSet id="23-09-2024_1" author="Harish Bagora" dbms="postgresql">
|
||||||
|
<!-- Procedure for automatically setting the updated_date -->
|
||||||
|
<createProcedure>
|
||||||
|
CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()
|
||||||
|
RETURNS TRIGGER
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
NEW.updated_date = clock_timestamp();
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
</createProcedure>
|
||||||
|
|
||||||
|
<createProcedure>
|
||||||
|
CREATE OR REPLACE FUNCTION gepafin_schema.clock_timestamp_created_date_column()
|
||||||
|
RETURNS TRIGGER
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS $$
|
||||||
|
BEGIN
|
||||||
|
IF NEW.created_date IS NULL THEN
|
||||||
|
NEW.created_date = clock_timestamp();
|
||||||
|
END IF;
|
||||||
|
NEW.updated_date = NEW.created_date;
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
</createProcedure>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="23-09-2024_1" author="Rajesh Khore">
|
<changeSet id="23-09-2024_1" author="Rajesh Khore">
|
||||||
<createTable tableName="saml_response">
|
<createTable tableName="saml_response">
|
||||||
@@ -833,5 +862,170 @@
|
|||||||
<column name="start_time" type="TIME"></column>
|
<column name="start_time" type="TIME"></column>
|
||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
<changeSet id="03-10-2024_1" author="Nisha Kashyap">
|
||||||
|
<sql>
|
||||||
|
TRUNCATE TABLE FORM_FIELD RESTART IDENTITY;
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="classpath:db/dump/updated_form_field_data_03-10-2024.sql" />
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="08-10-2024_1" author="Rajesh Khore">
|
||||||
|
<createTable tableName="user_company_delegation">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints nullable="false" primaryKey="true"
|
||||||
|
primaryKeyName="user_company_delegation_pkey" />
|
||||||
|
</column>
|
||||||
|
<column name="USER_ID" type="INTEGER" />
|
||||||
|
<column name="COMPANY_ID" type="INTEGER" />
|
||||||
|
<column name="BENEFICIARY_ID" type="INTEGER" />
|
||||||
|
<column name="FILE_NAME" type="VARCHAR(255)" />
|
||||||
|
<column name="FILE_PATH" type="VARCHAR(255)" />
|
||||||
|
<column name="STATUS" type="VARCHAR(50)" />
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE" />
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE" />
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<!-- Optional: If you have any indexes, constraints, or foreign keys -->
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="user_company_delegation" baseColumnNames="USER_ID"
|
||||||
|
referencedTableName="gepafin_user" referencedColumnNames="ID"
|
||||||
|
constraintName="fk_user_company_delegation_gepafin_user" />
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="user_company_delegation" baseColumnNames="COMPANY_ID"
|
||||||
|
referencedTableName="company" referencedColumnNames="ID"
|
||||||
|
constraintName="fk_user_company_delegation_company" />
|
||||||
|
|
||||||
|
<addForeignKeyConstraint
|
||||||
|
baseTableName="user_company_delegation"
|
||||||
|
baseColumnNames="BENEFICIARY_ID" referencedTableName="beneficiary"
|
||||||
|
referencedColumnNames="ID"
|
||||||
|
constraintName="fk_user_company_delegation_beneficiary" />
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="08-10-2024_2" author="Rajesh Khore">
|
||||||
|
<addColumn tableName="user_with_company">
|
||||||
|
<column name="IS_LEGAL_REPRESENTANT" type="BOOLEAN" />
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="03-10-2024_2" author="Nisha Kashyap">
|
||||||
|
<sql>
|
||||||
|
TRUNCATE TABLE FORM_FIELD RESTART IDENTITY;
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="classpath:db/dump/updated_form_field_data_03-10-2024_1.sql" />
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="07-10-2024_1" author="Harish Bagora">
|
||||||
|
<addColumn tableName="beneficiary">
|
||||||
|
<column name="PRIVACY" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||||
|
<column name="TERMS" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||||
|
<column name="MARKETING" type="BOOLEAN"/>
|
||||||
|
<column name="OFFERS" type="BOOLEAN"/>
|
||||||
|
<column name="THIRD_PARTY" type="BOOLEAN"/>
|
||||||
|
<column name="email_pec" type="VARCHAR(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
<addNotNullConstraint tableName="beneficiary" columnName="PRIVACY" />
|
||||||
|
<addNotNullConstraint tableName="beneficiary" columnName="TERMS" />
|
||||||
|
<addColumn tableName="COMPANY">
|
||||||
|
<column name="contact_name" type="VARCHAR(255)"/>
|
||||||
|
<column name="contact_email" type="VARCHAR(255)"/>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="07-10-2024_2" author="Nisha Kashyap">
|
||||||
|
<modifyDataType
|
||||||
|
tableName="application_form_field"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<changeSet id="10-10-2024_1" author="Rajesh Khore">
|
||||||
|
<createTable tableName="system_email_template">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints nullable="false" primaryKey="true"
|
||||||
|
primaryKeyName="system_email_template_pkey" />
|
||||||
|
</column>
|
||||||
|
<column name="TEMPLATE_NAME" type="VARCHAR(255)"/>
|
||||||
|
<column name="TYPE" type="VARCHAR(255)"/>
|
||||||
|
<column name="HTML_CONTENT" type="TEXT"/>
|
||||||
|
<column name="SUBJECT" type="TEXT"/>
|
||||||
|
<column name="JSON" type="TEXT"/>
|
||||||
|
<column name="SYSTEM" type="BOOLEAN"/>
|
||||||
|
<column name="IS_DELETED" type="BOOLEAN" defaultValueBoolean="true">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="10-10-2024_2" author="Rajesh Khore">
|
||||||
|
<sqlFile dbms="postgresql"
|
||||||
|
path="db/dump/insert_system_email_template_for_application_submission.sql" />
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="12-10-2024_1" author="Rajesh Khore">
|
||||||
|
|
||||||
|
<createTable tableName="application_signed_document">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true" primaryKeyName="application_signed_document_pkey" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="APPLICATION_ID" type="INTEGER">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="FILE_NAME" type="VARCHAR(255)"/>
|
||||||
|
<column name="FILE_PATH" type="VARCHAR(255)"/>
|
||||||
|
<column name="STATUS" type="VARCHAR(64)"/>
|
||||||
|
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addForeignKeyConstraint baseTableName="application_signed_document"
|
||||||
|
baseColumnNames="APPLICATION_ID"
|
||||||
|
referencedTableName="application"
|
||||||
|
referencedColumnNames="ID"
|
||||||
|
constraintName="fk_application_signed_document_application"/>
|
||||||
|
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="13-10-2024_1" author="Rajesh Khore">
|
||||||
|
<update tableName="form_field">
|
||||||
|
<column name="validators" value='{"custom": "nonEmptyTables"}' />
|
||||||
|
<where>name='table'</where>
|
||||||
|
</update>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.23.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.23.xsd">
|
||||||
|
|
||||||
<include file="db/changelog/db.changelog-1.0.0.xml"/>
|
<include file="db/changelog/db.changelog-1.0.0.xml"/>
|
||||||
|
<include file="db/changelog/dynamic-triggers.xml" />
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
51
src/main/resources/db/changelog/dynamic-triggers.xml
Normal file
51
src/main/resources/db/changelog/dynamic-triggers.xml
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||||
|
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.23.xsd">
|
||||||
|
<changeSet id="23-09-2024_3" author="Harish Bagora" runAlways="true">
|
||||||
|
<sql splitStatements="false">
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
r RECORD;
|
||||||
|
BEGIN
|
||||||
|
-- Loop through all tables in the schema that have the 'updated_date' column
|
||||||
|
FOR r IN (
|
||||||
|
SELECT table_name
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE column_name = 'updated_date'
|
||||||
|
AND table_schema = 'gepafin_schema'
|
||||||
|
)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_updated_at_%I
|
||||||
|
BEFORE UPDATE ON gepafin_schema.%I
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_updated_date_column()',
|
||||||
|
r.table_name, r.table_name
|
||||||
|
);
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
-- Loop through all tables in the schema that have the 'created_date' column
|
||||||
|
FOR r IN (
|
||||||
|
SELECT table_name
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE column_name = 'created_date'
|
||||||
|
AND table_schema = 'gepafin_schema'
|
||||||
|
)
|
||||||
|
LOOP
|
||||||
|
EXECUTE format(
|
||||||
|
'CREATE OR REPLACE TRIGGER tg_gepafin_schema_created_at_%I
|
||||||
|
BEFORE INSERT ON gepafin_schema.%I
|
||||||
|
FOR EACH ROW
|
||||||
|
EXECUTE FUNCTION gepafin_schema.clock_timestamp_created_date_column()',
|
||||||
|
r.table_name, r.table_name
|
||||||
|
);
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
</sql>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
INSERT INTO gepafin_schema.system_email_template (id, template_name, "type", html_content, subject, "json", "system", is_deleted, created_date, updated_date) VALUES(1, 'Application submission template to beneficiary and company', 'APPLICATION_SUBMISSION_TO_USER_AND_COMPANY', '<html>
|
||||||
|
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
|
||||||
|
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
|
||||||
|
<p>Buongiorno,</p>
|
||||||
|
<p>
|
||||||
|
Si comunica che, in riferimento alla domanda di concessione di
|
||||||
|
Finanziamento agevolato a valere sul Fondo prestiti
|
||||||
|
<strong>{{call_name}}</strong> di cui all''oggetto, la stessa è stata
|
||||||
|
regolarmente acquisita ed è stata registrata con Protocollo n.
|
||||||
|
<strong>{{protocol_number}}</strong> del <strong>{{date}}</strong> alle
|
||||||
|
<strong>{{time}}</strong>.
|
||||||
|
</p>
|
||||||
|
<p>Distinti Saluti,</p>
|
||||||
|
<p>
|
||||||
|
<strong>Gepafin S.p.a.</strong>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>', 'BANDO {{call_name}} - Domanda di concessione di finanziamento agevolato {{company_name}}', NULL, true, false, '2024-10-10 16:10:31.035', '2024-10-11 10:09:23.037');
|
||||||
|
INSERT INTO gepafin_schema.system_email_template (id, template_name, "type", html_content, subject, "json", "system", is_deleted, created_date, updated_date) VALUES(2, 'Application submission template to gepafin', 'APPLICATION_SUBMISSION_TO_GEPAFIN', '<html>
|
||||||
|
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
|
||||||
|
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
|
||||||
|
<p>
|
||||||
|
In riferimento alla domanda di concessione di Finanziamento agevolato a valere sul Fondo prestiti
|
||||||
|
<strong>{{call_name}}</strong> di cui all’oggetto, la stessa è stata regolarmente acquisita ed è stata
|
||||||
|
registrata con Protocollo n. <strong>{{protocol_number}}</strong> del <strong>{{date}}</strong> e <strong>{{time}}</strong>.
|
||||||
|
</p>
|
||||||
|
<p>Distinti Saluti,</p>
|
||||||
|
<p>
|
||||||
|
<strong>Gepafin S.p.a.</strong>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>', 'BANDO {{call_name}} - Domanda di concessione di finanziamento agevolato {{company_name}}', NULL, true, false, '2024-10-10 16:10:31.035', '2024-10-11 10:09:57.224');
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
INSERT INTO FORM_FIELD (SORT_ORDER, NAME, LABEL, DESCRIPTION, SETTINGS, VALIDATORS, CREATED_DATE, UPDATED_DATE)
|
||||||
|
VALUES
|
||||||
|
(1, 'textinput', 'Testo Breve', 'Per risposte concise (nomi, titoli, brevi descrizioni)',
|
||||||
|
'[{"name": "label", "value": "Testo Breve"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(2, 'textarea', 'Testo Lungo', 'Campo di testo esteso per paragrafi, descrizioni, proposte',
|
||||||
|
'[{"name": "label", "value": "Testo Lungo"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(3, 'wysiwyg', 'Campo di Testo Formattato', 'Editor avanzato per testo con formattazione',
|
||||||
|
'[{"name": "label", "value": "Testo Formattato"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(4, 'numberinput', 'Campo Numerico', 'Per l''inserimento di valori numerici (quantità, importi, percentuali)',
|
||||||
|
'[{"name": "label", "value": "Numero"}, {"name": "placeholder", "value": "0"}, {"name": "step", "value": "0"}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(5, 'radio', 'Scelta Singola', 'Gruppo di opzioni per selezione singola',
|
||||||
|
'[{"name": "label", "value": "Scelta Singola"}, {"name": "options", "value": "[]"}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(6, 'select', 'Menu a Tendina', 'Selezione da opzioni predefinite',
|
||||||
|
'[{"name": "label", "value": "Menu a Tendina"}, {"name": "options", "value": "[]"}]',
|
||||||
|
'{"isRequired": false,"custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(7, 'checkboxes', 'Scelta Multipla', 'Gruppo di opzioni per selezione singola o multipla',
|
||||||
|
'[{"name": "label", "value": "Scelta Multipla"}, {"name": "options", "value": "[]"}]',
|
||||||
|
'{"isRequired": false,"custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(8, 'switch', 'Casella di Spunta', 'Per selezioni binarie, accettazioni, conferme',
|
||||||
|
'[{"name": "label", "value": "Casella di Spunta"}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(9, 'datepicker', 'Data', 'Selezione di data',
|
||||||
|
'[{"name": "label", "value": "Data"}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(10, 'fileupload', 'Caricamento File', 'Per l''upload di documenti o immagini',
|
||||||
|
'[{"name": "label", "value": "Caricamento File"}, {"name": "mime", "value": "[]"}]',
|
||||||
|
'{"isRequired": false, "maxSize": 100000, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(11, 'textinput', 'Campo Partita IVA', 'Specifico per l''inserimento del numero di Partita IVA',
|
||||||
|
'[{"name": "label", "value": "Partita IVA"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true,"custom": "isPIVA"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(12, 'textinput', 'Campo Codice Fiscale', 'Specifico per l''inserimento del Codice Fiscale italiano per persone fisiche e giuridiche',
|
||||||
|
'[{"name": "label", "value": "Codice Fiscale"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true, "custom": "isCodiceFiscale"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(13, 'numberinput', 'Campo CAP', 'Per l''inserimento del Codice di Avviamento Postale',
|
||||||
|
'[{"name": "label", "value": "CAP"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true,"custom": "isCAP"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(14, 'textinput', 'Campo IBAN', 'Per l''inserimento del codice IBAN',
|
||||||
|
'[{"name": "label", "value": "IBAN"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true,"custom": "isIBAN"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(15, 'textinput', 'Campo Email', 'Per l''inserimento di indirizzi email standard (non PEC)',
|
||||||
|
'[{"name": "label", "value": "Campo Email"}, {"name": "placeholder", "value": "nome@esempio.it"}]',
|
||||||
|
'{"isRequired": false, "custom": "isEmail"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(16, 'textinput', 'Campo PEC', 'Specifico per l''inserimento di un indirizzo di Posta Elettronica Certificata',
|
||||||
|
'[{"name": "label", "value": "Campo PEC"}, {"name": "placeholder", "value": "nome@pec.it"}]',
|
||||||
|
'{"isRequired": false, "custom": "isEmailPEC"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(17, 'textinput', 'Campo URL', 'Per l''inserimento di indirizzi web',
|
||||||
|
'[{"name": "label", "value": "Indirizzo URL"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "custom": "isUrl"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(18, 'textinput', 'Marca da bollo', 'Per inserire codice di marca da bollo',
|
||||||
|
'[{"name": "label", "value": "Marca da bollo"}, {"name": "placeholder", "value": "Numero identificativo"}]',
|
||||||
|
'{"isRequired": false, "custom": "isMarcaDaBollo"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(19, 'paragraph', 'Paragrafo', 'Semplice testo formattato',
|
||||||
|
'[{"name": "text", "value": ""}]', '{}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(20, 'table', 'Tabella', 'Tabella',
|
||||||
|
'[{"name": "label", "value": "Tabella"}, {"name": "table_columns", "value": {}}]', '{}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
INSERT INTO FORM_FIELD (SORT_ORDER, NAME, LABEL, DESCRIPTION, SETTINGS, VALIDATORS, CREATED_DATE, UPDATED_DATE)
|
||||||
|
VALUES
|
||||||
|
(1, 'textinput', 'Testo Breve', 'Per risposte concise (nomi, titoli, brevi descrizioni)',
|
||||||
|
'[{"name": "label", "value": "Testo Breve"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(2, 'textarea', 'Testo Lungo', 'Campo di testo esteso per paragrafi, descrizioni, proposte',
|
||||||
|
'[{"name": "label", "value": "Testo Lungo"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(3, 'wysiwyg', 'Campo di Testo Formattato', 'Editor avanzato per testo con formattazione',
|
||||||
|
'[{"name": "label", "value": "Testo Formattato"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "minLength": null, "maxLength": null, "pattern": null, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(4, 'numberinput', 'Campo Numerico', 'Per l''inserimento di valori numerici (quantità, importi, percentuali)',
|
||||||
|
'[{"name": "label", "value": "Numero"}, {"name": "placeholder", "value": "0"}, {"name": "step", "value": "0"}]',
|
||||||
|
'{"isRequired": false, "min": null, "max": null, "pattern": null, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(5, 'radio', 'Scelta Singola', 'Gruppo di opzioni per selezione singola',
|
||||||
|
'[{"name": "label", "value": "Scelta Singola"}, {"name": "options", "value": []}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(6, 'select', 'Menu a Tendina', 'Selezione da opzioni predefinite',
|
||||||
|
'[{"name": "label", "value": "Menu a Tendina"}, {"name": "options", "value": []}]',
|
||||||
|
'{"isRequired": false, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(7, 'checkboxes', 'Scelta Multipla', 'Gruppo di opzioni per selezione singola o multipla',
|
||||||
|
'[{"name": "label", "value": "Scelta Multipla"}, {"name": "options", "value": []}]',
|
||||||
|
'{"isRequired": false, "min": null, "max": null, "custom": null}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(8, 'switch', 'Casella di Spunta', 'Per selezioni binarie, accettazioni, conferme',
|
||||||
|
'[{"name": "label", "value": "Casella di Spunta"}]',
|
||||||
|
'{"isRequired": false}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(9, 'datepicker', 'Data', 'Selezione di data',
|
||||||
|
'[{"name": "label", "value": "Data"}]',
|
||||||
|
'{"isRequired": false}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(10, 'fileupload', 'Caricamento File', 'Per l''upload di documenti o immagini',
|
||||||
|
'[{"name": "label", "value": "Caricamento File"}, {"name": "mime", "value": []}]',
|
||||||
|
'{"isRequired": false, "maxSize": 100000}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(11, 'textinput', 'Campo Partita IVA', 'Specifico per l''inserimento del numero di Partita IVA',
|
||||||
|
'[{"name": "label", "value": "Partita IVA"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true, "custom": "isPIVA"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(12, 'textinput', 'Campo Codice Fiscale','Specifico per l''inserimento del Codice Fiscale italiano per persone fisiche e giuridiche',
|
||||||
|
'[{"name": "label", "value": "Codice Fiscale"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true, "custom": "isCodiceFiscale"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(13, 'textinput', 'Campo CAP','Per l''inserimento del Codice di Avviamento Postale',
|
||||||
|
'[{"name": "label", "value": "CAP"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true, "custom": "isCAP"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(14, 'textinput', 'Campo IBAN', 'Per l''inserimento del codice IBAN',
|
||||||
|
'[{"name": "label", "value": "IBAN"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": true, "custom": "isIBAN"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(15, 'textinput', 'Campo Email', 'Per l''inserimento di indirizzi email standard (non PEC)',
|
||||||
|
'[{"name": "label", "value": "Campo Email"}, {"name": "placeholder", "value": "nome@esempio.it"}]',
|
||||||
|
'{"isRequired": false, "custom": "isEmail"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(16, 'textinput', 'Campo PEC', 'Specifico per l''inserimento di un indirizzo di Posta Elettronica Certificata',
|
||||||
|
'[{"name": "label", "value": "Campo PEC"}, {"name": "placeholder", "value": "nome@pec.it"}]',
|
||||||
|
'{"isRequired": false, "custom": "isEmailPEC"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(17, 'textinput', 'Campo URL', 'Per l''inserimento di indirizzi web',
|
||||||
|
'[{"name": "label", "value": "Indirizzo URL"}, {"name": "placeholder", "value": ""}]',
|
||||||
|
'{"isRequired": false, "custom": "isUrl"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(18, 'textinput', 'Marca da bollo', 'Per inserire codice di marca da bollo',
|
||||||
|
'[{"name": "label", "value": "Marca da bollo"}, {"name": "placeholder", "value": "Numero identificativo"}]',
|
||||||
|
'{"isRequired": false, "custom": "isMarcaDaBollo"}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(19, 'paragraph', 'Paragrafo', 'Semplice testo formattato',
|
||||||
|
'[{"name": "text", "value": ""}]',
|
||||||
|
'{}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
|
||||||
|
|
||||||
|
(20, 'table', 'Tabella', 'Tabella',
|
||||||
|
'[{"name": "label", "value": "Tabella"}, {"name": "table_columns", "value": []}]',
|
||||||
|
'{}',
|
||||||
|
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
|
||||||
@@ -206,3 +206,33 @@ vatnumber.already.exists=VatNumber already exists.
|
|||||||
invalid.email=Invalid email.
|
invalid.email=Invalid email.
|
||||||
company.id.mandatory=Company id is mandatory.
|
company.id.mandatory=Company id is mandatory.
|
||||||
user.already.connected.to.company=The user is already connected to this company.
|
user.already.connected.to.company=The user is already connected to this company.
|
||||||
|
validation.error.missing.firstName=First name is required.
|
||||||
|
validation.error.missing.lastName=Last name is required.
|
||||||
|
validation.error.missing.codiceFiscale=Codice Fiscale is required.
|
||||||
|
delegation.file.upload.success=Delegation file uploaded successfully.
|
||||||
|
delegation.fetch.success=Delegation fetched successfully.
|
||||||
|
delegation.template.generation.error=Something went wrong while generating the delegation template.
|
||||||
|
validation.error.file.empty=The uploaded file is empty.
|
||||||
|
validation.error.file.invalidType=Only .p7m files are accepted.
|
||||||
|
upload.error.s3=Failed to upload the file to S3.
|
||||||
|
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
user.not.authorized.create.application=User must be a legal representative or have delegation.
|
||||||
|
application.submitted.cannot.change=The submitted application cannot be changed.
|
||||||
|
# Call Document Messages
|
||||||
|
call.documents.fetch.success=Documents fetched successfully.
|
||||||
|
call.documents.not.found=No documents found for the specified call.
|
||||||
|
permission.denied=You are not authorized to access this data.
|
||||||
|
signed.document.file.upload.success=Signed document file uploaded successfully.
|
||||||
|
get.signed.document.file.success=Signed document file retrieved successfully.
|
||||||
|
application.signed.document.not.found=Signed document for the application not found.
|
||||||
|
delete.signed.document.file.success=Signed document deleted successfully.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ get_user_success_msg=Utente recuperato con successo.
|
|||||||
get_user_error_msg=Si � verificato un errore durante il recupero dell'utente.
|
get_user_error_msg=Si � verificato un errore durante il recupero dell'utente.
|
||||||
user.not.active=Utente non attivo. Si prega di contattare il supporto.
|
user.not.active=Utente non attivo. Si prega di contattare il supporto.
|
||||||
user.already.exist.msg=L'utente esiste gi� per questo codice fiscale.
|
user.already.exist.msg=L'utente esiste gi� 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 � obbligatoria e deve essere nel formato corretto. Si prega di verificare e riprovare.
|
||||||
validate.password=La password e confPassword sono obbligatorie. Verifica e riprova.
|
validate.password=La password e confPassword sono obbligatorie. Verifica e riprova.
|
||||||
# Role-related messages
|
# Role-related messages
|
||||||
role.created.success=Ruolo creato con successo.
|
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.
|
update.role.error=Errore durante l'aggiornamento del ruolo.
|
||||||
role.fetch.success=Ruolo recuperato con successo.
|
role.fetch.success=Ruolo recuperato con successo.
|
||||||
delete.role.error=Errore durante l'eliminazione del ruolo.
|
delete.role.error=Errore durante l'eliminazione del ruolo.
|
||||||
role.id.mandatory=L'ID del ruolo è obbligatorio.
|
role.id.mandatory=L'ID del ruolo � obbligatorio.
|
||||||
|
|
||||||
# Region-related messages
|
# Region-related messages
|
||||||
region.created.success=Regione creata con successo.
|
region.created.success=Regione creata con successo.
|
||||||
@@ -194,8 +194,41 @@ company.get.success=Azienda recuperata con successo.
|
|||||||
company.not.found=Azienda non trovata.
|
company.not.found=Azienda non trovata.
|
||||||
check.vatnumber.success=Numero di partita IVA verificato con successo.
|
check.vatnumber.success=Numero di partita IVA verificato con successo.
|
||||||
invalid.vatnumber=Numero di partita IVA non valido.
|
invalid.vatnumber=Numero di partita IVA non valido.
|
||||||
vatnumber.mandatory=Il numero di partita IVA è obbligatorio.
|
vatnumber.mandatory=Il numero di partita IVA � obbligatorio.
|
||||||
vatnumber.already.exists=Il numero di partita IVA esiste già.
|
vatnumber.already.exists=Il numero di partita IVA esiste gi�.
|
||||||
invalid.email=Email non valida.
|
invalid.email=Email non valida.
|
||||||
company.id.mandatory=L'ID dell'azienda è obbligatorio.
|
company.id.mandatory=L'ID dell'azienda � obbligatorio.
|
||||||
user.already.connected.to.company=L'utente è già collegato a questa azienda.
|
user.already.connected.to.company=L'utente � gi� collegato a questa azienda.
|
||||||
|
validation.error.missing.firstName=Il nome � obbligatorio.
|
||||||
|
validation.error.missing.lastName=Il cognome � obbligatorio.
|
||||||
|
validation.error.missing.codiceFiscale=Il Codice Fiscale � obbligatorio.
|
||||||
|
delegation.file.upload.success=File di delega caricato con successo.
|
||||||
|
delegation.fetch.success=Delega recuperata con successo.
|
||||||
|
delegation.template.generation.error=Si � verificato un errore durante la generazione del modello di delega.
|
||||||
|
validation.error.file.empty=Il file caricato � vuoto.
|
||||||
|
validation.error.file.invalidType=Sono accettati solo file .p7m.
|
||||||
|
upload.error.s3=Impossibile caricare il file su S3.
|
||||||
|
|
||||||
|
company.id.mandatory=L'ID dell'azienda � obbligatorio.
|
||||||
|
user.already.connected.to.company=L'utente � gi� collegato a questa azienda.
|
||||||
|
call.not.started.yet = La chiamata non � ancora iniziata. Attendere fino alla data e all'ora di inizio specificate.
|
||||||
|
call.already.ended = La chiamata � gi� terminata. Non � 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 � gi� 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.
|
||||||
|
user.not.authorized.create.application=L'utente deve essere un rappresentante legale o avere una delega.
|
||||||
|
application.submitted.cannot.change=La domanda inviata non può essere modificata.
|
||||||
|
|
||||||
|
# Call Document Messages
|
||||||
|
call.documents.fetch.success=Documenti recuperati con successo.
|
||||||
|
call.documents.not.found=Nessun documento trovato per la chiamata specificata.
|
||||||
|
permission.denied=Non sei autorizzato ad accedere a questi dati.
|
||||||
|
signed.document.file.upload.success=File del documento firmato caricato con successo.
|
||||||
|
get.signed.document.file.success=File del documento firmato recuperato con successo.
|
||||||
|
application.signed.document.not.found=Documento firmato per l'applicazione non trovato.
|
||||||
|
delete.signed.document.file.success=Documento firmato eliminato con successo.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user