91354: WIP: basic fix for reindexing older versions of items

This commit is contained in:
Bruno Roemers
2022-05-18 13:30:27 +02:00
parent ea8b4f4896
commit b0482bcdd8
5 changed files with 40 additions and 1 deletions

View File

@@ -245,6 +245,10 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
return itemDAO.findAll(context, true, true); return itemDAO.findAll(context, true, true);
} }
public Iterator<Item> findAllRegularItems(Context context) throws SQLException {
return itemDAO.findAllRegularItems(context);
};
@Override @Override
public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException { public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException {
return itemDAO.findBySubmitter(context, eperson); return itemDAO.findBySubmitter(context, eperson);

View File

@@ -32,8 +32,22 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
public Iterator<Item> findAll(Context context, boolean archived, int limit, int offset) throws SQLException; public Iterator<Item> findAll(Context context, boolean archived, int limit, int offset) throws SQLException;
@Deprecated
public Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn) throws SQLException; public Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn) throws SQLException;
/**
* Find all items that are:
* - NOT in the workspace
* - NOT in the workflow
* - NOT a template item for e.g. a collection
*
* This implies that the result also contains older versions of items and withdrawn items.
* @param context the DSpace context.
* @return iterator over all regular items.
* @throws SQLException if database error.
*/
public Iterator<Item> findAllRegularItems(Context context) throws SQLException;
/** /**
* Find all Items modified since a Date. * Find all Items modified since a Date.
* *

View File

@@ -79,6 +79,13 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
return iterate(query); return iterate(query);
} }
@Override
public Iterator<Item> findAllRegularItems(Context context) throws SQLException {
// TODO exclude workspace, workflow, template items
Query query = createQuery(context, "FROM Item ORDER BY id");
return iterate(query);
}
@Override @Override
public Iterator<Item> findAll(Context context, boolean archived, public Iterator<Item> findAll(Context context, boolean archived,
boolean withdrawn, boolean discoverable, Date lastModified) boolean withdrawn, boolean discoverable, Date lastModified)

View File

@@ -112,8 +112,22 @@ public interface ItemService
* @return an iterator over the items in the archive. * @return an iterator over the items in the archive.
* @throws SQLException if database error * @throws SQLException if database error
*/ */
@Deprecated
public Iterator<Item> findAllUnfiltered(Context context) throws SQLException; public Iterator<Item> findAllUnfiltered(Context context) throws SQLException;
/**
* Find all items that are:
* - NOT in the workspace
* - NOT in the workflow
* - NOT a template item for e.g. a collection
*
* This implies that the result also contains older versions of items and withdrawn items.
* @param context the DSpace context.
* @return iterator over all regular items.
* @throws SQLException if database error.
*/
public Iterator<Item> findAllRegularItems(Context context) throws SQLException;
/** /**
* Find all the items in the archive by a given submitter. The order is * Find all the items in the archive by a given submitter. The order is
* indeterminate. Only items with the "in archive" flag set are included. * indeterminate. Only items with the "in archive" flag set are included.

View File

@@ -103,7 +103,7 @@ public class ItemIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Indexable
@Override @Override
public Iterator<IndexableItem> findAll(Context context) throws SQLException { public Iterator<IndexableItem> findAll(Context context) throws SQLException {
Iterator<Item> items = itemService.findAllUnfiltered(context); Iterator<Item> items = itemService.findAllRegularItems(context);
return new Iterator<IndexableItem>() { return new Iterator<IndexableItem>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {