use of com.liferay.portlet.expando.model.ExpandoColumn in project liferay-ide by liferay.
the class LiferayAppDataService method doGetPersonData.
protected DataCollection doGetPersonData(Set<UserId> userIds, GroupId groupId, String appId, Set<String> fields, SecurityToken securityToken) throws Exception {
long companyId = getCompanyId(securityToken);
Map<String, Map<String, String>> peopleAppData = new HashMap<String, Map<String, String>>();
List<ExpandoColumn> expandoColumns = getExpandoColumns(companyId, appId);
if (expandoColumns == null) {
return null;
}
if (fields.isEmpty()) {
fields = new LinkedHashSet<String>();
for (ExpandoColumn expandoColumn : expandoColumns) {
fields.add(expandoColumn.getName());
}
}
for (UserId userId : userIds) {
String userIdString = userId.getUserId(securityToken);
long userIdLong = GetterUtil.getLong(userIdString);
Map<String, String> personAppData = new HashMap<String, String>();
for (String field : fields) {
String value = getExpandoValue(companyId, appId, userIdLong, getColumnName(appId, field));
personAppData.put(field, value);
}
peopleAppData.put(userIdString, personAppData);
}
return new DataCollection(peopleAppData);
}
use of com.liferay.portlet.expando.model.ExpandoColumn in project sw360portal by sw360.
the class CustomFieldHelper method ensureUserCustomFieldExists.
private static void ensureUserCustomFieldExists(com.liferay.portal.model.User liferayUser, String customFieldName, int customFieldType) throws PortalException, SystemException {
ExpandoBridge exp = liferayUser.getExpandoBridge();
if (!exp.hasAttribute(customFieldName)) {
exp.addAttribute(customFieldName, customFieldType, false);
long companyId = liferayUser.getCompanyId();
ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(companyId, exp.getClassName(), ExpandoTableConstants.DEFAULT_TABLE_NAME, customFieldName);
String[] roleNames = new String[] { RoleConstants.USER, RoleConstants.POWER_USER };
for (String roleName : roleNames) {
Role role = RoleLocalServiceUtil.getRole(companyId, roleName);
if (role != null && column != null) {
ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(column.getColumnId()), role.getRoleId(), new String[] { ActionKeys.VIEW, ActionKeys.UPDATE });
}
}
}
}
use of com.liferay.portlet.expando.model.ExpandoColumn in project liferay-ide by liferay.
the class LiferayAppDataService method doUpdatePersonData.
protected void doUpdatePersonData(UserId userId, GroupId groupId, String appId, Set<String> fields, Map<String, String> values, SecurityToken securityToken) throws Exception {
long companyId = getCompanyId(securityToken);
long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
for (String key : values.keySet()) {
// Workaround for a Shindig bug that stores a Long in value instead
// of the expected String so we cannot use generics here
String value = String.valueOf(values.get(key));
ExpandoColumn expandoColumn = getExpandoColumn(companyId, getColumnName(appId, key));
ExpandoValueLocalServiceUtil.addValue(companyId, User.class.getName(), ShindigUtil.getTableOpenSocial(), expandoColumn.getName(), userIdLong, value);
}
return;
}
use of com.liferay.portlet.expando.model.ExpandoColumn in project liferay-ide by liferay.
the class LiferayAppDataService method getExpandoColumn.
protected ExpandoColumn getExpandoColumn(long companyId, String columnName) throws Exception {
ExpandoTable expandoTable = null;
try {
expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ShindigUtil.getTableOpenSocial());
} catch (NoSuchTableException nste) {
_log.error(nste, nste);
}
ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), columnName);
if (expandoColumn == null) {
expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), columnName, ExpandoColumnConstants.STRING);
}
return expandoColumn;
}
use of com.liferay.portlet.expando.model.ExpandoColumn in project liferay-ide by liferay.
the class LiferayAppDataService method doDeletePersonData.
protected void doDeletePersonData(UserId userId, GroupId groupId, String appId, Set<String> fields, SecurityToken securityToken) throws Exception {
long companyId = getCompanyId(securityToken);
long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
for (String field : fields) {
ExpandoColumn expandoColumn = getExpandoColumn(companyId, getColumnName(appId, field));
ExpandoValueLocalServiceUtil.deleteValue(companyId, User.class.getName(), ShindigUtil.getTableOpenSocial(), expandoColumn.getName(), userIdLong);
}
return;
}
Aggregations