Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content reports ported from DSpace 6.x #8598

Merged
merged 133 commits into from Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
ce53411
content Reports
Nov 30, 2022
bee1772
Merge branch 'DSpace:main' into main
jeffmorin Dec 2, 2022
7cf1003
Fixed CheckStyle errors
Dec 2, 2022
d47a4f5
Merge branch 'main' of github.com:jeffmorin/DSpace
Dec 2, 2022
25f4b95
Fixed CheckStyle errors
Dec 12, 2022
e38a9fd
Fixed CheckStyle errors
Dec 12, 2022
08ac81a
Merge branch 'main' into main
jeffmorin Dec 12, 2022
bcb2edf
Merge branch 'DSpace:main' into main
jeffmorin Jan 9, 2023
0ba471c
Merge branch 'DSpace:main' into main
jeffmorin Jan 11, 2023
3117e81
Merge branch 'DSpace:main' into main
jeffmorin Jan 12, 2023
a331184
First batch of fixes: mainly Javadoc, and a bit of code re-engineering
Jan 12, 2023
7a3b2c6
Fixed CheckStyle errors
Jan 12, 2023
619c456
Fixed CheckStyle errors in dspace-server-webapp
Jan 12, 2023
99788c1
Merge branch 'DSpace:main' into main
jeffmorin Jan 13, 2023
fa59743
Merge branch 'DSpace:main' into main
jeffmorin Jan 16, 2023
d5542ce
Merge branch 'DSpace:main' into main
jeffmorin Jan 24, 2023
9c91e7a
Merge branch 'DSpace:main' into main
jeffmorin Jan 31, 2023
0287f68
Merge branch 'DSpace:main' into main
jeffmorin Feb 7, 2023
6a0f6d7
Merge branch 'DSpace:main' into main
jeffmorin Feb 8, 2023
522f053
Merge branch 'DSpace:main' into main
jeffmorin Feb 10, 2023
fec4d8a
Merge branch 'DSpace:main' into main
jeffmorin Feb 15, 2023
d8c47fe
Merge branch 'DSpace:main' into main
jeffmorin Feb 16, 2023
d1115b1
Merge branch 'DSpace:main' into main
jeffmorin Feb 20, 2023
bee1f75
Merge branch 'DSpace:main' into main
jeffmorin Mar 1, 2023
75585f8
Merge branch 'DSpace:main' into main
jeffmorin Mar 2, 2023
e0fc2dc
Merge branch 'DSpace:main' into main
jeffmorin Mar 9, 2023
027c26a
Merge branch 'DSpace:main' into main
jeffmorin Mar 23, 2023
613b7e5
Applied requested changes for DSpace code conventions compliance
Mar 24, 2023
690f8b4
Merge branch 'DSpace:main' into main
jeffmorin Apr 5, 2023
386e44d
Merge branch 'DSpace:main' into main
jeffmorin Apr 12, 2023
6805937
Merge branch 'DSpace:main' into main
jeffmorin Apr 19, 2023
4f7031c
Added GET endpoint to Filtered Items report
Apr 19, 2023
65ab0e3
Merge branch 'DSpace:main' into main
jeffmorin Apr 21, 2023
98cf7f7
Merge branch 'DSpace:main' into main
jeffmorin Apr 25, 2023
6bc0ca8
Merge branch 'DSpace:main' into main
jeffmorin Apr 28, 2023
d6ab248
Resolved conflicts
May 1, 2023
ad18f0a
Merge branch 'DSpace:main' into main
jeffmorin May 3, 2023
5f591de
Merge branch 'DSpace:main' into main
jeffmorin May 4, 2023
e255640
Merge branch 'DSpace:main' into main
jeffmorin May 25, 2023
524de27
Merge branch 'DSpace:main' into main
jeffmorin May 30, 2023
a55dd0f
Merge branch 'DSpace:main' into main
jeffmorin Jun 5, 2023
5efa67c
Merge branch 'main' of github.com:jeffmorin/DSpace
Nov 20, 2023
a4dd112
Updated to latest version from main branch
Nov 21, 2023
0f0f784
Merge branch 'DSpace:main' into main
jeffmorin Dec 18, 2023
c9099cc
Resolved conflicts
Feb 12, 2024
205287e
Fixed missing imports
Feb 12, 2024
75e092b
Fixed CheckStyle errors
Feb 12, 2024
033e6ec
Fixed H2 database initialization
Feb 12, 2024
542b73b
Fixed unit tests and an integration test
Feb 13, 2024
7df747e
Fixed CheckStyle errors
Feb 13, 2024
249ac17
Fixed CheckStyle errors
Feb 13, 2024
b7ef087
Fixed ItemServiceIT test
Feb 13, 2024
be4aeaf
Test without collection criterion
Feb 13, 2024
fc8f75c
Fixed max result count in integration test
Feb 13, 2024
8736bfd
Disable findByMetadataQuery test to diagnose errors in other tests
Feb 13, 2024
2dec78a
Disabled ContentReportRestRepositoryIT test to validate existing tests
Feb 13, 2024
bde17ce
Re-enable test in dspace-api
Feb 13, 2024
183e73e
Re-enabled ContentReportRestRepositoryIT tests to diagnose failures
Feb 13, 2024
fb922e0
Fixed item matching in the second test
Feb 14, 2024
c15528b
Fixed JSON path error
Feb 14, 2024
e16eefa
Use projections to trigger embedding the owning collection in ItemRes…
Feb 14, 2024
ea8221a
Fixed usage of allowEmbedding() through non-null arguments
Feb 14, 2024
276f7f8
Exclude owning collection from ItemRest when null/empty
Feb 14, 2024
74662b4
Merge branch 'DSpace:main' into main
jeffmorin Feb 15, 2024
f613b64
Trying an alternate way to discriminate report-based Item conversions
Feb 15, 2024
a902d57
Fixed embedded owning collection management
Feb 15, 2024
b1d79f0
Replaced ItemConverter with correct version
Feb 15, 2024
17c2739
Fixed Filtered Collections test in ContentReportRestRepositoryIT
Feb 15, 2024
99c7219
Fixed test
Feb 15, 2024
d31ed1e
Transferred owning collection to a separate class FilteredItemRest
Feb 16, 2024
4743f64
Merge branch 'DSpace:main' into main
jeffmorin Feb 16, 2024
9d19eb4
Rollback to DSpace repo version
Feb 16, 2024
911afb9
Fixed matcher for Filtered Collections summary
Feb 16, 2024
d8c2494
Fixed matcher for Filtered Collections summary (take 2)
Feb 16, 2024
80dfa59
Add printing mock request results to diagnose remaining problems
Feb 16, 2024
8f48451
Try logging output through System.err
Feb 16, 2024
6986e0c
Cancelled attempt to print JSON results (does nothing)
Feb 16, 2024
464ca4a
Attempt to fix ContentReportRestRepositoryIT tests
Feb 16, 2024
e6a18b1
Removed predefined UUIDs and handles
Feb 16, 2024
77ace73
Fixed import formatting
Feb 16, 2024
615b5f1
Fixed expected results in ContentReportRestRepositoryIT
Feb 16, 2024
4001b64
Switched to a custom matcher for the Filtered Item report test
Feb 17, 2024
8e8dcdb
Fixed import format
Feb 17, 2024
b5eb6b0
Fixed JSON collection matching in Filtered Items test
Feb 17, 2024
10aebae
Fixed Filtered Items matcher
Feb 17, 2024
ed456c1
Fixed expected result
Feb 17, 2024
55202c9
Fixed the test for now...
Feb 17, 2024
f2dcb29
Fixed test again
Feb 17, 2024
7dca831
Disabled non-working test
Feb 17, 2024
f26f257
Fixed a few typos
Feb 17, 2024
8c2edc2
Merge branch 'DSpace:main' into main
jeffmorin Feb 19, 2024
5e8cb73
Moved Filtered Collections report business logic to dspace-api
Feb 20, 2024
671436f
Merge branch 'main' of git@github.com:jeffmorin/DSpace.git into main
Feb 20, 2024
aba71ea
Fixed outdated controller
Feb 20, 2024
2b1c98a
Fixed import and lost @Ignore annotation
Feb 20, 2024
15f3cf1
Retrieved a lost test correction
Feb 20, 2024
b149f79
Fixed Filtered Collections test
Feb 21, 2024
e39a473
Reverted to the last working version (except for 2nd test, which remains
Feb 21, 2024
66bd10e
Moved Filtered Items report business logic to dspace-api
Feb 21, 2024
cf4314c
Merge branch 'DSpace:main' into main
jeffmorin Feb 21, 2024
2b6a227
Fixed import style
Feb 21, 2024
a987eea
Merge branch 'main' of git@github.com:jeffmorin/DSpace.git into main
Feb 21, 2024
bf58f85
Merge branch 'DSpace:main' into main
jeffmorin Feb 22, 2024
3862c6a
Merge branch 'DSpace:main' into main
jeffmorin Feb 22, 2024
7256519
Added switch to enable/disable Content Reports
Feb 22, 2024
2e7db41
Fixed an out-of-date class
Feb 22, 2024
b6c63d4
Removed unused imports
Feb 22, 2024
6f6ecd5
Fixed activation configuration for Content Reports
Feb 22, 2024
7157b6f
Added missing @Test annotation
Feb 22, 2024
f51a59e
A forgotten Hibernate dialect configuration. I also removed obsolete
Feb 23, 2024
92cf2e7
Switched to GET requests for Content Reports
Feb 23, 2024
e266bb2
Switched to GET requests for Content Reports
Feb 23, 2024
e228abd
Fixed styling in imports
Feb 23, 2024
22cc04c
Fixed imports
Feb 23, 2024
d23a5d2
Cleaned deprecated code
Feb 26, 2024
ff72eee
Simplified regex since trim() method is invoked on each token thereafter
Feb 26, 2024
ec298dc
Merge branch 'DSpace:main' into main
jeffmorin Feb 27, 2024
f3de5ab
Added Javadoc in the interface.
Feb 27, 2024
c1b5bd8
Relocated Content Reports configuration into a new file
Feb 27, 2024
aefd498
Added "unauthorized" tests and cleaned up code repetitions
Feb 27, 2024
0f00dc7
Fixed parameter according to Javadoc
Feb 27, 2024
60d93f1
Fixed Filtered Items test
Feb 27, 2024
eea94b1
Merge branch 'DSpace:main' into main
jeffmorin Feb 27, 2024
a49ee67
Use of @ConditionalOnProperty annotation
Feb 27, 2024
631acc3
Merge branch 'main' of git@github.com:jeffmorin/DSpace.git into main
Feb 27, 2024
369897c
Rolled back to manual parameter managing
Feb 27, 2024
4028d66
Second try on @ConditionalOnProperty, with proper test configuration
Feb 27, 2024
f247723
Rolled back (again) to manual service activation checking (needed for
Feb 27, 2024
2464067
Eliminated inheritance between FilteredItemRest and ItemRest
Feb 27, 2024
ad3b0d4
Resolved conflicts
Feb 27, 2024
21e12df
Re-established the type property in FilteredItemRest (and in
Feb 27, 2024
3f81a8e
Merge branch 'main' of git@github.com:jeffmorin/DSpace.git into main
Feb 27, 2024
05f0ff8
Merge branch 'DSpace:main' into main
jeffmorin Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 35 additions & 25 deletions dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java
Expand Up @@ -49,6 +49,7 @@
import org.dspace.content.service.RelationshipService;
import org.dspace.content.service.WorkspaceItemService;
import org.dspace.content.virtual.VirtualMetadataPopulator;
import org.dspace.contentreport.QueryPredicate;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogHelper;
Expand Down Expand Up @@ -175,7 +176,6 @@
private QAEventsDAO qaEventsDao;

protected ItemServiceImpl() {
super();
}

@Override
Expand Down Expand Up @@ -275,9 +275,8 @@
+ template.getID()));

return template;
} else {
return collection.getTemplateItem();
}
return collection.getTemplateItem();

