Skip to content

Commit

Permalink
#648 - applied to location query
Browse files Browse the repository at this point in the history
(cherry picked from commit f378e3a)
  • Loading branch information
petmongrels authored and himeshr committed Nov 27, 2023
1 parent 4201614 commit d0fff59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.avni.server.domain.AddressLevel;
import org.avni.server.domain.AddressLevelType;
import org.avni.server.domain.Catchment;
import org.avni.server.framework.security.UserContextHolder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
Expand Down Expand Up @@ -131,9 +132,13 @@ default AddressLevel findChildLocation(AddressLevel parent, String title) {
return this.findByParentAndTitleIgnoreCaseAndIsVoidedFalse(parent, title);
}

@Query("select a from AddressLevel a where a.uuid =:id or a.legacyId = :id")
@Query("select a from AddressLevel a where (a.uuid =?1 or a.legacyId = ?1) and a.organisationId = ?2")
@QueryHints({@QueryHint(name = org.hibernate.jpa.QueryHints.HINT_CACHEABLE, value = "true")})
AddressLevel findByLegacyIdOrUuid(String id);
AddressLevel findByLegacyIdOrUuidAndOrgId(String id, Long organisationId);

default AddressLevel findByLegacyIdOrUuid(String id) {
return this.findByLegacyIdOrUuidAndOrgId(id, UserContextHolder.getUserContext().getOrganisationId());
}

@Query(value = "select al.*\n" +
"from address_level al\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static SubjectTypeContractWeb fromOperationalSubjectType(OperationalSubje
contract.setSyncRegistrationConcept2Usable(subjectType.isSyncRegistrationConcept2Usable());
contract.setNameHelpText(subjectType.getNameHelpText());
contract.setSubjectTypeId(subjectType.getId());
contract.setEnableRegistrationApproval(formMapping.isEnableApproval());
if (formMapping != null)
contract.setEnableRegistrationApproval(formMapping.isEnableApproval());

return contract;
}
Expand Down

0 comments on commit d0fff59

Please sign in to comment.