Added methods with limit and offset parameter to page models repo
Former-commit-id: 1c34927e92
restapi
parent
8b0e00dca8
commit
35b86a224a
|
|
@ -58,7 +58,7 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
||||||
public Long getIdOfEntity(final PageModel entity) {
|
public Long getIdOfEntity(final PageModel entity) {
|
||||||
return entity.getPageModelId();
|
return entity.getPageModelId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNew(final PageModel pageModel) {
|
public boolean isNew(final PageModel pageModel) {
|
||||||
|
|
||||||
|
|
@ -91,7 +91,6 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
@Override
|
@Override
|
||||||
public void save(final PageModel pageModel) {
|
public void save(final PageModel pageModel) {
|
||||||
|
|
||||||
pageModel.setLastModified(new Date());
|
pageModel.setLastModified(new Date());
|
||||||
|
|
||||||
super.save(pageModel);
|
super.save(pageModel);
|
||||||
|
|
@ -106,11 +105,30 @@ public class PageModelRepository extends AbstractEntityRepository<Long, PageMode
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<PageModel> findAllDraftModels() {
|
public List<PageModel> findAllDraftModels() {
|
||||||
|
return getEntityManager()
|
||||||
|
.createNamedQuery("PageModel.findAllDraftModels", PageModel.class)
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
final TypedQuery<PageModel> query = getEntityManager()
|
/**
|
||||||
.createNamedQuery("PageModel.findAllDraftModels", PageModel.class);
|
* Find all draft versions of {@link PageModel}s.
|
||||||
|
*
|
||||||
return query.getResultList();
|
* @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)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
public List<PageModel> findAllLiveModels() {
|
public List<PageModel> findAllLiveModels() {
|
||||||
|
return getEntityManager()
|
||||||
|
.createNamedQuery("PageModel.findAllLiveModels", PageModel.class)
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
final TypedQuery<PageModel> query = getEntityManager()
|
/**
|
||||||
.createNamedQuery("PageModel.findAllLiveModels", PageModel.class);
|
* Find all live versions of {@link PageModel}s.
|
||||||
|
*
|
||||||
return query.getResultList();
|
* @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
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
public List<PageModel> findDraftByApplication(
|
public List<PageModel> findDraftByApplication(
|
||||||
final CcmApplication application) {
|
final CcmApplication application
|
||||||
|
) {
|
||||||
|
|
||||||
Objects.requireNonNull(application,
|
Objects.requireNonNull(application,
|
||||||
"Can't find page models for application null");
|
"Can't find page models for application null");
|
||||||
|
|
||||||
final TypedQuery<PageModel> query = getEntityManager()
|
return getEntityManager()
|
||||||
.createNamedQuery("PageModel.findDraftByApplication",
|
.createNamedQuery("PageModel.findDraftByApplication",
|
||||||
PageModel.class);
|
PageModel.class)
|
||||||
query.setParameter("application", application);
|
.setParameter("application", application)
|
||||||
|
.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
|
||||||
|
) {
|
||||||
|
|
||||||
return query.getResultList();
|
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