use of com.liferay.petra.string.StringBundler 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();
}
use of com.liferay.petra.string.StringBundler 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();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxModelImpl method toXmlString.
@Override
public String toXmlString() {
Map<String, Function<Qux, 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<Qux, Object>> entry : attributeGetterFunctions.entrySet()) {
String attributeName = entry.getKey();
Function<Qux, Object> attributeGetterFunction = entry.getValue();
sb.append("<column><column-name>");
sb.append(attributeName);
sb.append("</column-name><column-value><![CDATA[");
sb.append(attributeGetterFunction.apply((Qux) this));
sb.append("]]></column-value></column>");
}
sb.append("</model>");
return sb.toString();
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method findByUuid_C.
/**
* Returns an ordered range of all the quxs where uuid = ? and companyId = ?.
*
* <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 and pagination is required (<code>start</code> and <code>end</code> are not <code>QueryUtil#ALL_POS</code>), then the query will include the default ORDER BY logic from <code>QuxModelImpl</code>. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
* </p>
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of quxs
* @param end the upper bound of the range of quxs (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param retrieveFromCache whether to retrieve from the finder cache
* @return the ordered range of matching quxs
*/
@Override
public List<Qux> findByUuid_C(String uuid, long companyId, int start, int end, OrderByComparator<Qux> orderByComparator, boolean retrieveFromCache) {
uuid = Objects.toString(uuid, "");
boolean pagination = true;
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
pagination = false;
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] { uuid, companyId };
} else {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] { uuid, companyId, start, end, orderByComparator };
}
List<Qux> list = null;
if (retrieveFromCache) {
list = (List<Qux>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Qux qux : list) {
if (!uuid.equals(qux.getUuid()) || (companyId != qux.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(4);
}
query.append(_SQL_SELECT_QUX_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
query.append(_FINDER_COLUMN_UUID_C_UUID_3);
} else {
bindUuid = true;
query.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
query.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else if (pagination) {
query.append(QuxModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
if (bindUuid) {
qPos.add(uuid);
}
qPos.add(companyId);
if (!pagination) {
list = (List<Qux>) QueryUtil.list(q, getDialect(), start, end, false);
Collections.sort(list);
list = Collections.unmodifiableList(list);
} else {
list = (List<Qux>) QueryUtil.list(q, getDialect(), start, end);
}
cacheResult(list);
finderCache.putResult(finderPath, finderArgs, list);
} catch (Exception e) {
finderCache.removeResult(finderPath, finderArgs);
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
use of com.liferay.petra.string.StringBundler in project liferay-blade-samples by liferay.
the class QuxPersistenceImpl method findByUuid_Last.
/**
* Returns the last qux in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
* @return the last matching qux
* @throws NoSuchQuxException if a matching qux could not be found
*/
@Override
public Qux findByUuid_Last(String uuid, OrderByComparator<Qux> orderByComparator) throws NoSuchQuxException {
Qux qux = fetchByUuid_Last(uuid, orderByComparator);
if (qux != null) {
return qux;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchQuxException(msg.toString());
}
Aggregations