Check warning on line 279 in dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java#L279

Added line #L279 was not covered by tests
}

@Override
Expand Down Expand Up @@ -1190,9 +1189,8 @@
if (item.getOwningCollection() == null) {
if (!isInProgressSubmission(context, item)) {
return true;
} else {
return false;
}
return false;
}

return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
Expand Down Expand Up @@ -1284,8 +1282,8 @@
if (!authorizeService
.isAnIdenticalPolicyAlreadyInPlace(context, dso, defaultPolicy.getGroup(), Constants.READ,
defaultPolicy.getID()) &&
(!appendMode && this.isNotAlreadyACustomRPOfThisTypeOnDSO(context, dso) ||
appendMode && this.shouldBeAppended(context, dso, defaultPolicy))) {
(!appendMode && isNotAlreadyACustomRPOfThisTypeOnDSO(context, dso) ||
appendMode && shouldBeAppended(context, dso, defaultPolicy))) {
ResourcePolicy newPolicy = resourcePolicyService.clone(context, defaultPolicy);
newPolicy.setdSpaceObject(dso);
newPolicy.setAction(Constants.READ);
Expand Down Expand Up @@ -1384,9 +1382,8 @@

if (Item.ANY.equals(value)) {
return itemDAO.findByMetadataField(context, mdf, null, true);
} else {
return itemDAO.findByMetadataField(context, mdf, value, true);
}
return itemDAO.findByMetadataField(context, mdf, value, true);
}

