Example usage for com.liferay.portal.kernel.util StringPool PERCENT

List of usage examples for com.liferay.portal.kernel.util StringPool PERCENT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool PERCENT.

Prototype

String PERCENT

To view the source code for com.liferay.portal.kernel.util StringPool PERCENT.

Click Source Link

Usage

From source file:com.liferay.journal.content.web.internal.upgrade.v1_0_0.UpgradePortletPreferences.java

License:Open Source License

@Override
protected String[] getPortletIds() {
    return new String[] { StringPool.PERCENT + JournalContentPortletKeys.JOURNAL_CONTENT + StringPool.PERCENT };
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java

License:Open Source License

@Override
public List<KBArticle> getSectionsKBArticles(long groupId, String[] sections, int status, int start, int end,
        OrderByComparator<KBArticle> orderByComparator) {

    String[] array = AdminUtil.escapeSections(sections);

    for (int i = 0; i < array.length; i++) {
        array[i] = StringUtil.quote(array[i], StringPool.PERCENT);
    }// w  w w .  j  a v a2 s .c  om

    if (status == WorkflowConstants.STATUS_ANY) {
        return kbArticlePersistence.findByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
                true, start, end, orderByComparator);
    } else if (status == WorkflowConstants.STATUS_APPROVED) {
        return kbArticlePersistence.findByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
                true, start, end, orderByComparator);
    }

    return kbArticlePersistence.findByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
            status, start, end, orderByComparator);
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java

License:Open Source License

@Override
public int getSectionsKBArticlesCount(long groupId, String[] sections, int status) {

    String[] array = AdminUtil.escapeSections(sections);

    for (int i = 0; i < array.length; i++) {
        array[i] = StringUtil.quote(array[i], StringPool.PERCENT);
    }//from   w  w w.ja v a  2s  . c o  m

    if (status == WorkflowConstants.STATUS_ANY) {
        return kbArticlePersistence.countByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
                true);
    } else if (status == WorkflowConstants.STATUS_APPROVED) {
        return kbArticlePersistence.countByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
                true);
    }

    return kbArticlePersistence.countByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
            status);
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java

License:Open Source License

protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate,
        Date endDate, boolean andOperator) {

    Junction junction = null;/*from   w  w  w.  ja  va 2s.  com*/

    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.splitKeywords(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, 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);
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java

License:Open Source License

@Override
public List<KBArticle> getSectionsKBArticles(long groupId, String[] sections, int status, int start, int end,
        OrderByComparator<KBArticle> orderByComparator) {

    String[] array = AdminUtil.escapeSections(sections);

    for (int i = 0; i < array.length; i++) {
        array[i] = StringUtil.quote(array[i], StringPool.PERCENT);
    }//from w w  w  .  j  av a 2  s.  c  o m

    if (status == WorkflowConstants.STATUS_ANY) {
        return kbArticlePersistence.filterFindByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID,
                array, true, start, end, orderByComparator);
    } else if (status == WorkflowConstants.STATUS_APPROVED) {
        return kbArticlePersistence.filterFindByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID,
                array, true, start, end, orderByComparator);
    }

    return kbArticlePersistence.filterFindByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
            status, start, end, orderByComparator);
}

From source file:com.liferay.knowledgebase.service.impl.KBArticleServiceImpl.java

License:Open Source License

@Override
public int getSectionsKBArticlesCount(long groupId, String[] sections, int status) {

    String[] array = AdminUtil.escapeSections(sections);

    for (int i = 0; i < array.length; i++) {
        array[i] = StringUtil.quote(array[i], StringPool.PERCENT);
    }/*from  w  w w  .jav a  2s  .c o m*/

    if (status == WorkflowConstants.STATUS_ANY) {
        return kbArticlePersistence.filterCountByG_P_S_L(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID,
                array, true);
    } else if (status == WorkflowConstants.STATUS_APPROVED) {
        return kbArticlePersistence.filterCountByG_P_S_M(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID,
                array, true);
    }

    return kbArticlePersistence.filterCountByG_P_S_S(groupId, KBFolderConstants.DEFAULT_PARENT_FOLDER_ID, array,
            status);
}

From source file:com.liferay.knowledgebase.service.impl.KBStructureLocalServiceImpl.java

License:Open Source License

protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate,
        Date endDate, boolean andOperator) {

    Junction junction = null;//w ww  . j  a  v  a 2  s .c o  m

    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)) {
        String escapedContent = StringEscapeUtils.escapeXml(content);

        terms.put("content", content + StringPool.SPACE + escapedContent);
    }

    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 ((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(KBStructure.class,
            getClass().getClassLoader());

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

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

    return dynamicQuery.add(junction);
}

From source file:com.liferay.knowledgebase.service.impl.KBTemplateLocalServiceImpl.java

License:Open Source License

protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate,
        Date endDate, boolean andOperator) {

    Junction junction = null;/*from   w  w w. ja  v  a2  s .  c o  m*/

    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.splitKeywords(value)) {
            Criterion criterion = RestrictionsFactoryUtil.ilike(key,
                    StringUtil.quote(keyword, StringPool.PERCENT));

            disjunction.add(criterion);
        }

        junction.add(disjunction);
    }

    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(KBTemplate.class, getClassLoader());

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

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

    return dynamicQuery.add(junction);
}

From source file:com.liferay.mbsubscriptionmanager.util.SubscriptionManagerUtil.java

License:Open Source License

public static List<MBCategory> getMBCategories(long groupId, String name, int start, int end) {

    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBCategory.class,
            PortalClassLoaderUtil.getClassLoader());

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

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

    if (Validator.isNotNull(name)) {
        name = StringPool.PERCENT + name + StringPool.PERCENT;

        property = PropertyFactoryUtil.forName("name");

        dynamicQuery.add(property.like(name));
    }/*from w  w  w.  j a  va 2s  .  co m*/

    dynamicQuery.addOrder(OrderFactoryUtil.asc("name"));

    return MBCategoryLocalServiceUtil.dynamicQuery(dynamicQuery, start, end);
}

From source file:com.liferay.mbsubscriptionmanager.util.SubscriptionManagerUtil.java

License:Open Source License

public static int getMBCategoriesCount(long groupId, String name) {
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBCategory.class,
            PortalClassLoaderUtil.getClassLoader());

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

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

    if (Validator.isNotNull(name)) {
        name = StringPool.PERCENT + name + StringPool.PERCENT;

        property = PropertyFactoryUtil.forName("name");

        dynamicQuery.add(property.like(name));
    }//from  w w  w  .  j  a va  2s  . c om

    return (int) MBCategoryLocalServiceUtil.dynamicQueryCount(dynamicQuery);
}