Search in sources :

Example 21 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class JSPPortlet method updateBar.

protected void updateBar(ActionRequest actionRequest) throws Exception {
    long barId = ParamUtil.getLong(actionRequest, "barId");
    String field1 = ParamUtil.getString(actionRequest, "field1");
    boolean field2 = ParamUtil.getBoolean(actionRequest, "field2");
    int field3 = ParamUtil.getInteger(actionRequest, "field3");
    String field5 = ParamUtil.getString(actionRequest, "field5");
    int dateMonth = ParamUtil.getInteger(actionRequest, "field4Month");
    int dateDay = ParamUtil.getInteger(actionRequest, "field4Day");
    int dateYear = ParamUtil.getInteger(actionRequest, "field4Year");
    int dateHour = ParamUtil.getInteger(actionRequest, "field4Hour");
    int dateMinute = ParamUtil.getInteger(actionRequest, "field4Minute");
    int dateAmPm = ParamUtil.getInteger(actionRequest, "field4AmPm");
    if (dateAmPm == Calendar.PM) {
        dateHour += 12;
    }
    Date field4 = PortalUtil.getDate(dateMonth, dateDay, dateYear, dateHour, dateMinute, PortalException.class);
    if (barId <= 0) {
        Bar bar = getBarLocalService().createBar(0);
        bar.setField1(field1);
        bar.setField2(field2);
        bar.setField3(field3);
        bar.setField4(field4);
        bar.setField5(field5);
        bar.isNew();
        getBarLocalService().addBarWithoutId(bar);
    } else {
        Bar bar = getBarLocalService().fetchBar(barId);
        bar.setBarId(barId);
        bar.setField1(field1);
        bar.setField2(field2);
        bar.setField3(field3);
        bar.setField4(field4);
        bar.setField5(field5);
        getBarLocalService().updateBar(bar);
    }
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Date(java.util.Date)

Example 22 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarLocalServiceBaseImpl method getExportActionableDynamicQuery.

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
            StagedModelType stagedModelType = getStagedModelType();
            long modelAdditionCount = super.performCount();
            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);
            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext, stagedModelType);
            manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);
            return modelAdditionCount;
        }
    };
    initActionableDynamicQuery(exportActionableDynamicQuery);
    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Bar>() {

        @Override
        public void performAction(Bar bar) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, bar);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Bar.class.getName())));
    return exportActionableDynamicQuery;
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ManifestSummary(com.liferay.exportimport.kernel.lar.ManifestSummary) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Example 23 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceImpl method findByUuid_First.

/**
 * Returns the first bar in the ordered set where uuid = &#63;.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first matching bar
 * @throws NoSuchBarException if a matching bar could not be found
 */
@Override
public Bar findByUuid_First(String uuid, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
    Bar bar = fetchByUuid_First(uuid, orderByComparator);
    if (bar != null) {
        return bar;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append("}");
    throw new NoSuchBarException(msg.toString());
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) NoSuchBarException(com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException) StringBundler(com.liferay.petra.string.StringBundler)

Example 24 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceImpl method findByUUID_G.

/**
 * Returns the bar where uuid = &#63; and groupId = &#63; or throws a <code>NoSuchBarException</code> if it could not be found.
 *
 * @param uuid the uuid
 * @param groupId the group ID
 * @return the matching bar
 * @throws NoSuchBarException if a matching bar could not be found
 */
@Override
public Bar findByUUID_G(String uuid, long groupId) throws NoSuchBarException {
    Bar bar = fetchByUUID_G(uuid, groupId);
    if (bar == null) {
        StringBundler msg = new StringBundler(6);
        msg.append(_NO_SUCH_ENTITY_WITH_KEY);
        msg.append("uuid=");
        msg.append(uuid);
        msg.append(", groupId=");
        msg.append(groupId);
        msg.append("}");
        if (_log.isDebugEnabled()) {
            _log.debug(msg.toString());
        }
        throw new NoSuchBarException(msg.toString());
    }
    return bar;
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) NoSuchBarException(com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException) StringBundler(com.liferay.petra.string.StringBundler)

Example 25 with Bar

use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.

the class BarPersistenceImpl method findByField2.

/**
 * Returns an ordered range of all the bars where field2 = &#63;.
 *
 * <p>
 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to <code>QueryUtil#ALL_POS</code> will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent, then the query will include the default ORDER BY logic from <code>BarModelImpl</code>.
 * </p>
 *
 * @param field2 the field2
 * @param start the lower bound of the range of bars
 * @param end the upper bound of the range of bars (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @param useFinderCache whether to use the finder cache
 * @return the ordered range of matching bars
 */
@Override
public List<Bar> findByField2(boolean field2, int start, int end, OrderByComparator<Bar> orderByComparator, boolean useFinderCache) {
    FinderPath finderPath = null;
    Object[] finderArgs = null;
    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
        if (useFinderCache) {
            finderPath = _finderPathWithoutPaginationFindByField2;
            finderArgs = new Object[] { field2 };
        }
    } else if (useFinderCache) {
        finderPath = _finderPathWithPaginationFindByField2;
        finderArgs = new Object[] { field2, start, end, orderByComparator };
    }
    List<Bar> list = null;
    if (useFinderCache) {
        list = (List<Bar>) finderCache.getResult(finderPath, finderArgs, this);
        if ((list != null) && !list.isEmpty()) {
            for (Bar bar : list) {
                if (field2 != bar.isField2()) {
                    list = null;
                    break;
                }
            }
        }
    }
    if (list == null) {
        StringBundler query = null;
        if (orderByComparator != null) {
            query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2));
        } else {
            query = new StringBundler(3);
        }
        query.append(_SQL_SELECT_BAR_WHERE);
        query.append(_FINDER_COLUMN_FIELD2_FIELD2_2);
        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else {
            query.append(BarModelImpl.ORDER_BY_JPQL);
        }
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(field2);
            list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end);
            cacheResult(list);
            if (useFinderCache) {
                finderCache.putResult(finderPath, finderArgs, list);
            }
        } catch (Exception e) {
            if (useFinderCache) {
                finderCache.removeResult(finderPath, finderArgs);
            }
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return list;
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Query(com.liferay.portal.kernel.dao.orm.Query) FinderPath(com.liferay.portal.kernel.dao.orm.FinderPath) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.petra.string.StringBundler) NoSuchBarException(com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException) Session(com.liferay.portal.kernel.dao.orm.Session)

Aggregations

Bar (com.liferay.blade.samples.servicebuilder.adq.model.Bar)44 StringBundler (com.liferay.petra.string.StringBundler)17 NoSuchBarException (com.liferay.blade.samples.servicebuilder.adq.exception.NoSuchBarException)16 Test (org.junit.Test)15 Session (com.liferay.portal.kernel.dao.orm.Session)9 Query (com.liferay.portal.kernel.dao.orm.Query)8 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)7 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)6 BarImpl (com.liferay.blade.samples.servicebuilder.adq.model.impl.BarImpl)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)5 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 Serializable (java.io.Serializable)3 HashSet (java.util.HashSet)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Function (java.util.function.Function)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 DefaultActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery)1