示例#1
0
  protected void configureSubtypeFieldFilter(AssetEntryQuery assetEntryQuery, Locale locale)
      throws Exception {

    long[] classNameIds = getClassNameIds();
    long[] classTypeIds = getClassTypeIds();

    if (!isSubtypeFieldsFilterEnabled()
        || (classNameIds.length != 1)
        || (classTypeIds.length != 1)
        || Validator.isNull(getDDMStructureFieldName())
        || Validator.isNull(getDDMStructureFieldValue())) {

      return;
    }

    AssetRendererFactory<?> assetRendererFactory =
        AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassNameId(classNameIds[0]);

    ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

    ClassType classType = classTypeReader.getClassType(classTypeIds[0], locale);

    ClassTypeField classTypeField = classType.getClassTypeField(getDDMStructureFieldName());

    assetEntryQuery.setAttribute(
        "ddmStructureFieldName",
        AssetPublisherUtil.encodeName(
            classTypeField.getClassTypeId(), getDDMStructureFieldName(), locale));
    assetEntryQuery.setAttribute("ddmStructureFieldValue", getDDMStructureFieldValue());
  }
示例#2
0
  protected void setDDMStructure() throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    _ddmStructureDisplayFieldValue = StringPool.BLANK;
    _ddmStructureFieldLabel = StringPool.BLANK;
    _ddmStructureFieldName = StringPool.BLANK;
    _ddmStructureFieldValue = null;

    long[] classNameIds = getClassNameIds();
    long[] classTypeIds = getClassTypeIds();

    if (!isSubtypeFieldsFilterEnabled()
        || (classNameIds.length != 1)
        || (classTypeIds.length != 1)) {

      return;
    }

    _ddmStructureDisplayFieldValue =
        ParamUtil.getString(
            _request,
            "ddmStructureDisplayFieldValue",
            _portletPreferences.getValue("ddmStructureDisplayFieldValue", StringPool.BLANK));
    _ddmStructureFieldName =
        ParamUtil.getString(
            _request,
            "ddmStructureFieldName",
            _portletPreferences.getValue("ddmStructureFieldName", StringPool.BLANK));
    _ddmStructureFieldValue =
        ParamUtil.getString(
            _request,
            "ddmStructureFieldValue",
            _portletPreferences.getValue("ddmStructureFieldValue", StringPool.BLANK));

    if (Validator.isNotNull(_ddmStructureFieldName)
        && Validator.isNotNull(_ddmStructureFieldValue)) {

      AssetRendererFactory<?> assetRendererFactory =
          AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassNameId(classNameIds[0]);

      ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader();

      ClassType classType = classTypeReader.getClassType(classTypeIds[0], themeDisplay.getLocale());

      ClassTypeField classTypeField = classType.getClassTypeField(_ddmStructureFieldName);

      _ddmStructureFieldLabel = classTypeField.getLabel();
    }
  }