List of usage examples for com.liferay.portal.kernel.util StringUtil quote
public static String quote(String s, String quote)
From source file:com.htmsd.slayer.service.impl.ShoppingItemLocalServiceImpl.java
License:Open Source License
public List<ShoppingItem> searchItems(int status, String keyword, int start, int end) { String likeKeyword = StringUtil.quote(keyword, StringPool.PERCENT); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(ShoppingItem.class); Junction junctionOR = RestrictionsFactoryUtil.disjunction(); Property property = PropertyFactoryUtil.forName("userName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("updateUserName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("name"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("productCode"); junctionOR.add(property.like(likeKeyword)); dynamicQuery.add(junctionOR);/* w w w. j a va 2s . c o m*/ dynamicQuery.add(RestrictionsFactoryUtil.eq("status", status)); List<ShoppingItem> searchList = new ArrayList<ShoppingItem>(); try { searchList = ShoppingItemLocalServiceUtil.dynamicQuery(dynamicQuery, start, end); } catch (SystemException e) { } return searchList; }
From source file:com.htmsd.slayer.service.impl.ShoppingItemLocalServiceImpl.java
License:Open Source License
public int searchCount(int status, String keyword) { String likeKeyword = StringUtil.quote(keyword, StringPool.PERCENT); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(ShoppingItem.class); Junction junctionOR = RestrictionsFactoryUtil.disjunction(); Property property = PropertyFactoryUtil.forName("userName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("updateUserName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("name"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("productCode"); junctionOR.add(property.like(likeKeyword)); dynamicQuery.add(junctionOR);//w w w . j ava 2 s . c om dynamicQuery.add(RestrictionsFactoryUtil.eq("status", status)); int searchCount = 0; try { searchCount = (int) ShoppingItemLocalServiceUtil.dynamicQueryCount(dynamicQuery); } catch (SystemException e) { } return searchCount; }
From source file:com.htmsd.slayer.service.impl.ShoppingOrderLocalServiceImpl.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ShoppingOrder> searchShoppingOrder(int start, int end, long sellerId, boolean isSellerList, String keyword, String tabName) { _log.info("In searchShoppingOrder keyword is :-->> " + keyword); String likeKeyword = StringUtil.quote(keyword, StringPool.PERCENT); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(ShoppingOrder.class); Junction junctionOR = RestrictionsFactoryUtil.disjunction(); Property property = PropertyFactoryUtil.forName("sellerName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("userName"); junctionOR.add(property.like(likeKeyword)); if (CommonUtil.isNumeric(keyword)) { property = PropertyFactoryUtil.forName("quantity"); junctionOR.add(property.eq(Integer.valueOf(keyword))); }// w w w . java 2 s .c o m if (keyword.startsWith("HT")) { String orderId = keyword.substring(7, keyword.length()); _log.info("Order ItemId is ==>" + Long.valueOf(orderId)); junctionOR.add(RestrictionsFactoryUtil.eq("orderId", Long.valueOf(orderId))); } if (keyword.contains("-")) { Criterion criterion = PropertyFactoryUtil.forName("createDate") .between(getFromDateAndToDate(0, 0, 0, keyword), getFromDateAndToDate(23, 59, 59, keyword)); junctionOR.add(criterion); } dynamicQuery.add(junctionOR); if (isSellerList) { dynamicQuery.add(RestrictionsFactoryUtil.eq("sellerId", sellerId)); } else { dynamicQuery.add(RestrictionsFactoryUtil.eq("orderStatus", getOrderStatusByTabName(tabName))); } List<ShoppingOrder> searchList = new ArrayList<ShoppingOrder>(); try { searchList = ShoppingOrderLocalServiceUtil.dynamicQuery(dynamicQuery, start, end); } catch (SystemException e) { e.printStackTrace(); } return searchList; }
From source file:com.htmsd.slayer.service.impl.ShoppingOrderLocalServiceImpl.java
License:Open Source License
public int searchCount(long sellerId, boolean isSellerList, String tabName, String keyword) { _log.info("searchCount for Keyword :" + keyword); String likeKeyword = StringUtil.quote(keyword, StringPool.PERCENT); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(ShoppingOrder.class); Junction junctionOR = RestrictionsFactoryUtil.disjunction(); Property property = PropertyFactoryUtil.forName("sellerName"); junctionOR.add(property.like(likeKeyword)); property = PropertyFactoryUtil.forName("userName"); junctionOR.add(property.like(likeKeyword)); if (CommonUtil.isNumeric(keyword)) { property = PropertyFactoryUtil.forName("quantity"); junctionOR.add(property.eq(Integer.valueOf(keyword))); }//from w w w . j a v a 2 s . c o m if (keyword.startsWith("HT")) { String orderId = keyword.substring(7, keyword.length()); junctionOR.add(RestrictionsFactoryUtil.eq("orderId", Long.valueOf(orderId))); } if (keyword.contains("-")) { Criterion criterion = PropertyFactoryUtil.forName("createDate") .between(getFromDateAndToDate(0, 0, 0, keyword), getFromDateAndToDate(23, 59, 59, keyword)); junctionOR.add(criterion); } dynamicQuery.add(junctionOR); if (isSellerList) { dynamicQuery.add(RestrictionsFactoryUtil.eq("sellerId", sellerId)); } else { dynamicQuery.add(RestrictionsFactoryUtil.eq("orderStatus", getOrderStatusByTabName(tabName))); } int searchCount = 0; try { searchCount = (int) ShoppingOrderLocalServiceUtil.dynamicQueryCount(dynamicQuery); } catch (SystemException e) { e.printStackTrace(); } return searchCount; }
From source file:com.liferay.bbb.service.impl.BBBMeetingLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, long userId, String name, String description, int status, boolean andSearch) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(BBBMeeting.class, getClassLoader()); if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); }/*from w w w . ja v a 2 s. c o m*/ if (userId > 0) { Property property = PropertyFactoryUtil.forName("userId"); dynamicQuery.add(property.eq(userId)); } if (status != BBBMeetingConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("status"); dynamicQuery.add(property.eq(status)); } Junction junction = null; if (andSearch) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } if (Validator.isNotNull(name)) { Property property = PropertyFactoryUtil.forName("name"); String value = StringUtil.quote(name, StringPool.PERCENT); junction.add(property.like(value)); } if (Validator.isNotNull(description)) { Property property = PropertyFactoryUtil.forName("description"); String value = StringUtil.quote(description, StringPool.PERCENT); junction.add(property.like(value)); } dynamicQuery.add(junction); return dynamicQuery; }
From source file:com.liferay.customsql.CustomSQL.java
License:Open Source License
public String[] keywords(String keywords, boolean lowerCase) { if (Validator.isNull(keywords)) { return new String[] { null }; }//w w w . j av a2 s.c o m if (_CUSTOM_SQL_AUTO_ESCAPE_WILDCARDS_ENABLED) { keywords = escapeWildCards(keywords); } if (lowerCase) { keywords = StringUtil.toLowerCase(keywords); } keywords = keywords.trim(); List<String> keywordsList = new ArrayList<String>(); for (int i = 0; i < keywords.length(); i++) { char c = keywords.charAt(i); if (c == CharPool.QUOTE) { int pos = i + 1; i = keywords.indexOf(CharPool.QUOTE, pos); if (i == -1) { i = keywords.length(); } if (i > pos) { String keyword = keywords.substring(pos, i); keywordsList.add(StringUtil.quote(keyword, StringPool.PERCENT)); } } else { while (Character.isWhitespace(c)) { i++; c = keywords.charAt(i); } int pos = i; while (!Character.isWhitespace(c)) { i++; if (i == keywords.length()) { break; } c = keywords.charAt(i); } String keyword = keywords.substring(pos, i); keywordsList.add(StringUtil.quote(keyword, StringPool.PERCENT)); } } return keywordsList.toArray(new String[keywordsList.size()]); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getSectionsKBArticles(long groupId, String[] sections, int status, int start, int end, OrderByComparator<KBArticle> orderByComparator) { String[] array = AdminUtil.escapeSections(sections); for (int i = 0; i < array.length; i++) { array[i] = StringUtil.quote(array[i], StringPool.PERCENT); }//w w w. j a v a 2s .co m if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.findByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true, start, end, orderByComparator); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.findByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true, start, end, orderByComparator); } return kbArticlePersistence.findByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, status, start, end, orderByComparator); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
@Override public int getSectionsKBArticlesCount(long groupId, String[] sections, int status) { String[] array = AdminUtil.escapeSections(sections); for (int i = 0; i < array.length; i++) { array[i] = StringUtil.quote(array[i], StringPool.PERCENT); }// w w w .j a v a 2 s . c o m if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.countByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.countByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true); } return kbArticlePersistence.countByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, status); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate, Date endDate, boolean andOperator) { Junction junction = null;//from www. j a v a 2 s . c o m if (andOperator) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } Map<String, String> terms = new HashMap<String, String>(); if (Validator.isNotNull(title)) { terms.put("title", title); } if (Validator.isNotNull(content)) { terms.put("content", content); } for (Map.Entry<String, String> entry : terms.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) { Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT)); disjunction.add(criterion); } junction.add(disjunction); } if (status != WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("status"); junction.add(property.eq(status)); } if ((endDate != null) && (startDate != null)) { Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); String[] propertyNames = { "createDate", "modifiedDate" }; for (String propertyName : propertyNames) { Property property = PropertyFactoryUtil.forName(propertyName); Conjunction conjunction = RestrictionsFactoryUtil.conjunction(); conjunction.add(property.gt(startDate)); conjunction.add(property.lt(endDate)); disjunction.add(conjunction); } junction.add(disjunction); } DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBArticle.class, getClassLoader()); if (status == WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("latest"); dynamicQuery.add(property.eq(Boolean.TRUE)); } else if (status == WorkflowConstants.STATUS_APPROVED) { Property property = PropertyFactoryUtil.forName("main"); dynamicQuery.add(property.eq(Boolean.TRUE)); } if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); } return dynamicQuery.add(junction); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java
License:Open Source License
@Override public List<KBArticle> getSectionsKBArticles(long groupId, String[] sections, int status, int start, int end, OrderByComparator<KBArticle> orderByComparator) { String[] array = AdminUtil.escapeSections(sections); for (int i = 0; i < array.length; i++) { array[i] = StringUtil.quote(array[i], StringPool.PERCENT); }/*from w ww.ja v a 2s .c om*/ if (status == WorkflowConstants.STATUS_ANY) { return kbArticlePersistence.filterFindByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true, start, end, orderByComparator); } else if (status == WorkflowConstants.STATUS_APPROVED) { return kbArticlePersistence.filterFindByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, true, start, end, orderByComparator); } return kbArticlePersistence.filterFindByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array, status, start, end, orderByComparator); }