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.liferay.projects.dashboard.business.unit.service.persistence.impl.BusinessUnitPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, BusinessUnit> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w ww .ja va 2 s. co m*/ Map<Serializable, BusinessUnit> map = new HashMap<Serializable, BusinessUnit>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); BusinessUnit businessUnit = fetchByPrimaryKey(primaryKey); if (businessUnit != null) { map.put(primaryKey, businessUnit); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(BusinessUnitModelImpl.ENTITY_CACHE_ENABLED, BusinessUnitImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (BusinessUnit) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BUSINESSUNIT_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 (BusinessUnit businessUnit : (List<BusinessUnit>) q.list()) { map.put(businessUnit.getPrimaryKeyObj(), businessUnit); cacheResult(businessUnit); uncachedPrimaryKeys.remove(businessUnit.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BusinessUnitModelImpl.ENTITY_CACHE_ENABLED, BusinessUnitImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.projects.dashboard.business.unit.service.persistence.impl.ProjectBUPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, ProjectBU> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j a va 2 s.c o m*/ Map<Serializable, ProjectBU> map = new HashMap<Serializable, ProjectBU>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); ProjectBU projectBU = fetchByPrimaryKey(primaryKey); if (projectBU != null) { map.put(primaryKey, projectBU); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(ProjectBUModelImpl.ENTITY_CACHE_ENABLED, ProjectBUImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (ProjectBU) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_PROJECTBU_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 (ProjectBU projectBU : (List<ProjectBU>) q.list()) { map.put(projectBU.getPrimaryKeyObj(), projectBU); cacheResult(projectBU); uncachedPrimaryKeys.remove(projectBU.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ProjectBUModelImpl.ENTITY_CACHE_ENABLED, ProjectBUImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.projects.dashboard.business.unit.service.persistence.ProjectBUPK.java
License:Open Source License
@Override public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("businessUnitId"); sb.append(StringPool.EQUAL);//from www. j av a2 s . c o m sb.append(businessUnitId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("projectId"); sb.append(StringPool.EQUAL); sb.append(projectId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.liferay.projects.dashboard.problem.service.persistence.impl.ProblemPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Problem> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w w w . j ava 2 s .co m*/ Map<Serializable, Problem> map = new HashMap<Serializable, Problem>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Problem problem = fetchByPrimaryKey(primaryKey); if (problem != null) { map.put(primaryKey, problem); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(ProblemModelImpl.ENTITY_CACHE_ENABLED, ProblemImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Problem) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_PROBLEM_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 (Problem problem : (List<Problem>) q.list()) { map.put(problem.getPrimaryKeyObj(), problem); cacheResult(problem); uncachedPrimaryKeys.remove(problem.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ProblemModelImpl.ENTITY_CACHE_ENABLED, ProblemImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.pushnotifications.service.persistence.impl.PushNotificationsDevicePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, PushNotificationsDevice> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w ww . j a v a2 s . co m*/ Map<Serializable, PushNotificationsDevice> map = new HashMap<Serializable, PushNotificationsDevice>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); PushNotificationsDevice pushNotificationsDevice = fetchByPrimaryKey(primaryKey); if (pushNotificationsDevice != null) { map.put(primaryKey, pushNotificationsDevice); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { PushNotificationsDevice pushNotificationsDevice = (PushNotificationsDevice) EntityCacheUtil.getResult( PushNotificationsDeviceModelImpl.ENTITY_CACHE_ENABLED, PushNotificationsDeviceImpl.class, primaryKey); if (pushNotificationsDevice == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, pushNotificationsDevice); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_PUSHNOTIFICATIONSDEVICE_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 (PushNotificationsDevice pushNotificationsDevice : (List<PushNotificationsDevice>) q.list()) { map.put(pushNotificationsDevice.getPrimaryKeyObj(), pushNotificationsDevice); cacheResult(pushNotificationsDevice); uncachedPrimaryKeys.remove(pushNotificationsDevice.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(PushNotificationsDeviceModelImpl.ENTITY_CACHE_ENABLED, PushNotificationsDeviceImpl.class, primaryKey, _nullPushNotificationsDevice); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.pushnotifications.service.persistence.impl.PushNotificationsEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, PushNotificationsEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w w w .j av a2 s. com*/ Map<Serializable, PushNotificationsEntry> map = new HashMap<Serializable, PushNotificationsEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); PushNotificationsEntry pushNotificationsEntry = fetchByPrimaryKey(primaryKey); if (pushNotificationsEntry != null) { map.put(primaryKey, pushNotificationsEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { PushNotificationsEntry pushNotificationsEntry = (PushNotificationsEntry) EntityCacheUtil.getResult( PushNotificationsEntryModelImpl.ENTITY_CACHE_ENABLED, PushNotificationsEntryImpl.class, primaryKey); if (pushNotificationsEntry == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, pushNotificationsEntry); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_PUSHNOTIFICATIONSENTRY_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 (PushNotificationsEntry pushNotificationsEntry : (List<PushNotificationsEntry>) q.list()) { map.put(pushNotificationsEntry.getPrimaryKeyObj(), pushNotificationsEntry); cacheResult(pushNotificationsEntry); uncachedPrimaryKeys.remove(pushNotificationsEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(PushNotificationsEntryModelImpl.ENTITY_CACHE_ENABLED, PushNotificationsEntryImpl.class, primaryKey, _nullPushNotificationsEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.recommend.service.persistence.impl.RecommendEntityPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, RecommendEntity> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w w w . j a v a2 s. c o m Map<Serializable, RecommendEntity> map = new HashMap<Serializable, RecommendEntity>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); RecommendEntity recommendEntity = fetchByPrimaryKey(primaryKey); if (recommendEntity != null) { map.put(primaryKey, recommendEntity); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(RecommendEntityModelImpl.ENTITY_CACHE_ENABLED, RecommendEntityImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (RecommendEntity) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_RECOMMENDENTITY_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 (RecommendEntity recommendEntity : (List<RecommendEntity>) q.list()) { map.put(recommendEntity.getPrimaryKeyObj(), recommendEntity); cacheResult(recommendEntity); uncachedPrimaryKeys.remove(recommendEntity.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(RecommendEntityModelImpl.ENTITY_CACHE_ENABLED, RecommendEntityImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.roster.service.persistence.impl.ClubPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Club> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from www . j a va 2s.c o m Map<Serializable, Club> map = new HashMap<Serializable, Club>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Club club = fetchByPrimaryKey(primaryKey); if (club != null) { map.put(primaryKey, club); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Club club = (Club) entityCache.getResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey); if (club == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, club); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CLUB_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 (Club club : (List<Club>) q.list()) { map.put(club.getPrimaryKeyObj(), club); cacheResult(club); uncachedPrimaryKeys.remove(club.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(ClubModelImpl.ENTITY_CACHE_ENABLED, ClubImpl.class, primaryKey, _nullClub); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.roster.service.persistence.impl.RosterMemberPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, RosterMember> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from www. j av a2s. c o m Map<Serializable, RosterMember> map = new HashMap<Serializable, RosterMember>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); RosterMember rosterMember = fetchByPrimaryKey(primaryKey); if (rosterMember != null) { map.put(primaryKey, rosterMember); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { RosterMember rosterMember = (RosterMember) entityCache .getResult(RosterMemberModelImpl.ENTITY_CACHE_ENABLED, RosterMemberImpl.class, primaryKey); if (rosterMember == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, rosterMember); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_ROSTERMEMBER_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 (RosterMember rosterMember : (List<RosterMember>) q.list()) { map.put(rosterMember.getPrimaryKeyObj(), rosterMember); cacheResult(rosterMember); uncachedPrimaryKeys.remove(rosterMember.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(RosterMemberModelImpl.ENTITY_CACHE_ENABLED, RosterMemberImpl.class, primaryKey, _nullRosterMember); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.roster.service.persistence.impl.RosterPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Roster> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from www. ja v a 2 s .com*/ Map<Serializable, Roster> map = new HashMap<Serializable, Roster>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Roster roster = fetchByPrimaryKey(primaryKey); if (roster != null) { map.put(primaryKey, roster); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Roster roster = (Roster) entityCache.getResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, primaryKey); if (roster == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, roster); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_ROSTER_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 (Roster roster : (List<Roster>) q.list()) { map.put(roster.getPrimaryKeyObj(), roster); cacheResult(roster); uncachedPrimaryKeys.remove(roster.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, primaryKey, _nullRoster); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }