use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testUnmarshallCreditName.
@Test
public void testUnmarshallCreditName() throws SAXException, URISyntaxException {
CreditName creditName = (CreditName) unmarshallFromPath("/record_2.0_rc2/samples/credit-name-2.0_rc2.xml", CreditName.class, "/record_2.0_rc2/personal-details-2.0_rc2.xsd");
assertNotNull(creditName);
assertEquals("credit-name", creditName.getContent());
assertEquals(Visibility.PUBLIC.value(), creditName.getVisibility().value());
}
use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method testMarshallCreditName.
@Test
public void testMarshallCreditName() throws JAXBException, SAXException, URISyntaxException {
CreditName object = (CreditName) unmarshallFromPath("/record_2.0_rc2/samples/credit-name-2.0_rc2.xml", CreditName.class);
marshall(object, "/record_2.0_rc2/personal-details-2.0_rc2.xsd");
}
use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.
the class MongoMessageProcessorTest method testInsertAndUpsert.
@Test
public void testInsertAndUpsert() throws LockedRecordException, DeprecatedRecordException {
Record record = new Record();
record.setOrcidIdentifier(new OrcidIdentifier("http://orcid.org/" + this.orcid));
ActivitiesSummary sum = new ActivitiesSummary();
Works works = new Works();
WorkGroup group = new WorkGroup();
WorkSummary work = new WorkSummary();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("blah"));
work.setTitle(title);
group.getWorkSummary().add(work);
works.getWorkGroup().add(group);
sum.setWorks(works);
record.setActivitiesSummary(sum);
when(mock_orcid20ApiClient.fetchPublicRecord(Matchers.any())).thenReturn(record);
LastModifiedMessage m = new LastModifiedMessage(this.orcid, new Date());
mongo.accept(m);
// test record inserted (has work, no name)
Document d = new Document();
d.put("_id", this.orcid);
assertEquals(col.count(d), 1);
FindIterable<Document> it = col.find(d);
Document found = it.first();
assertEquals(found.get("orcid-identifier", Document.class).get("path"), "http://orcid.org/" + this.orcid);
List<Document> groups = (List<Document>) found.get("activities-summary", Document.class).get("works", Document.class).get("group");
List<Document> sums = (List<Document>) groups.get(0).get("work-summary");
assertEquals(sums.get(0).get("title", Document.class).get("title", Document.class).get("value"), "blah");
record.setPerson(new Person());
record.getPerson().setName(new Name());
record.getPerson().getName().setCreditName(new CreditName());
record.getPerson().getName().getCreditName().setContent("name");
;
LastModifiedMessage m2 = new LastModifiedMessage(this.orcid, new Date());
mongo.accept(m2);
it = col.find(d);
found = it.first();
assertEquals(found.get("person", Document.class).get("name", Document.class).get("credit-name", Document.class).get("value"), "name");
}
use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.
the class ProfileEntityManagerImpl method clearRecord.
/**
* Clears all record info but the email addresses, that stay unmodified
*/
private void clearRecord(String orcid, Boolean disableTokens) {
// Remove works
workManager.removeAllWorks(orcid);
// Remove funding
fundingManager.removeAllFunding(orcid);
// Remove affiliations
affiliationsManager.removeAllAffiliations(orcid);
// Remove peer reviews
peerReviewManager.removeAllPeerReviews(orcid);
// Remove addresses
addressManager.removeAllAddress(orcid);
// Remove external identifiers
externalIdentifierManager.removeAllExternalIdentifiers(orcid);
// Remove researcher urls
researcherUrlManager.removeAllResearcherUrls(orcid);
// Remove other names
otherNamesManager.removeAllOtherNames(orcid);
// Remove keywords
profileKeywordManager.removeAllKeywords(orcid);
// Remove biography
if (biographyManager.exists(orcid)) {
Biography deprecatedBio = new Biography();
deprecatedBio.setContent(null);
deprecatedBio.setVisibility(Visibility.PRIVATE);
biographyManager.updateBiography(orcid, deprecatedBio);
}
// Set the deactivated names
if (recordNameManager.exists(orcid)) {
Name name = new Name();
name.setCreditName(new CreditName());
name.setGivenNames(new GivenNames("Given Names Deactivated"));
name.setFamilyName(new FamilyName("Family Name Deactivated"));
name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
name.setPath(orcid);
recordNameManager.updateRecordName(orcid, name);
}
//
userConnectionDao.deleteByOrcid(orcid);
if (disableTokens) {
// Disable any token that belongs to this record
orcidOauth2TokenDetailService.disableAccessTokenByUserOrcid(orcid, RevokeReason.RECORD_DEACTIVATED);
}
// Change default visibility to private
profileDao.updateDefaultVisibility(orcid, Visibility.PRIVATE);
}
Aggregations