diff --git a/avni-server-api/src/main/java/org/avni/server/dao/CHSRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/CHSRepository.java index 16edf5733..995e3bb97 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/CHSRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/CHSRepository.java @@ -6,7 +6,7 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.data.repository.NoRepositoryBean; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/ChecklistItemRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/ChecklistItemRepository.java index 488c629b1..d4b5135a1 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/ChecklistItemRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/ChecklistItemRepository.java @@ -11,7 +11,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/ChecklistRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/ChecklistRepository.java index ffc0f3b3c..804b45347 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/ChecklistRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/ChecklistRepository.java @@ -11,7 +11,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/CommentRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/CommentRepository.java index dcce5e1bf..136d76e60 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/CommentRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/CommentRepository.java @@ -10,7 +10,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/CommentThreadRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/CommentThreadRepository.java index 0ab444c78..bd338dcae 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/CommentThreadRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/CommentThreadRepository.java @@ -11,7 +11,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/ConceptRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/ConceptRepository.java index 6b0a1c0d4..5cf10e6b8 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/ConceptRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/ConceptRepository.java @@ -15,7 +15,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.ArrayList; import java.util.List; import java.util.Map; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/EncounterRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/EncounterRepository.java index 41f2e150e..907fb3034 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/EncounterRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/EncounterRepository.java @@ -11,7 +11,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.Calendar; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java index 7395c946b..ea8cacc3d 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java @@ -17,7 +17,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/GroupSubjectRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/GroupSubjectRepository.java index a93f17aa1..845148d1c 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/GroupSubjectRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/GroupSubjectRepository.java @@ -16,7 +16,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/IndividualRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/IndividualRepository.java index b4e26e3c1..e574f393d 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/IndividualRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/IndividualRepository.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository; import org.springframework.util.StringUtils; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.List; import java.util.Optional; import java.util.stream.Stream; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/LocationRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/LocationRepository.java index c5450d90f..09d330d37 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/LocationRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/LocationRepository.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository; import org.springframework.util.StringUtils; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import jakarta.validation.constraints.NotNull; import java.util.*; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/OperatingIndividualScopeAwareRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/OperatingIndividualScopeAwareRepository.java index dc76324e9..8a1a2162c 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/OperatingIndividualScopeAwareRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/OperatingIndividualScopeAwareRepository.java @@ -15,7 +15,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.repository.NoRepositoryBean; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/ProgramEncounterRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/ProgramEncounterRepository.java index 00ced93fb..e421f2158 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/ProgramEncounterRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/ProgramEncounterRepository.java @@ -13,7 +13,7 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.Date; import java.util.Calendar; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/ProgramEnrolmentRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/ProgramEnrolmentRepository.java index 625bef1ba..594bacb2b 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/ProgramEnrolmentRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/ProgramEnrolmentRepository.java @@ -16,9 +16,9 @@ import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaQuery; +import jakarta.persistence.criteria.Root; import java.util.Date; import java.util.List; import java.util.stream.Stream; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/SubjectMigrationRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/SubjectMigrationRepository.java index 5c5bd0356..1c40ae356 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/SubjectMigrationRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/SubjectMigrationRepository.java @@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java index 3ebff3e44..8adca890a 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java @@ -16,7 +16,7 @@ import org.springframework.stereotype.Repository; import javax.persistence.EntityNotFoundException; -import javax.persistence.QueryHint; +import jakarta.persistence.QueryHint; import java.util.List; import java.util.Optional; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/individualRelationship/IndividualRelationshipRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/individualRelationship/IndividualRelationshipRepository.java index 283d6e85b..12bebaab5 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/individualRelationship/IndividualRelationshipRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/individualRelationship/IndividualRelationshipRepository.java @@ -16,7 +16,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/program/SubjectProgramEligibilityRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/program/SubjectProgramEligibilityRepository.java index b09d0efda..0cabae161 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/program/SubjectProgramEligibilityRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/program/SubjectProgramEligibilityRepository.java @@ -16,7 +16,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/dao/sync/TransactionDataCriteriaBuilderUtil.java b/avni-server-api/src/main/java/org/avni/server/dao/sync/TransactionDataCriteriaBuilderUtil.java index 2787d93a3..bb777f38e 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/sync/TransactionDataCriteriaBuilderUtil.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/sync/TransactionDataCriteriaBuilderUtil.java @@ -2,8 +2,8 @@ import org.avni.server.dao.SyncParameters; -import javax.persistence.criteria.From; -import javax.persistence.criteria.Join; +import jakarta.persistence.criteria.From; +import jakarta.persistence.criteria.Join; public class TransactionDataCriteriaBuilderUtil { public static Join joinUserSubjectAssignment(From fromSubject) { diff --git a/avni-server-api/src/main/java/org/avni/server/dao/task/TaskRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/task/TaskRepository.java index 01eee2017..6d0205a61 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/task/TaskRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/task/TaskRepository.java @@ -16,7 +16,7 @@ import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.stereotype.Repository; -import javax.persistence.criteria.*; +import jakarta.persistence.criteria.*; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/avni-server-api/src/main/java/org/avni/server/framework/postgres/CHSPostgreSQL94Dialect.java b/avni-server-api/src/main/java/org/avni/server/framework/postgres/CHSPostgreSQL94Dialect.java index 6aa98e1f5..aa30a285b 100644 --- a/avni-server-api/src/main/java/org/avni/server/framework/postgres/CHSPostgreSQL94Dialect.java +++ b/avni-server-api/src/main/java/org/avni/server/framework/postgres/CHSPostgreSQL94Dialect.java @@ -5,7 +5,6 @@ import java.sql.Types; public class CHSPostgreSQL94Dialect extends PostgreSQL94Dialect { - private static final String JSONB = "jsonb"; private static final String JSON = "json"; diff --git a/avni-server-api/src/main/java/org/avni/server/framework/security/ApiSecurity.java b/avni-server-api/src/main/java/org/avni/server/framework/security/ApiSecurity.java index f9a08c12b..bae4bb62a 100644 --- a/avni-server-api/src/main/java/org/avni/server/framework/security/ApiSecurity.java +++ b/avni-server-api/src/main/java/org/avni/server/framework/security/ApiSecurity.java @@ -82,5 +82,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .and() .addFilter(new AuthenticationFilter(authService, idpType, defaultUserName, avniBlacklistedUrlsFile, errorBodyBuilder)) .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); + return httpSecurity.build(); } } diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/JobService.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/JobService.java index a11d123e4..8c6b3fbdc 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/JobService.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/JobService.java @@ -21,6 +21,8 @@ import javax.transaction.Transactional; import jakarta.validation.constraints.NotNull; + +import java.time.LocalDateTime; import java.util.Arrays; import java.util.Date; @@ -50,16 +52,16 @@ public JobService(JobExplorer jobExplorer, JobRepository jobRepository, Job impo public void retryJobsFailedInLast2Hours() throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { for (JobExecution jobExecution : jobExplorer.findRunningJobExecutions(importJob.getName())) { BatchStatus status = jobExecution.getStatus(); - Date lastUpdated = jobExecution.getLastUpdated(); - Date nowMinus2Hours = new DateTime().minusHours(2).toDate(); - if (nowMinus2Hours.before(lastUpdated) && Arrays.asList(STARTING, STARTED, UNKNOWN).contains(status)) { + LocalDateTime lastUpdated = jobExecution.getLastUpdated(); + LocalDateTime nowMinus2Hours = LocalDateTime.now().minusHours(2); + if (nowMinus2Hours.isBefore(lastUpdated) && Arrays.asList(STARTING, STARTED, UNKNOWN).contains(status)) { jobExecution.upgradeStatus(BatchStatus.FAILED); - jobExecution.setEndTime(new Date()); + jobExecution.setEndTime(LocalDateTime.now()); jobRepository.update(jobExecution); for (StepExecution stepExecution : jobExecution.getStepExecutions()) { if (Arrays.asList(STARTING, STARTED, UNKNOWN).contains(stepExecution.getStatus())) { stepExecution.upgradeStatus(BatchStatus.FAILED); - stepExecution.setEndTime(new Date()); + stepExecution.setEndTime(LocalDateTime.now()); jobRepository.update(stepExecution); } } diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/CsvFileItemWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/CsvFileItemWriter.java index 8998de45b..c538280c1 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/CsvFileItemWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/CsvFileItemWriter.java @@ -3,6 +3,7 @@ import org.avni.server.framework.security.AuthService; import org.avni.server.importer.batch.model.Row; import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -57,9 +58,9 @@ private ItemWriter getWriter() { } @Override - public void write(List rows) throws Exception { + public void write(Chunk chunk) throws Exception { authService.authenticateByUserId(userId, organisationUUID); - getWriter().write(rows); + getWriter().write(chunk); } public Long getUserId() { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/EncounterWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/EncounterWriter.java index 2a5bdea8d..e6c7e811d 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/EncounterWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/EncounterWriter.java @@ -15,6 +15,7 @@ import org.avni.server.service.EncounterService; import org.avni.server.service.ObservationService; import org.avni.server.service.OrganisationConfigService; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -66,8 +67,8 @@ public EncounterWriter(EncounterRepository encounterRepository, } @Override - public void write(List rows) throws Exception { - for (Row row : rows) write(row); + public void write(Chunk chunk) throws Exception { + for (Row row : chunk.getItems()) write(row); } private void write(Row row) throws Exception { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/GroupSubjectWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/GroupSubjectWriter.java index 34a56d412..6d74d7ab0 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/GroupSubjectWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/GroupSubjectWriter.java @@ -17,6 +17,7 @@ import org.avni.server.service.GroupSubjectService; import org.avni.server.service.HouseholdService; import org.joda.time.LocalDate; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -55,8 +56,8 @@ public GroupSubjectWriter(GroupSubjectRepository groupSubjectRepository, } @Override - public void write(List rows) throws Exception { - for (Row row : rows) write(row); + public void write(Chunk chunk) throws Exception { + for (Row row : chunk.getItems()) write(row); } private void write(Row row) throws Exception { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/LocationWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/LocationWriter.java index ca96e7b50..15fc5c3db 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/LocationWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/LocationWriter.java @@ -2,6 +2,7 @@ import org.avni.server.importer.batch.model.Row; import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,11 +28,11 @@ public LocationWriter(BulkLocationCreator bulkLocationCreator, BulkLocationEdito } @Override - public void write(List rows) { + public void write(Chunk chunk) throws Exception { if (LocationUploadMode.isCreateMode(locationUploadMode)) { - this.bulkLocationCreator.write(rows, locationHierarchy); + this.bulkLocationCreator.write(chunk.getItems(), locationHierarchy); } else { - this.bulkLocationEditor.write(rows); + this.bulkLocationEditor.write(chunk.getItems()); } } diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEncounterWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEncounterWriter.java index 7206ca5cb..599446665 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEncounterWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEncounterWriter.java @@ -16,6 +16,7 @@ import org.avni.server.service.ObservationService; import org.avni.server.service.OrganisationConfigService; import org.avni.server.service.ProgramEncounterService; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -70,8 +71,8 @@ public ProgramEncounterWriter(ProgramEncounterRepository programEncounterReposit } @Override - public void write(List rows) throws Exception { - for (Row row : rows) write(row); + public void write(Chunk chunk) throws Exception { + for (Row row : chunk.getItems()) write(row); } private void write(Row row) throws Exception { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEnrolmentWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEnrolmentWriter.java index b78982aef..3c04ac4b5 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEnrolmentWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/ProgramEnrolmentWriter.java @@ -16,6 +16,7 @@ import org.avni.server.service.OrganisationConfigService; import org.avni.server.service.ProgramEnrolmentService; import org.joda.time.LocalDate; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -69,8 +70,8 @@ public ProgramEnrolmentWriter(ProgramEnrolmentRepository programEnrolmentReposit } @Override - public void write(List rows) throws Exception { - for (Row row : rows) write(row); + public void write(Chunk chunk) throws Exception { + for (Row row : chunk.getItems()) write(row); } private void write(Row row) throws Exception { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/SubjectWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/SubjectWriter.java index 09eb8b4bb..1822565ff 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/SubjectWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/SubjectWriter.java @@ -16,6 +16,7 @@ import org.joda.time.LocalDate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -76,8 +77,8 @@ public SubjectWriter(IndividualRepository individualRepository, } @Override - public void write(List rows) throws Exception { - for (Row row : rows) write(row); + public void write(Chunk chunk) throws Exception { + for (Row row : chunk.getItems()) write(row); } private void write(Row row) throws Exception { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/UserAndCatchmentWriter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/UserAndCatchmentWriter.java index 4ccc3843e..0f503f95c 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/UserAndCatchmentWriter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/csv/writer/UserAndCatchmentWriter.java @@ -14,6 +14,7 @@ import org.avni.server.util.RegionUtil; import org.avni.server.util.S; import org.avni.server.web.request.syncAttribute.UserSyncSettings; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -79,7 +80,8 @@ public UserAndCatchmentWriter(CatchmentService catchmentService, @Transactional(Transactional.TxType.REQUIRES_NEW) @Override - public void write(List rows) throws IDPException { + public void write(Chunk chunk) throws IDPException { + List rows = chunk.getItems(); if (!CollectionUtils.isEmpty(rows)) { validateHeaders(rows.get(0).getHeaders()); for (Row row : rows) write(row); diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/model/CustomJobParameter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/model/CustomJobParameter.java index bf82a24ce..ba256372a 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/model/CustomJobParameter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/model/CustomJobParameter.java @@ -4,13 +4,13 @@ import java.io.Serializable; -public class CustomJobParameter extends JobParameter { +public class CustomJobParameter extends JobParameter { private final T customParam; public CustomJobParameter(T customParam){ - super(""); + super(customParam, (Class) customParam.getClass()); this.customParam = customParam; } public T getValue(){ return customParam; } -} \ No newline at end of file +} diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/sync/attributes/bulkmigration/BulkSubjectMigrationJobListener.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/sync/attributes/bulkmigration/BulkSubjectMigrationJobListener.java index 923d70c2f..ccb259173 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/sync/attributes/bulkmigration/BulkSubjectMigrationJobListener.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/sync/attributes/bulkmigration/BulkSubjectMigrationJobListener.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.avni.server.framework.security.AuthService; import org.avni.server.service.BulkUploadS3Service; +import org.avni.server.util.DateTimeUtil; import org.avni.server.util.ObjectMapperSingleton; import org.avni.server.web.request.BulkSubjectMigrationRequest; import org.slf4j.Logger; @@ -16,6 +17,8 @@ import java.io.File; import java.io.IOException; +import java.time.Period; +import java.time.temporal.ChronoUnit; import java.util.Map; import static java.lang.String.format; @@ -61,7 +64,9 @@ public void beforeJob(JobExecution jobExecution) { public void afterJob(JobExecution jobExecution) { Map failedMigrations = (Map) jobExecution.getExecutionContext().get("failedMigrations"); logger.info("Finished Bulk Subject Migration Job {} mode: {} failedCount: {} exitStatus: {} waitTime: {}ms processingTime: {}ms fileName: {}", - uuid, mode, failedMigrations.size(), jobExecution.getExitStatus(), jobExecution.getStartTime().getTime() - jobExecution.getCreateTime().getTime(), jobExecution.getEndTime().getTime() - jobExecution.getStartTime().getTime(), fileName); + uuid, mode, failedMigrations.size(), jobExecution.getExitStatus(), + DateTimeUtil.getMilliSecondsDuration(jobExecution.getCreateTime(), jobExecution.getEndTime()), + DateTimeUtil.getMilliSecondsDuration(jobExecution.getStartTime(), jobExecution.getEndTime()), fileName); try { writeFailuresToFileAndUploadToS3(failedMigrations); } catch (Exception e) { diff --git a/avni-server-api/src/main/java/org/avni/server/importer/batch/zip/BundleZipFileImporter.java b/avni-server-api/src/main/java/org/avni/server/importer/batch/zip/BundleZipFileImporter.java index b7e3afa81..cce9cf7b8 100644 --- a/avni-server-api/src/main/java/org/avni/server/importer/batch/zip/BundleZipFileImporter.java +++ b/avni-server-api/src/main/java/org/avni/server/importer/batch/zip/BundleZipFileImporter.java @@ -32,6 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.item.Chunk; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -210,7 +211,8 @@ public void authenticateUser() { } @Override - public void write(List bundleFiles) throws Exception { + public void write(Chunk chunk) throws Exception { + List bundleFiles = chunk.getItems(); BundleZip bundleZip = new BundleZip(bundleFiles.stream().collect(Collectors.toMap(BundleFile::getName, BundleFile::getContent))); for (String filename : fileSequence) { Optional fromFileName = BundleFolder.getFromFileName(filename); diff --git a/avni-server-api/src/main/java/org/avni/server/util/DateTimeUtil.java b/avni-server-api/src/main/java/org/avni/server/util/DateTimeUtil.java index 62233c8f4..b3dc86878 100644 --- a/avni-server-api/src/main/java/org/avni/server/util/DateTimeUtil.java +++ b/avni-server-api/src/main/java/org/avni/server/util/DateTimeUtil.java @@ -5,6 +5,7 @@ import org.joda.time.Instant; import org.joda.time.LocalDate; +import java.time.LocalDateTime; import java.util.Calendar; import java.util.TimeZone; @@ -42,4 +43,8 @@ public static String toDateString(String dateStringWithTimezone) { .toDateTime(IST) .toString("yyyy-MM-dd"); } + + public static long getMilliSecondsDuration(LocalDateTime start, LocalDateTime end) { + return java.time.Duration.between(start, end).toMillis(); + } } diff --git a/avni-server-api/src/main/java/org/avni/server/web/FormController.java b/avni-server-api/src/main/java/org/avni/server/web/FormController.java index 9b3b4de6e..e769381bf 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/FormController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/FormController.java @@ -45,7 +45,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Predicate; import javax.transaction.Transactional; import java.io.InvalidObjectException; import java.util.*; diff --git a/avni-server-api/src/main/java/org/avni/server/web/OrganisationController.java b/avni-server-api/src/main/java/org/avni/server/web/OrganisationController.java index c6fc8a43e..d7b13ce50 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/OrganisationController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/OrganisationController.java @@ -14,7 +14,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import javax.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Predicate; import javax.transaction.Transactional; import java.util.*; import java.util.stream.Collectors; diff --git a/avni-server-api/src/main/java/org/avni/server/web/UserController.java b/avni-server-api/src/main/java/org/avni/server/web/UserController.java index 7f7ce1099..1a00cd8d3 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/UserController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/UserController.java @@ -33,9 +33,9 @@ import org.springframework.web.bind.annotation.*; import javax.persistence.EntityNotFoundException; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; +import jakarta.persistence.criteria.Root; import javax.transaction.Transactional; import java.util.List; import java.util.UUID;