Search in sources :

Example 11 with Relationship

use of org.orcid.jaxb.model.v3.dev1.record.Relationship 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 12 with Relationship

use of org.orcid.jaxb.model.v3.dev1.record.Relationship in project ORCID-Source by ORCID.

the class ExternalIDValidator method validateWorkOrPeerReview.

public void validateWorkOrPeerReview(ExternalIDs ids) {
    if (// yeuch
    ids == null)
        return;
    List<String> errors = Lists.newArrayList();
    for (ExternalID id : ids.getExternalIdentifier()) {
        if (id.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(id.getType())) {
            errors.add(id.getType());
        }
        if (PojoUtil.isEmpty(id.getValue())) {
            errors.add("value");
        }
        if (requireRelationshipOnExternalIdentifier) {
            if (id.getRelationship() == null) {
                errors.add("relationship");
            }
        }
    }
    checkAndThrow(errors);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Example 13 with Relationship

use of org.orcid.jaxb.model.v3.dev1.record.Relationship in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getExternalIdentifierMapperFacade.

public MapperFacade getExternalIdentifierMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<PersonExternalIdentifier, ExternalIdentifierEntity> externalIdentifierClassMap = mapperFactory.classMap(PersonExternalIdentifier.class, ExternalIdentifierEntity.class);
    addV3DateFields(externalIdentifierClassMap);
    externalIdentifierClassMap.field("putCode", "id");
    externalIdentifierClassMap.field("type", "externalIdCommonName");
    externalIdentifierClassMap.field("value", "externalIdReference");
    externalIdentifierClassMap.field("url.value", "externalIdUrl");
    externalIdentifierClassMap.fieldBToA("displayIndex", "displayIndex");
    externalIdentifierClassMap.byDefault();
    registerSourceConverters(mapperFactory, externalIdentifierClassMap);
    // TODO: add relationship to database schema for people.
    externalIdentifierClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)

Example 14 with Relationship

use of org.orcid.jaxb.model.v3.dev1.record.Relationship in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testEmptyRelationshipOnSingleExternalId_flagOn.

@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnSingleExternalId_flagOn() {
    validator.setRequireRelationshipOnExternalIdentifier(true);
    ExternalID id1 = new ExternalID();
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    validator.validateWorkOrPeerReview(id1);
    // empty relationship
    id1.setRelationship(null);
    validator.validateWorkOrPeerReview(id1);
    fail("no exception thrown for invalid type");
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)6 Url (org.orcid.jaxb.model.v3.dev1.common.Url)2 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)2 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)2 Work (org.orcid.jaxb.model.v3.dev1.record.Work)2 MapperFactory (ma.glasnost.orika.MapperFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 Item (org.orcid.jaxb.model.v3.dev1.notification.permission.Item)1 Education (org.orcid.jaxb.model.v3.dev1.record.Education)1 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)1 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)1 ExternalIdentifierEntity (org.orcid.persistence.jpa.entities.ExternalIdentifierEntity)1 PeerReviewEntity (org.orcid.persistence.jpa.entities.PeerReviewEntity)1 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)1 PublicationDateEntity (org.orcid.persistence.jpa.entities.PublicationDateEntity)1 WorkEntity (org.orcid.persistence.jpa.entities.WorkEntity)1