List of usage examples for com.liferay.portal.kernel.util StringUtil lowerCase
public static void lowerCase(String... array)
From source file:com.idetronic.subur.service.impl.ExpertiseLocalServiceImpl.java
License:Open Source License
@Override public List<Expertise> checkExpertises(long userId, Group group, String[] names) throws SystemException, PortalException { List<Expertise> expertises = new ArrayList<Expertise>(); for (String name : names) { Expertise expertise = null;/*from w ww . ja v a 2 s .co m*/ _log.info("exp=" + name); try { expertise = getExpertise(group.getGroupId(), StringUtil.lowerCase(name)); } catch (NoSuchExpertiseException nse) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(group.getGroupId()); expertise = addExpertise(userId, name, serviceContext); } if (expertise != null) expertises.add(expertise); } return expertises; }
From source file:com.idetronic.subur.service.impl.ExpertiseServiceImpl.java
License:Open Source License
@Override public JSONArray search(long[] groupIds, String name, int start, int end) throws SystemException { name = StringUtil.lowerCase(name); List<Expertise> expertises = expertiseLocalService.findByGroupsName(groupIds, name, start, end, null); return Autocomplete.listToJson(expertises, "name", "name"); }
From source file:com.idetronic.subur.service.impl.ResearchInterestLocalServiceImpl.java
License:Open Source License
public List<ResearchInterest> checkResearchInterests(long userId, Group group, String[] names) throws SystemException, PortalException { List<ResearchInterest> researchInterests = new ArrayList<ResearchInterest>(); for (String name : names) { ResearchInterest researchInterest = null; try {//from w w w .j ava 2 s . c o m researchInterest = getResearchInterest(group.getGroupId(), StringUtil.lowerCase(name)); } catch (NoSuchResearchInterestException nse) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(group.getGroupId()); researchInterest = addResearchInterest(userId, name, serviceContext); } if (researchInterest != null) researchInterests.add(researchInterest); } return researchInterests; }
From source file:com.idetronic.subur.service.impl.ResearchInterestServiceImpl.java
License:Open Source License
public JSONArray search(long[] groupIds, String name, int start, int end) throws SystemException { name = StringUtil.lowerCase(name); List<ResearchInterest> researchInterests = researchInterestLocalService.findByGroupsName(groupIds, name, start, end, null);/* w w w. j a v a2 s.com*/ return Autocomplete.listToJson(researchInterests, "name", "name"); }
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. ja v a 2 s .c om 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.customsql.CustomSQL.java
License:Open Source License
public String[] keywords(String[] keywordsArray, boolean lowerCase) { if (ArrayUtil.isEmpty(keywordsArray)) { return new String[] { null }; }// w w w . j a v a 2s .c om if (lowerCase) { for (int i = 0; i < keywordsArray.length; i++) { keywordsArray[i] = StringUtil.lowerCase(keywordsArray[i]); } } return keywordsArray; }
From source file:com.liferay.message.boards.parser.bbcode.internal.BBCodeToken.java
License:Open Source License
public BBCodeToken(String startTag, String attribute, String endTag, int start, int end) { _startTag = StringUtil.lowerCase(startTag); _attribute = attribute;//from www.j a va 2 s . co m _endTag = StringUtil.lowerCase(endTag); _start = start; _end = end; }
From source file:com.liferay.osb.scv.user.profile.util.UserProfileUtil.java
License:Open Source License
public static void updateDataSourceEntries(long mappingDataSourceId, Map<String, List<String>> searchTermFieldNameMap, JSONObject jsonObject) throws Exception { List<String> tableNames = new ArrayList<>(); List<String> pkFields = new ArrayList<>(); Iterator<String> iterator = jsonObject.keys(); while (iterator.hasNext()) { String tableName = iterator.next(); tableNames.add(tableName);/*from ww w. java2s . c o m*/ if (!StringUtil.equalsIgnoreCase(tableName, "user")) { pkFields.add(StringUtil.lowerCase(tableName) + "Ids"); } } for (String tableName : tableNames) { List<String> searchTermFieldNames = searchTermFieldNameMap.get(tableName); JSONArray jsonArray = jsonObject.getJSONArray(tableName); for (int i = 0; i < jsonArray.length(); i++) { JSONObject entityJSONObject = jsonArray.getJSONObject(i); String id = entityJSONObject.getString(StringUtil.lowerCase(tableName) + "Id"); List<String> searchTerms = new ArrayList<>(); if (!ListUtil.isEmpty(searchTermFieldNames)) { for (String searchTermFieldName : searchTermFieldNames) { searchTerms.add(entityJSONObject.getString(searchTermFieldName)); } for (String pkField : pkFields) { Object value = entityJSONObject.get(pkField); if (value == null) { continue; } entityJSONObject.put(UserProfileConstants.FIELD_ASSOCIATED + pkField, value); entityJSONObject.remove(pkField); } } updateDataSourceEntry(mappingDataSourceId, tableName, id, searchTerms, entityJSONObject); } } }
From source file:com.liferay.osb.scv.user.profile.util.UserProfileUtil.java
License:Open Source License
protected static VersionedDataSourceEntry getVersionedDataSourceEntry(long mappingDataSourceId, String tableName, String id, List<String> searchTerms, String documentType) throws Exception { DataSourceEntry dataSourceEntry = null; JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("mappingDataSourceId", mappingDataSourceId); jsonObject.put("id", id); jsonObject.put("tableName", StringUtil.lowerCase(tableName)); List<DataSourceEntry> dataSourceEntries = _userProfileCommandUtil.search(jsonObject, documentType); if (!dataSourceEntries.isEmpty()) { dataSourceEntry = dataSourceEntries.get(0); } else {//from w w w .j av a 2 s.co m dataSourceEntry = new DataSourceEntry(); dataSourceEntry.addProperties(jsonObject); } if (!searchTerms.isEmpty()) { JSONArray searchTermsJSONArray = JSONFactoryUtil.createJSONArray(); for (String searchTerm : searchTerms) { searchTermsJSONArray.put(searchTerm); } dataSourceEntry.addProperty("searchTerms", searchTermsJSONArray); } return new VersionedDataSourceEntry(dataSourceEntry); }
From source file:com.liferay.so.service.persistence.FavoriteSiteFinderImpl.java
License:Open Source License
public List<Object[]> findByU_N(long userId, String name, String groupRealName, int start, int end) throws SystemException { name = StringUtil.lowerCase(name); Session session = null;/*from www . j a v a2s .c om*/ try { session = openSession(); String sql = CustomSQLUtil.get(FIND_BY_U_N); SQLQuery q = session.createSQLQuery(sql); q.addScalar("userId", Type.LONG); q.addScalar("groupId", Type.LONG); QueryPos qPos = QueryPos.getInstance(q); qPos.add(userId); qPos.add(StringPool.PERCENT + name + StringPool.PERCENT); qPos.add(groupRealName); qPos.add(name); return (List<Object[]>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw new SystemException(e); } finally { closeSession(session); } }