From 4ca67b4798640c1cd05761133b322d1d9e530214 Mon Sep 17 00:00:00 2001 From: Nazariii Date: Mon, 2 Nov 2015 18:49:57 +0200 Subject: [PATCH] Added deprecated annotation to classes --- ...hivalCounterTypeQueryConstructorAdmin.java | 6 + ...lDevicesCategoryQueryConstructorAdmin.java | 6 + ...ArchivalEmployeeQueryConstructorAdmin.java | 6 + ...valOrganizationsQueryConstructorAdmin.java | 6 + ...rificationsQueryConstructorCalibrator.java | 6 + ...VerificationsQueryConstructorProvider.java | 6 + ...ificationsQueryConstructorVerificator.java | 208 +++++++++--------- ...brationTestQueryConstructorCalibrator.java | 7 +- ...rificationsQueryConstructorCalibrator.java | 7 +- ...VerificationsQueryConstructorProvider.java | 7 +- ...ificationsQueryConstructorVerificator.java | 7 +- .../service/utils/ProviderEmployeeQuery.java | 6 +- 12 files changed, 171 insertions(+), 107 deletions(-) diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalCounterTypeQueryConstructorAdmin.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalCounterTypeQueryConstructorAdmin.java index 391177c22..1a40fcd4c 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalCounterTypeQueryConstructorAdmin.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalCounterTypeQueryConstructorAdmin.java @@ -9,6 +9,12 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalCounterTypeQueryConstructorAdmin { static Logger logger = Logger.getLogger(ArchivalCounterTypeQueryConstructorAdmin.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalDevicesCategoryQueryConstructorAdmin.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalDevicesCategoryQueryConstructorAdmin.java index 5c2fe1d7a..dcc8963d7 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalDevicesCategoryQueryConstructorAdmin.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalDevicesCategoryQueryConstructorAdmin.java @@ -6,6 +6,12 @@ import javax.persistence.EntityManager; import javax.persistence.criteria.*; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalDevicesCategoryQueryConstructorAdmin { static Logger logger = Logger.getLogger(ArchivalDevicesCategoryQueryConstructorAdmin.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalEmployeeQueryConstructorAdmin.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalEmployeeQueryConstructorAdmin.java index 81b5e8570..234f65448 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalEmployeeQueryConstructorAdmin.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalEmployeeQueryConstructorAdmin.java @@ -9,6 +9,12 @@ import javax.persistence.EntityManager; import javax.persistence.criteria.*; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalEmployeeQueryConstructorAdmin { static Logger logger = Logger.getLogger(ArchivalEmployeeQueryConstructorAdmin.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalOrganizationsQueryConstructorAdmin.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalOrganizationsQueryConstructorAdmin.java index 6d476f355..6d2707e70 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalOrganizationsQueryConstructorAdmin.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalOrganizationsQueryConstructorAdmin.java @@ -9,6 +9,12 @@ import javax.persistence.criteria.*; import javax.print.DocFlavor; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalOrganizationsQueryConstructorAdmin { static Logger logger = Logger.getLogger(ArchivalOrganizationsQueryConstructorAdmin.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorCalibrator.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorCalibrator.java index 70c2d0630..225e78cbf 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorCalibrator.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorCalibrator.java @@ -13,6 +13,12 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalVerificationsQueryConstructorCalibrator { static Logger logger = Logger.getLogger(ArchivalVerificationsQueryConstructorProvider.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorProvider.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorProvider.java index 6ec7627d1..3b0fed2bd 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorProvider.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorProvider.java @@ -11,6 +11,12 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalVerificationsQueryConstructorProvider { static Logger logger = Logger.getLogger(ArchivalVerificationsQueryConstructorProvider.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorVerificator.java b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorVerificator.java index 43339c59e..174ab3592 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorVerificator.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ArchivalVerificationsQueryConstructorVerificator.java @@ -13,106 +13,112 @@ import java.util.Calendar; import java.util.Date; +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class ArchivalVerificationsQueryConstructorVerificator { -static Logger logger = Logger.getLogger(ArchivalVerificationsQueryConstructorProvider.class); - - - public static CriteriaQuery buildSearchQuery(Long employeeId, String dateToSearch, - String idToSearch, String fullNameToSearch, String streetToSearch, String status, String employeeName, - String sortCriteria, String sortOrder, User providerEmployee, EntityManager em) { - - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery criteriaQuery = cb.createQuery(Verification.class); - Root root = criteriaQuery.from(Verification.class); - Join calibratorJoin = root.join("stateVerificator"); - - Predicate predicate = ArchivalVerificationsQueryConstructorVerificator.buildPredicate(root, cb, employeeId, dateToSearch, idToSearch, - fullNameToSearch, streetToSearch, status, employeeName, providerEmployee, calibratorJoin); - if((sortCriteria != null)&&(sortOrder != null)) { - criteriaQuery.orderBy(SortCriteriaVerification.valueOf(sortCriteria.toUpperCase()).getSortOrder(root, cb, sortOrder)); - } else { - criteriaQuery.orderBy(cb.desc(root.get("initialDate"))); - } - criteriaQuery.select(root); - criteriaQuery.where(predicate); - return criteriaQuery; - } - - - public static CriteriaQuery buildCountQuery(Long employeeId, String dateToSearch, - String idToSearch, String fullNameToSearch, String streetToSearch, String status, String employeeName, - User providerEmployee, EntityManager em) { - - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery countQuery = cb.createQuery(Long.class); - Root root = countQuery.from(Verification.class); - Join verificatorJoin = root.join("stateVerificator"); - Predicate predicate = ArchivalVerificationsQueryConstructorVerificator.buildPredicate(root, cb, employeeId, dateToSearch, idToSearch, - fullNameToSearch, streetToSearch, status, employeeName, providerEmployee - , verificatorJoin); - countQuery.select(cb.count(root)); - countQuery.where(predicate); - return countQuery; - } - - private static Predicate buildPredicate(Root root, CriteriaBuilder cb, Long employeeId, String dateToSearch, String idToSearch, - String fullNameToSearch, String streetToSearch, String searchStatus, - String employeeName, User employee, Join verificatorJoin) { - - Predicate queryPredicate = cb.conjunction(); - queryPredicate = cb.and(cb.equal(verificatorJoin.get("id"), employeeId), queryPredicate); - - if (searchStatus != null) { - queryPredicate = cb.and(cb.equal(root.get("status"), Status.valueOf(searchStatus.trim())), queryPredicate); - } - - if (dateToSearch != null) { - Date date = null; - try { - date = new SimpleDateFormat("yyyy-MM-dd").parse(dateToSearch.substring(0, 10)); - Calendar c = Calendar.getInstance(); - c.setTime(date); - c.add(Calendar.DATE, 1); - date = c.getTime(); - } catch (ParseException pe) { - logger.error("Cannot parse date", pe); - } - queryPredicate = cb.and(cb.equal(root.get("initialDate"), date), queryPredicate); - } - - if ((idToSearch != null)&&(idToSearch.length()>0)) { - queryPredicate = cb.and(cb.like(root.get("id"), "%" + idToSearch + "%"), queryPredicate); - } - if ((fullNameToSearch != null)&&(fullNameToSearch.length()>0)) { - queryPredicate = cb.and(cb.like(root.get("clientData").get("lastName"), "%" + fullNameToSearch + "%"), - queryPredicate); - } - if ((fullNameToSearch != null)&&(fullNameToSearch.length()>0)) { - Predicate searchByClientFirstName = cb.like(root.get("clientData").get("firstName"), "%" + fullNameToSearch + "%"); - Predicate searchByClientLastName = cb.like(root.get("clientData").get("lastName"), "%" + fullNameToSearch + "%"); - Predicate searchByClientMiddleName = cb.like(root.get("clientData").get("middleName"), "%" + fullNameToSearch + "%"); - Predicate searchPredicateByClientFullName = cb.or(searchByClientFirstName, searchByClientLastName, searchByClientMiddleName); - queryPredicate = cb.and(searchPredicateByClientFullName, queryPredicate); - } - - if ((streetToSearch != null)&&(streetToSearch.length()>0)) { - queryPredicate = cb.and( - cb.like(root.get("clientData").get("clientAddress").get("street"), "%" + streetToSearch + "%"), - queryPredicate); - } - if ((employeeName != null)&&(employeeName.length()>0)) { - Join joinVerificatorEmployee = root.join("stateVerificatorEmployee"); - Predicate searchByVerificatorName = cb.like(joinVerificatorEmployee.get("firstName"), - "%" + employeeName + "%"); - Predicate searchByVerificatorSurname = cb.like(joinVerificatorEmployee.get("lastName"), - "%" + employeeName + "%"); - Predicate searchByVerificatorLastName = cb.like(joinVerificatorEmployee.get("middleName"), - "%" + employeeName + "%"); - Predicate searchPredicateByVerificatorEmployeeName = cb.or(searchByVerificatorName, - searchByVerificatorSurname, searchByVerificatorLastName); - queryPredicate = cb.and(searchPredicateByVerificatorEmployeeName, queryPredicate); - } - - return queryPredicate; - } + static Logger logger = Logger.getLogger(ArchivalVerificationsQueryConstructorProvider.class); + + + public static CriteriaQuery buildSearchQuery(Long employeeId, String dateToSearch, + String idToSearch, String fullNameToSearch, String streetToSearch, String status, String employeeName, + String sortCriteria, String sortOrder, User providerEmployee, EntityManager em) { + + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery criteriaQuery = cb.createQuery(Verification.class); + Root root = criteriaQuery.from(Verification.class); + Join calibratorJoin = root.join("stateVerificator"); + + Predicate predicate = ArchivalVerificationsQueryConstructorVerificator.buildPredicate(root, cb, employeeId, dateToSearch, idToSearch, + fullNameToSearch, streetToSearch, status, employeeName, providerEmployee, calibratorJoin); + if ((sortCriteria != null) && (sortOrder != null)) { + criteriaQuery.orderBy(SortCriteriaVerification.valueOf(sortCriteria.toUpperCase()).getSortOrder(root, cb, sortOrder)); + } else { + criteriaQuery.orderBy(cb.desc(root.get("initialDate"))); + } + criteriaQuery.select(root); + criteriaQuery.where(predicate); + return criteriaQuery; + } + + + public static CriteriaQuery buildCountQuery(Long employeeId, String dateToSearch, + String idToSearch, String fullNameToSearch, String streetToSearch, String status, String employeeName, + User providerEmployee, EntityManager em) { + + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery countQuery = cb.createQuery(Long.class); + Root root = countQuery.from(Verification.class); + Join verificatorJoin = root.join("stateVerificator"); + Predicate predicate = ArchivalVerificationsQueryConstructorVerificator.buildPredicate(root, cb, employeeId, dateToSearch, idToSearch, + fullNameToSearch, streetToSearch, status, employeeName, providerEmployee + , verificatorJoin); + countQuery.select(cb.count(root)); + countQuery.where(predicate); + return countQuery; + } + + private static Predicate buildPredicate(Root root, CriteriaBuilder cb, Long employeeId, String dateToSearch, String idToSearch, + String fullNameToSearch, String streetToSearch, String searchStatus, + String employeeName, User employee, Join verificatorJoin) { + + Predicate queryPredicate = cb.conjunction(); + queryPredicate = cb.and(cb.equal(verificatorJoin.get("id"), employeeId), queryPredicate); + + if (searchStatus != null) { + queryPredicate = cb.and(cb.equal(root.get("status"), Status.valueOf(searchStatus.trim())), queryPredicate); + } + + if (dateToSearch != null) { + Date date = null; + try { + date = new SimpleDateFormat("yyyy-MM-dd").parse(dateToSearch.substring(0, 10)); + Calendar c = Calendar.getInstance(); + c.setTime(date); + c.add(Calendar.DATE, 1); + date = c.getTime(); + } catch (ParseException pe) { + logger.error("Cannot parse date", pe); + } + queryPredicate = cb.and(cb.equal(root.get("initialDate"), date), queryPredicate); + } + + if ((idToSearch != null) && (idToSearch.length() > 0)) { + queryPredicate = cb.and(cb.like(root.get("id"), "%" + idToSearch + "%"), queryPredicate); + } + if ((fullNameToSearch != null) && (fullNameToSearch.length() > 0)) { + queryPredicate = cb.and(cb.like(root.get("clientData").get("lastName"), "%" + fullNameToSearch + "%"), + queryPredicate); + } + if ((fullNameToSearch != null) && (fullNameToSearch.length() > 0)) { + Predicate searchByClientFirstName = cb.like(root.get("clientData").get("firstName"), "%" + fullNameToSearch + "%"); + Predicate searchByClientLastName = cb.like(root.get("clientData").get("lastName"), "%" + fullNameToSearch + "%"); + Predicate searchByClientMiddleName = cb.like(root.get("clientData").get("middleName"), "%" + fullNameToSearch + "%"); + Predicate searchPredicateByClientFullName = cb.or(searchByClientFirstName, searchByClientLastName, searchByClientMiddleName); + queryPredicate = cb.and(searchPredicateByClientFullName, queryPredicate); + } + + if ((streetToSearch != null) && (streetToSearch.length() > 0)) { + queryPredicate = cb.and( + cb.like(root.get("clientData").get("clientAddress").get("street"), "%" + streetToSearch + "%"), + queryPredicate); + } + if ((employeeName != null) && (employeeName.length() > 0)) { + Join joinVerificatorEmployee = root.join("stateVerificatorEmployee"); + Predicate searchByVerificatorName = cb.like(joinVerificatorEmployee.get("firstName"), + "%" + employeeName + "%"); + Predicate searchByVerificatorSurname = cb.like(joinVerificatorEmployee.get("lastName"), + "%" + employeeName + "%"); + Predicate searchByVerificatorLastName = cb.like(joinVerificatorEmployee.get("middleName"), + "%" + employeeName + "%"); + Predicate searchPredicateByVerificatorEmployeeName = cb.or(searchByVerificatorName, + searchByVerificatorSurname, searchByVerificatorLastName); + queryPredicate = cb.and(searchPredicateByVerificatorEmployeeName, queryPredicate); + } + + return queryPredicate; + } } diff --git a/service/src/main/java/com/softserve/edu/service/utils/CalibrationTestQueryConstructorCalibrator.java b/service/src/main/java/com/softserve/edu/service/utils/CalibrationTestQueryConstructorCalibrator.java index 2b8a14a8a..eba36ab80 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/CalibrationTestQueryConstructorCalibrator.java +++ b/service/src/main/java/com/softserve/edu/service/utils/CalibrationTestQueryConstructorCalibrator.java @@ -12,7 +12,12 @@ import java.time.LocalDate; import java.time.format.DateTimeFormatter; - +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class CalibrationTestQueryConstructorCalibrator { static Logger logger = Logger.getLogger(CalibrationTestQueryConstructorCalibrator.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorCalibrator.java b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorCalibrator.java index f20198191..906bd79d4 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorCalibrator.java +++ b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorCalibrator.java @@ -13,7 +13,12 @@ import java.time.format.DateTimeFormatter; import java.util.Set; - + /** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ + @Deprecated public class NewVerificationsQueryConstructorCalibrator { static Logger logger = Logger.getLogger(NewVerificationsQueryConstructorProvider.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorProvider.java b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorProvider.java index 49b60e289..5c706c85d 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorProvider.java +++ b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorProvider.java @@ -13,7 +13,12 @@ import java.time.format.DateTimeFormatter; import java.util.Set; - +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class NewVerificationsQueryConstructorProvider { static Logger logger = Logger.getLogger(NewVerificationsQueryConstructorProvider.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorVerificator.java b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorVerificator.java index 67d92f166..4591af964 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorVerificator.java +++ b/service/src/main/java/com/softserve/edu/service/utils/NewVerificationsQueryConstructorVerificator.java @@ -22,7 +22,12 @@ import com.softserve.edu.entity.enumeration.user.UserRole; import com.softserve.edu.entity.enumeration.verification.Status; - +/** + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead + */ +@Deprecated public class NewVerificationsQueryConstructorVerificator { static Logger logger = Logger.getLogger(NewVerificationsQueryConstructorVerificator.class); diff --git a/service/src/main/java/com/softserve/edu/service/utils/ProviderEmployeeQuery.java b/service/src/main/java/com/softserve/edu/service/utils/ProviderEmployeeQuery.java index 01993de67..d9c0a8818 100644 --- a/service/src/main/java/com/softserve/edu/service/utils/ProviderEmployeeQuery.java +++ b/service/src/main/java/com/softserve/edu/service/utils/ProviderEmployeeQuery.java @@ -8,10 +8,12 @@ import javax.persistence.EntityManager; import javax.persistence.criteria.*; - /** - * Created by MAX on 11.07.2015. + * @deprecated this class have a lot of repeated code
+ * {need to be replaced and removed}
+ * use {@link com.softserve.edu.specification.SpecificationBuilder} instead */ +@Deprecated public class ProviderEmployeeQuery { static Logger logger = Logger.getLogger(ArchivalVerificationsQueryConstructorProvider.class);