use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class VisibilityFilterImpl method getMessageIdForLog.
private String getMessageIdForLog(OrcidMessage messageToBeFiltered) {
String messageIdForLog = "unknown";
OrcidSearchResults orcidSearchResults = messageToBeFiltered.getOrcidSearchResults();
OrcidProfile orcidProfile = messageToBeFiltered.getOrcidProfile();
if (orcidSearchResults != null) {
messageIdForLog = "orcid-search-results";
} else if (orcidProfile != null) {
OrcidIdentifier orcidIdentifier = orcidProfile.getOrcidIdentifier();
if (orcidIdentifier != null) {
messageIdForLog = orcidIdentifier.getPath();
}
Orcid orcid = orcidProfile.getOrcid();
if (orcid != null) {
messageIdForLog = orcid.getValue();
}
}
return messageIdForLog;
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class SetUpClientsAndUsers method createUser.
private void createUser(Map<String, String> params) throws Exception {
// Create it
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
if (params.get(MEMBER_TYPE) != null) {
orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
}
orcidProfile.setPassword(params.get(PASSWORD));
OrcidInternal internal = new OrcidInternal();
Preferences preferences = new Preferences();
ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
visibilityDefaults.setValue(Visibility.PUBLIC);
preferences.setActivitiesVisibilityDefault(visibilityDefaults);
internal.setPreferences(preferences);
orcidProfile.setOrcidInternal(internal);
Email email = new Email(params.get(EMAIL));
email.setCurrent(true);
email.setPrimary(true);
email.setVerified(true);
email.setVisibility(Visibility.PUBLIC);
List<Email> emails = new ArrayList<Email>();
emails.add(email);
ContactDetails contactDetails = new ContactDetails();
contactDetails.setEmail(emails);
org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
personalDetails.setCreditName(creditName);
personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
OrcidBio bio = new OrcidBio();
bio.setContactDetails(contactDetails);
bio.setPersonalDetails(personalDetails);
bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
orcidProfile.setOrcidBio(bio);
OrcidHistory history = new OrcidHistory();
history.setClaimed(new Claimed(true));
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
history.setCreationMethod(CreationMethod.DIRECT);
orcidProfile.setOrcidHistory(history);
orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
if (params.containsKey(LOCKED)) {
orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
}
if (params.containsKey(DEVELOPER_TOOLS)) {
profileEntityManager.enableDeveloperTools(orcidProfile);
}
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class RDFWriterTest method fakeBio.
private OrcidMessage fakeBio() throws DatatypeConfigurationException {
OrcidMessage orcidMessage = new OrcidMessage();
OrcidProfile orcidProfile1 = new OrcidProfile();
OrcidIdentifier orcidIdentifier = new OrcidIdentifier();
orcidProfile1.setOrcidIdentifier(orcidIdentifier);
orcidIdentifier.setUri("http://orcid.example.com/000-1337");
orcidIdentifier.setPath("000-1337");
OrcidBio bio = new OrcidBio();
orcidProfile1.setOrcidBio(bio);
OrcidHistory history = new OrcidHistory();
XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
history.setCreationMethod(CreationMethod.WEBSITE);
history.setLastModifiedDate(new LastModifiedDate(value));
orcidProfile1.setOrcidHistory(history);
PersonalDetails personal = new PersonalDetails();
bio.setPersonalDetails(personal);
personal.setFamilyName(new FamilyName("Doe"));
personal.setCreditName(new CreditName("John F Doe"));
personal.setGivenNames(new GivenNames("John"));
personal.setOtherNames(new OtherNames());
personal.getOtherNames().addOtherName("Johnny", Visibility.PUBLIC);
personal.getOtherNames().addOtherName("Mr Doe", Visibility.PUBLIC);
ResearcherUrls urls = new ResearcherUrls();
bio.setResearcherUrls(urls);
ResearcherUrl anonymous = new ResearcherUrl(new Url("http://example.com/anon"), Visibility.PUBLIC);
urls.getResearcherUrl().add(anonymous);
// "home page" - with strange casing
ResearcherUrl homePage = new ResearcherUrl(new Url("http://example.com/myPage"), new UrlName("homePage"), Visibility.PUBLIC);
urls.getResearcherUrl().add(homePage);
ResearcherUrl foaf = new ResearcherUrl(new Url("http://example.com/foaf#me"), new UrlName("FOAF"), Visibility.PUBLIC);
urls.getResearcherUrl().add(foaf);
ResearcherUrl webId = new ResearcherUrl(new Url("http://example.com/webId"), new UrlName("webID"), Visibility.PUBLIC);
urls.getResearcherUrl().add(webId);
ResearcherUrl other = new ResearcherUrl(new Url("http://example.com/other"), new UrlName("other"), Visibility.PUBLIC);
urls.getResearcherUrl().add(other);
bio.setContactDetails(new ContactDetails());
bio.getContactDetails().setEmail(Arrays.asList(new Email("john@example.org"), new Email("doe@example.com")));
bio.getContactDetails().setAddress(new Address());
bio.getContactDetails().getAddress().setCountry(new Country(Iso3166Country.GB));
orcidMessage.setOrcidProfile(orcidProfile1);
return orcidMessage;
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testDefaultPrivacyOnBio.
@Test
public void testDefaultPrivacyOnBio() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4499", ScopePathType.ORCID_BIO_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4499"));
orcidMessage.setOrcidProfile(orcidProfile);
OrcidBio orcidBio = new OrcidBio();
orcidProfile.setOrcidBio(orcidBio);
PersonalDetails personalDetails = new PersonalDetails();
orcidBio.setPersonalDetails(personalDetails);
GivenNames givenNames = new GivenNames("Test given names");
personalDetails.setGivenNames(givenNames);
CreditName creditName = new CreditName("Credit Name");
personalDetails.setCreditName(creditName);
ExternalIdentifier id = new ExternalIdentifier();
id.setExternalIdCommonName(new ExternalIdCommonName("cn1"));
id.setExternalIdReference(new ExternalIdReference("value1"));
orcidBio.setExternalIdentifiers(new ExternalIdentifiers());
orcidBio.getExternalIdentifiers().getExternalIdentifier().add(id);
personalDetails.setOtherNames(new OtherNames());
personalDetails.getOtherNames().addOtherName("on1", null);
orcidBio.setKeywords(new Keywords());
orcidBio.getKeywords().getKeyword().add(new Keyword("kw1", null));
orcidBio.setResearcherUrls(new ResearcherUrls());
orcidBio.getResearcherUrls().getResearcherUrl().add(new ResearcherUrl(new Url("http://rurl2.com"), null));
t2OrcidApiServiceDelegator.updateBioDetails(mockedUriInfo, "4444-4444-4444-4499", orcidMessage);
OrcidProfile p = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4499");
assertEquals("cn1", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
assertEquals("on1", p.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
assertEquals("kw1", p.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getKeywords().getVisibility());
assertEquals(new Url("http://rurl2.com"), p.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getResearcherUrls().getVisibility());
//now test what happens if we add a new one.
}
use of org.orcid.jaxb.model.message.OrcidIdentifier in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method addAffiliationTest.
@Test
public void addAffiliationTest() {
setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
Affiliation affiliation = new Affiliation();
affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
affiliation.setDepartmentName("Dep Name");
affiliation.setRoleTitle("Role Title");
affiliation.setType(AffiliationType.EDUCATION);
Organization organization = new Organization();
organization.setName("My Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.US);
organization.setAddress(add);
affiliation.setOrganization(organization);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
Response response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4441", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
}
Aggregations