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;
}
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;
}
}
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;
}
}
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;
}
}
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 = ? and companyId = ?.
*
* @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());
}
Aggregations