use of com.liferay.roster.model.Roster in project liferay-ide by liferay.
the class RosterPersistenceImpl method findByClubId_First.
/**
* Returns the first roster in the ordered set where clubId = ?.
*
* @param clubId the club ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching roster
* @throws NoSuchRosterException if a matching roster could not be found
*/
@Override
public Roster findByClubId_First(long clubId, OrderByComparator<Roster> orderByComparator) throws NoSuchRosterException {
Roster roster = fetchByClubId_First(clubId, orderByComparator);
if (roster != null) {
return roster;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("clubId=");
msg.append(clubId);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchRosterException(msg.toString());
}
use of com.liferay.roster.model.Roster in project liferay-ide by liferay.
the class RosterPersistenceImpl method clearCache.
@Override
public void clearCache(List<Roster> rosters) {
finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
for (Roster roster : rosters) {
entityCache.removeResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, roster.getPrimaryKey());
}
}
use of com.liferay.roster.model.Roster in project liferay-ide by liferay.
the class RosterPersistenceImpl method getByUuid_PrevAndNext.
protected Roster getByUuid_PrevAndNext(Session session, Roster roster, String uuid, OrderByComparator<Roster> orderByComparator, boolean previous) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_ROSTER_WHERE);
boolean bindUuid = false;
if (uuid == null) {
query.append(_FINDER_COLUMN_UUID_UUID_1);
} else if (uuid.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_UUID_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
query.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
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++) {
query.append(_ORDER_BY_ENTITY_ALIAS);
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 {
query.append(RosterModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(roster);
for (Object value : values) {
qPos.add(value);
}
}
List<Roster> list = q.list();
if (list.size() == 2) {
return list.get(1);
} else {
return null;
}
}
use of com.liferay.roster.model.Roster in project liferay-ide by liferay.
the class RosterPersistenceImpl method fetchByPrimaryKey.
/**
* Returns the roster with the primary key or returns <code>null</code> if it could not be found.
*
* @param primaryKey the primary key of the roster
* @return the roster, or <code>null</code> if a roster with the primary key could not be found
*/
@Override
public Roster fetchByPrimaryKey(Serializable primaryKey) {
Roster roster = (Roster) entityCache.getResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, primaryKey);
if (roster == _nullRoster) {
return null;
}
if (roster == null) {
Session session = null;
try {
session = openSession();
roster = (Roster) session.get(RosterImpl.class, primaryKey);
if (roster != null) {
cacheResult(roster);
} else {
entityCache.putResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, primaryKey, _nullRoster);
}
} catch (Exception e) {
entityCache.removeResult(RosterModelImpl.ENTITY_CACHE_ENABLED, RosterImpl.class, primaryKey);
throw processException(e);
} finally {
closeSession(session);
}
}
return roster;
}
use of com.liferay.roster.model.Roster in project liferay-ide by liferay.
the class RosterPersistenceImpl method findByUuid_First.
/**
* Returns the first roster in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the first matching roster
* @throws NoSuchRosterException if a matching roster could not be found
*/
@Override
public Roster findByUuid_First(String uuid, OrderByComparator<Roster> orderByComparator) throws NoSuchRosterException {
Roster roster = fetchByUuid_First(uuid, orderByComparator);
if (roster != null) {
return roster;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(StringPool.CLOSE_CURLY_BRACE);
throw new NoSuchRosterException(msg.toString());
}
Aggregations