mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
DS-3851 Add native support for pagination in the findBySubmitter
This commit is contained in:
@@ -131,6 +131,21 @@ public class XmlWorkflowItemServiceImpl implements XmlWorkflowItemService {
|
||||
return xmlWorkflowItemDAO.findBySubmitter(context, ep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<XmlWorkflowItem> findBySubmitter(Context context, EPerson ep, Integer pageNumber, Integer pageSize)
|
||||
throws SQLException {
|
||||
Integer offset = null;
|
||||
if (pageNumber != null && pageSize != null) {
|
||||
offset = pageNumber * pageSize;
|
||||
}
|
||||
return xmlWorkflowItemDAO.findBySubmitter(context, ep, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countBySubmitter(Context context, EPerson ep) throws SQLException {
|
||||
return xmlWorkflowItemDAO.countBySubmitter(context, ep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCollection(Context context, Collection collection)
|
||||
throws SQLException, IOException, AuthorizeException {
|
||||
|
@@ -53,4 +53,32 @@ public interface XmlWorkflowItemDAO extends GenericDAO<XmlWorkflowItem> {
|
||||
public List<XmlWorkflowItem> findByCollection(Context context, Collection collection) throws SQLException;
|
||||
|
||||
public XmlWorkflowItem findByItem(Context context, Item item) throws SQLException;
|
||||
|
||||
/**
|
||||
* Return all the workflow items from a specific submitter respecting the pagination parameters
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param ep
|
||||
* the eperson that has submitted the item
|
||||
* @param offset
|
||||
* the first record to return
|
||||
* @param limit
|
||||
* the max number of records to return
|
||||
* @return
|
||||
*/
|
||||
public List<XmlWorkflowItem> findBySubmitter(Context context, EPerson ep, Integer offset, Integer limit)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
* Count the number of workflow items from a specific submitter
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param ep
|
||||
* the eperson that has submitted the item
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public int countBySubmitter(Context context, EPerson ep) throws SQLException;
|
||||
}
|
||||
|
@@ -82,6 +82,18 @@ public class XmlWorkflowItemDAOImpl extends AbstractHibernateDAO<XmlWorkflowItem
|
||||
|
||||
@Override
|
||||
public List<XmlWorkflowItem> findBySubmitter(Context context, EPerson ep) throws SQLException {
|
||||
return findBySubmitter(context, ep, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<XmlWorkflowItem> findBySubmitter(Context context, EPerson ep, Integer offset, Integer limit)
|
||||
throws SQLException {
|
||||
if (offset == null) {
|
||||
offset = -1;
|
||||
}
|
||||
if (limit == null) {
|
||||
limit = -1;
|
||||
}
|
||||
|
||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, XmlWorkflowItem.class);
|
||||
@@ -90,7 +102,17 @@ public class XmlWorkflowItemDAOImpl extends AbstractHibernateDAO<XmlWorkflowItem
|
||||
criteriaQuery.select(xmlWorkflowItemRoot);
|
||||
criteriaQuery.where(criteriaBuilder.equal(join.get(Item_.submitter), ep));
|
||||
criteriaQuery.orderBy(criteriaBuilder.asc(xmlWorkflowItemRoot.get(XmlWorkflowItem_.id)));
|
||||
return list(context, criteriaQuery, false, XmlWorkflowItem.class, -1, -1);
|
||||
return list(context, criteriaQuery, false, XmlWorkflowItem.class, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countBySubmitter(Context context, EPerson ep) throws SQLException {
|
||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
||||
Root<XmlWorkflowItem> xmlWorkflowItemRoot = criteriaQuery.from(XmlWorkflowItem.class);
|
||||
Join<XmlWorkflowItem, Item> join = xmlWorkflowItemRoot.join("item");
|
||||
criteriaQuery.where(criteriaBuilder.equal(join.get(Item_.submitter), ep));
|
||||
return count(context, criteriaQuery, criteriaBuilder, xmlWorkflowItemRoot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.workflow.WorkflowItemService;
|
||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
|
||||
@@ -67,4 +68,33 @@ public interface XmlWorkflowItemService extends WorkflowItemService<XmlWorkflowI
|
||||
*/
|
||||
public int countAllInCollection(Context context, Collection collection) throws SQLException;
|
||||
|
||||
/**
|
||||
* Return all the workflow items from a specific submitter respecting the pagination parameters
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param ep
|
||||
* the eperson that has submitted the item
|
||||
* @param pageNumber
|
||||
* paging: page number
|
||||
* @param pageSize
|
||||
* paging: items per page
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public List<XmlWorkflowItem> findBySubmitter(Context context, EPerson ep, Integer pageNumber, Integer pageSize)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
* Count the number of workflow items from a specific submitter
|
||||
*
|
||||
* @param context
|
||||
* The relevant DSpace Context.
|
||||
* @param ep
|
||||
* the eperson that has submitted the item
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public int countBySubmitter(Context context, EPerson ep) throws SQLException;
|
||||
|
||||
}
|
||||
|
@@ -131,14 +131,16 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
@PreAuthorize("hasAuthority('ADMIN')")
|
||||
public Page<WorkflowItemRest> findBySubmitter(@Parameter(value = "uuid") UUID submitterID, Pageable pageable) {
|
||||
List<XmlWorkflowItem> witems = null;
|
||||
int total = 0;
|
||||
try {
|
||||
Context context = obtainContext();
|
||||
EPerson ep = epersonService.find(context, submitterID);
|
||||
witems = wis.findBySubmitter(context, ep);
|
||||
witems = wis.findBySubmitter(context, ep, pageable.getPageNumber(), pageable.getPageSize());
|
||||
total = wis.countBySubmitter(context, ep);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
Page<WorkflowItemRest> page = utils.getPage(witems, pageable).map(converter);
|
||||
Page<WorkflowItemRest> page = new PageImpl<XmlWorkflowItem>(witems, pageable, total).map(converter);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user