use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.
the class MongoMessageProcessorTest method testDeprecated.
@Test
public void testDeprecated() throws LockedRecordException, DeprecatedRecordException {
when(mock_orcid20ApiClient.fetchPublicRecord(Matchers.any())).thenThrow(new DeprecatedRecordException(new OrcidError()));
LastModifiedMessage m = new LastModifiedMessage(this.orcid, new Date());
mongo.accept(m);
// test db has entry for depreciated record
Document d = new Document();
d.put("_id", this.orcid);
assertEquals(col.count(d), 1);
FindIterable<Document> it = col.find(d);
assertEquals(it.first().get("status"), "deprecated");
}
use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.
the class MongoMessageProcessor method updateMongo.
private void updateMongo(BaseMessage message) {
String orcid = message.getOrcid();
LOG.info("Updating using Record " + orcid + " in Mongo");
try {
Record record = orcid20ApiClient.fetchPublicRecord(message);
// Remove deactivated records from Mongo
if (record.getHistory() != null && record.getHistory().getDeactivationDate() != null && record.getHistory().getDeactivationDate().getValue() != null) {
delete(message.getOrcid(), "deactivated");
return;
}
Document d = Document.parse(mapper.writeValueAsString(record));
d.put("_id", message.getOrcid());
Document index = new Document();
index.put("_id", message.getOrcid());
col.replaceOne(index, d, upsert);
recordStatusManager.markAsSent(orcid, AvailableBroker.MONGO);
} catch (LockedRecordException lre) {
LOG.error("Record " + orcid + " is locked");
delete(message.getOrcid(), "locked");
} catch (DeprecatedRecordException dre) {
LOG.error("Record " + orcid + " is deprecated");
delete(message.getOrcid(), "deprecated");
} catch (Exception e) {
LOG.error("pants", e);
recordStatusManager.markAsFailed(message.getOrcid(), AvailableBroker.MONGO);
}
}
use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.
the class ActivitiesGroup method belongsToGroup.
@Deprecated
public /**
* This method is only used by tests to confirm accuracy of ActivitiesGroupGenerator and should not be used in production
*
* @param activity
* @return
*/
boolean belongsToGroup(GroupableActivity activity) {
boolean isPeerReview = PeerReviewSummary.class.isAssignableFrom(activity.getClass());
// If there are no grouping keys
if (groupKeys == null || groupKeys.isEmpty()) {
if (isPeerReview) {
return false;
} else {
if (activity.getExternalIdentifiers() == null || activity.getExternalIdentifiers().getExternalIdentifier() == null || activity.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
// If the activity doesn't have any external identifier, check if the activity is in the group
if (activities.contains(activity))
return true;
else
return false;
} else {
// If any of the activities pass the grouping validation, the activity must belong to other group
for (GroupAble extId : activity.getExternalIdentifiers().getExternalIdentifier()) {
if (extId.isGroupAble())
return false;
}
// If none of the activities pass the groupings validation, so, lets check if the group actually contains the activity
if (activities.contains(activity))
return true;
else
return false;
}
}
}
if (isPeerReview) {
PeerReviewSummary peerReviewSummary = (PeerReviewSummary) activity;
PeerReviewGroupKey prgk = new PeerReviewGroupKey();
prgk.setGroupId(peerReviewSummary.getGroupId());
if (prgk.isGroupAble()) {
if (groupKeys.contains(prgk)) {
return true;
}
}
} else {
// Check existing keys
ExternalIdentifiersContainer container = activity.getExternalIdentifiers();
if (container != null) {
List<? extends GroupAble> extIds = (List<? extends GroupAble>) container.getExternalIdentifier();
for (GroupAble extId : extIds) {
// First check keys restrictions
if (extId.isGroupAble()) {
// If any of the keys already exists on this group, return true
if (containsKey(extId))
return true;
}
}
}
}
return false;
}
Aggregations