Search in sources :

Example 41 with Foo

use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceImpl method findByField2_PrevAndNext.

/**
 * Returns the foos before and after the current foo in the ordered set where field2 = ?.
 *
 * @param fooId the primary key of the current foo
 * @param field2 the field2
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next foo
 * @throws NoSuchFooException if a foo with the primary key could not be found
 */
@Override
public Foo[] findByField2_PrevAndNext(long fooId, boolean field2, OrderByComparator<Foo> orderByComparator) throws NoSuchFooException {
    Foo foo = findByPrimaryKey(fooId);
    Session session = null;
    try {
        session = openSession();
        Foo[] array = new FooImpl[3];
        array[0] = getByField2_PrevAndNext(session, foo, field2, orderByComparator, true);
        array[1] = foo;
        array[2] = getByField2_PrevAndNext(session, foo, field2, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Foo(com.liferay.blade.basic.model.Foo) FooImpl(com.liferay.blade.basic.model.impl.FooImpl) NoSuchFooException(com.liferay.blade.basic.exception.NoSuchFooException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 42 with Foo

use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.

the class FooPersistenceImpl method findByUuid_Last.

/**
 * Returns the last foo 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 last matching foo
 * @throws NoSuchFooException if a matching foo could not be found
 */
@Override
public Foo findByUuid_Last(String uuid, OrderByComparator<Foo> orderByComparator) throws NoSuchFooException {
    Foo foo = fetchByUuid_Last(uuid, orderByComparator);
    if (foo != null) {
        return foo;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append("}");
    throw new NoSuchFooException(msg.toString());
}
Also used : NoSuchFooException(com.liferay.blade.basic.exception.NoSuchFooException) Foo(com.liferay.blade.basic.model.Foo) StringBundler(com.liferay.petra.string.StringBundler)

Example 43 with Foo

use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.

the class JSPPortlet method updateFoo.

protected void updateFoo(ActionRequest actionRequest) throws Exception {
    long fooId = ParamUtil.getLong(actionRequest, "fooId");
    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 (fooId <= 0) {
        Foo foo = getFooLocalService().createFoo(0);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        foo.isNew();
        getFooLocalService().addFoo(foo);
    } else {
        Foo foo = getFooLocalService().fetchFoo(fooId);
        foo.setFooId(fooId);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        getFooLocalService().updateFoo(foo);
    }
}
Also used : Foo(com.liferay.blade.basic.model.Foo) Date(java.util.Date)

Example 44 with Foo

use of com.liferay.blade.basic.model.Foo in project liferay-blade-samples by liferay.

the class JSPWARPortlet method updateFoo.

public void updateFoo(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long fooId = ParamUtil.getLong(actionRequest, "fooId");
    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 (fooId <= 0) {
        if (_log.isInfoEnabled()) {
            _log.info("Adding a new foo...");
        }
        Foo foo = getFooLocalService().createFoo(0);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        foo.isNew();
        getFooLocalService().addFoo(foo);
    } else {
        if (_log.isInfoEnabled()) {
            _log.info("Updating a new foo...");
        }
        Foo foo = getFooLocalService().fetchFoo(fooId);
        foo.setFooId(fooId);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        getFooLocalService().updateFoo(foo);
    }
}
Also used : Foo(com.liferay.blade.basic.model.Foo) Date(java.util.Date)

Aggregations

Foo (com.liferay.blade.basic.model.Foo)44 StringBundler (com.liferay.petra.string.StringBundler)17 NoSuchFooException (com.liferay.blade.basic.exception.NoSuchFooException)16 Test (org.junit.Test)14 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 FooImpl (com.liferay.blade.basic.model.impl.FooImpl)5 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)5 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)4 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 Serializable (java.io.Serializable)3 Date (java.util.Date)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