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.micro.maintainance.task.service.persistence.impl.CandidateMaintenancePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CandidateMaintenance> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w. j av a 2 s . c o m Map<Serializable, CandidateMaintenance> map = new HashMap<Serializable, CandidateMaintenance>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CandidateMaintenance candidateMaintenance = fetchByPrimaryKey(primaryKey); if (candidateMaintenance != null) { map.put(primaryKey, candidateMaintenance); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(CandidateMaintenanceModelImpl.ENTITY_CACHE_ENABLED, CandidateMaintenanceImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (CandidateMaintenance) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CANDIDATEMAINTENANCE_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 (CandidateMaintenance candidateMaintenance : (List<CandidateMaintenance>) q.list()) { map.put(candidateMaintenance.getPrimaryKeyObj(), candidateMaintenance); cacheResult(candidateMaintenance); uncachedPrimaryKeys.remove(candidateMaintenance.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(CandidateMaintenanceModelImpl.ENTITY_CACHE_ENABLED, CandidateMaintenanceImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.micro.maintainance.task.service.persistence.impl.TaskEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TaskEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//w w w. ja va2s. c o m Map<Serializable, TaskEntry> map = new HashMap<Serializable, TaskEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TaskEntry taskEntry = fetchByPrimaryKey(primaryKey); if (taskEntry != null) { map.put(primaryKey, taskEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TaskEntryModelImpl.ENTITY_CACHE_ENABLED, TaskEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (TaskEntry) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TASKENTRY_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 (TaskEntry taskEntry : (List<TaskEntry>) q.list()) { map.put(taskEntry.getPrimaryKeyObj(), taskEntry); cacheResult(taskEntry); uncachedPrimaryKeys.remove(taskEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TaskEntryModelImpl.ENTITY_CACHE_ENABLED, TaskEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.microblogs.service.persistence.impl.MicroblogsEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, MicroblogsEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww . j a v a 2 s . c om*/ Map<Serializable, MicroblogsEntry> map = new HashMap<Serializable, MicroblogsEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MicroblogsEntry microblogsEntry = fetchByPrimaryKey(primaryKey); if (microblogsEntry != null) { map.put(primaryKey, microblogsEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { MicroblogsEntry microblogsEntry = (MicroblogsEntry) EntityCacheUtil.getResult( MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED, MicroblogsEntryImpl.class, primaryKey); if (microblogsEntry == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, microblogsEntry); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MICROBLOGSENTRY_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 (MicroblogsEntry microblogsEntry : (List<MicroblogsEntry>) q.list()) { map.put(microblogsEntry.getPrimaryKeyObj(), microblogsEntry); cacheResult(microblogsEntry); uncachedPrimaryKeys.remove(microblogsEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(MicroblogsEntryModelImpl.ENTITY_CACHE_ENABLED, MicroblogsEntryImpl.class, primaryKey, _nullMicroblogsEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.modules.wiki.extractor.service.persistence.impl.WikiContentPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, WikiContent> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w w w . ja va 2s. c om*/ Map<Serializable, WikiContent> map = new HashMap<Serializable, WikiContent>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WikiContent wikiContent = fetchByPrimaryKey(primaryKey); if (wikiContent != null) { map.put(primaryKey, wikiContent); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(WikiContentModelImpl.ENTITY_CACHE_ENABLED, WikiContentImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (WikiContent) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_WIKICONTENT_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 (WikiContent wikiContent : (List<WikiContent>) q.list()) { map.put(wikiContent.getPrimaryKeyObj(), wikiContent); cacheResult(wikiContent); uncachedPrimaryKeys.remove(wikiContent.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(WikiContentModelImpl.ENTITY_CACHE_ENABLED, WikiContentImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.monitoring.service.persistence.impl.MetricPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Metric> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from www . j ava 2s . c om*/ Map<Serializable, Metric> map = new HashMap<Serializable, Metric>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Metric metric = fetchByPrimaryKey(primaryKey); if (metric != null) { map.put(primaryKey, metric); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Metric metric = (Metric) EntityCacheUtil.getResult(MetricModelImpl.ENTITY_CACHE_ENABLED, MetricImpl.class, primaryKey); if (metric == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, metric); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_METRIC_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 (Metric metric : (List<Metric>) q.list()) { map.put(metric.getPrimaryKeyObj(), metric); cacheResult(metric); uncachedPrimaryKeys.remove(metric.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(MetricModelImpl.ENTITY_CACHE_ENABLED, MetricImpl.class, primaryKey, _nullMetric); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.online.service.persistence.impl.AppPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, App> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww. j a v a 2s. c o m Map<Serializable, App> map = new HashMap<Serializable, App>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); App app = fetchByPrimaryKey(primaryKey); if (app != null) { map.put(primaryKey, app); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { App app = (App) entityCache.getResult(AppModelImpl.ENTITY_CACHE_ENABLED, AppImpl.class, primaryKey); if (app == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, app); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_APP_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 (App app : (List<App>) q.list()) { map.put(app.getPrimaryKeyObj(), app); cacheResult(app); uncachedPrimaryKeys.remove(app.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(AppModelImpl.ENTITY_CACHE_ENABLED, AppImpl.class, primaryKey, _nullApp); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.opensocial.service.persistence.impl.GadgetPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Gadget> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww . j ava2 s.co m Map<Serializable, Gadget> map = new HashMap<Serializable, Gadget>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Gadget gadget = fetchByPrimaryKey(primaryKey); if (gadget != null) { map.put(primaryKey, gadget); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Gadget gadget = (Gadget) EntityCacheUtil.getResult(GadgetModelImpl.ENTITY_CACHE_ENABLED, GadgetImpl.class, primaryKey); if (gadget == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, gadget); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_GADGET_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 (Gadget gadget : (List<Gadget>) q.list()) { map.put(gadget.getPrimaryKeyObj(), gadget); cacheResult(gadget); uncachedPrimaryKeys.remove(gadget.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(GadgetModelImpl.ENTITY_CACHE_ENABLED, GadgetImpl.class, primaryKey, _nullGadget); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.opensocial.service.persistence.impl.OAuthConsumerPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, OAuthConsumer> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww .ja v a 2 s. c om Map<Serializable, OAuthConsumer> map = new HashMap<Serializable, OAuthConsumer>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); OAuthConsumer oAuthConsumer = fetchByPrimaryKey(primaryKey); if (oAuthConsumer != null) { map.put(primaryKey, oAuthConsumer); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { OAuthConsumer oAuthConsumer = (OAuthConsumer) EntityCacheUtil .getResult(OAuthConsumerModelImpl.ENTITY_CACHE_ENABLED, OAuthConsumerImpl.class, primaryKey); if (oAuthConsumer == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, oAuthConsumer); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_OAUTHCONSUMER_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 (OAuthConsumer oAuthConsumer : (List<OAuthConsumer>) q.list()) { map.put(oAuthConsumer.getPrimaryKeyObj(), oAuthConsumer); cacheResult(oAuthConsumer); uncachedPrimaryKeys.remove(oAuthConsumer.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(OAuthConsumerModelImpl.ENTITY_CACHE_ENABLED, OAuthConsumerImpl.class, primaryKey, _nullOAuthConsumer); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.opensocial.service.persistence.impl.OAuthTokenPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, OAuthToken> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w ww .j a va2s. c o m*/ Map<Serializable, OAuthToken> map = new HashMap<Serializable, OAuthToken>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); OAuthToken oAuthToken = fetchByPrimaryKey(primaryKey); if (oAuthToken != null) { map.put(primaryKey, oAuthToken); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { OAuthToken oAuthToken = (OAuthToken) EntityCacheUtil.getResult(OAuthTokenModelImpl.ENTITY_CACHE_ENABLED, OAuthTokenImpl.class, primaryKey); if (oAuthToken == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, oAuthToken); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_OAUTHTOKEN_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 (OAuthToken oAuthToken : (List<OAuthToken>) q.list()) { map.put(oAuthToken.getPrimaryKeyObj(), oAuthToken); cacheResult(oAuthToken); uncachedPrimaryKeys.remove(oAuthToken.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(OAuthTokenModelImpl.ENTITY_CACHE_ENABLED, OAuthTokenImpl.class, primaryKey, _nullOAuthToken); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.osb.scv.user.mapper.service.persistence.impl.MappingDataSourcePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, MappingDataSource> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww. ja v a2s .c o m Map<Serializable, MappingDataSource> map = new HashMap<Serializable, MappingDataSource>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); MappingDataSource mappingDataSource = fetchByPrimaryKey(primaryKey); if (mappingDataSource != null) { map.put(primaryKey, mappingDataSource); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(MappingDataSourceModelImpl.ENTITY_CACHE_ENABLED, MappingDataSourceImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (MappingDataSource) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_MAPPINGDATASOURCE_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 (MappingDataSource mappingDataSource : (List<MappingDataSource>) q.list()) { map.put(mappingDataSource.getPrimaryKeyObj(), mappingDataSource); cacheResult(mappingDataSource); uncachedPrimaryKeys.remove(mappingDataSource.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(MappingDataSourceModelImpl.ENTITY_CACHE_ENABLED, MappingDataSourceImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }