use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class JSPPortlet method updateBar.
protected void updateBar(ActionRequest actionRequest) throws Exception {
long barId = ParamUtil.getLong(actionRequest, "barId");
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 (barId <= 0) {
Bar bar = getBarLocalService().createBar(0);
bar.setField1(field1);
bar.setField2(field2);
bar.setField3(field3);
bar.setField4(field4);
bar.setField5(field5);
bar.isNew();
getBarLocalService().addBarWithoutId(bar);
} else {
Bar bar = getBarLocalService().fetchBar(barId);
bar.setBarId(barId);
bar.setField1(field1);
bar.setField2(field2);
bar.setField3(field3);
bar.setField4(field4);
bar.setField5(field5);
getBarLocalService().updateBar(bar);
}
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarLocalServiceBaseImpl method getExportActionableDynamicQuery.
@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(final PortletDataContext portletDataContext) {
final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
@Override
public long performCount() throws PortalException {
ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
StagedModelType stagedModelType = getStagedModelType();
long modelAdditionCount = super.performCount();
manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);
long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext, stagedModelType);
manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);
return modelAdditionCount;
}
};
initActionableDynamicQuery(exportActionableDynamicQuery);
exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
@Override
public void addCriteria(DynamicQuery dynamicQuery) {
portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
}
});
exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Bar>() {
@Override
public void performAction(Bar bar) throws PortalException {
StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, bar);
}
});
exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Bar.class.getName())));
return exportActionableDynamicQuery;
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUuid_First.
/**
* Returns the first bar 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 first matching bar
* @throws NoSuchBarException if a matching bar could not be found
*/
@Override
public Bar findByUuid_First(String uuid, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
Bar bar = fetchByUuid_First(uuid, orderByComparator);
if (bar != null) {
return bar;
}
StringBundler msg = new StringBundler(4);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append("}");
throw new NoSuchBarException(msg.toString());
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByUUID_G.
/**
* Returns the bar where uuid = ? and groupId = ? or throws a <code>NoSuchBarException</code> if it could not be found.
*
* @param uuid the uuid
* @param groupId the group ID
* @return the matching bar
* @throws NoSuchBarException if a matching bar could not be found
*/
@Override
public Bar findByUUID_G(String uuid, long groupId) throws NoSuchBarException {
Bar bar = fetchByUUID_G(uuid, groupId);
if (bar == null) {
StringBundler msg = new StringBundler(6);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("uuid=");
msg.append(uuid);
msg.append(", groupId=");
msg.append(groupId);
msg.append("}");
if (_log.isDebugEnabled()) {
_log.debug(msg.toString());
}
throw new NoSuchBarException(msg.toString());
}
return bar;
}
use of com.liferay.blade.samples.servicebuilder.adq.model.Bar in project liferay-blade-samples by liferay.
the class BarPersistenceImpl method findByField2.
/**
* Returns an ordered range of all the bars where field2 = ?.
*
* <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, then the query will include the default ORDER BY logic from <code>BarModelImpl</code>.
* </p>
*
* @param field2 the field2
* @param start the lower bound of the range of bars
* @param end the upper bound of the range of bars (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching bars
*/
@Override
public List<Bar> findByField2(boolean field2, int start, int end, OrderByComparator<Bar> orderByComparator, boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByField2;
finderArgs = new Object[] { field2 };
}
} else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByField2;
finderArgs = new Object[] { field2, start, end, orderByComparator };
}
List<Bar> list = null;
if (useFinderCache) {
list = (List<Bar>) finderCache.getResult(finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (Bar bar : list) {
if (field2 != bar.isField2()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler query = null;
if (orderByComparator != null) {
query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 2));
} else {
query = new StringBundler(3);
}
query.append(_SQL_SELECT_BAR_WHERE);
query.append(_FINDER_COLUMN_FIELD2_FIELD2_2);
if (orderByComparator != null) {
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
} else {
query.append(BarModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Session session = null;
try {
session = openSession();
Query q = session.createQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
qPos.add(field2);
list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
} catch (Exception e) {
if (useFinderCache) {
finderCache.removeResult(finderPath, finderArgs);
}
throw processException(e);
} finally {
closeSession(session);
}
}
return list;
}
Aggregations