Skip to content

Commit

Permalink
Merge pull request #1258 from ORCID/dontSyncAffiliationsForDeactivate…
Browse files Browse the repository at this point in the history
…dRecords

queries for creating or updating affiliations in the registry now exp…
  • Loading branch information
auumgn authored Feb 11, 2025
2 parents c2f6853 + 1139f92 commit cb7d569
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 cb7d569

Please sign in to comment.