com.liferay.blade.basic.model.Foo.setField1() - java examples

Here are the examples of the java api com.liferay.blade.basic.model.Foo.setField1() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

14 View Complete Implementation : AddTestData.java
Copyright Apache License 2.0
Author : liferay
@Activate
public void addTestData() {
    int entries = 2;
    while (entries > 0) {
        Foo foo = _fooLocalService.createFoo(0);
        foo.setField1("new field1 entry" + entries);
        foo.setField2(true);
        foo.setField3(10);
        foo.setField4(new Date());
        foo.setField5("new field5 entry" + entries);
        foo.isNew();
        _fooLocalService.addFoo(foo);
        entries--;
    }
}

11 View Complete Implementation : JSPPortlet.java
Copyright Apache License 2.0
Author : liferay
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.clreplaced);
    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);
    }
}

10 View Complete Implementation : JSPWARPortlet.java
Copyright Apache License 2.0
Author : liferay
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.clreplaced);
    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);
    }
}

6 View Complete Implementation : SpringMVCPortletViewController.java
Copyright Apache License 2.0
Author : liferay
/**
 * Handles the action when the action key is <code>updateFoo</code>. This is
 * the case when Foo is added and updated.
 *
 * @param  actionRequest the action request
 * @param  response the action response
 * @throws Exception if an exception occurred
 */
@ActionMapping(params = "action=updateFoo")
public void updateFoo(ActionRequest actionRequest, ActionResponse response) throws Exception {
    // See if there is an existing Foo ID.
    long fooId = ParamUtil.getLong(actionRequest, "fooId");
    // Extract the form field values.
    String field1 = ParamUtil.getString(actionRequest, "field1");
    boolean field2 = ParamUtil.getBoolean(actionRequest, "field2");
    int field3 = ParamUtil.getInteger(actionRequest, "field3");
    String field5 = ParamUtil.getString(actionRequest, "field5");
    // Convert the calendar details into a date.
    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.clreplaced);
    // If the Foo ID is less than or equal to zero, add a new Foo.
    if (fooId <= 0) {
        if (_log.isInfoEnabled()) {
            _log.info("Adding a new foo...");
        }
        // Create the Foo.
        Foo foo = FooLocalServiceUtil.createFoo(0);
        // Set the Foo's fields.
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        // Invoke the service layer to add the foo.
        FooLocalServiceUtil.addFoo(foo);
    } else {
        if (_log.isInfoEnabled()) {
            _log.info("Updating a new foo...");
        }
        // Retrieve the current Foo during the update.
        Foo foo = FooLocalServiceUtil.fetchFoo(fooId);
        // Update the Foo's fields.
        foo.setFooId(fooId);
        foo.setField1(field1);
        foo.setField2(field2);
        foo.setField3(field3);
        foo.setField4(field4);
        foo.setField5(field5);
        // Invoke the service layer to update the Foo.
        FooLocalServiceUtil.updateFoo(foo);
    }
}

0 View Complete Implementation : FooPersistenceTest.java
Copyright Apache License 2.0
Author : liferay
protected Foo addFoo() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Foo foo = _persistence.create(pk);
    foo.setUuid(RandomTestUtil.randomString());
    foo.setGroupId(RandomTestUtil.nextLong());
    foo.setCompanyId(RandomTestUtil.nextLong());
    foo.setUserId(RandomTestUtil.nextLong());
    foo.setUserName(RandomTestUtil.randomString());
    foo.setCreateDate(RandomTestUtil.nextDate());
    foo.setModifiedDate(RandomTestUtil.nextDate());
    foo.setField1(RandomTestUtil.randomString());
    foo.setField2(RandomTestUtil.randomBoolean());
    foo.setField3(RandomTestUtil.nextInt());
    foo.setField4(RandomTestUtil.nextDate());
    foo.setField5(RandomTestUtil.randomString());
    _foos.add(_persistence.update(foo));
    return foo;
}

0 View Complete Implementation : FooModelImpl.java
Copyright Apache License 2.0
Author : liferay
/**
 * 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 Foo toModel(FooSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    Foo model = new FooImpl();
    model.setUuid(soapModel.getUuid());
    model.setFooId(soapModel.getFooId());
    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.setField1(soapModel.getField1());
    model.setField2(soapModel.isField2());
    model.setField3(soapModel.getField3());
    model.setField4(soapModel.getField4());
    model.setField5(soapModel.getField5());
    return model;
}

0 View Complete Implementation : FooPersistenceTest.java
Copyright Apache License 2.0
Author : liferay
@Test
public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();
    Foo newFoo = _persistence.create(pk);
    newFoo.setUuid(RandomTestUtil.randomString());
    newFoo.setGroupId(RandomTestUtil.nextLong());
    newFoo.setCompanyId(RandomTestUtil.nextLong());
    newFoo.setUserId(RandomTestUtil.nextLong());
    newFoo.setUserName(RandomTestUtil.randomString());
    newFoo.setCreateDate(RandomTestUtil.nextDate());
    newFoo.setModifiedDate(RandomTestUtil.nextDate());
    newFoo.setField1(RandomTestUtil.randomString());
    newFoo.setField2(RandomTestUtil.randomBoolean());
    newFoo.setField3(RandomTestUtil.nextInt());
    newFoo.setField4(RandomTestUtil.nextDate());
    newFoo.setField5(RandomTestUtil.randomString());
    _foos.add(_persistence.update(newFoo));
    Foo existingFoo = _persistence.findByPrimaryKey(newFoo.getPrimaryKey());
    replacedert.replacedertEquals(existingFoo.getUuid(), newFoo.getUuid());
    replacedert.replacedertEquals(existingFoo.getFooId(), newFoo.getFooId());
    replacedert.replacedertEquals(existingFoo.getGroupId(), newFoo.getGroupId());
    replacedert.replacedertEquals(existingFoo.getCompanyId(), newFoo.getCompanyId());
    replacedert.replacedertEquals(existingFoo.getUserId(), newFoo.getUserId());
    replacedert.replacedertEquals(existingFoo.getUserName(), newFoo.getUserName());
    replacedert.replacedertEquals(Time.getShortTimestamp(existingFoo.getCreateDate()), Time.getShortTimestamp(newFoo.getCreateDate()));
    replacedert.replacedertEquals(Time.getShortTimestamp(existingFoo.getModifiedDate()), Time.getShortTimestamp(newFoo.getModifiedDate()));
    replacedert.replacedertEquals(existingFoo.getField1(), newFoo.getField1());
    replacedert.replacedertEquals(existingFoo.isField2(), newFoo.isField2());
    replacedert.replacedertEquals(existingFoo.getField3(), newFoo.getField3());
    replacedert.replacedertEquals(Time.getShortTimestamp(existingFoo.getField4()), Time.getShortTimestamp(newFoo.getField4()));
    replacedert.replacedertEquals(existingFoo.getField5(), newFoo.getField5());
}