List of usage examples for com.liferay.portal.kernel.util StringPool COMMA
String COMMA
To view the source code for com.liferay.portal.kernel.util StringPool COMMA.
Click Source Link
From source file:com.rivetlogic.services.service.persistence.impl.TipsOfTheDayCategoriesPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TipsOfTheDayCategories> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* ww w . ja v a 2 s . co m*/ Map<Serializable, TipsOfTheDayCategories> map = new HashMap<Serializable, TipsOfTheDayCategories>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TipsOfTheDayCategories tipsOfTheDayCategories = fetchByPrimaryKey(primaryKey); if (tipsOfTheDayCategories != null) { map.put(primaryKey, tipsOfTheDayCategories); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TipsOfTheDayCategoriesModelImpl.ENTITY_CACHE_ENABLED, TipsOfTheDayCategoriesImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (TipsOfTheDayCategories) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TIPSOFTHEDAYCATEGORIES_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long) primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (TipsOfTheDayCategories tipsOfTheDayCategories : (List<TipsOfTheDayCategories>) q.list()) { map.put(tipsOfTheDayCategories.getPrimaryKeyObj(), tipsOfTheDayCategories); cacheResult(tipsOfTheDayCategories); uncachedPrimaryKeys.remove(tipsOfTheDayCategories.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TipsOfTheDayCategoriesModelImpl.ENTITY_CACHE_ENABLED, TipsOfTheDayCategoriesImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.rivetlogic.services.service.persistence.impl.TipsOfTheDayUsersPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TipsOfTheDayUsers> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w .j a v a 2 s . co m Map<Serializable, TipsOfTheDayUsers> map = new HashMap<Serializable, TipsOfTheDayUsers>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TipsOfTheDayUsers tipsOfTheDayUsers = fetchByPrimaryKey(primaryKey); if (tipsOfTheDayUsers != null) { map.put(primaryKey, tipsOfTheDayUsers); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TipsOfTheDayUsersModelImpl.ENTITY_CACHE_ENABLED, TipsOfTheDayUsersImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (TipsOfTheDayUsers) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TIPSOFTHEDAYUSERS_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long) primaryKey); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (TipsOfTheDayUsers tipsOfTheDayUsers : (List<TipsOfTheDayUsers>) q.list()) { map.put(tipsOfTheDayUsers.getPrimaryKeyObj(), tipsOfTheDayUsers); cacheResult(tipsOfTheDayUsers); uncachedPrimaryKeys.remove(tipsOfTheDayUsers.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TipsOfTheDayUsersModelImpl.ENTITY_CACHE_ENABLED, TipsOfTheDayUsersImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.rivetlogic.skype.service.persistence.impl.SkypeGroupPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, SkypeGroup> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww .j av a2 s . co m Map<Serializable, SkypeGroup> map = new HashMap<Serializable, SkypeGroup>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); SkypeGroup skypeGroup = fetchByPrimaryKey(primaryKey); if (skypeGroup != null) { map.put(primaryKey, skypeGroup); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(SkypeGroupModelImpl.ENTITY_CACHE_ENABLED, SkypeGroupImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (SkypeGroup) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_SKYPEGROUP_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (SkypeGroup skypeGroup : (List<SkypeGroup>) q.list()) { map.put(skypeGroup.getPrimaryKeyObj(), skypeGroup); cacheResult(skypeGroup); uncachedPrimaryKeys.remove(skypeGroup.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(SkypeGroupModelImpl.ENTITY_CACHE_ENABLED, SkypeGroupImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.rivetlogic.tout.portlet.ToutConfigPortlet.java
License:Open Source License
private void displayMatchingPages(ResourceRequest request, ResourceResponse response) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); try {//from w ww .j a va 2s. c o m String sitesIdsParam = ParamUtil.getString(request, ToutPortletConstants.ATTR_TOUT_SITES); String pagesRegex = ParamUtil.getString(request, ToutPortletConstants.ATTR_TOUT_PAGES); if (null == pagesRegex || pagesRegex.isEmpty()) { printJsonResponse( LanguageUtil.get(portletConfig, themeDisplay.getLocale(), ToutPortletConstants.ERROR_BAD_PARAMETER_REGEX), String.valueOf(HttpServletResponse.SC_BAD_REQUEST), response); return; } Pattern pattern = null; try { pattern = Pattern.compile(pagesRegex.toLowerCase()); } catch (PatternSyntaxException e) { logger.error(e); printJsonResponse( LanguageUtil.get(portletConfig, themeDisplay.getLocale(), ToutPortletConstants.ERROR_BAD_PARAMETER_REGEX), String.valueOf(HttpServletResponse.SC_BAD_REQUEST), response); return; } String[] sitesIdsArr = (null != sitesIdsParam && !sitesIdsParam.isEmpty() ? sitesIdsParam.split(StringPool.COMMA) : null); Set<Layout> pages = getSitesPages(sitesIdsArr, themeDisplay.getCompanyId()); Set<String> matchingSitesPagesStr = new HashSet<String>(); if (null != pages) for (Layout layout : pages) { if (pattern.matcher(layout.getNameCurrentValue().toLowerCase()).find()) { String matchingSitePageStr = layout.getGroup().getDescriptiveName() + StringPool.SPACE + StringPool.DASH + StringPool.SPACE + layout.getNameCurrentValue(); matchingSitesPagesStr.add(matchingSitePageStr); } } if (!matchingSitesPagesStr.isEmpty()) { JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (String item : matchingSitesPagesStr) { jsonArray.put(JSONFactoryUtil.serialize(item)); } printJsonResponse(jsonArray.toString(), String.valueOf(HttpServletResponse.SC_OK), response); } else { printJsonResponse( LanguageUtil.get(portletConfig, themeDisplay.getLocale(), ToutPortletConstants.ERROR_NO_MATCHING_PAGES), String.valueOf(HttpServletResponse.SC_NOT_FOUND), response); } } catch (Exception e) { logger.error(e); printJsonResponse( LanguageUtil.get(portletConfig, themeDisplay.getLocale(), ToutPortletConstants.ERROR_RETRIEVING_MATCHING_PAGES), String.valueOf(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), response); } }
From source file:com.rivetlogic.tout.service.persistence.ToutUserStatusPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("userId"); sb.append(StringPool.EQUAL);/*from w w w .ja v a2s. c om*/ sb.append(userId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("toutConfigId"); sb.append(StringPool.EQUAL); sb.append(toutConfigId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.rivetlogic.util.SkillsUtil.java
License:Open Source License
private static DynamicQuery buildQuery(String terms) throws PortalException, SystemException { long companyId = PortalUtil.getDefaultCompanyId(); long classNameId = ClassNameLocalServiceUtil.getClassNameId(User.class); ExpandoTable table = ExpandoTableLocalServiceUtil.getDefaultTable(companyId, classNameId); ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(table.getTableId(), "skills"); if (column != null) { DynamicQuery query = ExpandoValueLocalServiceUtil.dynamicQuery(); query.add(RestrictionsFactoryUtil.eq("companyId", companyId)); query.add(RestrictionsFactoryUtil.eq("tableId", table.getTableId())); query.add(RestrictionsFactoryUtil.eq("columnId", column.getColumnId())); String[] skills = terms.split(StringPool.COMMA); if (skills.length > 0) { for (String skill : skills) { query.add(RestrictionsFactoryUtil.ilike("data", String.format("%%%s%%", skill))); }// w w w. ja v a 2 s . c o m } return query; } return null; }
From source file:com.simple.service.persistence.impl.UserViewPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, UserView> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w w w .j a v a2 s . c om Map<Serializable, UserView> map = new HashMap<Serializable, UserView>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); UserView userView = fetchByPrimaryKey(primaryKey); if (userView != null) { map.put(primaryKey, userView); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(UserViewModelImpl.ENTITY_CACHE_ENABLED, UserViewImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (UserView) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_USERVIEW_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (UserView userView : (List<UserView>) q.list()) { map.put(userView.getPrimaryKeyObj(), userView); cacheResult(userView); uncachedPrimaryKeys.remove(userView.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(UserViewModelImpl.ENTITY_CACHE_ENABLED, UserViewImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.sky.skyseries.apm.service.persistence.impl.BuildingPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Building> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* www . j a va 2s.c o m*/ Map<Serializable, Building> map = new HashMap<Serializable, Building>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Building building = fetchByPrimaryKey(primaryKey); if (building != null) { map.put(primaryKey, building); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(BuildingModelImpl.ENTITY_CACHE_ENABLED, BuildingImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Building) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BUILDING_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Building building : (List<Building>) q.list()) { map.put(building.getPrimaryKeyObj(), building); cacheResult(building); uncachedPrimaryKeys.remove(building.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BuildingModelImpl.ENTITY_CACHE_ENABLED, BuildingImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.sky.skyseries.apm.service.persistence.impl.FloorPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Floor> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*w ww .j a v a 2 s .co m*/ Map<Serializable, Floor> map = new HashMap<Serializable, Floor>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Floor floor = fetchByPrimaryKey(primaryKey); if (floor != null) { map.put(primaryKey, floor); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(FloorModelImpl.ENTITY_CACHE_ENABLED, FloorImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Floor) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_FLOOR_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Floor floor : (List<Floor>) q.list()) { map.put(floor.getPrimaryKeyObj(), floor); cacheResult(floor); uncachedPrimaryKeys.remove(floor.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(FloorModelImpl.ENTITY_CACHE_ENABLED, FloorImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.sky.skyseries.apm.service.persistence.impl.LegalEntityPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, LegalEntity> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww . j av a 2 s . c o m Map<Serializable, LegalEntity> map = new HashMap<Serializable, LegalEntity>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); LegalEntity legalEntity = fetchByPrimaryKey(primaryKey); if (legalEntity != null) { map.put(primaryKey, legalEntity); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(LegalEntityModelImpl.ENTITY_CACHE_ENABLED, LegalEntityImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (LegalEntity) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_LEGALENTITY_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (LegalEntity legalEntity : (List<LegalEntity>) q.list()) { map.put(legalEntity.getPrimaryKeyObj(), legalEntity); cacheResult(legalEntity); uncachedPrimaryKeys.remove(legalEntity.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(LegalEntityModelImpl.ENTITY_CACHE_ENABLED, LegalEntityImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }