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);
}
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);
}
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();
}
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");
}
Aggregations