@Override
Expand Down Expand Up @@ -1430,9 +1427,24 @@

if (Item.ANY.equals(value)) {
return itemDAO.findByMetadataField(context, mdf, null, true);
} else {
return itemDAO.findByMetadataField(context, mdf, value, true);
}
return itemDAO.findByMetadataField(context, mdf, value, true);
}

@Override
public List<Item> findByMetadataQuery(Context context, List<QueryPredicate> queryPredicates,
List<UUID> collectionUuids, long offset, int limit)
throws SQLException {
return itemDAO.findByMetadataQuery(context, queryPredicates, collectionUuids, "text_value ~ ?",
offset, limit);
}


@Override
public long countForMetadataQuery(Context context, List<QueryPredicate> queryPredicates,
List<UUID> collectionUuids)
throws SQLException {
return itemDAO.countForMetadataQuery(context, queryPredicates, collectionUuids, "text_value ~ ?");
}

@Override
Expand Down Expand Up @@ -1498,20 +1510,19 @@
Collection ownCollection = item.getOwningCollection();
if (ownCollection != null) {
return ownCollection;
} else {
InProgressSubmission inprogress = ContentServiceFactory.getInstance().getWorkspaceItemService()
.findByItem(context,
item);
if (inprogress == null) {
inprogress = WorkflowServiceFactory.getInstance().getWorkflowItemService().findByItem(context, item);
}
}
InProgressSubmission inprogress = ContentServiceFactory.getInstance().getWorkspaceItemService()
.findByItem(context,
item);
if (inprogress == null) {
inprogress = WorkflowServiceFactory.getInstance().getWorkflowItemService().findByItem(context, item);
}

