Skip to content

Commit

Permalink
queries for creating or updating affiliations in the registry now exp…
Browse files Browse the repository at this point in the history
…licitly don't include deprecated / deactivated status
  • Loading branch information
George Nash committed Feb 11, 2025
1 parent c2f6853 commit 1139f92
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.mongodb.client.DistinctIterable;
import com.mongodb.client.model.Filters;
import org.springframework.util.Assert;

@Repository
public class AssertionRepositoryCustomImpl implements AssertionRepositoryCustom {
Expand Down Expand Up @@ -60,7 +61,13 @@ public List<Assertion> findAllToUpdateInOrcidRegistry(Pageable pageable) {
Criteria needsUpdatingInOrcid = new Criteria();
needsUpdatingInOrcid.orOperator(modifiedAfterUpdateInOrcid, modifiedAfterAddingToOrcidAndUpdateInOrcidNotSet);

MatchOperation matchUpdatedAfterSync = Aggregation.match(needsUpdatingInOrcid);
Criteria notDeprecatedOrDeactivated = new Criteria();
notDeprecatedOrDeactivated.andOperator(Criteria.where("status").ne(AssertionStatus.RECORD_DEACTIVATED_OR_DEPRECATED.name()));

Criteria needsUpdatingInOrcidAndNotDeprecatedOrDeactivated = new Criteria();
needsUpdatingInOrcidAndNotDeprecatedOrDeactivated.andOperator(needsUpdatingInOrcid, notDeprecatedOrDeactivated);

MatchOperation matchUpdatedAfterSync = Aggregation.match(needsUpdatingInOrcidAndNotDeprecatedOrDeactivated);

// pagination aggregation operations
SortOperation sort = new SortOperation(pageable.getSort());
Expand All @@ -85,9 +92,16 @@ public List<MemberAssertionStatusCount> getMemberAssertionStatusCounts() {

@Override
public List<Assertion> findAllToCreateInOrcidRegistry(Pageable pageable) {
Criteria criteria = new Criteria();
criteria.orOperator(Criteria.where("added_to_orcid").exists(false), Criteria.where("added_to_orcid").is(null));
Query query = new Query(criteria);
Criteria notAddedToOrcid = new Criteria();
notAddedToOrcid.orOperator(Criteria.where("added_to_orcid").exists(false), Criteria.where("added_to_orcid").is(null));

Criteria notDeprecatedOrDeactivated = new Criteria();
notDeprecatedOrDeactivated.andOperator(Criteria.where("status").ne(AssertionStatus.RECORD_DEACTIVATED_OR_DEPRECATED.name()));

Criteria notAddedToOrcidAndNotDeprecatedOrDeactivated = new Criteria();
notAddedToOrcidAndNotDeprecatedOrDeactivated.andOperator(notAddedToOrcid, notDeprecatedOrDeactivated);

Query query = new Query(notAddedToOrcidAndNotDeprecatedOrDeactivated);
query.with(pageable);
return mongoTemplate.find(query, Assertion.class);
}
Expand Down

0 comments on commit 1139f92

Please sign in to comment.