Skip to content

Commit

Permalink
Merge branch 'java-upgrade'
Browse files Browse the repository at this point in the history
# Conflicts:
#	avni-server-api/src/main/java/org/avni/messaging/domain/MessageRequest.java
#	avni-server-api/src/main/java/org/avni/server/dao/CHSRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/ChecklistItemRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/ChecklistRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/EncounterRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/EndOfLife1EndpointRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/GroupPrivilegeRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/GroupSubjectRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/IdentifierAssignmentRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/IdentifierSourceRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/IndividualRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/LocationMappingRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/LocationRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/NewsRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/OperatingIndividualScopeAwareRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/OperationalEncounterTypeRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/OperationalProgramRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/ProgramEnrolmentRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/RuleDependencyRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/UserGroupRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/UserRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/UserSubjectAssignmentRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/individualRelationship/IndividualRelationshipRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/task/TaskRepository.java
#	avni-server-api/src/main/java/org/avni/server/dao/task/TaskUnAssignmentRepository.java
#	avni-server-api/src/main/java/org/avni/server/domain/AbstractEncounter.java
#	avni-server-api/src/main/java/org/avni/server/domain/ApprovalStatus.java
#	avni-server-api/src/main/java/org/avni/server/domain/Checklist.java
#	avni-server-api/src/main/java/org/avni/server/domain/ChecklistItem.java
#	avni-server-api/src/main/java/org/avni/server/domain/CommentThread.java
#	avni-server-api/src/main/java/org/avni/server/domain/EntityApprovalStatus.java
#	avni-server-api/src/main/java/org/avni/server/domain/GroupSubject.java
#	avni-server-api/src/main/java/org/avni/server/domain/Individual.java
#	avni-server-api/src/main/java/org/avni/server/domain/News.java
#	avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java
#	avni-server-api/src/main/java/org/avni/server/domain/StandardReportCardType.java
#	avni-server-api/src/main/java/org/avni/server/domain/SyncTelemetry.java
#	avni-server-api/src/main/java/org/avni/server/domain/VideoTelemetric.java
#	avni-server-api/src/main/java/org/avni/server/domain/individualRelationship/IndividualRelationship.java
#	avni-server-api/src/main/java/org/avni/server/domain/program/SubjectProgramEligibility.java
#	avni-server-api/src/main/java/org/avni/server/domain/task/Task.java
#	avni-server-api/src/main/java/org/avni/server/service/IdentifierAssignmentService.java
  • Loading branch information
himeshr committed Dec 19, 2024
2 parents 2dac0b5 + c08c11e commit 067b27a
Show file tree
Hide file tree
Showing 93 changed files with 611 additions and 583 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include makefiles/externalDB.mk
include makefiles/prod.mk
include makefiles/api-test-data.mk
include makefiles/lfe.mk
include makefiles/gradle.mk

help:
@IFS=$$'\n' ; \
Expand Down
24 changes: 11 additions & 13 deletions avni-server-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ plugins {
id 'java'
}

ext { springBootVersion = '3.3.5' }
//todo: Remove when upgrading Spring version. This was introduced to use SameSiteCookies
//ext['tomcat.version'] = '9.0.80'