if (inprogress != null) {
return inprogress.getCollection();
}
// is a template item?
return item.getTemplateItemOf();
if (inprogress != null) {
return inprogress.getCollection();
}
// is a template item?
return item.getTemplateItemOf();
}

@Override
Expand Down Expand Up @@ -1611,9 +1622,8 @@
try {
if (StringUtils.isNumeric(id)) {
return findByLegacyId(context, Integer.parseInt(id));
} else {
return find(context, UUID.fromString(id));
}
return find(context, UUID.fromString(id));
} catch (IllegalArgumentException e) {
// Not a valid legacy ID or valid UUID
return null;
Expand Down
62 changes: 42 additions & 20 deletions dspace-api/src/main/java/org/dspace/content/dao/ItemDAO.java
Expand Up @@ -11,11 +11,13 @@
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;

import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.contentreport.QueryPredicate;
import org.dspace.core.Context;
import org.dspace.eperson.EPerson;

Expand All @@ -27,12 +29,11 @@
* @author kevinvandevelde at atmire.com
*/
public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
public Iterator<Item> findAll(Context context, boolean archived) throws SQLException;
Iterator<Item> findAll(Context context, boolean archived) throws SQLException;

public Iterator<Item> findAll(Context context, boolean archived, int limit, int offset) throws SQLException;
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;
@Deprecated Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn) throws SQLException;

/**
* Find all items that are:
Expand All @@ -45,7 +46,7 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return iterator over all regular items.
* @throws SQLException if database error.
*/
public Iterator<Item> findAllRegularItems(Context context) throws SQLException;
Iterator<Item> findAllRegularItems(Context context) throws SQLException;

/**
* Find all Items modified since a Date.
Expand All @@ -55,10 +56,10 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return iterator over items
* @throws SQLException if database error
*/
public Iterator<Item> findByLastModifiedSince(Context context, Date since)
Iterator<Item> findByLastModifiedSince(Context context, Date since)
throws SQLException;

