Search in sources :

Example 21 with KBTemplate

use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.

the class KBTemplateModelImpl method toModel.

/**
 * Converts the soap model instance into a normal model instance.
 *
 * @param soapModel the soap model instance to convert
 * @return the normal model instance
 */
public static KBTemplate toModel(KBTemplateSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    KBTemplate model = new KBTemplateImpl();
    model.setUuid(soapModel.getUuid());
    model.setKbTemplateId(soapModel.getKbTemplateId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setTitle(soapModel.getTitle());
    model.setContent(soapModel.getContent());
    return model;
}
Also used : KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Example 22 with KBTemplate

use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.

the class KBTemplateModifiedDateComparator method compare.

@Override
public int compare(Object obj1, Object obj2) {
    KBTemplate kbTemplate1 = (KBTemplate) obj1;
    KBTemplate kbTemplate2 = (KBTemplate) obj2;
    int value = DateUtil.compareTo(kbTemplate1.getModifiedDate(), kbTemplate2.getModifiedDate());
    if (_ascending) {
        return value;
    } else {
        return -value;
    }
}
Also used : KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Example 23 with KBTemplate

use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.

the class KBTemplateUserNameComparator method compare.

@Override
public int compare(Object obj1, Object obj2) {
    KBTemplate kbTemplate1 = (KBTemplate) obj1;
    KBTemplate kbTemplate2 = (KBTemplate) obj2;
    int value = StringUtil.toLowerCase(kbTemplate1.getUserName()).compareTo(StringUtil.toLowerCase(kbTemplate2.getUserName()));
    if (_ascending) {
        return value;
    } else {
        return -value;
    }
}
Also used : KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Example 24 with KBTemplate

use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.

the class KBTemplatePersistenceImpl method filterGetByGroupId_PrevAndNext.

protected KBTemplate filterGetByGroupId_PrevAndNext(Session session, KBTemplate kbTemplate, long groupId, OrderByComparator orderByComparator, boolean previous) {
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6));
    } else {
        query = new StringBundler(3);
    }
    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_KBTEMPLATE_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_KBTEMPLATE_NO_INLINE_DISTINCT_WHERE_1);
    }
    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_KBTEMPLATE_NO_INLINE_DISTINCT_WHERE_2);
    }
    if (orderByComparator != null) {
        String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
        if (orderByConditionFields.length > 0) {
            query.append(WHERE_AND);
        }
        for (int i = 0; i < orderByConditionFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByConditionFields[i]);
            if ((i + 1) < orderByConditionFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
                } else {
                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN);
                } else {
                    query.append(WHERE_LESSER_THAN);
                }
            }
        }
        query.append(ORDER_BY_CLAUSE);
        String[] orderByFields = orderByComparator.getOrderByFields();
        for (int i = 0; i < orderByFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByFields[i]);
            if ((i + 1) < orderByFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC_HAS_NEXT);
                } else {
                    query.append(ORDER_BY_DESC_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC);
                } else {
                    query.append(ORDER_BY_DESC);
                }
            }
        }
    } else {
        if (getDB().isSupportsInlineDistinct()) {
            query.append(KBTemplateModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(KBTemplateModelImpl.ORDER_BY_SQL);
        }
    }
    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), KBTemplate.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
    SQLQuery q = session.createSQLQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    if (getDB().isSupportsInlineDistinct()) {
        q.addEntity(_FILTER_ENTITY_ALIAS, KBTemplateImpl.class);
    } else {
        q.addEntity(_FILTER_ENTITY_TABLE, KBTemplateImpl.class);
    }
    QueryPos qPos = QueryPos.getInstance(q);
    qPos.add(groupId);
    if (orderByComparator != null) {
        Object[] values = orderByComparator.getOrderByConditionValues(kbTemplate);
        for (Object value : values) {
            qPos.add(value);
        }
    }
    List<KBTemplate> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : KBTemplate(com.liferay.knowledgebase.model.KBTemplate) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 25 with KBTemplate

use of com.liferay.knowledgebase.model.KBTemplate in project liferay-ide by liferay.

the class KBTemplatePersistenceImpl method findByUuid_C_Last.

/**
 * Returns the last k b template in the ordered set where uuid = &#63; and companyId = &#63;.
 *
 * @param uuid the uuid
 * @param companyId the company ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching k b template
 * @throws com.liferay.knowledgebase.NoSuchTemplateException if a matching k b template could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public KBTemplate findByUuid_C_Last(String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchTemplateException, SystemException {
    KBTemplate kbTemplate = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
    if (kbTemplate != null) {
        return kbTemplate;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(", companyId=");
    msg.append(companyId);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchTemplateException(msg.toString());
}
Also used : NoSuchTemplateException(com.liferay.knowledgebase.NoSuchTemplateException) KBTemplate(com.liferay.knowledgebase.model.KBTemplate) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

KBTemplate (com.liferay.knowledgebase.model.KBTemplate)40 NoSuchTemplateException (com.liferay.knowledgebase.NoSuchTemplateException)21 StringBundler (com.liferay.portal.kernel.util.StringBundler)17 SystemException (com.liferay.portal.kernel.exception.SystemException)14 Session (com.liferay.portal.kernel.dao.orm.Session)12 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)10 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)9 Query (com.liferay.portal.kernel.dao.orm.Query)8 KBTemplateImpl (com.liferay.knowledgebase.model.impl.KBTemplateImpl)7 ArrayList (java.util.ArrayList)7 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)6 List (java.util.List)6 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 KBArticle (com.liferay.knowledgebase.model.KBArticle)3 PortalException (com.liferay.portal.kernel.exception.PortalException)2 JSONObject (com.liferay.portal.kernel.json.JSONObject)2 KBArticleImportException (com.liferay.knowledgebase.KBArticleImportException)1 KBCommentContentException (com.liferay.knowledgebase.KBCommentContentException)1 KBTemplateContentException (com.liferay.knowledgebase.KBTemplateContentException)1 KBTemplateTitleException (com.liferay.knowledgebase.KBTemplateTitleException)1