diff --git a/repository/src/main/java/com/softserve/edu/repository/OrganizationRepository.java b/repository/src/main/java/com/softserve/edu/repository/OrganizationRepository.java index e9376503c..3c9bcf9c8 100644 --- a/repository/src/main/java/com/softserve/edu/repository/OrganizationRepository.java +++ b/repository/src/main/java/com/softserve/edu/repository/OrganizationRepository.java @@ -58,10 +58,10 @@ public interface OrganizationRepository extends CrudRepository findOrganizationByLocalityIdAndType(@Param("localityId") Long localityId, @Param("organizationType") OrganizationType organizationType); /** - * Find all organizations in selected and organization type - * - * @param organizationType - * @return + * Find all organizations by organization types and device types + * @param organizationType type of organization + * @param deviceType type of device + * @return list of organization */ @Query("SELECT org FROM Organization org " + "WHERE ( :organizationType in elements(org.organizationTypes)) AND ( :deviceType in elements(org.deviceTypes)) ") diff --git a/repository/src/main/java/com/softserve/edu/repository/catalogue/RegionRepository.java b/repository/src/main/java/com/softserve/edu/repository/catalogue/RegionRepository.java index 5c379af41..49a5dcc13 100644 --- a/repository/src/main/java/com/softserve/edu/repository/catalogue/RegionRepository.java +++ b/repository/src/main/java/com/softserve/edu/repository/catalogue/RegionRepository.java @@ -9,8 +9,14 @@ @Repository public interface RegionRepository extends CrudRepository { + Region findByDesignation(String designation); + /** + * Find region by district id + * @param districtId id of district + * @return region + */ @Query("SELECT region FROM District district INNER JOIN district.region region WHERE district.id=:districtId") Region findByDistrictId(@Param("districtId") Long districtId); } diff --git a/repository/src/main/java/com/softserve/edu/specification/SearchCriterion.java b/repository/src/main/java/com/softserve/edu/specification/SearchCriterion.java index 72a4c4dbe..bd75bd7f6 100644 --- a/repository/src/main/java/com/softserve/edu/specification/SearchCriterion.java +++ b/repository/src/main/java/com/softserve/edu/specification/SearchCriterion.java @@ -11,20 +11,19 @@ public class SearchCriterion> { private String key; private String entityField; - private String additionKey; private Operator operation; + private String additionKey; private ValueType valueType; private String joinEntityField; private Class enumKeyType; /** - * - * @param key key to filter - * @param entityField name of corresponding entity field - * @param operation type of operation - * @param enumKeyType type of Enum, if entity field is Enum - * @param additionKey addition key to filter (e.g: for between operation) - * @param valueType type of key value + * @param key key to filter + * @param entityField name of corresponding entity field + * @param operation type of operation + * @param enumKeyType type of Enum, if entity field is Enum + * @param additionKey addition key to filter (e.g: for between operation) + * @param valueType type of key value * @param joinEntityField name of entity field that need to be accessed by join if need to make join on entityField */ public SearchCriterion(String key, String entityField, Operator operation, Class enumKeyType, String additionKey, ValueType valueType, String joinEntityField) { @@ -38,10 +37,9 @@ public SearchCriterion(String key, String entityField, Operator operation, Class } /** - * - * @param key key to filter + * @param key key to filter * @param entityField name of corresponding entity field - * @param operation type of operation + * @param operation type of operation * @param enumKeyType type of Enum, if entity field is Enum */ public SearchCriterion(String key, String entityField, Operator operation, Class enumKeyType) { @@ -49,22 +47,20 @@ public SearchCriterion(String key, String entityField, Operator operation, Class } /** - * - * @param key key to filter + * @param key key to filter * @param entityField name of corresponding entity field - * @param operation type of operation - * @param valueType type of key value + * @param operation type of operation + * @param valueType type of key value */ public SearchCriterion(String key, String entityField, Operator operation, ValueType valueType) { this(key, entityField, operation, null, null, valueType, null); } /** - * - * @param key key to filter - * @param entityField name of corresponding entity field - * @param operation type of operation - * @param valueType type of key value + * @param key key to filter + * @param entityField name of corresponding entity field + * @param operation type of operation + * @param valueType type of key value * @param joinEntityField name of entity field that need to be accessed by join if need to make join on entityField */ public SearchCriterion(String key, String entityField, Operator operation, ValueType valueType, String joinEntityField) { @@ -72,10 +68,9 @@ public SearchCriterion(String key, String entityField, Operator operation, Value } /** - * - * @param key key to filter + * @param key key to filter * @param entityField name of corresponding entity field - * @param operation type of operation + * @param operation type of operation * @param additionKey addition key to filter (e.g: for between operation) */ public SearchCriterion(String key, String entityField, Operator operation, String additionKey) { @@ -84,6 +79,7 @@ public SearchCriterion(String key, String entityField, Operator operation, Strin /** * Get Enum from value by enumKeyType class + * * @param key value that converts to corresponding enum * @return Enum of enumKeyType class */ @@ -95,7 +91,7 @@ public T getEnum(String key) { * */ public enum Operator { - EQUAL, EQUAL_BY_ENUM, BETWEEN_DATE, LIKE + EQUAL, EQUAL_BY_ENUM, BETWEEN_DATE, LIKE } public enum ValueType { diff --git a/service/src/main/java/com/softserve/edu/service/admin/OrganizationService.java b/service/src/main/java/com/softserve/edu/service/admin/OrganizationService.java index 2203b1289..1cc5a2572 100644 --- a/service/src/main/java/com/softserve/edu/service/admin/OrganizationService.java +++ b/service/src/main/java/com/softserve/edu/service/admin/OrganizationService.java @@ -46,6 +46,12 @@ void editOrganization(Long organizationId, String name, String phone, String ema Set findDeviceTypesByOrganizationId( Long organizationId); + /** + * Find all organizations by organization types and device types + * @param organizationType type of organization + * @param deviceType type of device + * @return list of organization + */ List findByOrganizationTypeAndDeviceType( OrganizationType organizationType, Device.DeviceType deviceType); Set findByIdAndTypeAndActiveAgreementDeviceType( Long customerId, OrganizationType organizationType, Device.DeviceType deviceType); diff --git a/service/src/main/java/com/softserve/edu/service/admin/impl/OrganizationServiceImpl.java b/service/src/main/java/com/softserve/edu/service/admin/impl/OrganizationServiceImpl.java index 0086b2279..95d57ea45 100644 --- a/service/src/main/java/com/softserve/edu/service/admin/impl/OrganizationServiceImpl.java +++ b/service/src/main/java/com/softserve/edu/service/admin/impl/OrganizationServiceImpl.java @@ -294,6 +294,12 @@ public Set findDeviceTypesByOrganizationId(Long organizationI return organizationRepository.findDeviceTypesByOrganizationId(organizationId); } + /** + * Find all organizations by organization types and device types + * @param organizationType type of organization + * @param deviceType type of device + * @return list of organization + */ @Override @Transactional(readOnly = true) public List findByOrganizationTypeAndDeviceType(OrganizationType organizationType, Device.DeviceType deviceType) { diff --git a/service/src/main/java/com/softserve/edu/service/catalogue/LocalityService.java b/service/src/main/java/com/softserve/edu/service/catalogue/LocalityService.java index 07ca48599..ad668de49 100644 --- a/service/src/main/java/com/softserve/edu/service/catalogue/LocalityService.java +++ b/service/src/main/java/com/softserve/edu/service/catalogue/LocalityService.java @@ -12,8 +12,14 @@ public interface LocalityService { Locality findById(Long id); - List findByDistrictIdAndOrganizationId( Long districtId, Long organizationId); - + List findByDistrictIdAndOrganizationId(Long districtId, Long organizationId); + + /** + * Finds all localities by organization id + * + * @param organizationId id of organizaton + * @return list of localities + */ List findLocalitiesByOrganizationId(Long organizationId); } \ No newline at end of file diff --git a/service/src/main/java/com/softserve/edu/service/catalogue/RegionService.java b/service/src/main/java/com/softserve/edu/service/catalogue/RegionService.java index 6891cfd20..beea5b05e 100644 --- a/service/src/main/java/com/softserve/edu/service/catalogue/RegionService.java +++ b/service/src/main/java/com/softserve/edu/service/catalogue/RegionService.java @@ -8,5 +8,10 @@ public interface RegionService { Region getRegionByDesignation(String designation); + /** + * Find region by district id + * @param districtId id of district + * @return region + */ Region findByDistrictId(Long districtId); }