use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOff.
@Test
public void testValidExtIdsWorksFine_flagOff() {
ExternalIDs extIds = new ExternalIDs();
ExternalID id1 = new ExternalID();
id1.setRelationship(null);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
ExternalID id2 = new ExternalID();
id2.setRelationship(null);
id2.setType("doi");
id2.setValue("value1");
id2.setUrl(new Url("http://value1.com"));
ExternalID id3 = new ExternalID();
id3.setRelationship(null);
id3.setType("doi");
id3.setValue("value1");
id3.setUrl(new Url("http://value1.com"));
extIds.getExternalIdentifier().add(id1);
extIds.getExternalIdentifier().add(id2);
extIds.getExternalIdentifier().add(id3);
validator.validateWorkOrPeerReview(extIds);
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOn.
@Test
public void testValidExtIdsWorksFine_flagOn() {
validator.setRequireRelationshipOnExternalIdentifier(true);
ExternalIDs extIds = new ExternalIDs();
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("doi");
id2.setValue("value1");
id2.setUrl(new Url("http://value1.com"));
ExternalID id3 = new ExternalID();
id3.setRelationship(Relationship.SELF);
id3.setType("doi");
id3.setValue("value1");
id3.setUrl(new Url("http://value1.com"));
extIds.getExternalIdentifier().add(id1);
extIds.getExternalIdentifier().add(id2);
extIds.getExternalIdentifier().add(id3);
validator.validateWorkOrPeerReview(extIds);
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class ExternalIDValidatorTest method testValidateWorkOrPeerReview.
@Test
public void testValidateWorkOrPeerReview() {
// call for ExternalID and ExternalIDs
// ID valid
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("value1");
id1.setUrl(new Url("http://value1.com"));
validator.validateWorkOrPeerReview(id1);
// ID bad type
try {
id1.setType("invalid");
validator.validateWorkOrPeerReview(id1);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
// id null
try {
id1.setType(null);
validator.validateWorkOrPeerReview(id1);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
ExternalIDs ids = new ExternalIDs();
ids.getExternalIdentifier().add(id1);
// IDS one invalid
id1.setType("invalid");
try {
validator.validateWorkOrPeerReview(ids);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
// IDS one valid (lowercase)
id1.setType("doi");
validator.validateWorkOrPeerReview(ids);
// IDS two valid
ExternalID id2 = new ExternalID();
id2.setRelationship(Relationship.SELF);
id2.setType("source-work-id");
id2.setValue("value2");
id2.setUrl(new Url("http://value1.com"));
ids.getExternalIdentifier().add(id2);
validator.validateWorkOrPeerReview(ids);
// IDS one invalid, one valid
id2.setType("not-a-type");
try {
validator.validateWorkOrPeerReview(ids);
fail("no exception thrown for invalid type");
} catch (Exception e) {
if (!(e instanceof ActivityIdentifierValidationException))
throw e;
}
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class PersonValidatorTest method getPersonExternalIdentifier.
private PersonExternalIdentifier getPersonExternalIdentifier() {
PersonExternalIdentifier extId = new PersonExternalIdentifier();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://test.orcid.org"));
extId.setValue("extId1");
extId.setVisibility(Visibility.PUBLIC);
return extId;
}
use of org.orcid.jaxb.model.v3.dev1.common.Url in project ORCID-Source by ORCID.
the class BibtexManagerImpl method workToBibtex.
public String workToBibtex(Work work, String creditName) {
StringBuffer out = new StringBuffer();
switch(work.getWorkType()) {
case JOURNAL_ARTICLE:
out.append("@article{");
break;
case BOOK:
case BOOK_CHAPTER:
out.append("@book{");
break;
case CONFERENCE_PAPER:
case CONFERENCE_ABSTRACT:
case CONFERENCE_POSTER:
out.append("@conference{");
break;
default:
out.append("@misc{");
break;
}
// id
out.append(escapeStringForBibtex(creditName).replace(' ', '_') + work.getPutCode());
// title
out.append(",\ntitle={" + escapeStringForBibtex((work.getWorkTitle() != null) ? work.getWorkTitle().getTitle().getContent() : "No Title") + "}");
// journal title
if (work.getJournalTitle() != null) {
out.append(",\njournal={" + escapeStringForBibtex(work.getJournalTitle().getContent()) + "}");
}
// name
List<String> names = new ArrayList<String>();
names.add(creditName);
if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
for (Contributor c : work.getWorkContributors().getContributor()) {
if (c.getCreditName() != null && c.getCreditName().getContent() != null) {
names.add(c.getCreditName().getContent());
}
}
}
out.append(",\nauthor={" + escapeStringForBibtex(Joiner.on(" and ").skipNulls().join(names)) + "}");
// ids
String doi = extractID(work, WorkExternalIdentifierType.DOI);
String url = extractID(work, WorkExternalIdentifierType.URI);
if (doi != null) {
out.append(",\ndoi={" + escapeStringForBibtex(doi) + "}");
}
if (url != null) {
out.append(",\nurl={" + escapeStringForBibtex(url) + "}");
} else if (doi != null) {
out.append(",\nurl={" + escapeStringForBibtex("http://doi.org/" + doi) + "}");
} else {
url = extractID(work, WorkExternalIdentifierType.HANDLE);
if (url != null) {
out.append(",\nurl={" + escapeStringForBibtex(url) + "}");
}
}
String isbn = extractID(work, WorkExternalIdentifierType.ISBN);
if (isbn != null)
out.append(",\nisbn={" + escapeStringForBibtex(isbn) + "}");
String issn = extractID(work, WorkExternalIdentifierType.ISSN);
if (issn != null)
out.append(",\nissn={" + escapeStringForBibtex(issn) + "}");
// year
if (work.getPublicationDate() != null) {
int year = 0;
try {
year = Integer.parseInt(work.getPublicationDate().getYear().getValue());
} catch (Exception e) {
}
if (year > 0) {
out.append(",\nyear={" + year + "}");
}
}
out.append("\n}");
return out.toString();
}
Aggregations