Search in sources :

Example 11 with Item

use of org.orcid.jaxb.model.v3.dev1.notification.permission.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.v3.dev1.notification.permission.Item)

Example 12 with Item

use of org.orcid.jaxb.model.v3.dev1.notification.permission.Item in project ORCID-Source by ORCID.

the class WorkManagerImpl method createItemList.

private List<Item> createItemList(WorkEntity workEntity) {
    Item item = new Item();
    item.setItemName(workEntity.getTitle());
    item.setItemType(ItemType.WORK);
    item.setPutCode(String.valueOf(workEntity.getId()));
    return Arrays.asList(item);
}
Also used : Item(org.orcid.jaxb.model.v3.dev1.notification.permission.Item)

Example 13 with Item

use of org.orcid.jaxb.model.v3.dev1.notification.permission.Item in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewWorkCitation.

@Override
public Response viewWorkCitation(String orcid, Long putCode) {
    Work w = (Work) this.viewWork(orcid, putCode).getEntity();
    ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
    String creditName = null;
    RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
    if (recordNameEntity != null) {
        if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
            creditName = recordNameEntity.getCreditName();
            if (StringUtils.isBlank(creditName)) {
                creditName = recordNameEntity.getGivenNames();
                String familyName = recordNameEntity.getFamilyName();
                if (StringUtils.isNotBlank(familyName)) {
                    creditName += " " + familyName;
                }
            }
        }
    }
    V3WorkToCiteprocTranslator tran = new V3WorkToCiteprocTranslator();
    CSLItemData item = tran.toCiteproc(w, creditName, true);
    return Response.ok(item).build();
}
Also used : CSLItemData(de.undercouch.citeproc.csl.CSLItemData) Work(org.orcid.jaxb.model.v3.dev1.record.Work) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) V3WorkToCiteprocTranslator(org.orcid.api.common.writer.citeproc.V3WorkToCiteprocTranslator) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 14 with Item

use of org.orcid.jaxb.model.v3.dev1.notification.permission.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.v3.dev1.notification.permission.Item) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Example 15 with Item

use of org.orcid.jaxb.model.v3.dev1.notification.permission.Item in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidateNotificationItems.

@Test
public void testValidateNotificationItems() {
    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(Relationship.SELF);
    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);
    // IDS one valid, one invalid
    id2.setType("blah");
    try {
        validator.validateNotificationItems(items);
        fail("no exception thrown for invalid type");
    } catch (Exception e) {
        if (!(e instanceof ActivityIdentifierValidationException))
            throw e;
    }
    // IDS one valid, one VALID due to null (at least we have to do this if we want other tests to pass!)
    id2.setType(null);
    validator.validateNotificationItems(items);
}
Also used : Item(org.orcid.jaxb.model.v3.dev1.notification.permission.Item) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Items(org.orcid.jaxb.model.v3.dev1.notification.permission.Items) Url(org.orcid.jaxb.model.v3.dev1.common.Url) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) Test(org.junit.Test)

Aggregations

Item (org.orcid.jaxb.model.v3.dev1.notification.permission.Item)11 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)8 Test (org.junit.Test)7 Items (org.orcid.jaxb.model.v3.dev1.notification.permission.Items)6 Url (org.orcid.jaxb.model.v3.dev1.common.Url)5 NotificationAmended (org.orcid.jaxb.model.v3.dev1.notification.amended.NotificationAmended)3 Work (org.orcid.jaxb.model.v3.dev1.record.Work)3 BaseTest (org.orcid.core.BaseTest)2 Source (org.orcid.jaxb.model.v3.dev1.common.Source)2 SourceClientId (org.orcid.jaxb.model.v3.dev1.common.SourceClientId)2 Title (org.orcid.jaxb.model.v3.dev1.common.Title)2 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)2 AuthorizationUrl (org.orcid.jaxb.model.v3.dev1.notification.permission.AuthorizationUrl)2 NotificationPermission (org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermission)2 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)2 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)2 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)2 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)2 NotificationAddItemsEntity (org.orcid.persistence.jpa.entities.NotificationAddItemsEntity)2 NotificationAmendedEntity (org.orcid.persistence.jpa.entities.NotificationAmendedEntity)2