List of usage examples for com.liferay.portal.kernel.dao.orm Session close
public Connection close() throws ORMException;
From source file:org.opencps.accountmgt.service.persistence.BusinessFinderImpl.java
License:Open Source License
/** * @param groupId//w ww .j a va2s.c om * @param keywords * @param accountStatus * @param andOperator * @param businessDomain * @param start * @param end * @return */ private List<Business> _searchBusiness(long groupId, String keywords, int accountStatus, String businessDomain, int start, int end) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(SEARCH_BUSINESS); if (Validator.isNull(groupId)) { sql = sql.replace("AND (opencps_acc_business.groupId = ?)", StringPool.BLANK); } if (accountStatus == -1) { sql = sql.replace("AND (opencps_acc_business.accountStatus = ?)", StringPool.BLANK); } if (Validator.isNull(keywords)) { sql = sql.replace("AND ((lower(opencps_acc_business.name) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.shortName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.enName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.email) LIKE ?))", StringPool.BLANK); } if (Validator.isNull(businessDomain)) { sql = sql.replace( "INNER JOIN " + "opencps_acc_businessdomain " + "ON " + "opencps_acc_business.businessId = opencps_acc_businessdomain.businessId", StringPool.BLANK); sql = sql.replace("AND (opencps_acc_businessdomain.businessDomainCode = ?)", StringPool.BLANK); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("Business", BusinessImpl.class); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(groupId)) { qPos.add(groupId); } if (accountStatus != -1) { qPos.add(accountStatus); } if (Validator.isNotNull(keywords)) { qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); } if (Validator.isNotNull(businessDomain)) { qPos.add(businessDomain); } return (List<Business>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(); } finally { session.close(); } }
From source file:org.opencps.accountmgt.service.persistence.BusinessFinderImpl.java
License:Open Source License
/** * @param groupId//from w ww . java 2s . co m * @param keywords * @param accountStatus * @param businessDomain * @param andOperator * @return */ private int _countBussiness(long groupId, String keywords, int accountStatus, String businessDomain) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BUSINESS); if (Validator.isNull(groupId)) { sql = sql.replace("AND (opencps_acc_business.groupId = ?)", StringPool.BLANK); } if (accountStatus == -1) { sql = sql.replace("AND (opencps_acc_business.accountStatus = ?)", StringPool.BLANK); } if (Validator.isNull(keywords)) { sql = sql.replace("AND ((lower(opencps_acc_business.name) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.shortName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.enName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_business.email) LIKE ?))", StringPool.BLANK); } if (Validator.isNull(businessDomain)) { sql = sql.replace( "INNER JOIN " + "opencps_acc_businessdomain " + "ON " + "opencps_acc_business.businessId = opencps_acc_businessdomain.businessId", StringPool.BLANK); sql = sql.replace("AND (opencps_acc_businessdomain.businessDomainCode = ?)", StringPool.BLANK); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(groupId)) { qPos.add(groupId); } if (accountStatus != -1) { qPos.add(accountStatus); } if (Validator.isNotNull(keywords)) { qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); } if (Validator.isNotNull(businessDomain)) { qPos.add(businessDomain); } Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(); } finally { session.close(); } }
From source file:org.opencps.accountmgt.service.persistence.CitizenFinderImpl.java
License:Open Source License
/** * @param groupId/*from w w w . ja v a2 s .co m*/ * @param keywords * @param accountStatus * @param andOperator * @param start * @param end * @return */ private List<Citizen> _searchCitizen(long groupId, String keywords, int accountStatus, int start, int end) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(SEARCH_CITIZEN); if (Validator.isNull(groupId)) { sql = sql.replace("AND (opencps_acc_citizen.groupId = ?)", StringPool.BLANK); } if (accountStatus == -1) { sql = sql.replace("AND (opencps_acc_citizen.accountStatus = ?)", StringPool.BLANK); } if (Validator.isNull(keywords)) { sql = sql.replace("AND ((lower(opencps_acc_citizen.fullName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_citizen.email) LIKE ?))", StringPool.BLANK); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("Citizen", CitizenImpl.class); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(groupId)) { qPos.add(groupId); } if (accountStatus != -1) { qPos.add(accountStatus); } if (Validator.isNotNull(keywords)) { qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); } return (List<Citizen>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(); } finally { session.close(); } }
From source file:org.opencps.accountmgt.service.persistence.CitizenFinderImpl.java
License:Open Source License
/** * @param groupId//w ww . j av a 2s . c om * @param keywords * @param accountStatus * @param andOperator * @return */ private int _countCitizen(long groupId, String keywords, int accountStatus) throws SystemException { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_CITIZEN); if (Validator.isNull(groupId)) { sql = sql.replace("AND (opencps_acc_citizen.groupId = ?)", StringPool.BLANK); } if (accountStatus == -1) { sql = sql.replace("AND (opencps_acc_citizen.accountStatus = ?)", StringPool.BLANK); } if (Validator.isNull(keywords)) { sql = sql.replace("AND ((lower(opencps_acc_citizen.fullName) LIKE ?)", StringPool.BLANK); sql = sql.replace("OR (lower(opencps_acc_citizen.email) LIKE ?))", StringPool.BLANK); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(groupId)) { qPos.add(groupId); } if (accountStatus != -1) { qPos.add(accountStatus); } if (Validator.isNotNull(keywords)) { qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); qPos.add(StringPool.PERCENT + keywords + StringPool.PERCENT); } Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(); } finally { session.close(); } }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
/** * @param groupId/*w ww. ja va2 s . c om*/ * @param keywords * @param govAgencyCode * @param domainCode * @param andOperator * @return */ private int _countServiceConfig(long groupId, String[] keywords, String govAgencyCode, String domainCode, boolean andOperator) { keywords = CustomSQLUtil.keywords(keywords, false); Session session = null; try { session = openSession(); // get sql command from sql xml String sql = CustomSQLUtil.get(COUNT_SERVICE_CONFIG_SQL); if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossiertemplate.templateName)", StringPool.LIKE, true, keywords); sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_serviceinfo.serviceName)", StringPool.LIKE, true, keywords); } else { sql = StringUtil.replace(sql, "INNER JOIN opencps_serviceinfo ON opencps_service_config.serviceInfoId = opencps_serviceinfo.serviceinfoId", StringPool.BLANK); sql = StringUtil.replace(sql, "INNER JOIN opencps_dossiertemplate ON opencps_service_config.dossierTemplateId = opencps_dossiertemplate.dossierTemplateId", StringPool.BLANK); sql = StringUtil.replace(sql, "AND ((lower(opencps_dossiertemplate.templateName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); sql = StringUtil.replace(sql, "OR ((lower(opencps_serviceinfo.serviceName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); } // remove condition query if (govAgencyCode.equals(StringPool.BLANK)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyCode = ?)", StringPool.BLANK); } if (domainCode.equals("0") || domainCode.equals(StringPool.BLANK)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.domainCode = ?)", StringPool.BLANK); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); qPos.add(keywords, 2); } if (!govAgencyCode.equals(StringPool.BLANK)) { qPos.add(govAgencyCode); } if (!domainCode.equals(StringPool.BLANK) && !domainCode.equals("0")) { qPos.add(domainCode); } Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { _log.error(e); } finally { session.close(); } return 0; }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
/** * @param groupId/* w ww.ja v a 2 s . com*/ * @param keywords * @param servicePortal * @param serviceOnegate * @param serviceBackoffice * @param serviceCitizen * @param serviceBusinees * @param serviceDomainIndex * @param govAgencyIndex * @param andOperator * @return */ private int _countServiceConfigAdvance(long groupId, String[] keywords, int servicePortal, int serviceOnegate, int serviceBackoffice, int serviceCitizen, int serviceBusinees, String serviceDomainIndex, String govAgencyIndex, boolean andOperator) { Session session = null; try { session = openSession(); // get sql command from sql xml String sql = CustomSQLUtil.get(COUNT_SERVICE_CONFIG_ADVANCE_SQL); if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_serviceinfo.serviceName)", StringPool.LIKE, true, keywords); } else { sql = StringUtil.replace(sql, "AND ((lower(opencps_serviceinfo.serviceName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); } if (servicePortal != 1 && servicePortal != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.servicePortal = ?", StringPool.BLANK); } if (serviceOnegate != 1 && serviceOnegate != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceOnegate = ?", StringPool.BLANK); } if (serviceBackoffice != 1 && serviceBackoffice != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceBackoffice = ?", StringPool.BLANK); } if (serviceCitizen != 1 && serviceCitizen != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceCitizen = ?", StringPool.BLANK); } if (serviceBusinees != 1 && serviceBusinees != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceBusinees = ?", StringPool.BLANK); } if (Validator.isNull(serviceDomainIndex)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.serviceDomainIndex LIKE ? OR opencps_service_config.serviceDomainIndex = ?)", StringPool.BLANK); } else { if (StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { serviceDomainIndex = serviceDomainIndex.substring(0, serviceDomainIndex.indexOf(StringPool.PERIOD) + 1); sql = StringUtil.replace(sql, "AND (opencps_service_config.serviceDomainIndex LIKE ? OR opencps_service_config.serviceDomainIndex = ?)", "AND (opencps_service_config.serviceDomainIndex LIKE ?"); } } if (Validator.isNull(govAgencyIndex)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyIndex LIKE ? OR opencps_service_config.govAgencyIndex = ?)", StringPool.BLANK); } else { if (StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { govAgencyIndex = govAgencyIndex.substring(0, govAgencyIndex.indexOf(StringPool.PERIOD) + 1); sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyIndex LIKE ? OR opencps_service_config.govAgencyIndex = ?)", "AND (opencps_service_config.govAgencyIndex LIKE ?"); } } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); } if (servicePortal == 1) { qPos.add(true); } else if (servicePortal == 0) { qPos.add(false); } if (serviceOnegate == 1) { qPos.add(true); } else if (serviceOnegate == 0) { qPos.add(false); } if (serviceBackoffice == 1) { qPos.add(true); } else if (serviceBackoffice == 0) { qPos.add(false); } if (serviceCitizen == 1) { qPos.add(true); } else if (serviceCitizen == 0) { qPos.add(false); } if (serviceBusinees == 1) { qPos.add(true); } else if (serviceBusinees == 0) { qPos.add(false); } if (Validator.isNotNull(serviceDomainIndex) && StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { qPos.add(serviceDomainIndex + StringPool.PERCENT); } else if (Validator.isNotNull(serviceDomainIndex) && !StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { qPos.add(serviceDomainIndex + StringPool.PERIOD + StringPool.PERCENT); qPos.add(serviceDomainIndex); } if (Validator.isNotNull(govAgencyIndex) && StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { qPos.add(govAgencyIndex + StringPool.PERCENT); } else if (Validator.isNotNull(govAgencyIndex) && !StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { qPos.add(govAgencyIndex + StringPool.PERIOD + StringPool.PERCENT); qPos.add(govAgencyIndex); } Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { _log.error(e); } finally { session.close(); } return 0; }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
/** * @param groupId/*from w w w.j a v a 2 s. com*/ * @param keywords * @param govAgencyCode * @param domainCode * @param andOperator * @param start * @param end * @return */ private List<ServiceConfig> _searchServiceConfig(long groupId, String[] keywords, String govAgencyCode, String domainCode, boolean andOperator, int start, int end) { keywords = CustomSQLUtil.keywords(keywords, false); Session session = null; try { session = openSession(); // get sql command from sql xml String sql = CustomSQLUtil.get(SEARCH_SERVICE_CONFIG_SQL); if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossiertemplate.templateName)", StringPool.LIKE, true, keywords); sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_serviceinfo.serviceName)", StringPool.LIKE, true, keywords); } else { sql = StringUtil.replace(sql, "INNER JOIN opencps_serviceinfo ON opencps_service_config.serviceInfoId = opencps_serviceinfo.serviceinfoId", StringPool.BLANK); sql = StringUtil.replace(sql, "INNER JOIN opencps_dossiertemplate ON opencps_service_config.dossierTemplateId = opencps_dossiertemplate.dossierTemplateId", StringPool.BLANK); sql = StringUtil.replace(sql, "AND ((lower(opencps_dossiertemplate.templateName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); sql = StringUtil.replace(sql, "OR ((lower(opencps_serviceinfo.serviceName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); } // remove condition query if (govAgencyCode.equals(StringPool.BLANK)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyCode = ?)", StringPool.BLANK); } if (domainCode.equals("0") || domainCode.equals(StringPool.BLANK)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.domainCode = ?)", StringPool.BLANK); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("ServiceConfig", ServiceConfigImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); qPos.add(keywords, 2); } if (!govAgencyCode.equals(StringPool.BLANK)) { qPos.add(govAgencyCode); } if (!domainCode.equals(StringPool.BLANK) && !domainCode.equals("0")) { qPos.add(domainCode); } return (List<ServiceConfig>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { _log.error(e); } finally { session.close(); } return null; }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
/** * @param groupId//from w w w . java 2 s .c o m * @param keywords * @param servicePortal * @param serviceOnegate * @param serviceBackoffice * @param serviceCitizen * @param serviceBusinees * @param serviceDomainIndex * @param govAgencyIndex * @param start * @param end * @param orderByComparator * @param andOperator * @return */ private List<ServiceBean> _searchServiceConfigAdvance(long groupId, String[] keywords, int servicePortal, int serviceOnegate, int serviceBackoffice, int serviceCitizen, int serviceBusinees, String serviceDomainIndex, String govAgencyIndex, int start, int end, OrderByComparator orderByComparator, boolean andOperator) { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(SEARCH_SERVICE_CONFIG_ADVANCE_SQL); if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_serviceinfo.serviceName)", StringPool.LIKE, true, keywords); } else { sql = StringUtil.replace(sql, "AND ((lower(opencps_serviceinfo.serviceName) LIKE ? [$AND_OR_NULL_CHECK$]))", StringPool.BLANK); } if (servicePortal != 1 && servicePortal != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.servicePortal = ?", StringPool.BLANK); } if (serviceOnegate != 1 && serviceOnegate != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceOnegate = ?", StringPool.BLANK); } if (serviceBackoffice != 1 && serviceBackoffice != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceBackoffice = ?", StringPool.BLANK); } if (serviceCitizen != 1 && serviceCitizen != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceCitizen = ?", StringPool.BLANK); } if (serviceBusinees != 1 && serviceBusinees != 0) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceBusinees = ?", StringPool.BLANK); } if (Validator.isNull(serviceDomainIndex)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.serviceDomainIndex LIKE ? OR opencps_service_config.serviceDomainIndex = ?)", StringPool.BLANK); } else { if (StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { serviceDomainIndex = serviceDomainIndex.substring(0, serviceDomainIndex.indexOf(StringPool.PERIOD) + 1); sql = StringUtil.replace(sql, "AND (opencps_service_config.serviceDomainIndex LIKE ? OR opencps_service_config.serviceDomainIndex = ?)", "AND (opencps_service_config.serviceDomainIndex LIKE ?"); } } if (Validator.isNull(govAgencyIndex)) { sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyIndex LIKE ? OR opencps_service_config.govAgencyIndex = ?)", StringPool.BLANK); } else { if (StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { govAgencyIndex = govAgencyIndex.substring(0, govAgencyIndex.indexOf(StringPool.PERIOD) + 1); sql = StringUtil.replace(sql, "AND (opencps_service_config.govAgencyIndex LIKE ? OR opencps_service_config.govAgencyIndex = ?)", "AND (opencps_service_config.govAgencyIndex LIKE ?"); } } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("ServiceConfig", ServiceConfigImpl.class); q.addScalar("serviceName", Type.STRING); q.addScalar("fullName", Type.STRING); q.addScalar("serviceNo", Type.STRING); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); } if (servicePortal == 1) { qPos.add(true); } else if (servicePortal == 0) { qPos.add(false); } if (serviceOnegate == 1) { qPos.add(true); } else if (serviceOnegate == 0) { qPos.add(false); } if (serviceBackoffice == 1) { qPos.add(true); } else if (serviceBackoffice == 0) { qPos.add(false); } if (serviceCitizen == 1) { qPos.add(true); } else if (serviceCitizen == 0) { qPos.add(false); } if (serviceBusinees == 1) { qPos.add(true); } else if (serviceBusinees == 0) { qPos.add(false); } if (Validator.isNotNull(serviceDomainIndex) && StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { qPos.add(serviceDomainIndex + StringPool.PERCENT); } else if (Validator.isNotNull(serviceDomainIndex) && !StringUtil.contains(serviceDomainIndex, StringPool.PERIOD)) { qPos.add(serviceDomainIndex + StringPool.PERIOD + StringPool.PERCENT); qPos.add(serviceDomainIndex); } if (Validator.isNotNull(govAgencyIndex) && StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { qPos.add(govAgencyIndex + StringPool.PERCENT); } else if (Validator.isNotNull(govAgencyIndex) && !StringUtil.contains(govAgencyIndex, StringPool.PERIOD)) { qPos.add(govAgencyIndex + StringPool.PERIOD + StringPool.PERCENT); qPos.add(govAgencyIndex); } Iterator<Object[]> itr = (Iterator<Object[]>) QueryUtil.list(q, getDialect(), start, end).iterator(); List<ServiceBean> serviceBeans = new ArrayList<ServiceBean>(); if (itr.hasNext()) { while (itr.hasNext()) { ServiceBean serviceBean = new ServiceBean(); Object[] objects = itr.next(); ServiceConfig serviceConfig = (ServiceConfig) objects[0]; String serviceName = (String) objects[1]; String fullName = (String) objects[2]; String serviceNo = (String) objects[3]; serviceBean.setCompanyId(serviceConfig.getCompanyId()); serviceBean.setDossierTemplateId(serviceConfig.getDossierTemplateId()); serviceBean.setFullName(fullName); serviceBean.setDomainCode(serviceConfig.getDomainCode()); serviceBean.setLevel(serviceConfig.getServiceLevel()); serviceBean.setGovAgencyCode(serviceConfig.getGovAgencyCode()); serviceBean.setGovAgencyIndex(serviceConfig.getGovAgencyIndex()); serviceBean.setGovAgencyName(serviceConfig.getGovAgencyName()); serviceBean.setGovAgencyOrganizationId(serviceConfig.getGovAgencyOrganizationId()); serviceBean.setGroupId(groupId); serviceBean.setServiceAdministrationIndex(serviceConfig.getServiceAdministrationIndex()); serviceBean.setServiceBackoffice(serviceConfig.getServiceBackoffice()); serviceBean.setServiceBusinees(serviceConfig.getServiceBusinees()); serviceBean.setServiceCitizen(serviceConfig.getServiceCitizen()); serviceBean.setServiceConfigId(serviceConfig.getServiceConfigId()); serviceBean.setServiceDomainIndex(serviceDomainIndex); serviceBean.setServiceInfoId(serviceConfig.getServiceInfoId()); serviceBean.setServiceLevel(serviceConfig.getServiceLevel()); serviceBean.setServiceName(serviceName); serviceBean.setServiceNo(serviceNo); serviceBean.setServiceOnegate(serviceConfig.getServiceOnegate()); serviceBean.setServicePortal(serviceConfig.getServicePortal()); serviceBean.setServiceProcessId(serviceConfig.getServiceProcessId()); serviceBean.setUserId(serviceConfig.getUserId()); serviceBeans.add(serviceBean); } } return serviceBeans; } catch (Exception e) { _log.error(e); } finally { session.close(); } return null; }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
public int countServiceConfigByServiceMode(long groupId, int[] serviceModes) { Session session = null; try {/* w w w . j a va 2 s .c om*/ session = openSession(); String sql = CustomSQLUtil.get(COUNT_SERVICE_CONFIG_BY_SERVICE_MODE_SQL); if (Validator.isNull(serviceModes)) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceMode IN (?)", StringPool.BLANK); } else { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceMode IN (?)", "AND opencps_service_config.serviceMode IN (" + StringUtil.merge(serviceModes) + ")"); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } } catch (Exception e) { _log.error(e); } finally { session.close(); } return 0; }
From source file:org.opencps.dossiermgt.service.persistence.ServiceConfigFinderImpl.java
License:Open Source License
public List<ServiceConfig> searchServiceConfigByServiceMode(long groupId, int[] serviceModes, int start, int end, OrderByComparator orderByComparator) { Session session = null; try {/*from w ww . j a v a 2 s.c om*/ session = openSession(); String sql = CustomSQLUtil.get(SEARCH_SERVICE_CONFIG_BY_SERVICE_MODE_SQL); if (Validator.isNull(serviceModes)) { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceMode IN (?)", StringPool.BLANK); } else { sql = StringUtil.replace(sql, "AND opencps_service_config.serviceMode IN (?)", "AND opencps_service_config.serviceMode IN (" + StringUtil.merge(serviceModes) + ")"); } SQLQuery q = session.createSQLQuery(sql); q.setCacheable(false); q.addEntity("ServiceConfig", ServiceConfigImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); return (List<ServiceConfig>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { _log.error(e); } finally { session.close(); } return null; }