use of org.powerbot.script.rt6.Item in project ORCID-Source by ORCID.
the class ExternalIDValidator method validateNotificationItems.
public void validateNotificationItems(Items items) {
if (items == null)
return;
List<String> errors = Lists.newArrayList();
for (Item i : items.getItems()) {
if (i.getExternalIdentifier() != null && i.getExternalIdentifier().getType() != null) {
ExternalID extId = i.getExternalIdentifier();
if (extId.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(extId.getType())) {
errors.add(i.getExternalIdentifier().getType());
}
if (PojoUtil.isEmpty(extId.getValue())) {
errors.add("value");
}
if (requireRelationshipOnExternalIdentifier) {
if (extId.getRelationship() == null) {
errors.add("relationship");
}
}
}
}
checkAndThrow(errors);
}
use of org.powerbot.script.rt6.Item in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createItem.
private Item createItem(OrgAffiliationRelationEntity orgAffiliationEntity) {
Item item = new Item();
item.setItemName(orgAffiliationEntity.getOrg().getName());
item.setItemType(AffiliationType.EDUCATION.equals(orgAffiliationEntity.getAffiliationType()) ? ItemType.EDUCATION : ItemType.EMPLOYMENT);
item.setPutCode(String.valueOf(orgAffiliationEntity.getId()));
return item;
}
use of org.powerbot.script.rt6.Item in project ORCID-Source by ORCID.
the class PeerReviewManagerImpl method createItemList.
private List<Item> createItemList(PeerReviewEntity peerReviewEntity) {
Item item = new Item();
item.setItemName(peerReviewEntity.getSubjectName());
item.setItemType(ItemType.PEER_REVIEW);
item.setPutCode(String.valueOf(peerReviewEntity.getId()));
return Arrays.asList(item);
}
use of org.powerbot.script.rt6.Item in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createItemList.
private List<Item> createItemList(OrgAffiliationRelationEntity orgAffiliationEntity) {
Item item = new Item();
item.setItemName(orgAffiliationEntity.getOrg().getName());
item.setItemType(AffiliationType.EDUCATION.value().equals(orgAffiliationEntity.getAffiliationType().value()) ? ItemType.EDUCATION : ItemType.EMPLOYMENT);
item.setPutCode(String.valueOf(orgAffiliationEntity.getId()));
return Arrays.asList(item);
}
use of org.powerbot.script.rt6.Item in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOn.
@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOn() {
validator.setRequireRelationshipOnExternalIdentifier(true);
Item i = new Item();
Item i2 = new Item();
Items items = new Items();
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("source-work-id");
id2.setValue("value2");
id2.setUrl(new Url("http://value1.com"));
i.setExternalIdentifier(id1);
i2.setExternalIdentifier(id2);
items.getItems().add(i);
items.getItems().add(i2);
// both valid
validator.validateNotificationItems(items);
fail("no exception thrown for invalid type");
}
Aggregations