diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f99697fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# --- Stage 1: Build the application using Maven --- +FROM maven:3.9.6-eclipse-temurin-17 AS build + +WORKDIR /app + +COPY . . + +# Build the application while caching Maven dependencies to speed up future builds +RUN --mount=type=cache,target=/root/.m2 \ + mvn clean package -DENV_VAR=docker -DskipTests -Dgit.skip=true + +# --- Stage 2: Run the application with a minimal JRE image --- +FROM eclipse-temurin:17-jre + +WORKDIR /app + +# Copy the built WAR file from the build stage +COPY --from=build /app/target/*.war app.war + +EXPOSE 8080 + +ENTRYPOINT ["java", "-jar", "app.war"] diff --git a/pom.xml b/pom.xml index c41d078a..ffbae092 100644 --- a/pom.xml +++ b/pom.xml @@ -456,6 +456,18 @@ + + org.springframework.boot + spring-boot-maven-plugin + 3.2.2 + + + + repackage + + + + diff --git a/src/main/environment/1097_ci.properties b/src/main/environment/1097_ci.properties index ea60930f..a2b79037 100644 --- a/src/main/environment/1097_ci.properties +++ b/src/main/environment/1097_ci.properties @@ -18,3 +18,6 @@ tm-url=@TM_API@ # FHIR Config fhir-url=@FHIR_API@ + +# Redis Config +spring.redis.host=@env.REDIS_HOST@ \ No newline at end of file diff --git a/src/main/environment/1097_docker.properties b/src/main/environment/1097_docker.properties new file mode 100644 index 00000000..5510dfce --- /dev/null +++ b/src/main/environment/1097_docker.properties @@ -0,0 +1,22 @@ +# DataSource settings: set here your own configurations for the database +spring.datasource.url=${DATABASE_1097_IDENTITY_URL} +spring.datasource.username=${DATABASE_IDENTITY_USERNAME} +spring.datasource.password=${DATABASE_IDENTITY_PASSWORD} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver + +#ELK logging file name +logging.path=logs/ +logging.file.name=${IDENTITY_API_1097_LOGGING_FILE_NAME} + +springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED} + +jwt.secret=${JWT_SECRET_KEY} + # TM Config +tm-url=${TM_API} + +# FHIR Config +fhir-url=${FHIR_API} + +# Redis Config +spring.redis.host=${REDIS_HOST} \ No newline at end of file diff --git a/src/main/environment/1097_example.properties b/src/main/environment/1097_example.properties index 6a7d8b0f..9eeee5c4 100644 --- a/src/main/environment/1097_example.properties +++ b/src/main/environment/1097_example.properties @@ -14,4 +14,7 @@ logging.file.name=logs/1097identity-api.log tm-url=http://localhost:8089/ # FHIR Config -fhir-url=http://localhost:8093/ \ No newline at end of file +fhir-url=http://localhost:8093/ + +# Redis Config +spring.redis.host=localhost \ No newline at end of file diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index d6b426ef..debf33c4 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -18,3 +18,6 @@ tm-url=@TM_API@ # FHIR Config fhir-url=@FHIR_API@ + +# Redis Config +spring.redis.host=@env.REDIS_HOST@ \ No newline at end of file diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties new file mode 100644 index 00000000..4409906e --- /dev/null +++ b/src/main/environment/common_docker.properties @@ -0,0 +1,23 @@ +# DataSource settings: set here your own configurations for the database +spring.datasource.url=${DATABASE_IDENTITY_URL} +spring.datasource.username=${DATABASE_IDENTITY_USERNAME} +spring.datasource.password=${DATABASE_IDENTITY_PASSWORD} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver + +#ELK logging file name +logging.path=logs/ +logging.file.name=${IDENTITY_API_LOGGING_FILE_NAME} + +springdoc.api-docs.enabled=${SWAGGER_DOC_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_DOC_ENABLED} + +jwt.secret=${JWT_SECRET_KEY} + + # TM Config +tm-url=${TM_API} + +# FHIR Config +fhir-url=${FHIR_API} + +# Redis Config +spring.redis.host=${REDIS_HOST} \ No newline at end of file diff --git a/src/main/environment/common_example.properties b/src/main/environment/common_example.properties index 79dfeb12..ca58c85c 100644 --- a/src/main/environment/common_example.properties +++ b/src/main/environment/common_example.properties @@ -13,4 +13,7 @@ logging.file.name=logs/identity-api.log tm-url=http://localhost:8089/ # FHIR Config -fhir-url=http://localhost:8093/ \ No newline at end of file +fhir-url=http://localhost:8093/ + +# Redis Config +spring.redis.host=localhost \ No newline at end of file diff --git a/src/main/java/com/iemr/common/identity/service/IdentityService.java b/src/main/java/com/iemr/common/identity/service/IdentityService.java index 21bfbc50..14582773 100644 --- a/src/main/java/com/iemr/common/identity/service/IdentityService.java +++ b/src/main/java/com/iemr/common/identity/service/IdentityService.java @@ -1047,31 +1047,31 @@ private MBeneficiarydetail convertIdentityEditDTOToMBeneficiarydetail(IdentityEd public BeneficiaryCreateResp createIdentity(IdentityDTO identity) { logger.info("IdentityService.createIdentity - start"); - List list = null; - MBeneficiaryregidmapping regMap = null; - synchronized (queue) { - if (queue.isEmpty()) { - logger.info("fetching 10000 rows"); - list = regIdRepo.findTop10000ByProvisionedAndReserved(false, false); - logger.info("Adding SynchronousQueue start-- "); - for (MBeneficiaryregidmapping map : list) { - queue.add(map); + List list = null; + MBeneficiaryregidmapping regMap = null; + synchronized (queue) { + if (queue.isEmpty()) { + logger.info("fetching 10000 rows"); + list = regIdRepo.findTop10000ByProvisionedAndReserved(false, false); + logger.info("Adding SynchronousQueue start-- "); + for (MBeneficiaryregidmapping map : list) { + queue.add(map); + } + logger.info("Adding SynchronousQueue end-- "); } - logger.info("Adding SynchronousQueue end-- "); + regMap = queue.removeFirst(); + } + regMap.setReserved(true); + if (regMap.getCreatedDate() == null) { + SimpleDateFormat sdf = new SimpleDateFormat(CREATED_DATE_FORMAT); + String dateToStoreInDataBase = sdf.format(new Date()); + Timestamp ts = Timestamp.valueOf(dateToStoreInDataBase); + regMap.setCreatedDate(ts); } - regMap = queue.removeFirst(); - } - regMap.setReserved(true); - if (regMap.getCreatedDate() == null) { - SimpleDateFormat sdf = new SimpleDateFormat(CREATED_DATE_FORMAT); - String dateToStoreInDataBase = sdf.format(new Date()); - Timestamp ts = Timestamp.valueOf(dateToStoreInDataBase); - regMap.setCreatedDate(ts); - } - regIdRepo.save(regMap); + regIdRepo.save(regMap); - regMap.setProvisioned(true); + regMap.setProvisioned(true); logger.info("IdentityService.createIdentity - saving Address"); ObjectMapper objectMapper = new ObjectMapper(); @@ -1332,6 +1332,7 @@ private MBeneficiarydetail convertIdentityDTOToMBeneficiarydetail(IdentityDTO dt beneficiarydetail.setOccupationId(dto.getOccupationId()); beneficiarydetail.setPhcId(dto.getPhcId()); beneficiarydetail.setPlaceOfWork(dto.getPlaceOfWork()); + beneficiarydetail.setPreferredLanguageId(dto.getPreferredLanguageId()); beneficiarydetail.setPreferredLanguage(dto.getPreferredLanguage()); beneficiarydetail.setReligion(dto.getReligion()); if (dto.getFaceEmbedding() != null) diff --git a/src/main/java/com/iemr/common/identity/service/familyTagging/FamilyTagServiceImpl.java b/src/main/java/com/iemr/common/identity/service/familyTagging/FamilyTagServiceImpl.java index f890f693..2a60571b 100644 --- a/src/main/java/com/iemr/common/identity/service/familyTagging/FamilyTagServiceImpl.java +++ b/src/main/java/com/iemr/common/identity/service/familyTagging/FamilyTagServiceImpl.java @@ -157,7 +157,7 @@ public String editFamilyDetails(String request) throws IEMRException { if (benFamilyRS != null) { if (benFamilyObj.getIsHeadOfTheFamily() != null && benFamilyObj.getMemberName() != null) { - if(benFamilyRS.getFamilyHeadName().trim().equals(benFamilyObj.getMemberName().trim()) && Boolean.TRUE.equals(!benFamilyObj.getIsHeadOfTheFamily())) + if(null != benFamilyRS.getFamilyHeadName() && benFamilyRS.getFamilyHeadName().trim().equals(benFamilyObj.getMemberName().trim()) && Boolean.TRUE.equals(!benFamilyObj.getIsHeadOfTheFamily())) benFamilyRS.setFamilyHeadName(""); else benFamilyRS.setFamilyHeadName(benFamilyObj.getMemberName()); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0a0293e6..a0828d00 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -12,7 +12,6 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect #Below lines are added for security reasons spring.session.store-type=redis -spring.redis.host=localhost spring.redis.password= spring.redis.port=6379