use of org.orcid.jaxb.model.message.Affiliation in project ORCID-Source by ORCID.
the class OrcidMessageUtil method setSourceName.
public void setSourceName(OrcidProfile orcidProfile) {
if (orcidProfile != null) {
if (orcidProfile.getOrcidActivities() != null) {
OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
if (orcidActivities.getAffiliations() != null) {
Affiliations affs = orcidActivities.getAffiliations();
List<Affiliation> affList = affs.getAffiliation();
if (affList != null) {
for (Affiliation aff : affList) {
setSourceName(aff);
}
}
}
if (orcidActivities.getFundings() != null) {
FundingList fundingList = orcidActivities.getFundings();
List<Funding> fundings = fundingList.getFundings();
if (fundings != null) {
for (Funding funding : fundings) {
setSourceName(funding);
}
}
}
if (orcidActivities.getOrcidWorks() != null) {
OrcidWorks orcidWorks = orcidActivities.getOrcidWorks();
List<OrcidWork> works = orcidWorks.getOrcidWork();
if (works != null) {
for (OrcidWork work : works) {
setSourceName(work);
}
}
}
}
if (orcidProfile.getOrcidBio() != null) {
OrcidBio orcidBio = orcidProfile.getOrcidBio();
if (orcidBio.getContactDetails() != null) {
Address address = orcidBio.getContactDetails().getAddress();
if (address != null) {
setSourceName(address);
}
}
if (orcidBio.getExternalIdentifiers() != null) {
ExternalIdentifiers extIds = orcidBio.getExternalIdentifiers();
List<ExternalIdentifier> extIdsList = extIds.getExternalIdentifier();
if (extIdsList != null) {
for (ExternalIdentifier extId : extIdsList) {
setSourceName(extId);
}
}
}
if (orcidBio.getKeywords() != null) {
Keywords keywords = orcidBio.getKeywords();
List<Keyword> keywordList = keywords.getKeyword();
if (keywordList != null) {
for (Keyword keyword : keywordList) {
setSourceName(keyword);
}
}
}
if (orcidBio.getPersonalDetails() != null) {
OtherNames otherNames = orcidBio.getPersonalDetails().getOtherNames();
if (otherNames != null) {
List<OtherName> otherNameList = otherNames.getOtherName();
if (otherNameList != null) {
for (OtherName otherName : otherNameList) {
setSourceName(otherName);
}
}
}
}
if (orcidBio.getResearcherUrls() != null) {
ResearcherUrls rUrls = orcidBio.getResearcherUrls();
List<ResearcherUrl> rUrlList = rUrls.getResearcherUrl();
if (rUrlList != null) {
for (ResearcherUrl rUrl : rUrlList) {
setSourceName(rUrl);
}
}
}
}
}
}
use of org.orcid.jaxb.model.message.Affiliation in project ORCID-Source by ORCID.
the class Api12Helper method addAffiliation.
protected static void addAffiliation(String userOrcid, String token, String orgName, T2OAuthAPIService<ClientResponse> oauthT2Client) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation = new Affiliation();
affiliation.setVisibility(Visibility.LIMITED);
affiliations.getAffiliation().add(affiliation);
affiliation.setType(AffiliationType.EDUCATION);
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName(orgName);
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
organizationAddress.setCity("Edinburgh");
organizationAddress.setCountry(Iso3166Country.GB);
ClientResponse clientResponse = oauthT2Client.addAffiliationsXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
use of org.orcid.jaxb.model.message.Affiliation in project ORCID-Source by ORCID.
the class Api12MembersTest method viewOwnPrivateAffiliationsTest.
@Test
public void viewOwnPrivateAffiliationsTest() throws InterruptedException, JSONException {
changeDefaultUserVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
String client1Id = getClient1ClientId();
String client1RedirectUri = getClient1RedirectUri();
String client1Secret = getClient1ClientSecret();
String client2Id = getClient2ClientId();
String client2RedirectUri = getClient2RedirectUri();
String client2Secret = getClient2ClientSecret();
String userId = getUser1OrcidId();
String password = getUser1Password();
String client1AccessToken = getAccessToken(userId, password, Arrays.asList("/activities/read-limited", "/activities/update"), client1Id, client1Secret, client1RedirectUri, true);
String client2AccessToken = getAccessToken(userId, password, Arrays.asList("/activities/read-limited", "/activities/update"), client2Id, client2Secret, client2RedirectUri, true);
String orgName1 = "Client 1 - Education " + System.currentTimeMillis();
String orgName2 = "Client 2 - Education " + System.currentTimeMillis();
Api12Helper.addAffiliation(userId, client1AccessToken, orgName1, t2OAuthClient_1_2);
Api12Helper.addAffiliation(userId, client2AccessToken, orgName2, t2OAuthClient_1_2);
Long putCode1 = 0L;
Long putCode2 = 0L;
// Fetch with client 1 and verify it can only see his private affiliations
ClientResponse client1Response = t2OAuthClient_1_2.viewAffiliationDetailsXml(userId, client1AccessToken);
assertNotNull(client1Response);
assertEquals(200, client1Response.getStatus());
OrcidMessage orcidMessageWithNewFunding = client1Response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessageWithNewFunding);
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation());
boolean found = false;
for (Affiliation affiliation : orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation()) {
if (orgName2.equals(affiliation.getOrganization().getName())) {
fail("I found affiliation for client # 2, which is wrong since it is private");
}
if (orgName1.equals(affiliation.getOrganization().getName())) {
assertEquals(Visibility.PRIVATE, affiliation.getVisibility());
putCode1 = Long.valueOf(affiliation.getPutCode());
found = true;
}
}
assertTrue(found);
// Fetch with client 2 and verify it can only see his private affiliations
ClientResponse client2Response = t2OAuthClient_1_2.viewAffiliationDetailsXml(userId, client2AccessToken);
assertNotNull(client2Response);
assertEquals(200, client2Response.getStatus());
orcidMessageWithNewFunding = client2Response.getEntity(OrcidMessage.class);
assertNotNull(orcidMessageWithNewFunding);
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations());
assertNotNull(orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation());
found = false;
for (Affiliation affiliation : orcidMessageWithNewFunding.getOrcidProfile().getOrcidActivities().getAffiliations().getAffiliation()) {
if (orgName1.equals(affiliation.getOrganization().getName())) {
fail("I found funding for client # 1, which is wrong since it is private");
}
if (orgName2.equals(affiliation.getOrganization().getName())) {
assertEquals(Visibility.PRIVATE, affiliation.getVisibility());
putCode2 = Long.valueOf(affiliation.getPutCode());
found = true;
}
}
assertTrue(found);
// Delete both affiliations before finishing
ClientResponse deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), putCode1, client1AccessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), putCode2, client2AccessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
use of org.orcid.jaxb.model.message.Affiliation in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method checkAffiliations.
private void checkAffiliations(List<Affiliation> affiliations) {
assertNotNull(affiliations);
assertEquals(3, affiliations.size());
Affiliation affiliation = affiliations.get(2);
assertEquals(Visibility.LIMITED, affiliation.getVisibility());
assertEquals("An institution", affiliation.getOrganization().getName());
assertEquals("A Department", affiliation.getDepartmentName());
assertEquals("2010-07-02", affiliation.getStartDate().toString());
assertEquals("2011-07-02", affiliation.getEndDate().toString());
assertEquals("Primary Researcher", affiliation.getRoleTitle());
DisambiguatedOrganization disambiguatedAffiliation = affiliation.getOrganization().getDisambiguatedOrganization();
assertNotNull(disambiguatedAffiliation);
assertEquals("abc456", disambiguatedAffiliation.getDisambiguatedOrganizationIdentifier());
assertEquals("WDB", disambiguatedAffiliation.getDisambiguationSource());
checkAddress(affiliation.getOrganization().getAddress());
}
use of org.orcid.jaxb.model.message.Affiliation in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testOrgReuse.
@Test
@Transactional
@Rollback(true)
public void testOrgReuse() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
OrcidActivities orcidActivities = profile1.getOrcidActivities();
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation = new Affiliation();
affiliations.getAffiliation().add(affiliation);
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName("New College");
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
organizationAddress.setCity("Edinburgh");
organizationAddress.setCountry(Iso3166Country.GB);
orcidProfileManager.createOrcidProfile(profile1, false, false);
ProfileEntity profileEntity = profileDao.find(TEST_ORCID);
assertEquals(1, profileEntity.getOrgAffiliationRelations().size());
OrgEntity orgEntity = profileEntity.getOrgAffiliationRelations().iterator().next().getOrg();
assertNotNull(orgEntity);
// Now create another profile with the same affiliation and check that
// the org is reused;
String otherOrcid = "4444-4444-4444-4448";
OrcidProfile profile2 = createBasicProfile();
profile2.setOrcidIdentifier(otherOrcid);
List<Email> emailList2 = profile2.getOrcidBio().getContactDetails().getEmail();
emailList2.clear();
emailList2.add(new Email("another@semantico.com"));
profile2.getOrcidActivities().setAffiliations(affiliations);
orcidProfileManager.createOrcidProfile(profile2, false, false);
ProfileEntity profileEntity2 = profileDao.find(otherOrcid);
assertEquals(1, profileEntity2.getOrgAffiliationRelations().size());
OrgEntity orgEntity2 = profileEntity2.getOrgAffiliationRelations().iterator().next().getOrg();
assertNotNull(orgEntity);
assertEquals(orgEntity.getId(), orgEntity2.getId());
}
Aggregations