use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method buildMessageWithAffiliation.
private OrcidMessage buildMessageWithAffiliation(AffiliationType type, String dept, String role, String orcid) {
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier(orcid));
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(dept);
affiliation.setRoleTitle(role);
affiliation.setType(type);
Organization organization = new Organization();
organization.setName("My Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.US);
organization.setAddress(add);
DisambiguatedOrganization dorg = new DisambiguatedOrganization();
dorg.setDisambiguatedOrganizationIdentifier("disambiguated org ID");
dorg.setDisambiguationSource("THESOURCE");
organization.setDisambiguatedOrganization(dorg);
affiliation.setOrganization(organization);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
return orcidMessage;
}
use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.
the class Api12Helper method addFunding.
protected static void addFunding(String userOrcid, String token, String title, 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);
FundingList fundings = new FundingList();
Funding funding = new Funding();
funding.setVisibility(Visibility.LIMITED);
FundingTitle fundingTitle = new FundingTitle();
fundingTitle.setTitle(new Title(title));
funding.setTitle(fundingTitle);
funding.setType(FundingType.SALARY_AWARD);
Amount amount = new Amount();
amount.setCurrencyCode("CRC");
amount.setContent("1,250,000");
funding.setAmount(amount);
funding.setStartDate(new FuzzyDate(2010, 1, 1));
funding.setEndDate(new FuzzyDate(2013, 1, 1));
funding.setDescription("My Grant description");
funding.setUrl(new Url("http://url.com"));
Organization org = new Organization();
org.setName("Orcid Integration Test Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.CR);
org.setAddress(add);
funding.setOrganization(org);
FundingExternalIdentifier extIdentifier = new FundingExternalIdentifier();
extIdentifier.setType(FundingExternalIdentifierType.fromValue("grant_number"));
extIdentifier.setUrl(new Url("http://url.com"));
extIdentifier.setValue("My value");
FundingExternalIdentifiers extIdentifiers = new FundingExternalIdentifiers();
extIdentifiers.getFundingExternalIdentifier().add(extIdentifier);
funding.setFundingExternalIdentifiers(extIdentifiers);
FundingContributors contributors = new FundingContributors();
FundingContributor contributor = new FundingContributor();
contributor.setCreditName(new CreditName("My Credit Name"));
contributor.setContributorEmail(new ContributorEmail("my.email@orcid-integration-test.com"));
FundingContributorAttributes attributes = new FundingContributorAttributes();
attributes.setContributorRole(FundingContributorRole.LEAD);
contributor.setContributorAttributes(attributes);
contributors.getContributor().add(contributor);
funding.setFundingContributors(contributors);
fundings.getFundings().add(funding);
orcidMessage.getOrcidProfile().getOrcidActivities().setFundings(fundings);
ClientResponse clientResponse = oauthT2Client.addFundingXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getOrgAffiliationRelationEntity.
private OrgAffiliationRelationEntity getOrgAffiliationRelationEntity(Affiliation affiliation, OrgAffiliationRelationEntity exisitingOrgAffiliationEntity) {
if (affiliation != null) {
// Get the org
OrgEntity orgEntity = getOrgEntity(affiliation);
OrgAffiliationRelationEntity orgRelationEntity = null;
if (exisitingOrgAffiliationEntity == null) {
String putCode = affiliation.getPutCode();
if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
throw new IllegalArgumentException("Invalid put-code was supplied for an affiliation: " + putCode);
}
orgRelationEntity = new OrgAffiliationRelationEntity();
} else {
orgRelationEntity = exisitingOrgAffiliationEntity;
orgRelationEntity.clean();
}
FuzzyDate startDate = affiliation.getStartDate();
FuzzyDate endDate = affiliation.getEndDate();
if (affiliation.getType() != null) {
orgRelationEntity.setAffiliationType(AffiliationType.fromValue(affiliation.getType().value()));
}
if (affiliation.getVisibility() != null) {
orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(affiliation.getVisibility().value()));
} else {
orgRelationEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
//Set source
setSource(affiliation.getSource(), orgRelationEntity);
orgRelationEntity.setDepartment(affiliation.getDepartmentName());
orgRelationEntity.setEndDate(endDate != null ? new EndDateEntity(endDate) : null);
orgRelationEntity.setOrg(orgEntity);
orgRelationEntity.setTitle(affiliation.getRoleTitle());
orgRelationEntity.setStartDate(startDate != null ? new StartDateEntity(startDate) : null);
if (affiliation.getCreatedDate() != null && affiliation.getCreatedDate().getValue() != null)
orgRelationEntity.setDateCreated(affiliation.getCreatedDate().getValue().toGregorianCalendar().getTime());
if (affiliation.getLastModifiedDate() != null && affiliation.getLastModifiedDate().getValue() != null)
orgRelationEntity.setLastModified(affiliation.getLastModifiedDate().getValue().toGregorianCalendar().getTime());
return orgRelationEntity;
}
return null;
}
use of org.orcid.jaxb.model.message.FuzzyDate 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());
}
use of org.orcid.jaxb.model.message.FuzzyDate in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method getAffiliation.
public Affiliation getAffiliation() throws DatatypeConfigurationException {
GregorianCalendar cal = new GregorianCalendar();
XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
Affiliation affiliation = new Affiliation();
affiliation.setStartDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
affiliation.setEndDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
affiliation.setType(AffiliationType.EDUCATION);
affiliation.setRoleTitle("A Role");
affiliation.setDepartmentName("A Department");
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName("Past Institution");
OrganizationAddress address = new OrganizationAddress();
address.setCountry(Iso3166Country.GB);
organization.setAddress(address);
return affiliation;
}
Aggregations