Search in sources :

Example 1 with Bar

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

the class ADQTest method testMassUpdate.

@Test
public void testMassUpdate() throws PortalException {
    // Set up
    Bar bar1 = BarLocalServiceUtil.createBar(CounterLocalServiceUtil.increment());
    bar1.setField1(_BAR1);
    bar1.setField2(false);
    bar1.setField3(0);
    bar1.setField4(_DATE);
    bar1.setField5(_TEST);
    bar1 = BarLocalServiceUtil.addBar(bar1);
    long bar1Id = bar1.getBarId();
    Bar bar2 = BarLocalServiceUtil.createBar(CounterLocalServiceUtil.increment());
    bar2.setField1(_BAR2);
    bar2.setField2(false);
    bar2.setField3(99);
    bar2.setField4(_DATE);
    bar2.setField5(_TEST);
    bar2 = BarLocalServiceUtil.addBar(bar2);
    long bar2Id = bar2.getBarId();
    Bar bar3 = BarLocalServiceUtil.createBar(CounterLocalServiceUtil.increment());
    bar3.setField1(_BAR3);
    bar3.setField2(false);
    bar3.setField3(100);
    bar3.setField4(_DATE);
    bar3.setField5(_TEST);
    bar3 = BarLocalServiceUtil.addBar(bar3);
    long bar3Id = bar3.getBarId();
    Bar bar4 = BarLocalServiceUtil.createBar(CounterLocalServiceUtil.increment());
    bar4.setField1(_BAR4);
    bar4.setField2(false);
    bar4.setField3(101);
    bar4.setField4(_DATE);
    bar4.setField5(_TEST);
    bar4 = BarLocalServiceUtil.addBar(bar4);
    long bar4Id = bar4.getBarId();
    Bar bar5 = BarLocalServiceUtil.createBar(CounterLocalServiceUtil.increment());
    bar5.setField1(_BAR5);
    bar5.setField2(false);
    bar5.setField3(200);
    bar5.setField4(_DATE);
    bar5.setField5(_TEST);
    bar5 = BarLocalServiceUtil.addBar(bar5);
    long bar5Id = bar5.getBarId();
    // Perform 1st mass update and make assertions
    BarLocalServiceUtil.massUpdate();
    bar1 = BarLocalServiceUtil.getBar(bar1Id);
    Assert.assertTrue("Expected " + 1 + ", but saw " + bar1.getField3(), bar1.getField3() == 1);
    bar2 = BarLocalServiceUtil.getBar(bar2Id);
    Assert.assertTrue("Expected " + 100 + ", but saw " + bar2.getField3(), bar2.getField3() == 100);
    bar3 = BarLocalServiceUtil.getBar(bar3Id);
    Assert.assertTrue("Expected " + 100 + ", but saw " + bar3.getField3(), bar3.getField3() == 100);
    bar4 = BarLocalServiceUtil.getBar(bar4Id);
    Assert.assertTrue("Expected " + 101 + ", but saw " + bar4.getField3(), bar4.getField3() == 101);
    bar5 = BarLocalServiceUtil.getBar(bar5Id);
    Assert.assertTrue("Expected " + 200 + ", but saw " + bar5.getField3(), bar5.getField3() == 200);
    // Step 3: Perform 2nd mass update and make assertions
    BarLocalServiceUtil.massUpdate();
    bar1 = BarLocalServiceUtil.getBar(bar1Id);
    Assert.assertTrue("Expected " + 1 + ", but saw " + bar1.getField3(), bar1.getField3() == 2);
    bar2 = BarLocalServiceUtil.getBar(bar2Id);
    Assert.assertTrue("Expected " + 100 + ", but saw " + bar2.getField3(), bar2.getField3() == 100);
    bar3 = BarLocalServiceUtil.getBar(bar3Id);
    Assert.assertTrue("Expected " + 100 + ", but saw " + bar3.getField3(), bar3.getField3() == 100);
    bar4 = BarLocalServiceUtil.getBar(bar4Id);
    Assert.assertTrue("Expected " + 101 + ", but saw " + bar4.getField3(), bar4.getField3() == 101);
    bar5 = BarLocalServiceUtil.getBar(bar5Id);
    Assert.assertTrue("Expected " + 200 + ", but saw " + bar5.getField3(), bar5.getField3() == 200);
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) Test(org.junit.Test)

Example 2 with Bar

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

the class BarModelImpl method toXmlString.

@Override
public String toXmlString() {
    Map<String, Function<Bar, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
    StringBundler sb = new StringBundler(5 * attributeGetterFunctions.size() + 4);
    sb.append("<model><model-name>");
    sb.append(getModelClassName());
    sb.append("</model-name>");
    for (Map.Entry<String, Function<Bar, Object>> entry : attributeGetterFunctions.entrySet()) {
        String attributeName = entry.getKey();
        Function<Bar, Object> attributeGetterFunction = entry.getValue();
        sb.append("<column><column-name>");
        sb.append(attributeName);
        sb.append("</column-name><column-value><![CDATA[");
        sb.append(attributeGetterFunction.apply((Bar) this));
        sb.append("]]></column-value></column>");
    }
    sb.append("</model>");
    return sb.toString();
}
Also used : Function(java.util.function.Function) Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringBundler(com.liferay.petra.string.StringBundler)

Example 3 with Bar

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

the class BarModelImpl method toModel.

/**
 * 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 Bar toModel(BarSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    Bar model = new BarImpl();
    model.setUuid(soapModel.getUuid());
    model.setBarId(soapModel.getBarId());
    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;
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar)

Example 4 with Bar

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

the class BarModelImpl method toString.

@Override
public String toString() {
    Map<String, Function<Bar, Object>> attributeGetterFunctions = getAttributeGetterFunctions();
    StringBundler sb = new StringBundler(4 * attributeGetterFunctions.size() + 2);
    sb.append("{");
    for (Map.Entry<String, Function<Bar, Object>> entry : attributeGetterFunctions.entrySet()) {
        String attributeName = entry.getKey();
        Function<Bar, Object> attributeGetterFunction = entry.getValue();
        sb.append(attributeName);
        sb.append("=");
        sb.append(attributeGetterFunction.apply((Bar) this));
        sb.append(", ");
    }
    if (sb.index() > 1) {
        sb.setIndex(sb.index() - 1);
    }
    sb.append("}");
    return sb.toString();
}
Also used : Function(java.util.function.Function) Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringBundler(com.liferay.petra.string.StringBundler)

Example 5 with Bar

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

the class BarModelImpl method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof Bar)) {
        return false;
    }
    Bar bar = (Bar) obj;
    long primaryKey = bar.getPrimaryKey();
    if (getPrimaryKey() == primaryKey) {
        return true;
    } else {
        return false;
    }
}
Also used : Bar(com.liferay.blade.samples.servicebuilder.adq.model.Bar)

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