Skip to content

Commit

Permalink
Java docs added
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazariii committed Nov 2, 2015
1 parent a9c2127 commit 4614e95
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public interface OrganizationRepository extends CrudRepository<Organization, Lon
List<Organization> 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)) ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@

@Repository
public interface RegionRepository extends CrudRepository<Region, Long> {

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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
public class SearchCriterion<T extends Enum<T>> {
private String key;
private String entityField;
private String additionKey;
private Operator operation;
private String additionKey;
private ValueType valueType;
private String joinEntityField;
private Class<T> 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<T> enumKeyType, String additionKey, ValueType valueType, String joinEntityField) {
Expand All @@ -38,44 +37,40 @@ 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<T> enumKeyType) {
this(key, entityField, operation, enumKeyType, null, null, null);
}

/**
*
* @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) {
this(key, entityField, operation, null, null, valueType, joinEntityField);
}

/**
*
* @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) {
Expand All @@ -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
*/
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ void editOrganization(Long organizationId, String name, String phone, String ema

Set<Device.DeviceType> 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<Organization> findByOrganizationTypeAndDeviceType( OrganizationType organizationType, Device.DeviceType deviceType);

Set<Organization> findByIdAndTypeAndActiveAgreementDeviceType( Long customerId, OrganizationType organizationType, Device.DeviceType deviceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ public Set<Device.DeviceType> 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<Organization> findByOrganizationTypeAndDeviceType(OrganizationType organizationType, Device.DeviceType deviceType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ public interface LocalityService {

Locality findById(Long id);

List<Locality> findByDistrictIdAndOrganizationId( Long districtId, Long organizationId);

List<Locality> findByDistrictIdAndOrganizationId(Long districtId, Long organizationId);

/**
* Finds all localities by organization id
*
* @param organizationId id of organizaton
* @return list of localities
*/
List<Locality> findLocalitiesByOrganizationId(Long organizationId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 4614e95

Please sign in to comment.