use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetPersistenceImpl method findByUuid_C_PrevAndNext.
/**
* Returns the gadgets before and after the current gadget in the ordered set where uuid = ? and companyId = ?.
*
* @param gadgetId the primary key of the current gadget
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next gadget
* @throws com.liferay.opensocial.NoSuchGadgetException if a gadget with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Gadget[] findByUuid_C_PrevAndNext(long gadgetId, String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchGadgetException, SystemException {
Gadget gadget = findByPrimaryKey(gadgetId);
Session session = null;
try {
session = openSession();
Gadget[] array = new GadgetImpl[3];
array[0] = getByUuid_C_PrevAndNext(session, gadget, uuid, companyId, orderByComparator, true);
array[1] = gadget;
array[2] = getByUuid_C_PrevAndNext(session, gadget, uuid, companyId, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetPersistenceImpl method fetchByC_U.
/**
* Returns the gadget where companyId = ? and url = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
*
* @param companyId the company ID
* @param url the url
* @param retrieveFromCache whether to use the finder cache
* @return the matching gadget, or <code>null</code> if a matching gadget could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Gadget fetchByC_U(long companyId, String url, boolean retrieveFromCache) throws SystemException {
Object[] finderArgs = new Object[] { companyId, url };
Object result = null;
if (retrieveFromCache) {
result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U, finderArgs, this);
}
if (result instanceof Gadget) {
Gadget gadget = (Gadget) result;
if ((companyId != gadget.getCompanyId()) || !Validator.equals(url, gadget.getUrl())) {
result = null;
}
}
if (result == null) {
StringBundler query = new StringBundler(4);
query.append(_SQL_SELECT_GADGET_WHERE);
query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
boolean bindUrl = false;
if (url == null) {
query.append(_FINDER_COLUMN_C_U_URL_1);
} else if (url.equals(StringPool.BLANK)) {
query.append(_FINDER_COLUMN_C_U_URL_3);
} else {
bindUrl = true;
query.append(_FINDER_COLUMN_C_U_URL_2);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(companyId);
if (bindUrl) {
qPos.add(url);
}
List<Gadget> list = q.list();
if (list.isEmpty()) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U, finderArgs, list);
} else {
Gadget gadget = list.get(0);
result = gadget;
cacheResult(gadget);
if ((gadget.getCompanyId() != companyId) || (gadget.getUrl() == null) || !gadget.getUrl().equals(url)) {
FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U, finderArgs, gadget);
}
}
} catch (Exception e) {
FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
if (result instanceof List<?>) {
return null;
} else {
return (Gadget) result;
}
}
use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetPersistenceImpl method filterFindByUuid_PrevAndNext.
/**
* Returns the gadgets before and after the current gadget in the ordered set of gadgets that the user has permission to view where uuid = ?.
*
* @param gadgetId the primary key of the current gadget
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the previous, current, and next gadget
* @throws com.liferay.opensocial.NoSuchGadgetException if a gadget with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Gadget[] filterFindByUuid_PrevAndNext(long gadgetId, String uuid, OrderByComparator orderByComparator) throws NoSuchGadgetException, SystemException {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByUuid_PrevAndNext(gadgetId, uuid, orderByComparator);
}
Gadget gadget = findByPrimaryKey(gadgetId);
Session session = null;
try {
session = openSession();
Gadget[] array = new GadgetImpl[3];
array[0] = filterGetByUuid_PrevAndNext(session, gadget, uuid, orderByComparator, true);
array[1] = gadget;
array[2] = filterGetByUuid_PrevAndNext(session, gadget, uuid, orderByComparator, false);
return array;
} catch (Exception e) {
throw processException(e);
} finally {
closeSession(session);
}
}
use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetPersistenceImpl method findByC_U.
/**
* Returns the gadget where companyId = ? and url = ? or throws a {@link com.liferay.opensocial.NoSuchGadgetException} if it could not be found.
*
* @param companyId the company ID
* @param url the url
* @return the matching gadget
* @throws com.liferay.opensocial.NoSuchGadgetException if a matching gadget could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Gadget findByC_U(long companyId, String url) throws NoSuchGadgetException, SystemException {
Gadget gadget = fetchByC_U(companyId, url);
if (gadget == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("companyId=");
msg.append(companyId);
msg.append(", url=");
msg.append(url);
msg.append(StringPool.CLOSE_CURLY_BRACE);
if (_log.isWarnEnabled()) {
_log.warn(msg.toString());
}
throw new NoSuchGadgetException(msg.toString());
}
return gadget;
}
use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetStagedModelDataHandler method deleteStagedModel.
@Override
public void deleteStagedModel(String uuid, long groupId, String className, String extraData) throws PortalException, SystemException {
Group group = GroupLocalServiceUtil.getGroup(groupId);
Gadget gadget = GadgetLocalServiceUtil.fetchGadgetByUuidAndCompanyId(uuid, group.getCompanyId());
if (gadget != null) {
GadgetLocalServiceUtil.deleteGadget(gadget);
}
}
Aggregations