Added methods with limit and offset parameter to page models repo
parent
65eefb9f2f
commit
1c34927e92
|
|
@ -91,7 +91,6 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public void save(final PageModel pageModel) {
|
||||
|
||||
pageModel.setLastModified(new Date());
|
||||
|
||||
super.save(pageModel);
|
||||
|
|
@ -106,11 +105,30 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
|||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PageModel> findAllDraftModels() {
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllDraftModels", PageModel.class)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
final TypedQuery<PageModel> query = getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllDraftModels", PageModel.class);
|
||||
|
||||
return query.getResultList();
|
||||
/**
|
||||
* Find all draft versions of {@link PageModel}s.
|
||||
*
|
||||
* @param limit
|
||||
* @param offset
|
||||
*
|
||||
* @return A list with all draft versions of {@link PageModel}s.
|
||||
*/
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PageModel> findAllDraftModels(
|
||||
final int limit, final int offset
|
||||
) {
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllDraftModels", PageModel.class)
|
||||
.setMaxResults(limit)
|
||||
.setFirstResult(offset)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -120,11 +138,27 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
|||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PageModel> findAllLiveModels() {
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllLiveModels", PageModel.class)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
final TypedQuery<PageModel> query = getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllLiveModels", PageModel.class);
|
||||
|
||||
return query.getResultList();
|
||||
/**
|
||||
* Find all live versions of {@link PageModel}s.
|
||||
*
|
||||
* @param limit
|
||||
* @param offset
|
||||
* @return A list with all draft versions of {@link PageModel}s.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PageModel> findAllLiveModels(
|
||||
final int limit, final int offset
|
||||
) {
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findAllLiveModels", PageModel.class)
|
||||
.setMaxResults(limit)
|
||||
.setFirstResult(offset)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,17 +175,50 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
|||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
public List<PageModel> findDraftByApplication(
|
||||
final CcmApplication application) {
|
||||
final CcmApplication application
|
||||
) {
|
||||
|
||||
Objects.requireNonNull(application,
|
||||
"Can't find page models for application null");
|
||||
|
||||
final TypedQuery<PageModel> query = getEntityManager()
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findDraftByApplication",
|
||||
PageModel.class);
|
||||
query.setParameter("application", application);
|
||||
PageModel.class)
|
||||
.setParameter("application", application)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
return query.getResultList();
|
||||
/**
|
||||
* Finds the draft versions of all {@link PageModel}s for the provided
|
||||
* application.
|
||||
*
|
||||
* @param application The application for which the {@link PageModel}s are
|
||||
* retrieved.
|
||||
* @param limit
|
||||
* @param offset
|
||||
*
|
||||
* @return A list of the {@link PageModel}s defined for the provided
|
||||
* {@code application}.
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
public List<PageModel> findDraftByApplication(
|
||||
final CcmApplication application,
|
||||
final int limit,
|
||||
final int offset
|
||||
) {
|
||||
|
||||
Objects.requireNonNull(application,
|
||||
"Can't find page models for application null");
|
||||
|
||||
return getEntityManager()
|
||||
.createNamedQuery("PageModel.findDraftByApplication",
|
||||
PageModel.class)
|
||||
.setParameter("application", application)
|
||||
.setMaxResults(limit)
|
||||
.setFirstResult(offset)
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue