Search in sources :

Example 16 with Item

use of org.powerbot.script.rt4.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);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID)

Example 17 with Item

use of org.powerbot.script.rt4.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;
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Example 18 with Item

use of org.powerbot.script.rt4.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);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Example 19 with Item

use of org.powerbot.script.rt4.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);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item)

Example 20 with Item

use of org.powerbot.script.rt4.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");
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Aggregations

Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 Test (org.junit.Test)5 Items (org.orcid.jaxb.model.notification.permission_v2.Items)5 Url (org.orcid.jaxb.model.common_v2.Url)3 Font (java.awt.Font)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Source (org.orcid.jaxb.model.common_v2.Source)2 SourceClientId (org.orcid.jaxb.model.common_v2.SourceClientId)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 NotificationAmended (org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)2 AuthorizationUrl (org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl)2 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)2 NotificationAddItemsEntity (org.orcid.persistence.jpa.entities.NotificationAddItemsEntity)2 NotificationAmendedEntity (org.orcid.persistence.jpa.entities.NotificationAmendedEntity)2 NotificationEntity (org.orcid.persistence.jpa.entities.NotificationEntity)2 NotificationWorkEntity (org.orcid.persistence.jpa.entities.NotificationWorkEntity)2 Component (org.powerbot.script.rt6.Component)2 Item (org.powerbot.script.rt6.Item)2