use of com.ableneo.liferay.portal.setup.domain.PagePortletType in project liferay-db-setup-core by ableneo.
the class SetupPages method addArticleDisplayPortletIntoPage.
private static void addArticleDisplayPortletIntoPage(final PageType page, final Layout layout, final ArticleDisplayPortletType portlet, final long companyId, final long groupId) throws PortalException {
if (isLinkPage(page)) {
return;
}
LOG.info("Adding ArticleDisplayPortlet: " + portlet.getColumn() + "@" + portlet.getColumnPosition() + "-" + portlet.getPortletId() + "; " + portlet.getArticleFolder().getFolderPath() + ":" + portlet.getArticleId());
PagePortletType toInsert = null;
long folderId = SetupArticles.getCreateFolderId(portlet.getArticleFolder().getFolderPath(), groupId, portlet.getArticleFolder().getRolePermissions());
JournalArticle journalArticle = SetupArticles.getJournalArticle(portlet.getArticleId(), folderId, groupId, portlet.getArticleFolder().getFolderPath());
if (journalArticle != null) {
Long assetEntryId = SetupArticles.getJournalAssetEntryId(journalArticle);
toInsert = new PagePortletType();
toInsert.setColumn(portlet.getColumn());
toInsert.setColumnPosition(portlet.getColumnPosition());
toInsert.setPortletId(portlet.getPortletId());
toInsert.getPortletPreference().addAll(portlet.getPortletPreference());
toInsert.setRolePermissions(portlet.getRolePermissions());
toInsert.getPortletPreference().add(newPortletPreference("groupId", String.valueOf(groupId)));
// String.valueOf(journalArticle.getPrimaryKey())));
toInsert.getPortletPreference().add(newPortletPreference("articleId", journalArticle.getArticleId()));
if (assetEntryId != null) {
toInsert.getPortletPreference().add(newPortletPreference("assetEntryId", String.valueOf(assetEntryId)));
}
} else {
LOG.error("No journal entry found = skip adding it to the wrappedPortlet. Manual task!");
toInsert = portlet;
}
insertPortletIntoPage(page, layout, toInsert, companyId, groupId);
}
use of com.ableneo.liferay.portal.setup.domain.PagePortletType in project liferay-db-setup-core by ableneo.
the class SetupPages method addMenuViewPortletIntoPage.
private static void addMenuViewPortletIntoPage(PageType page, Layout layout, MenuViewPortletType portlet, long companyId, long groupId) throws PortalException {
if (isLinkPage(page)) {
LOG.info(" ! SKIP-page is a link");
return;
}
LOG.info("Adding MenuViewPortlet: " + portlet.getColumn() + "@" + portlet.getColumnPosition() + "-" + portlet.getPortletId() + "; " + portlet.getAdtTemplate() + ":" + portlet.getMenuName());
PagePortletType toInsert = null;
Long menuId = getMenuIdByName(groupId, portlet.getMenuName());
if (menuId == null || menuId == 0L) {
LOG.info(" ! SKIP-no such menu to add");
return;
}
portlet.getPortletPreference().add(newPortletPreference("siteNavigationMenuId", String.valueOf(menuId)));
DDMTemplate adtTemplate = getAdtTemplate(groupId, portlet.getAdtTemplate(), portlet.getAdtTemplateSiteUrl());
if (adtTemplate == null) {
LOG.info(" ! SKIP-no such template to display with");
return;
}
portlet.getPortletPreference().add(newPortletPreference("displayStyle", "ddmTemplate_" + portlet.getAdtTemplate()));
Group group = GroupLocalServiceUtil.getFriendlyURLGroup(companyId, portlet.getAdtTemplateSiteUrl());
portlet.getPortletPreference().add(//
newPortletPreference("displayStyleGroupId", String.valueOf(group.getPrimaryKey())));
toInsert = new PagePortletType();
toInsert.setColumn(portlet.getColumn());
toInsert.setColumnPosition(portlet.getColumnPosition());
toInsert.setPortletId(portlet.getPortletId());
toInsert.setRolePermissions(portlet.getRolePermissions());
for (Entry<String, String> e : CONFIG_MENU_VIEW_PREFERENCES.entrySet()) {
toInsert.getPortletPreference().add(newPortletPreference(e.getKey(), e.getValue()));
}
toInsert.getPortletPreference().addAll(portlet.getPortletPreference());
insertPortletIntoPage(page, layout, toInsert, companyId, groupId);
}
use of com.ableneo.liferay.portal.setup.domain.PagePortletType in project liferay-db-setup-core by ableneo.
the class SetupPages method setupLiferayPage.
private static void setupLiferayPage(final Layout layout, final PageType page, final String defaultLayout, final String defaultLayoutContainedInThemeWithId, final long groupId, final boolean isPrivate, final long company, final long userId, final String pageTemplateName) throws PortalException {
if (page.getTheme() != null) {
setPageTheme(layout, page);
}
if (page.getLayout() != null) {
setLayoutTemplate(layout, page, userId);
}
setPageTarget(page, layout);
List<PagePortletType> portlets = page.getPagePortlet();
if (portlets != null && !portlets.isEmpty()) {
List<PortletWithRuntimeData> deferredAdd = new ArrayList<SetupPages.PortletWithRuntimeData>();
for (PagePortletType portlet : portlets) {
addRuntimeInfo(deferredAdd, portlet, page, layout, company, groupId);
}
portlets.clear();
portlets.addAll(deferredAdd);
}
List<PageType> subPages = page.getPage();
if (subPages != null && !subPages.isEmpty()) {
if (pageTemplateName != null && !pageTemplateName.equals("")) {
LOG.error(String.format("Page template %1$s may not have any sub-pages! Will ignore them!", pageTemplateName));
} else {
addPages(subPages, defaultLayout, defaultLayoutContainedInThemeWithId, groupId, isPrivate, layout.getLayoutId(), company, userId);
}
}
if (page.getCustomFieldSetting() != null && !page.getCustomFieldSetting().isEmpty()) {
setCustomFields(groupId, company, page, layout);
}
SetupPermissions.updatePermission(String.format("Page %1$s", page.getFriendlyUrl()), company, layout.getPlid(), Layout.class, page.getRolePermissions(), getDefaultPermissions(isPrivate));
}
use of com.ableneo.liferay.portal.setup.domain.PagePortletType in project liferay-db-setup-core by ableneo.
the class SetupPages method addAssetPublisherPortletIntoPage.
private static void addAssetPublisherPortletIntoPage(PageType page, Layout layout, AssetPublisherPortletType portlet, long company, long groupId) throws PortalException {
if (isLinkPage(page)) {
return;
}
LOG.info("Adding AssetPublisherPortlet: " + portlet.getColumn() + "@" + portlet.getColumnPosition() + "-" + portlet.getPortletId() + "; ADTgroupIdFrom:" + portlet.getAdtTemplateSiteUrl());
PagePortletType toInsert = null;
toInsert = new PagePortletType();
toInsert.setColumn(portlet.getColumn());
toInsert.setColumnPosition(portlet.getColumnPosition());
toInsert.setPortletId(portlet.getPortletId());
toInsert.getPortletPreference().addAll(portlet.getPortletPreference());
toInsert.setRolePermissions(portlet.getRolePermissions());
// // ADT STYLE is in this groupId: // 35345 == myra portal, now..
// prefMap.put("displayStyleGroupId", "35345");
Group group = GroupLocalServiceUtil.getFriendlyURLGroup(company, portlet.getAdtTemplateSiteUrl());
toInsert.getPortletPreference().add(newPortletPreference("displayStyleGroupId", String.valueOf(group.getPrimaryKey())));
// //-TODO: decode runtime..
// // [ WIKI-FTl, ...
// // prefMap.put("classNameIds", new String[] {"32502", "28501", "20008", "28506", "33222", "34325", "33246", "20009", "34316", "33208"});
List<String> shownArticleClasses = StringUtil.split(portlet.getShownArticleClasses(), CharPool.SEMICOLON);
Set<String> shownClassIds = new HashSet<String>();
for (String cls : shownArticleClasses) {
ClassName shownClass = ClassNameLocalServiceUtil.getClassName(cls);
shownClassIds.add(String.valueOf(shownClass.getPrimaryKey()));
}
toInsert.getPortletPreference().add(newPortletPreference("classNameIds", StringUtil.merge(shownClassIds, StringPool.COMMA)));
// // //TODO: runtime query of all structure templates, where class-type == com.liferay.journal.model.JournalArticle
// // //BASIC-WEB-CONTENT, TEXT-ARRAY-STRUCT, BUTTON-BOTTOM-STRUCT
// //// 28501: INSERT INTO CLASSNAME_ VALUES(0,28501,'com.liferay.journal.model.JournalArticle')
// //// INSERT INTO DDMSTRUCTURE VALUES(0,'55d9d223-9da5-bda0-0c80-88b8d8c97997',34987,20128,20101,20105,NULL,20105,NULL,'2020-11-21 04:57:26.721000','2020-11-21 04:57:26.721000',0,28501,'BASIC-WEB-CONTENT','1.0','<?xml version=''1.0'' encoding=''UTF-8''?><root available-locales="en_US,sv_SE,pt_BR,ja_JP,fr_FR,hu_HU,de_DE,ca_ES,ar_SA,fi_FI,zh_CN,es_ES,nl_NL" default-locale="en_US"><Name language-id="sv_SE">Vanligt inneh\u00e5ll</Name><Name language-id="pt_BR">Conte\u00fado Web b\u00e1sico</Name><Name language-id="ja_JP">\u57fa\u672cWeb\u30b3\u30f3\u30c6\u30f3\u30c4</Name><Name language-id="fr_FR">Contenu web basique</Name><Name language-id="hu_HU">Alapvet\u0151 webtartalom</Name><Name language-id="de_DE">Einfacher Webcontent</Name><Name language-id="ca_ES">Contigut web b\u00e0sic</Name><Name language-id="ar_SA">\u062a\u062d\u0631\u064a\u0631 \u0645\u062d\u062a\u0648\u0649</Name><Name language-id="fi_FI">Tavallinen web-sis\u00e4lt\u00f6</Name><Name language-id="en_US">Basic Web Content</Name><Name language-id="zh_CN">\u57fa\u672c Web \u5185\u5bb9</Name><Name language-id="es_ES">Contenido web b\u00e1sico</Name><Name language-id="nl_NL">Basiswebcontent</Name></root>','<?xml version=''1.0'' encoding=''UTF-8''?><root available-locales="en_US,sv_SE,pt_BR,ja_JP,fr_FR,hu_HU,de_DE,ca_ES,ar_SA,fi_FI,zh_CN,es_ES,nl_NL" default-locale="en_US"><Description language-id="sv_SE">Vanligt inneh\u00e5ll</Description><Description language-id="pt_BR">Conte\u00fado Web b\u00e1sico</Description><Description language-id="ja_JP">\u57fa\u672cWeb\u30b3\u30f3\u30c6\u30f3\u30c4</Description><Description language-id="fr_FR">Contenu web basique</Description><Description language-id="hu_HU">Alapvet\u0151 webtartalom</Description><Description language-id="de_DE">Einfacher Webcontent</Description><Description language-id="ca_ES">Contigut web b\u00e0sic</Description><Description language-id="ar_SA">\u062a\u062d\u0631\u064a\u0631 \u0645\u062d\u062a\u0648\u0649</Description><Description language-id="fi_FI">Tavallinen web-sis\u00e4lt\u00f6</Description><Description language-id="en_US">Basic Web Content</Description><Description language-id="zh_CN">\u57fa\u672c Web \u5185\u5bb9</Description><Description language-id="es_ES">Contenido web b\u00e1sico</Description><Description language-id="nl_NL">Basiswebcontent</Description></root>','{"availableLanguageIds":["en_US"],"successPage":{"body":{},"title":{},"enabled":false},"defaultLanguageId":"en_US","fields":[{"fieldNamespace":"ddm","indexType":"text","dataType":"html","predefinedValue":{},"name":"content","localizable":true,"tip":{},"label":{"en_US":"content"},"type":"ddm-text-html","showLabel":true}]}','json',0,NULL)
// //// INSERT INTO DDMSTRUCTURE VALUES(0,'5dbceeef-b83f-63db-651a-159ce9964d6e',35348,35345,20101,20130,'Test Test',20130,'Test Test','2020-11-25 13:18:47.567000','2020-11-25 13:18:47.567000',0,28501,'TEXT-ARRAY-STRUCT','1.0','<?xml version=''1.0'' encoding=''UTF-8''?><root available-locales="en_US" default-locale="en_US"><Name language-id="en_US">TEXT-ARRAY-STRUCT</Name></root>','','{"availableLanguageIds":["en_US"],"successPage":{"body":{},"title":{},"enabled":false},"defaultLanguageId":"en_US","fields":[{"indexType":"keyword","repeatable":true,"dataType":"string","predefinedValue":{"en_US":""},"name":"textString","localizable":false,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"Sz\u00f6veg"},"type":"text","required":false,"showLabel":true}]}','json',0,NULL)
// //// INSERT INTO DDMSTRUCTURE VALUES(0,'006c2151-f6cb-c1fe-19f6-5ce259582b28',35352,35345,20101,20130,'Test Test',20130,'Test Test','2020-11-25 13:18:47.648000','2020-11-25 13:18:47.648000',0,28501,'BUTTON-BOTTOM-STRUCT','1.0','<?xml version=''1.0'' encoding=''UTF-8''?><root available-locales="en_US" default-locale="en_US"><Name language-id="en_US">BUTTON-BOTTOM-STRUCT</Name></root>','','{"availableLanguageIds":["en_US"],"successPage":{"body":{},"title":{},"enabled":false},"defaultLanguageId":"en_US","fields":[{"indexType":"keyword","repeatable":false,"dataType":"string","predefinedValue":{"en_US":""},"name":"titletext","localizable":true,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"Cimsor"},"type":"text","required":false,"showLabel":true},{"indexType":"text","repeatable":true,"dataType":"string","predefinedValue":{"en_US":""},"name":"contenttext","localizable":true,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"Szoveges tartalom"},"type":"textarea","required":false,"showLabel":true},{"dataType":"boolean","predefinedValue":{"en_US":"false"},"readOnly":false,"label":{"en_US":"van gombja?"},"type":"checkbox","required":false,"showLabel":true,"nestedFields":[{"indexType":"keyword","repeatable":false,"dataType":"string","predefinedValue":{"en_US":""},"name":"buttontitle","localizable":true,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"szovege"},"type":"text","required":false,"showLabel":true},{"indexType":"keyword","repeatable":false,"dataType":"string","predefinedValue":{"en_US":""},"name":"buttonlink","localizable":true,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"Url/link"},"type":"text","required":false,"showLabel":true},{"dataType":"string","predefinedValue":{"en_US":"[\"\"]"},"multiple":false,"readOnly":false,"label":{"en_US":"gomb szine/tipusa"},"type":"select","required":false,"showLabel":true,"indexType":"keyword","repeatable":false,"name":"buttontype","options":[{"label":{"en_US":"elsodleges"},"value":"btn-primary"},{"label":{"en_US":"masodlagos"},"value":"btn-secondary"},{"label":{"en_US":"atlatszo"},"value":"btn-info"},{"label":{"en_US":"link-szeru"},"value":"btn-link"}],"localizable":true,"tip":{"en_US":""}},{"indexType":"keyword","repeatable":false,"dataType":"string","predefinedValue":{"en_US":""},"name":"buttonicon","localizable":true,"readOnly":false,"tip":{"en_US":""},"label":{"en_US":"ikon/css class"},"type":"text","required":false,"showLabel":true}],"indexType":"keyword","repeatable":true,"name":"hasbutton","localizable":true,"tip":{"en_US":""}}]}','json',0,NULL)
// // prefMap.put("classTypeIdsJournalArticleAssetRendererFactory", "34987,35348,35352");
// ClassName journalArticleClass = ClassNameLocalServiceUtil.getClassName(portlet.getAssetRendererBaseClass());
// List<DDLRecordSet> journalDescendants = DDLRecordSetLocalServiceUtil.getDDMStructureRecordSets(journalArticleClass.getPrimaryKey());
// Set<String> ddlIds = new HashSet<String>();
// for (DDLRecordSet ddlRecord : journalDescendants) {
// ddlIds.add(String.valueOf(ddlRecord.getPrimaryKey()));
// }
// toInsert.getPortletPreference().add(newPortletPreference("classTypeIdsJournalArticleAssetRendererFactory",StringUtil.merge(ddlIds, StringPool.COMMA)));
insertPortletIntoPage(page, layout, toInsert, company, groupId);
}
Aggregations