List of usage examples for com.liferay.portal.kernel.util StringPool LIKE
String LIKE
To view the source code for com.liferay.portal.kernel.util StringPool LIKE.
Click Source Link
From source file:com.liferay.portlet.journal.service.persistence.JournalStructureFinderImpl.java
License:Open Source License
protected int doCountByC_G_S_N_D(long companyId, long[] groupIds, String[] structureIds, String[] names, String[] descriptions, boolean andOperator, boolean inlineSQLHelper) throws SystemException { structureIds = CustomSQLUtil.keywords(structureIds, false); names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions); Session session = null;//from www . j av a2 s .c o m try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_C_G_S_N_D); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "structureId", StringPool.LIKE, false, structureIds); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "lower(description)", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalStructure.class.getName(), "JournalStructure.id_", groupIds); sql = StringUtil.replace(sql, "(companyId", "(JournalStructure.companyId"); sql = StringUtil.replace(sql, "(name", "(JournalStructure.name"); } SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupIds); qPos.add(structureIds, 2); qPos.add(names, 2); qPos.add(descriptions, 2); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.journal.service.persistence.JournalStructureFinderImpl.java
License:Open Source License
protected List<JournalStructure> doFindByC_G_S_N_D(long companyId, long[] groupIds, String[] structureIds, String[] names, String[] descriptions, boolean andOperator, int start, int end, OrderByComparator obc, boolean inlineSQLHelper) throws SystemException { structureIds = CustomSQLUtil.keywords(structureIds, false); names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions); Session session = null;//ww w . j a v a 2 s. c o m try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_S_N_D); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "structureId", StringPool.LIKE, false, structureIds); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "lower(description)", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, obc); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalStructure.class.getName(), "JournalStructure.id_", groupIds); sql = StringUtil.replace(sql, "(companyId", "(JournalStructure.companyId"); sql = StringUtil.replace(sql, "(name", "(JournalStructure.name"); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("JournalStructure", JournalStructureImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupIds); qPos.add(structureIds, 2); qPos.add(names, 2); qPos.add(descriptions, 2); return (List<JournalStructure>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.journal.service.persistence.JournalTemplateFinderImpl.java
License:Open Source License
protected int doCountByC_G_T_S_N_D(long companyId, long[] groupIds, String[] templateIds, String structureId, String structureIdComparator, String[] names, String[] descriptions, boolean andOperator, boolean inlineSQLHelper) throws SystemException { templateIds = CustomSQLUtil.keywords(templateIds, false); names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions); Session session = null;// w ww . j a v a2 s . c om try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_C_G_T_S_N_D); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "templateId", StringPool.LIKE, false, templateIds); if (structureIdComparator.equals(StringPool.NOT_LIKE)) { sql = replaceStructureIdComparator(sql); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "lower(description)", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalTemplate.class.getName(), "JournalTemplate.id_", groupIds); sql = StringUtil.replace(sql, "(companyId", "(JournalTemplate.companyId"); sql = StringUtil.replace(sql, "(name", "(JournalTemplate.name"); } SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupIds); qPos.add(templateIds, 2); if (structureIdComparator.equals(StringPool.LIKE)) { qPos.add(structureId); qPos.add(structureId); } qPos.add(names, 2); qPos.add(descriptions, 2); if (structureIdComparator.equals(StringPool.NOT_LIKE)) { if (CustomSQLUtil.isVendorOracle()) { } else { qPos.add(structureId); } } Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.journal.service.persistence.JournalTemplateFinderImpl.java
License:Open Source License
protected List<JournalTemplate> doFindByC_G_T_S_N_D(long companyId, long[] groupIds, String[] templateIds, String structureId, String structureIdComparator, String[] names, String[] descriptions, boolean andOperator, int start, int end, OrderByComparator obc, boolean inlineSQLHelper) throws SystemException { templateIds = CustomSQLUtil.keywords(templateIds, false); names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions); Session session = null;/* www . ja va 2s . c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_C_G_T_S_N_D); sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds)); sql = CustomSQLUtil.replaceKeywords(sql, "templateId", StringPool.LIKE, false, templateIds); if (structureIdComparator.equals(StringPool.NOT_LIKE)) { sql = replaceStructureIdComparator(sql); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "lower(description)", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, obc); if (inlineSQLHelper) { sql = InlineSQLHelperUtil.replacePermissionCheck(sql, JournalTemplate.class.getName(), "JournalTemplate.id_", groupIds); sql = StringUtil.replace(sql, "(companyId", "(JournalTemplate.companyId"); sql = StringUtil.replace(sql, "(name", "(JournalTemplate.name"); } SQLQuery q = session.createSQLQuery(sql); q.addEntity("JournalTemplate", JournalTemplateImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); qPos.add(groupIds); qPos.add(templateIds, 2); if (structureIdComparator.equals(StringPool.LIKE)) { qPos.add(structureId); qPos.add(structureId); } qPos.add(names, 2); qPos.add(descriptions, 2); if (structureIdComparator.equals(StringPool.NOT_LIKE)) { if (CustomSQLUtil.isVendorOracle()) { } else { qPos.add(structureId); } } return (List<JournalTemplate>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.mobiledevicerules.service.persistence.MDRRuleGroupFinderImpl.java
License:Open Source License
public int countByG_N(long groupId, String[] names, boolean andOperator) throws SystemException { names = CustomSQLUtil.keywords(names); Session session = null;/*from www . j av a 2s .co m*/ try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_G_N); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, true, names); sql = CustomSQLUtil.replaceAndOperator(sql, false); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(names, 2); Iterator<Long> itr = q.iterate(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.portlet.mobiledevicerules.service.persistence.MDRRuleGroupFinderImpl.java
License:Open Source License
public List<MDRRuleGroup> findByG_N(long groupId, String[] names, boolean andOperator, int start, int end) throws SystemException { names = CustomSQLUtil.keywords(names); Session session = null;/* w w w . ja va 2s . c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_G_N); sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, true, names); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("MDRRuleGroup", MDRRuleGroupImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(names, 2); return (List<MDRRuleGroup>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.timesheet.service.persistence.ProjectFinderImpl.java
License:Open Source License
protected int doCountByN_D(long companyId, long groupId, String[] names, String[] descriptions, boolean andOperator) throws SystemException { names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;/*from www . j a v a2s. co m*/ try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_BY_N_D); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(names, 2); qPos.add(descriptions, 2); Iterator<Long> itr = q.list().iterator(); if (itr.hasNext()) { Long count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:com.liferay.timesheet.service.persistence.ProjectFinderImpl.java
License:Open Source License
protected List<Project> doFindByN_D(long companyId, long groupId, String[] names, String[] descriptions, boolean andOperator, int start, int end, OrderByComparator orderByComparator) throws SystemException { names = CustomSQLUtil.keywords(names); descriptions = CustomSQLUtil.keywords(descriptions, false); Session session = null;/*w w w. ja v a2 s . c o m*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_N_D); if (groupId <= 0) { sql = StringUtil.replace(sql, "(groupId = ?) AND", ""); } sql = CustomSQLUtil.replaceKeywords(sql, "lower(name)", StringPool.LIKE, false, names); sql = CustomSQLUtil.replaceKeywords(sql, "description", StringPool.LIKE, true, descriptions); sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator); SQLQuery q = session.createSQLQuery(sql); q.addEntity("Project", ProjectImpl.class); QueryPos qPos = QueryPos.getInstance(q); qPos.add(companyId); if (groupId > 0) { qPos.add(groupId); } qPos.add(names, 2); qPos.add(descriptions, 2); return (List<Project>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }
From source file:org.opencps.datamgt.service.persistence.DictItemFinderImpl.java
License:Open Source License
private List<DictItem> searchDictItemByName_like(String collectionCode, String itemCode, String[] keywords, long groupId, boolean andOperator, int start, int end, OrderByComparator obc) throws SystemException { // TODO Auto-generated method stub Session session = null;/* w w w. ja va 2s. c o m*/ List<DictItem> results = new ArrayList<DictItem>(); try { session = openSession(); String sql = CustomSQLUtil.get(SEARCH_DICT_ITEM_BY_NAME_LIKE); if (Validator.isNull(collectionCode)) { sql = StringUtil.replace(sql, "and opencps_dictcollection.collectionCode = ?", StringPool.BLANK); } if (Validator.isNull(itemCode) || itemCode.equals("0")) { sql = StringUtil.replace(sql, "and opencps_dictitem.itemCode = ?", StringPool.BLANK); } else { sql = StringUtil.replace(sql, "and opencps_dictitem.parentItemId = ?", StringPool.BLANK); } if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(ExtractValue(itemName, '//ItemName'))", StringPool.LIKE, true, keywords); } else { sql = StringUtil.replace(sql, "and (lower(ExtractValue(itemName, '//ItemName')) LIKE ? [$AND_OR_NULL_CHECK$])", StringPool.BLANK); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); _log.info("SQL autocomplete:" + sql); SQLQuery q = session.createSQLQuery(sql); q.addEntity("DictItem", DictItemImpl.class); QueryPos qPos = QueryPos.getInstance(q); if (Validator.isNotNull(collectionCode)) { qPos.add(collectionCode); } qPos.add(itemCode); qPos.add(groupId); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); } results = (List<DictItem>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(); } finally { closeSession(session); } return results; }
From source file:org.opencps.dossiermgt.service.persistence.DossierFileFinderImpl.java
License:Open Source License
/** * @param groupId//from w ww . ja va 2 s . co m * @param keywords * @param templateFileNo * @param removed * @param andOperator * @return */ private int countDossierFile(long groupId, long ownerUserId, long ownerOrganizationId, String[] keywords, String templateFileNo, int removed, boolean andOperator) { Session session = null; try { session = openSession(); String sql = CustomSQLUtil.get(COUNT_DOSSIER_FILE_BY_G_K_T_R); if (keywords != null && keywords.length > 0) { sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossier_file.displayName)", StringPool.LIKE, true, keywords); sql = CustomSQLUtil.replaceKeywords(sql, "lower(opencps_dossier_file.dossierFileNo)", StringPool.LIKE, true, keywords); } if (keywords == null || keywords.length == 0) { sql = StringUtil.replace(sql, "AND (lower(opencps_dossier_file.displayName) LIKE ? [$AND_OR_NULL_CHECK$])", StringPool.BLANK); sql = StringUtil.replace(sql, "OR (lower(opencps_dossier_file.dossierFileNo) LIKE ? [$AND_OR_NULL_CHECK$])", StringPool.BLANK); } if (Validator.isNull(templateFileNo)) { sql = StringUtil.replace(sql, "AND (opencps_dossier_file.templateFileNo = ?)", StringPool.BLANK); } if (ownerUserId <= 0) { sql = StringUtil.replace(sql, "AND (opencps_dossier_file.ownerUserId = ?)", StringPool.BLANK); } if (ownerOrganizationId <= 0) { sql = StringUtil.replace(sql, "AND (opencps_dossier_file.ownerOrganizationId = ?)", StringPool.BLANK); } sql = CustomSQLUtil.replaceAndOperator(sql, andOperator); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, Type.INTEGER); QueryPos qPos = QueryPos.getInstance(q); qPos.add(groupId); qPos.add(removed); if (keywords != null && keywords.length > 0) { qPos.add(keywords, 2); qPos.add(keywords, 2); } if (Validator.isNotNull(templateFileNo)) { qPos.add(templateFileNo); } if (ownerUserId > 0) { qPos.add(ownerUserId); } if (ownerOrganizationId > 0) { qPos.add(ownerOrganizationId); } Iterator<Integer> itr = q.iterate(); if (itr.hasNext()) { Integer count = itr.next(); if (count != null) { return count.intValue(); } } return 0; } catch (Exception e) { _log.error(e); } finally { closeSession(session); } return 0; }