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.bookmarks.service.persistence.impl.BookmarksEntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, BookmarksEntry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w ww.j a v a 2 s . com Map<Serializable, BookmarksEntry> map = new HashMap<Serializable, BookmarksEntry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); BookmarksEntry bookmarksEntry = fetchByPrimaryKey(primaryKey); if (bookmarksEntry != null) { map.put(primaryKey, bookmarksEntry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (BookmarksEntry) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BOOKMARKSENTRY_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 (BookmarksEntry bookmarksEntry : (List<BookmarksEntry>) q.list()) { map.put(bookmarksEntry.getPrimaryKeyObj(), bookmarksEntry); cacheResult(bookmarksEntry); uncachedPrimaryKeys.remove(bookmarksEntry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BookmarksEntryModelImpl.ENTITY_CACHE_ENABLED, BookmarksEntryImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.bookmarks.service.persistence.impl.BookmarksFolderPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, BookmarksFolder> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// w w w . j ava 2 s . c o m Map<Serializable, BookmarksFolder> map = new HashMap<Serializable, BookmarksFolder>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); BookmarksFolder bookmarksFolder = fetchByPrimaryKey(primaryKey); if (bookmarksFolder != null) { map.put(primaryKey, bookmarksFolder); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED, BookmarksFolderImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (BookmarksFolder) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BOOKMARKSFOLDER_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 (BookmarksFolder bookmarksFolder : (List<BookmarksFolder>) q.list()) { map.put(bookmarksFolder.getPrimaryKeyObj(), bookmarksFolder); cacheResult(bookmarksFolder); uncachedPrimaryKeys.remove(bookmarksFolder.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BookmarksFolderModelImpl.ENTITY_CACHE_ENABLED, BookmarksFolderImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.bootcamp.service.persistence.impl.BookPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Book> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from ww w . java 2 s. c om Map<Serializable, Book> map = new HashMap<Serializable, Book>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Book book = fetchByPrimaryKey(primaryKey); if (book != null) { map.put(primaryKey, book); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Book book = (Book) entityCache.getResult(BookModelImpl.ENTITY_CACHE_ENABLED, BookImpl.class, primaryKey); if (book == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, book); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_BOOK_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 (Book book : (List<Book>) q.list()) { map.put(book.getPrimaryKeyObj(), book); cacheResult(book); uncachedPrimaryKeys.remove(book.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(BookModelImpl.ENTITY_CACHE_ENABLED, BookImpl.class, primaryKey, _nullBook); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.calendar.service.persistence.impl.CalendarBookingPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CalendarBooking> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww . ja va 2 s.c om*/ Map<Serializable, CalendarBooking> map = new HashMap<Serializable, CalendarBooking>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CalendarBooking calendarBooking = fetchByPrimaryKey(primaryKey); if (calendarBooking != null) { map.put(primaryKey, calendarBooking); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { CalendarBooking calendarBooking = (CalendarBooking) EntityCacheUtil.getResult( CalendarBookingModelImpl.ENTITY_CACHE_ENABLED, CalendarBookingImpl.class, primaryKey); if (calendarBooking == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, calendarBooking); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CALENDARBOOKING_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 (CalendarBooking calendarBooking : (List<CalendarBooking>) q.list()) { map.put(calendarBooking.getPrimaryKeyObj(), calendarBooking); cacheResult(calendarBooking); uncachedPrimaryKeys.remove(calendarBooking.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(CalendarBookingModelImpl.ENTITY_CACHE_ENABLED, CalendarBookingImpl.class, primaryKey, _nullCalendarBooking); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.calendar.service.persistence.impl.CalendarNotificationTemplatePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CalendarNotificationTemplate> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w w w. ja v a 2 s . c o m Map<Serializable, CalendarNotificationTemplate> map = new HashMap<Serializable, CalendarNotificationTemplate>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CalendarNotificationTemplate calendarNotificationTemplate = fetchByPrimaryKey(primaryKey); if (calendarNotificationTemplate != null) { map.put(primaryKey, calendarNotificationTemplate); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { CalendarNotificationTemplate calendarNotificationTemplate = (CalendarNotificationTemplate) EntityCacheUtil .getResult(CalendarNotificationTemplateModelImpl.ENTITY_CACHE_ENABLED, CalendarNotificationTemplateImpl.class, primaryKey); if (calendarNotificationTemplate == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, calendarNotificationTemplate); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CALENDARNOTIFICATIONTEMPLATE_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 (CalendarNotificationTemplate calendarNotificationTemplate : (List<CalendarNotificationTemplate>) q .list()) { map.put(calendarNotificationTemplate.getPrimaryKeyObj(), calendarNotificationTemplate); cacheResult(calendarNotificationTemplate); uncachedPrimaryKeys.remove(calendarNotificationTemplate.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(CalendarNotificationTemplateModelImpl.ENTITY_CACHE_ENABLED, CalendarNotificationTemplateImpl.class, primaryKey, _nullCalendarNotificationTemplate); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.calendar.service.persistence.impl.CalendarPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Calendar> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//w ww.ja v a 2s .c o m Map<Serializable, Calendar> map = new HashMap<Serializable, Calendar>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Calendar calendar = fetchByPrimaryKey(primaryKey); if (calendar != null) { map.put(primaryKey, calendar); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Calendar calendar = (Calendar) EntityCacheUtil.getResult(CalendarModelImpl.ENTITY_CACHE_ENABLED, CalendarImpl.class, primaryKey); if (calendar == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, calendar); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CALENDAR_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 (Calendar calendar : (List<Calendar>) q.list()) { map.put(calendar.getPrimaryKeyObj(), calendar); cacheResult(calendar); uncachedPrimaryKeys.remove(calendar.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(CalendarModelImpl.ENTITY_CACHE_ENABLED, CalendarImpl.class, primaryKey, _nullCalendar); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.calendar.service.persistence.impl.CalendarResourcePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, CalendarResource> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww.j a v a 2 s . c o m Map<Serializable, CalendarResource> map = new HashMap<Serializable, CalendarResource>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); CalendarResource calendarResource = fetchByPrimaryKey(primaryKey); if (calendarResource != null) { map.put(primaryKey, calendarResource); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { CalendarResource calendarResource = (CalendarResource) EntityCacheUtil.getResult( CalendarResourceModelImpl.ENTITY_CACHE_ENABLED, CalendarResourceImpl.class, primaryKey); if (calendarResource == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, calendarResource); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_CALENDARRESOURCE_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 (CalendarResource calendarResource : (List<CalendarResource>) q.list()) { map.put(calendarResource.getPrimaryKeyObj(), calendarResource); cacheResult(calendarResource); uncachedPrimaryKeys.remove(calendarResource.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(CalendarResourceModelImpl.ENTITY_CACHE_ENABLED, CalendarResourceImpl.class, primaryKey, _nullCalendarResource); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.calendar.util.CalendarICalDataHandler.java
License:Open Source License
protected void importICalEvent(long calendarId, VEvent vEvent) throws Exception { Calendar calendar = CalendarLocalServiceUtil.getCalendar(calendarId); // Title//from w w w. java 2 s . com User user = UserLocalServiceUtil.getUser(calendar.getUserId()); Map<Locale, String> titleMap = new HashMap<Locale, String>(); Summary summary = vEvent.getSummary(); if (summary != null) { String title = ModelHintsUtil.trimString(CalendarBooking.class.getName(), "title", summary.getValue()); titleMap.put(user.getLocale(), title); } // Description Map<Locale, String> descriptionMap = new HashMap<Locale, String>(); Description description = vEvent.getDescription(); if (description != null) { descriptionMap.put(user.getLocale(), description.getValue()); } // Location String locationString = StringPool.BLANK; Location location = vEvent.getLocation(); if (location != null) { locationString = location.getValue(); } // Dates DtStart dtStart = vEvent.getStartDate(); Date startDate = dtStart.getDate(); DtEnd dtEnd = vEvent.getEndDate(); Date endDate = dtEnd.getDate(); // All day boolean allDay = false; if (isICalDateOnly(dtStart)) { allDay = true; long time = endDate.getTime(); endDate.setTime(time - 1); } // Recurrence RRule rrule = (RRule) vEvent.getProperty(Property.RRULE); String recurrence = StringPool.BLANK; if (rrule != null) { recurrence = StringUtil.trim(rrule.toString()); PropertyList propertyList = vEvent.getProperties(Property.EXDATE); if (!propertyList.isEmpty()) { StringBundler sb = new StringBundler(); Iterator<ExDate> iterator = propertyList.iterator(); while (iterator.hasNext()) { ExDate exDate = iterator.next(); DateList dateList = exDate.getDates(); ListIterator<Date> listIterator = dateList.listIterator(); while (listIterator.hasNext()) { Date date = listIterator.next(); java.util.Calendar jCalendar = JCalendarUtil.getJCalendar(date.getTime()); int year = jCalendar.get(java.util.Calendar.YEAR); int month = jCalendar.get(java.util.Calendar.MONTH) + 1; int day = jCalendar.get(java.util.Calendar.DATE); int hour = jCalendar.get(java.util.Calendar.HOUR_OF_DAY); int minute = jCalendar.get(java.util.Calendar.MINUTE); int second = jCalendar.get(java.util.Calendar.SECOND); sb.append(String.format(_EXDATE_FORMAT, year, month, day, hour, minute, second)); if (listIterator.hasNext()) { sb.append(StringPool.COMMA); } } if (iterator.hasNext()) { sb.append(StringPool.COMMA); } } recurrence = recurrence.concat(StringPool.NEW_LINE).concat(_EXDATE).concat(sb.toString()); } } // Reminders ComponentList componentList = vEvent.getAlarms(); long[] reminders = new long[componentList.size()]; String[] reminderTypes = new String[componentList.size()]; int i = 0; for (Iterator<VAlarm> iterator = componentList.iterator(); iterator.hasNext();) { VAlarm vAlarm = iterator.next(); Action action = vAlarm.getAction(); String value = StringUtil.lowerCase(action.getValue()); if (!isActionSupported(value)) { continue; } reminderTypes[i] = value; Trigger trigger = vAlarm.getTrigger(); long time = 0; DateTime dateTime = trigger.getDateTime(); Dur dur = trigger.getDuration(); if ((dateTime == null) && (dur == null)) { continue; } if (dateTime != null) { time = startDate.getTime() - dateTime.getTime(); if (time < 0) { continue; } } else { if (!dur.isNegative()) { continue; } time += dur.getWeeks() * Time.WEEK; time += dur.getDays() * Time.DAY; time += dur.getHours() * Time.HOUR; time += dur.getMinutes() * Time.MINUTE; time += dur.getSeconds() * Time.SECOND; } reminders[i] = time; i++; } long firstReminder = 0; String firstReminderType = null; long secondReminder = 0; String secondReminderType = null; if (i > 0) { firstReminder = reminders[0]; firstReminderType = reminderTypes[0]; } if (i > 1) { secondReminder = reminders[1]; secondReminderType = reminderTypes[1]; } // Attendees PropertyList propertyList = vEvent.getProperties(Property.ATTENDEE); List<Long> childCalendarIds = new ArrayList<Long>(); for (Iterator<Attendee> iterator = propertyList.iterator(); iterator.hasNext();) { Attendee attendee = iterator.next(); URI uri = attendee.getCalAddress(); if (uri == null) { continue; } User attendeeUser = UserLocalServiceUtil.fetchUserByEmailAddress(calendar.getCompanyId(), uri.getSchemeSpecificPart()); if ((attendeeUser == null) || (calendar.getUserId() == attendeeUser.getUserId())) { continue; } ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(calendar.getCompanyId()); serviceContext.setScopeGroupId(calendar.getGroupId()); CalendarResource calendarResource = CalendarResourceUtil .getUserCalendarResource(attendeeUser.getUserId(), serviceContext); if (calendarResource == null) { continue; } childCalendarIds.add(calendarResource.getDefaultCalendarId()); } long[] childCalendarIdsArray = ArrayUtil .toArray(childCalendarIds.toArray(new Long[childCalendarIds.size()])); // Merge calendar booking CalendarBooking calendarBooking = null; String uuid = null; Uid uid = vEvent.getUid(); if (uid != null) { uuid = uid.getValue(); calendarBooking = CalendarBookingLocalServiceUtil.fetchCalendarBooking(uuid, calendar.getGroupId()); } ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setAttribute("sendNotification", Boolean.FALSE); serviceContext.setScopeGroupId(calendar.getGroupId()); if (calendarBooking == null) { serviceContext.setUuid(uuid); CalendarBookingServiceUtil.addCalendarBooking(calendarId, childCalendarIdsArray, CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, titleMap, descriptionMap, locationString, startDate.getTime(), endDate.getTime(), allDay, recurrence, firstReminder, firstReminderType, secondReminder, secondReminderType, serviceContext); } else { CalendarBookingServiceUtil.updateCalendarBooking(calendarBooking.getCalendarBookingId(), calendarId, childCalendarIdsArray, titleMap, descriptionMap, locationString, startDate.getTime(), endDate.getTime(), allDay, recurrence, firstReminder, firstReminderType, secondReminder, secondReminderType, calendarBooking.getStatus(), serviceContext); } }
From source file:com.liferay.chat.service.persistence.impl.EntryPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Entry> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }//from w ww . j a v a 2 s.c o m Map<Serializable, Entry> map = new HashMap<Serializable, Entry>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Entry entry = fetchByPrimaryKey(primaryKey); if (entry != null) { map.put(primaryKey, entry); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Entry entry = (Entry) EntityCacheUtil.getResult(EntryModelImpl.ENTITY_CACHE_ENABLED, EntryImpl.class, primaryKey); if (entry == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, entry); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_ENTRY_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 (Entry entry : (List<Entry>) q.list()) { map.put(entry.getPrimaryKeyObj(), entry); cacheResult(entry); uncachedPrimaryKeys.remove(entry.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult(EntryModelImpl.ENTITY_CACHE_ENABLED, EntryImpl.class, primaryKey, _nullEntry); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.liferay.chat.service.persistence.impl.StatusFinderImpl.java
License:Open Source License
protected String getFindBySocialRelationTypes_SQL(int[] types) { String sql = CustomSQLUtil.get(FIND_BY_SOCIAL_RELATION_TYPES); if (types.length == 0) { return StringUtil.replace(sql, "[$SOCIAL_RELATION_TYPES$]", StringPool.BLANK); }/* w ww.j av a2 s. c o m*/ StringBundler sb = new StringBundler(types.length * 2 - 1); for (int i = 0; i < types.length; i++) { sb.append(StringPool.QUESTION); if ((i + 1) < types.length) { sb.append(StringPool.COMMA); } } return StringUtil.replace(sql, "[$SOCIAL_RELATION_TYPES$]", "SocialRelation.type_ IN (" + sb.toString() + ") AND"); }