Search in sources :

Example 1 with ClassName

use of com.liferay.portal.kernel.model.ClassName 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);
}
Also used : Group(com.liferay.portal.kernel.model.Group) ClassName(com.liferay.portal.kernel.model.ClassName) PagePortletType(com.ableneo.liferay.portal.setup.domain.PagePortletType) HashSet(java.util.HashSet)

Example 2 with ClassName

use of com.liferay.portal.kernel.model.ClassName in project liferay-db-setup-core by ableneo.

the class SetupCategorization method composeVocabularySettings.

private static String composeVocabularySettings(Vocabulary vocabulary, final long groupId) {
    // class copied into the bundle from com.liferay.portal.impl bundle with maven shade plugin
    AssetVocabularySettingsHelper assetVocabularySettingsHelper = new AssetVocabularySettingsHelper();
    assetVocabularySettingsHelper.setMultiValued(vocabulary.isMultiValued());
    List<AssociatedAssetType> types = vocabulary.getAssociatedAssetType();
    if (Objects.isNull(types) || types.isEmpty()) {
        assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(new long[] { AssetCategoryConstants.ALL_CLASS_NAME_ID }, new long[] { AssetCategoryConstants.ALL_CLASS_TYPE_PK }, new boolean[] { false });
        return assetVocabularySettingsHelper.toString();
    }
    List<Long> classNameIds = new LinkedList<>();
    List<Long> classTypePKs = new LinkedList<>();
    List<Boolean> requireds = new LinkedList<>();
    for (AssociatedAssetType type : types) {
        ClassName className = ClassNameLocalServiceUtil.fetchClassName(type.getClassName());
        if (className.getValue().isEmpty()) {
            continue;
        }
        long subtypePK = -1;
        if (Objects.nonNull(type.getSubtypeStructureKey()) && !type.getSubtypeStructureKey().isEmpty()) {
            // has subtype
            try {
                subtypePK = ResolverUtil.getStructureId(type.getSubtypeStructureKey(), groupId, type.getClassName(), true);
            } catch (PortalException e) {
                LOG.error("Class can not be be resolved for classname: {}", type.getClassName(), e);
                continue;
            }
        }
        classNameIds.add(className.getClassNameId());
        classTypePKs.add(subtypePK);
        requireds.add(type.isRequired());
    }
    // no valid associated types case
    if (classNameIds.isEmpty()) {
        assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(new long[] { AssetCategoryConstants.ALL_CLASS_NAME_ID }, new long[] { AssetCategoryConstants.ALL_CLASS_TYPE_PK }, new boolean[] { false });
        return assetVocabularySettingsHelper.toString();
    }
    // when associated types exists
    boolean[] requiredsArray = new boolean[requireds.size()];
    for (int i = 0; i < requireds.size(); i++) {
        requiredsArray[i] = requireds.get(i);
    }
    assetVocabularySettingsHelper.setClassNameIdsAndClassTypePKs(ArrayUtil.toLongArray(classNameIds), ArrayUtil.toLongArray(classTypePKs), requiredsArray);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Vocabulary settings composed for vocabulary: [{}]. Content: {}", vocabulary.getName(), assetVocabularySettingsHelper);
    }
    return assetVocabularySettingsHelper.toString();
}
Also used : LinkedList(java.util.LinkedList) AssociatedAssetType(com.ableneo.liferay.portal.setup.domain.AssociatedAssetType) ClassName(com.liferay.portal.kernel.model.ClassName) PortalException(com.liferay.portal.kernel.exception.PortalException) AssetVocabularySettingsHelper(com.liferay.portlet.asset.util.AssetVocabularySettingsHelper)

Aggregations

ClassName (com.liferay.portal.kernel.model.ClassName)2 AssociatedAssetType (com.ableneo.liferay.portal.setup.domain.AssociatedAssetType)1 PagePortletType (com.ableneo.liferay.portal.setup.domain.PagePortletType)1 PortalException (com.liferay.portal.kernel.exception.PortalException)1 Group (com.liferay.portal.kernel.model.Group)1 AssetVocabularySettingsHelper (com.liferay.portlet.asset.util.AssetVocabularySettingsHelper)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1