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