List of usage examples for com.liferay.portal.util PropsValues USERS_EXPORT_CSV_FIELDS
String[] USERS_EXPORT_CSV_FIELDS
To view the source code for com.liferay.portal.util PropsValues USERS_EXPORT_CSV_FIELDS.
Click Source Link
From source file:com.liferay.portlet.usersadmin.action.ExportUsersAction.java
License:Open Source License
protected String getUserCSV(User user) { StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2); for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) { String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i]; if (field.equals("fullName")) { sb.append(CSVUtil.encode(user.getFullName())); } else if (field.startsWith("expando:")) { String attributeName = field.substring(8); ExpandoBridge expandoBridge = user.getExpandoBridge(); sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName))); } else {/* w ww .ja v a 2 s .com*/ sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field))); } if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) { sb.append(StringPool.COMMA); } } sb.append(StringPool.NEW_LINE); return sb.toString(); }
From source file:com.liferay.users.admin.web.internal.portlet.action.ExportUsersMVCResourceCommand.java
License:Open Source License
protected String getUserCSV(User user) { StringBundler sb = new StringBundler(PropsValues.USERS_EXPORT_CSV_FIELDS.length * 2); for (int i = 0; i < PropsValues.USERS_EXPORT_CSV_FIELDS.length; i++) { String field = PropsValues.USERS_EXPORT_CSV_FIELDS[i]; if (field.startsWith("expando:")) { String attributeName = field.substring(8); ExpandoBridge expandoBridge = user.getExpandoBridge(); sb.append(CSVUtil.encode(expandoBridge.getAttribute(attributeName))); } else if (field.contains("Date")) { Date date = (Date) BeanPropertiesUtil.getObject(user, field); if (date instanceof Timestamp) { date = new Date(date.getTime()); }//from w w w.j av a 2 s. c o m sb.append(CSVUtil.encode(String.valueOf(date))); } else if (field.equals("fullName")) { sb.append(CSVUtil.encode(user.getFullName())); } else { sb.append(CSVUtil.encode(BeanPropertiesUtil.getString(user, field))); } if ((i + 1) < PropsValues.USERS_EXPORT_CSV_FIELDS.length) { sb.append(StringPool.COMMA); } } sb.append(StringPool.NEW_LINE); return sb.toString(); }