Expand Down Expand Up @@ -49,7 +48,7 @@ configurations {
dependencies {
implementation group: 'org.apache.tomcat', name: 'tomcat-jdbc'
implementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
implementation("org.springframework.boot:spring-boot-starter-cache:${springBootVersion}")
testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-rest:${springBootVersion}"
implementation("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
Expand All @@ -62,9 +61,6 @@ dependencies {
exclude(group: 'org.hibernate', module: 'hibernate-core')
}
runtimeOnly("javax.transaction:jta:1.1")
// implementation(group: 'org.jadira.usertype', name: 'usertype.core', version: '7.0.0.CR1') {
// exclude(group: 'org.hibernate', module: 'hibernate-core')
// }
implementation "org.flywaydb:flyway-core:10.20.1"
runtimeOnly("org.flywaydb:flyway-database-postgresql:10.20.1")
implementation "org.flywaydb.flyway-test-extensions:flyway-spring6-test:10.0.0"
Expand All @@ -74,29 +70,31 @@ dependencies {
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.3'
implementation 'com.auth0:jwks-rsa:0.3.0'
implementation 'com.auth0:java-jwt:3.3.0'
// implementation(group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.9.2.Final') {
// exclude(group: 'org.hibernate', module: 'hibernate-core')
// }
implementation 'com.bugsnag:bugsnag:3.+'
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'com.amazonaws:aws-java-sdk-cognitoidp'
implementation 'commons-validator:commons-validator:1.4.1'
implementation 'org.passay:passay:1.6.3'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.keycloak:keycloak-spring-boot-starter:24.0.4'
implementation 'org.keycloak:keycloak-admin-client:24.0.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.4'
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.4'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.4'
implementation 'com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.15.2'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.15.4'
implementation('org.hibernate:hibernate-ehcache:5.6.15.Final') {

implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}"
implementation 'javax.cache:cache-api:1.1.1'
implementation("org.hibernate.orm:hibernate-jcache:6.5.2.Final") {
exclude(group: "org.hibernate.orm", module: "hibernate-core")
}
runtimeOnly('org.hibernate:hibernate-ehcache:5.6.15.Final') {
exclude(group: 'org.hibernate', module: 'hibernate-core')
}

implementation('org.ehcache:ehcache:3.10.8:jakarta')

runtimeOnly("javax.xml.bind:jaxb-api:2.3.1")
runtimeOnly('org.ehcache:ehcache:3.10.8')
runtimeOnly("org.hibernate:hibernate-jcache:6.5.1.Final")
implementation 'javax.cache:cache-api:1.1.1'
dev "org.springframework.boot:spring-boot-devtools:${springBootVersion}"
testImplementation "org.mockito:mockito-core:3.12.4"
testImplementation 'org.powermock:powermock-core:2.0.9'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import org.avni.server.domain.OrganisationAwareEntity;
import org.avni.server.util.DateTimeUtil;
import org.joda.time.DateTime;

import java.time.Instant;

@Entity
@Table(name = "message_request_queue")
public class MessageRequest extends OrganisationAwareEntity {
Expand All @@ -30,15 +27,15 @@ public class MessageRequest extends OrganisationAwareEntity {

@Column
@NotNull
private Instant scheduledDateTime;
private DateTime scheduledDateTime;

@Column
@NotNull
@Enumerated(EnumType.STRING)
private MessageDeliveryStatus deliveryStatus;

@Column
private Instant deliveredDateTime;
private DateTime deliveredDateTime;

public void setMessageRule(MessageRule messageRule) {
this.messageRule = messageRule;
Expand All @@ -53,15 +50,15 @@ public void setEntityId(Long entityId) {
}

public void setScheduledDateTime(DateTime scheduledDateTime) {
this.scheduledDateTime = DateTimeUtil.toInstant(scheduledDateTime);
this.scheduledDateTime = scheduledDateTime;
}

public void setDeliveryStatus(MessageDeliveryStatus deliveryStatus) {
this.deliveryStatus = deliveryStatus;
}

public void setDeliveredDateTime(DateTime deliveredDateTime) {
this.deliveredDateTime = DateTimeUtil.toInstant(deliveredDateTime);
this.deliveredDateTime = deliveredDateTime;
}

public MessageRequest() {
Expand All @@ -71,20 +68,20 @@ public MessageRequest(MessageRule messageRule, MessageReceiver messageReceiverId
this.messageRule = messageRule;
this.messageReceiver = messageReceiverId;
this.entityId = entityId;
this.setScheduledDateTime(scheduledDateTime);
this.scheduledDateTime = scheduledDateTime;
this.deliveryStatus = MessageDeliveryStatus.NotSent;
}

public MessageRequest(ManualMessage manualMessage, MessageReceiver messageReceiver, DateTime scheduledDateTime) {
this.manualMessage = manualMessage;
this.messageReceiver = messageReceiver;
this.setScheduledDateTime(scheduledDateTime);
this.scheduledDateTime = scheduledDateTime;
this.deliveryStatus = MessageDeliveryStatus.NotSent;
}

public void markComplete() {
deliveryStatus = MessageDeliveryStatus.Sent;
setDeliveredDateTime(DateTime.now());
deliveredDateTime = DateTime.now();
}

public MessageRule getMessageRule() {
Expand All @@ -100,15 +97,15 @@ public Long getEntityId() {
}

public DateTime getScheduledDateTime() {
return DateTimeUtil.toJodaDateTime(scheduledDateTime);
return scheduledDateTime;
}

public MessageDeliveryStatus getDeliveryStatus() {
return deliveryStatus;
}

public DateTime getDeliveredDateTime() {
return DateTimeUtil.toJodaDateTime(deliveredDateTime);
return deliveredDateTime;
}

public boolean isDelivered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,24 @@
import org.avni.messaging.domain.MessageRule;
import org.avni.server.dao.CHSRepository;
import org.avni.server.framework.security.UserContextHolder;
import org.avni.server.util.DateTimeUtil;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import java.util.Date;
import java.util.Optional;
import java.util.stream.Stream;

@Repository
public interface MessageRequestQueueRepository extends CHSRepository<MessageRequest> {

Stream<MessageRequest> findAllByDeliveryStatusNotAndIsVoidedFalseAndScheduledDateTimeBetween(MessageDeliveryStatus messageDeliveryStatus, Instant then, Instant now);
Stream<MessageRequest> findAllByDeliveryStatusNotAndIsVoidedFalseAndScheduledDateTimeBetween(MessageDeliveryStatus messageDeliveryStatus, DateTime then, DateTime now);
Optional<MessageRequest> findByEntityIdAndMessageRule(Long entityId, MessageRule messageRule);

default Stream<MessageRequest> findDueMessageRequests(Duration duration) {
return findAllByDeliveryStatusNotAndIsVoidedFalseAndScheduledDateTimeBetween(MessageDeliveryStatus.Sent,
DateTimeUtil.toInstant(DateTime.now().minus(duration)), DateTimeUtil.toInstant(DateTime.now()));
return findAllByDeliveryStatusNotAndIsVoidedFalseAndScheduledDateTimeBetween(MessageDeliveryStatus.Sent, DateTime.now().minus(duration), DateTime.now());
}

@Modifying(clearAutomatically = true, flushAutomatically=true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Repository;

import java.time.Instant;

@Repository
@RepositoryRestResource(collectionResourceRel = "approvalStatus", path = "approvalStatus")
public interface ApprovalStatusRepository extends AvniJpaRepository<ApprovalStatus, Long> {
@RestResource(path = "lastModified", rel = "lastModified")
Page<ApprovalStatus> findByLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant now,
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime now,
Pageable pageable);

ApprovalStatus findByUuid(String uuid);

ApprovalStatus findByStatus(ApprovalStatus.Status status);

boolean existsByLastModifiedDateTimeGreaterThan(Instant lastModifiedDateTime);
boolean existsByLastModifiedDateTimeGreaterThan(DateTime lastModifiedDateTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import jakarta.persistence.criteria.*;
import org.avni.server.domain.CHSEntity;
import org.avni.server.domain.Concept;
import org.avni.server.util.DateTimeUtil;
import org.joda.time.DateTime;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.repository.NoRepositoryBean;

import java.time.Instant;
import jakarta.persistence.criteria.*;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -47,7 +47,7 @@ default Expression<String> convertToDate(Path<?> path, CriteriaBuilder cb) {
return cb.function("TO_CHAR", String.class, path, cb.literal("yyyy-MM-dd"));
}

default Specification lastModifiedBetween(Instant lastModifiedDateTime, Instant now) {
default Specification lastModifiedBetween(Date lastModifiedDateTime, Date now) {
Specification<T> spec = (Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
List<Predicate> predicates = new ArrayList<>();

Expand All @@ -62,10 +62,6 @@ default Specification lastModifiedBetween(Instant lastModifiedDateTime, Instant
return spec;
}

default Specification lastModifiedBetween(Date lastModifiedDateTime, Date now) {
return this.lastModifiedBetween(DateTimeUtil.toInstant(lastModifiedDateTime), DateTimeUtil.toInstant(now));
}

default Specification withConceptValues(Map<Concept, String> concepts, String observationField) {
Specification<T> spec = (Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) -> {
List<Predicate> predicates = new ArrayList<>();
Expand All @@ -84,9 +80,9 @@ default void voidEntity(Long id) {
this.save(entity);
}

boolean existsByLastModifiedDateTimeGreaterThan(Instant lastModifiedDateTime);
boolean existsByLastModifiedDateTimeGreaterThan(Date lastModifiedDateTime);

default boolean existsByLastModifiedDateTimeGreaterThan(DateTime lastModifiedDateTime) {
return existsByLastModifiedDateTimeGreaterThan(DateTimeUtil.toInstant(lastModifiedDateTime));
return existsByLastModifiedDateTimeGreaterThan(lastModifiedDateTime == null ? null : lastModifiedDateTime.toDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

import jakarta.persistence.criteria.*;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -21,7 +23,7 @@
public interface ChecklistItemRepository extends TransactionalDataRepository<ChecklistItem>, OperatingIndividualScopeAwareRepository<ChecklistItem>, SubjectTreeItemRepository {

Page<ChecklistItem> findByChecklistProgramEnrolmentIndividualAddressLevelVirtualCatchmentsIdAndLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
long catchmentId, Instant lastModifiedDateTime, Instant now, Pageable pageable);
long catchmentId, Date lastModifiedDateTime, Date now, Pageable pageable);

ChecklistItem findByChecklistUuidAndChecklistItemDetailUuid(String checklistUUID, String checklistItemDetailUUID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import jakarta.persistence.criteria.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
Expand All @@ -21,7 +22,7 @@
public interface ChecklistRepository extends TransactionalDataRepository<Checklist>, OperatingIndividualScopeAwareRepository<Checklist>, SubjectTreeItemRepository {

Page<Checklist> findByProgramEnrolmentIndividualAddressLevelVirtualCatchmentsIdAndLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
long catchmentId, Instant lastModifiedDateTime, Instant now, Pageable pageable);
long catchmentId, Date lastModifiedDateTime, Date now, Pageable pageable);

Checklist findByProgramEnrolmentId(long programEnrolmentId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import jakarta.persistence.criteria.*;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
Expand All @@ -23,10 +24,10 @@
@RepositoryRestResource(collectionResourceRel = "encounter", path = "encounter", exported = false)
public interface EncounterRepository extends TransactionalDataRepository<Encounter>, OperatingIndividualScopeAwareRepository<Encounter>, SubjectTreeItemRepository {
Page<Encounter> findByLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
Instant lastModifiedDateTime, Instant now, Pageable pageable);
Date lastModifiedDateTime, Date now, Pageable pageable);

Page<Encounter> findByIndividualAddressLevelVirtualCatchmentsIdAndLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
long catchmentId, Instant lastModifiedDateTime, Instant now, Pageable pageable);
long catchmentId, Date lastModifiedDateTime, Date now, Pageable pageable);

@Override
default Specification<Encounter> syncTypeIdSpecification(Long typeId) {
Expand Down Expand Up @@ -82,13 +83,12 @@ default Specification<Encounter> withIndividualId(Long id) {

default Specification<Encounter> withEncounterEarliestVisitDateTime(DateTime earliestVisitDateTime) {
return (Root<Encounter> root, CriteriaQuery<?> query, CriteriaBuilder cb) ->
earliestVisitDateTime == null ? null : cb.equal(root.get("earliestVisitDateTime").as(Instant.class), DateTimeUtil.toInstant(earliestVisitDateTime));
earliestVisitDateTime == null ? null : cb.equal(root.get("earliestVisitDateTime").as(java.sql.Date.class), earliestVisitDateTime.toDate());
}

default Specification<Encounter> withEncounterDateTime(DateTime encounterDateTime) {
return (Root<Encounter> root, CriteriaQuery<?> query, CriteriaBuilder cb) ->
encounterDateTime == null ? null : cb.equal(root.get("encounterDateTime").as(Instant.class),
DateTimeUtil.toInstant(encounterDateTime));
encounterDateTime == null ? null : cb.equal(root.get("encounterDateTime").as(java.sql.Date.class), encounterDateTime.toDate());
}

default Specification<Encounter> withNotNullEncounterDateTime() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.Instant;
import java.util.Date;

/*
* This is a marker interface for all the repositories that are used to fetch entities with old endpoints that do not serve new data after configured date.
Expand All @@ -20,7 +20,7 @@
public interface EndOfLife1EndpointRepository<T extends CHSEntity> {
@RestResource(path = "lastModified", rel = "lastModified")
Page<T> findByLastModifiedDateTimeIsGreaterThanEqualAndLastModifiedDateTimeLessThanEqualOrderByLastModifiedDateTimeAscIdAsc(
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant now,
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date now,
Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Repository;

import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Repository
Expand All @@ -35,8 +35,8 @@ public interface EntityApprovalStatusRepository extends TransactionalDataReposit
@PreAuthorize("hasAnyAuthority('user')")
@RestResource(path = "lastModified", rel = "lastModified")
Page<EntityApprovalStatus> findByLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant now,
@Param("lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date lastModifiedDateTime,
@Param("now") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date now,
Pageable pageable);

default Page<EntityApprovalStatus> findEntityApprovalStatuses(EntityApprovalStatusSearchParams searchParams, Pageable pageable) {
Expand Down
Loading

0 comments on commit 067b27a

Please sign in to comment.