public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException;
Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException;

/**
* Find all the items by a given submitter. The order is
Expand All @@ -70,19 +71,40 @@ public Iterator<Item> findByLastModifiedSince(Context context, Date since)
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/
public Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems)
Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems)
throws SQLException;

public Iterator<Item> findBySubmitter(Context context, EPerson eperson, MetadataField metadataField, int limit)
Iterator<Item> findBySubmitter(Context context, EPerson eperson, MetadataField metadataField, int limit)
throws SQLException;

public Iterator<Item> findByMetadataField(Context context, MetadataField metadataField, String value,
Iterator<Item> findByMetadataField(Context context, MetadataField metadataField, String value,
boolean inArchive) throws SQLException;

public Iterator<Item> findByAuthorityValue(Context context, MetadataField metadataField, String authority,
/**
* Returns all the Items that belong to the specified aollections (if any)
* and match the provided predicates.
* @param context The relevant DSpace context
* @param queryPredicates List of predicates that returned items are required to match
* @param collectionUuids UUIDs of the collections to search.
* If none are provided, the entire repository will be searched.
* @param regexClause Syntactic expression used to query the database using a regular expression
* (e.g.: "text_value ~ ?")
* @param offset The offset for the query
* @param limit Maximum number of items to return
* @return A list containing the items that match the provided criteria
* @throws SQLException if something goes wrong
*/
List<Item> findByMetadataQuery(Context context, List<QueryPredicate> queryPredicates,
jeffmorin marked this conversation as resolved.
Show resolved Hide resolved
List<UUID> collectionUuids, String regexClause,
long offset, int limit) throws SQLException;

long countForMetadataQuery(Context context, List<QueryPredicate> queryPredicates,
List<UUID> collectionUuids, String regexClause) throws SQLException;

Iterator<Item> findByAuthorityValue(Context context, MetadataField metadataField, String authority,
boolean inArchive) throws SQLException;

public Iterator<Item> findArchivedByCollection(Context context, Collection collection, Integer limit,
Iterator<Item> findArchivedByCollection(Context context, Collection collection, Integer limit,
Integer offset) throws SQLException;

/**
Expand All @@ -95,7 +117,7 @@ public Iterator<Item> findArchivedByCollection(Context context, Collection colle
* @return An iterator containing the items for which the constraints hold true
* @throws SQLException If something goes wrong
*/
public Iterator<Item> findArchivedByCollectionExcludingOwning(Context context, Collection collection, Integer limit,
Iterator<Item> findArchivedByCollectionExcludingOwning(Context context, Collection collection, Integer limit,
Integer offset) throws SQLException;

/**
Expand All @@ -106,11 +128,11 @@ public Iterator<Item> findArchivedByCollectionExcludingOwning(Context context, C
* @return The total amount of items that fit the constraints
* @throws SQLException If something goes wrong
*/
public int countArchivedByCollectionExcludingOwning(Context context, Collection collection) throws SQLException;
int countArchivedByCollectionExcludingOwning(Context context, Collection collection) throws SQLException;

public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException;
Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException;

public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset)
Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset)
throws SQLException;

/**
Expand All @@ -123,7 +145,7 @@ public Iterator<Item> findAllByCollection(Context context, Collection collection
* @return item count
* @throws SQLException if database error
*/
public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn)
int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn)
throws SQLException;

/**
Expand All @@ -139,7 +161,7 @@ public int countItems(Context context, Collection collection, boolean includeArc
* @return item count
* @throws SQLException if database error
*/
public int countItems(Context context, List<Collection> collections, boolean includeArchived,
int countItems(Context context, List<Collection> collections, boolean includeArchived,
boolean includeWithdrawn) throws SQLException;

/**
Expand All @@ -153,7 +175,7 @@ public int countItems(Context context, List<Collection> collections, boolean inc
* @return iterator over items
* @throws SQLException if database error
*/
public Iterator<Item> findAll(Context context, boolean archived,
Iterator<Item> findAll(Context context, boolean archived,
boolean withdrawn, boolean discoverable, Date lastModified)
throws SQLException;

Expand Down Expand Up @@ -187,7 +209,7 @@ public Iterator<Item> findAll(Context context, boolean archived,
* @return count of items
* @throws SQLException if database error
*/
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
throws SQLException;

}