protected void exportLayoutPrototypes(
      PortletDataContext portletDataContext,
      LayoutSetPrototype layoutSetPrototype,
      Element layoutSetPrototypeElement)
      throws Exception {

    DynamicQuery dynamicQuery = _layoutLocalService.dynamicQuery();

    Property groupIdProperty = PropertyFactoryUtil.forName("groupId");

    dynamicQuery.add(groupIdProperty.eq(layoutSetPrototype.getGroupId()));

    Conjunction conjunction = RestrictionsFactoryUtil.conjunction();

    Property layoutPrototypeUuidProperty = PropertyFactoryUtil.forName("layoutPrototypeUuid");

    conjunction.add(layoutPrototypeUuidProperty.isNotNull());
    conjunction.add(layoutPrototypeUuidProperty.ne(StringPool.BLANK));

    dynamicQuery.add(conjunction);

    List<Layout> layouts = _layoutLocalService.dynamicQuery(dynamicQuery);

    boolean exportLayoutPrototypes =
        portletDataContext.getBooleanParameter("layout_set_prototypes", "page-templates");

    for (Layout layout : layouts) {
      String layoutPrototypeUuid = layout.getLayoutPrototypeUuid();

      LayoutPrototype layoutPrototype =
          _layoutPrototypeLocalService.getLayoutPrototypeByUuidAndCompanyId(
              layoutPrototypeUuid, portletDataContext.getCompanyId());

      portletDataContext.addReferenceElement(
          layout,
          layoutSetPrototypeElement,
          layoutPrototype,
          PortletDataContext.REFERENCE_TYPE_DEPENDENCY,
          !exportLayoutPrototypes);

      if (exportLayoutPrototypes) {
        StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, layoutPrototype);
      }
    }
  }
コード例 #2
0
  protected DynamicQuery buildDynamicQuery(
      long groupId,
      String title,
      String content,
      int status,
      Date startDate,
      Date endDate,
      boolean andOperator) {

    Junction junction = null;

    if (andOperator) {
      junction = RestrictionsFactoryUtil.conjunction();
    } else {
      junction = RestrictionsFactoryUtil.disjunction();
    }

    Map<String, String> terms = new HashMap<String, String>();

    if (Validator.isNotNull(title)) {
      terms.put("title", title);
    }

    if (Validator.isNotNull(content)) {
      terms.put("content", content);
    }

    for (Map.Entry<String, String> entry : terms.entrySet()) {
      String key = entry.getKey();
      String value = entry.getValue();

      Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

      for (String keyword : KnowledgeBaseUtil.parseKeywords(value)) {
        Criterion criterion =
            RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT));

        disjunction.add(criterion);
      }

      junction.add(disjunction);
    }

    if (status != WorkflowConstants.STATUS_ANY) {
      Property property = PropertyFactoryUtil.forName("status");

      junction.add(property.eq(status));
    }

    if ((endDate != null) && (startDate != null)) {
      Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

      String[] propertyNames = {"createDate", "modifiedDate"};

      for (String propertyName : propertyNames) {
        Property property = PropertyFactoryUtil.forName(propertyName);

        Conjunction conjunction = RestrictionsFactoryUtil.conjunction();

        conjunction.add(property.gt(startDate));
        conjunction.add(property.lt(endDate));

        disjunction.add(conjunction);
      }

      junction.add(disjunction);
    }

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(KBArticle.class, getClass().getClassLoader());

    if (status == WorkflowConstants.STATUS_ANY) {
      Property property = PropertyFactoryUtil.forName("latest");

      dynamicQuery.add(property.eq(Boolean.TRUE));
    } else if (status == WorkflowConstants.STATUS_APPROVED) {
      Property property = PropertyFactoryUtil.forName("main");

      dynamicQuery.add(property.eq(Boolean.TRUE));
    }

    if (groupId > 0) {
      Property property = PropertyFactoryUtil.forName("groupId");

      dynamicQuery.add(property.eq(groupId));
    }

    return dynamicQuery.add(junction);
  }