use of com.ableneo.liferay.portal.setup.domain.CustomFieldSetting in project liferay-db-setup-core by ableneo.
the class SetupPages method setCustomFields.
private static void setCustomFields(final long groupId, final long company, final PageType page, final Layout layout) {
Class clazz = Layout.class;
String resolverHint = "Resolving customized value for page " + page.getFriendlyUrl() + " " + "failed for key " + "%%key%% and value %%value%%";
for (CustomFieldSetting cfs : page.getCustomFieldSetting()) {
String key = cfs.getKey();
String value = cfs.getValue();
CustomFieldSettingUtil.setExpandoValue(resolverHint.replace("%%key%%", key).replace("%%value%%", value), groupId, company, clazz, layout.getPlid(), key, value);
}
}
use of com.ableneo.liferay.portal.setup.domain.CustomFieldSetting in project liferay-db-setup-core by ableneo.
the class SetupSites method setCustomFields.
static void setCustomFields(final long groupId, final List<CustomFieldSetting> customFieldSettings) {
if (customFieldSettings == null || customFieldSettings.isEmpty()) {
LOG.info("Site does has no Expando field settings.");
} else {
Class clazz = com.liferay.portal.kernel.model.Group.class;
String resolverHint = "Resolving customized value failed for key %1$s and value %2$s";
for (CustomFieldSetting cfs : customFieldSettings) {
String key = cfs.getKey();
String value = cfs.getValue();
CustomFieldSettingUtil.setExpandoValue(String.format(resolverHint, key, value), groupId, SetupConfigurationThreadLocal.getRunInCompanyId(), clazz, groupId, key, value);
}
}
}
use of com.ableneo.liferay.portal.setup.domain.CustomFieldSetting in project liferay-db-setup-core by ableneo.
the class SetupUsers method setCustomFields.
private static void setCustomFields(final long groupId, final long company, final User liferayUser, final com.ableneo.liferay.portal.setup.domain.User user) {
Class clazz = liferayUser.getClass();
for (CustomFieldSetting cfs : user.getCustomFieldSetting()) {
String resolverHint = "Custom value for user " + user.getScreenName() + ", " + user.getEmailAddress() + "" + " Key " + cfs.getKey() + ", value " + cfs.getValue();
CustomFieldSettingUtil.setExpandoValue(resolverHint, groupId, company, clazz, liferayUser.getUserId(), cfs.getKey(), cfs.getValue());
}
}
use of com.ableneo.liferay.portal.setup.domain.CustomFieldSetting in project liferay-db-setup-core by ableneo.
the class SetupMenus method createMenuItem.
private static SiteNavigationMenuItem createMenuItem(long groupId, long userId, ServiceContext serviceContext, long parentMenuId, long parentMenuItem, MenuItem newMenuItem) {
// SiteNavigationMenuItemTypeConstants: layout(==page..), node, url
String type = newMenuItem.getType();
if (false == newMenuItem.getMenuItem().isEmpty()) {
type = "node";
} else if (type == null || "".equals(type)) {
type = "url";
} else {
type = "url";
}
LOG.info(" i setting item '" + newMenuItem.getName() + "' as '" + type + "': [" + newMenuItem.getTypeSettings() + "]");
// 'layout','groupId=20121 ; layoutUuid=accf0b5c-800f-d049-01bc-0a706e3fad15 ; privateLayout=false ; title=Search ; '
// defaultLanguageId=en_US ; name_en_US=tarsoldalak ;
String typeSettings = newMenuItem.getTypeSettings();
// LayoutSiteNavigationMenuItemType => page
// NodeSiteNavigationMenuItemType => submenu
// URLSiteNavigationMenuItemType => url link
SiteNavigationMenuItem savedItem = null;
try {
List<SiteNavigationMenuItem> items = SiteNavigationMenuItemLocalServiceUtil.getSiteNavigationMenuItems(parentMenuId, parentMenuItem);
for (SiteNavigationMenuItem item : items) {
if (item.getName().equals(newMenuItem.getName())) {
LOG.info("existing menu-item[" + newMenuItem.getName() + "]");
savedItem = item;
break;
}
}
} catch (Exception e) {
LOG.error("Can not list/find existing menu item '" + newMenuItem.getName() + "', CREATE NEW : ", e);
}
if (savedItem == null) {
try {
serviceContext.setUuid(UUID.randomUUID().toString());
LOG.info("Inserting menu-item[" + newMenuItem.getName() + "]");
savedItem = SiteNavigationMenuItemLocalServiceUtil.addSiteNavigationMenuItem(userId, groupId, parentMenuId, parentMenuItem, type, /*order,*/
typeSettings, serviceContext);
} catch (PortalException e) {
LOG.error("Can not add menu item '" + newMenuItem.getName() + "' : ", e);
return null;
}
}
try {
LOG.info("Updating menu-item[" + newMenuItem.getName() + "] @" + savedItem.getPrimaryKey() + "");
savedItem.setName(newMenuItem.getName());
savedItem.setType(type);
savedItem.setTypeSettings(typeSettings);
savedItem = SiteNavigationMenuItemLocalServiceUtil.updateSiteNavigationMenuItem(savedItem);
} catch (Exception e) {
LOG.error("Can not update menu item '" + newMenuItem.getName() + "' : ", e);
return null;
}
for (CustomFieldSetting cfs : newMenuItem.getCustomFieldSetting()) {
savedItem.getExpandoBridge().setAttribute(cfs.getKey(), cfs.getValue(), false);
}
return savedItem;
}
use of com.ableneo.liferay.portal.setup.domain.CustomFieldSetting in project liferay-db-setup-core by ableneo.
the class SetupOrganizations method setCustomFields.
private static void setCustomFields(final long groupId, final com.ableneo.liferay.portal.setup.domain.Organization org, final Organization liferayOrg) {
Class clazz = Organization.class;
String resolverHint = "Resolving customized value for page " + org.getName() + " " + "failed for key %%key%% " + "and value %%value%%";
for (CustomFieldSetting cfs : org.getCustomFieldSetting()) {
String key = cfs.getKey();
String value = cfs.getValue();
long company = SetupConfigurationThreadLocal.getRunInCompanyId();
CustomFieldSettingUtil.setExpandoValue(resolverHint.replace("%%key%%", key).replace("%%value%%", value), groupId, company, clazz, liferayOrg.getOrganizationId(), key, value);
}
}
Aggregations