Search in sources :

Example 21 with Region

use of com.liferay.blade.samples.jndiservicebuilder.model.Region in project liferay-blade-samples by liferay.

the class RegionPersistenceTest method testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist.

@Test
public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist() throws Exception {
    Region newRegion = addRegion();
    long pk = RandomTestUtil.nextLong();
    Set<Serializable> primaryKeys = new HashSet<Serializable>();
    primaryKeys.add(newRegion.getPrimaryKey());
    primaryKeys.add(pk);
    Map<Serializable, Region> regions = _persistence.fetchByPrimaryKeys(primaryKeys);
    Assert.assertEquals(1, regions.size());
    Assert.assertEquals(newRegion, regions.get(newRegion.getPrimaryKey()));
}
Also used : Serializable(java.io.Serializable) Region(com.liferay.blade.samples.jndiservicebuilder.model.Region) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 22 with Region

use of com.liferay.blade.samples.jndiservicebuilder.model.Region in project liferay-blade-samples by liferay.

the class RegionModelImpl method toXmlString.

@Override
public String toXmlString() {
    Map<String, Function<Region, 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<Region, Object>> entry : attributeGetterFunctions.entrySet()) {
        String attributeName = entry.getKey();
        Function<Region, Object> attributeGetterFunction = entry.getValue();
        sb.append("<column><column-name>");
        sb.append(attributeName);
        sb.append("</column-name><column-value><![CDATA[");
        sb.append(attributeGetterFunction.apply((Region) this));
        sb.append("]]></column-value></column>");
    }
    sb.append("</model>");
    return sb.toString();
}
Also used : Function(java.util.function.Function) Region(com.liferay.blade.samples.jndiservicebuilder.model.Region) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringBundler(com.liferay.petra.string.StringBundler)

Example 23 with Region

use of com.liferay.blade.samples.jndiservicebuilder.model.Region in project liferay-blade-samples by liferay.

the class RegionModelImpl method toString.

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

Aggregations

Region (com.liferay.blade.samples.jndiservicebuilder.model.Region)23 Test (org.junit.Test)13 Serializable (java.io.Serializable)5 NoSuchRegionException (com.liferay.blade.samples.jndiservicebuilder.exception.NoSuchRegionException)4 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)4 Session (com.liferay.portal.kernel.dao.orm.Session)4 RegionImpl (com.liferay.blade.samples.jndiservicebuilder.model.impl.RegionImpl)3 StringBundler (com.liferay.petra.string.StringBundler)3 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Query (com.liferay.portal.kernel.dao.orm.Query)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Function (java.util.function.Function)2 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)1 IntegerWrapper (com.liferay.portal.kernel.util.IntegerWrapper)1 StringBundler (com.liferay.portal.kernel.util.StringBundler)1 List (java.util.List)1