use of org.orcid.jaxb.model.message.OrcidHistory in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorImpl method setSponsorFromAuthentication.
public void setSponsorFromAuthentication(OrcidProfile profile) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (profile.getOrcidHistory() == null) {
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setCreationMethod(CreationMethod.API);
profile.setOrcidHistory(orcidHistory);
}
profile.getOrcidHistory().setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
if (OAuth2Authentication.class.isAssignableFrom(authentication.getClass())) {
OAuth2Request authorizationRequest = ((OAuth2Authentication) authentication).getOAuth2Request();
Source sponsor = new Source();
String sponsorId = authorizationRequest.getClientId();
ClientDetailsEntity clientDetails = clientDetailsManager.findByClientId(sponsorId);
if (clientDetails != null) {
sponsor.setSourceName(new SourceName(clientDetails.getClientName()));
if (OrcidStringUtils.isClientId(sponsorId)) {
sponsor.setSourceClientId(new SourceClientId(sponsorId));
} else {
sponsor.setSourceOrcid(new SourceOrcid(sponsorId));
}
}
profile.getOrcidHistory().setSource(sponsor);
}
}
use of org.orcid.jaxb.model.message.OrcidHistory in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorks.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorks() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
String originalPutCode = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode();
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidWorks orcidWorks = new OrcidWorks();
profile2.setOrcidWorks(orcidWorks);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("Another Title"));
workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
OrcidWork work1 = createWork1(workTitle1);
Source source = new Source(TEST_ORCID);
work1.setSource(source);
orcidWorks.getOrcidWork().add(work1);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("New Title"));
workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work2 = createWork2(workTitle2);
orcidWorks.getOrcidWork().add(work2);
// Try to add a duplicate
WorkTitle workTitle3 = new WorkTitle();
workTitle3.setTitle(new Title("New Title"));
workTitle3.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work3 = createWork2(workTitle3);
work3.setVisibility(Visibility.LIMITED);
orcidWorks.getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile2);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
assertEquals(3, works.size());
assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
for (OrcidWork work : works) {
assertEquals(Visibility.PRIVATE, work.getVisibility());
}
assertEquals("Put code of original work should not have changed", originalPutCode, works.get(2).getPutCode());
}
use of org.orcid.jaxb.model.message.OrcidHistory in project ORCID-Source by ORCID.
the class RDFMessageBodyWriter method describeAccount.
private Individual describeAccount(OrcidProfile orcidProfile, OntModel m, Individual person) {
String orcidURI = orcidProfile.getOrcidIdentifier().getUri();
String orcidPublicationsUri = orcidURI + "#workspace-works";
Individual publications = m.createIndividual(orcidPublicationsUri, FOAF.Document);
// list of publications
// (anchor in the HTML rendering - foaf:publications goes to a foaf:Document - not to an
// RDF list of publications - although we should probably also have that)
person.addProperty(FOAF.publications, publications);
String orcidAccountUri = orcidURI + "#orcid-id";
Individual account = m.createIndividual(orcidAccountUri, FOAF.OnlineAccount);
person.addProperty(FOAF.account, account);
Individual webSite = null;
if (baseUri != null) {
webSite = m.createIndividual(baseUri, null);
account.addProperty(FOAF.accountServiceHomepage, webSite);
}
String orcId = orcidProfile.getOrcidIdentifier().getPath();
account.addProperty(FOAF.accountName, orcId);
account.addLabel(orcId, null);
// The current page is the foaf:PersonalProfileDocument - this assumes
// we have done a 303 See Other redirect to the RDF resource, so that it
// differs from the ORCID uri.
// for example:
//
// GET http://orcid.org/0000-0003-4654-1403
// Accept: text/turtle
//
// HTTP/1.1 303 See Other
// Location: https://pub.orcid.org/experimental_rdf_v1/0000-0001-9842-9718
String profileUri;
if (getUriInfo() != null) {
profileUri = getUriInfo().getAbsolutePath().toASCIIString();
} else {
// Some kind of fallback, although the PersonalProfiledocument should be an
// information resource without #anchor
profileUri = orcidURI + "#personalProfileDocument";
}
Individual profileDoc = m.createIndividual(profileUri, FOAF.PersonalProfileDocument);
profileDoc.addProperty(FOAF.primaryTopic, person);
OrcidHistory history = orcidProfile.getOrcidHistory();
if (history != null) {
if (history.isClaimed().booleanValue()) {
// Set account as PersonalProfileDocument
profileDoc.addProperty(FOAF.maker, person);
}
// Who made the profile?
switch(history.getCreationMethod()) {
case DIRECT:
case MEMBER_REFERRED:
case WEBSITE:
profileDoc.addProperty(PAV.createdBy, person);
profileDoc.addProperty(PROV.wasAttributedTo, person);
if (webSite != null && (history.getCreationMethod() == CreationMethod.WEBSITE || history.getCreationMethod() == CreationMethod.DIRECT)) {
profileDoc.addProperty(PAV.createdWith, webSite);
}
break;
case API:
Individual api = m.createIndividual(MEMBER_API, PROV.SoftwareAgent);
profileDoc.addProperty(PAV.importedBy, api);
if (history.isClaimed().booleanValue()) {
profileDoc.addProperty(PAV.curatedBy, person);
}
break;
default:
// Some unknown agent!
profileDoc.addProperty(PAV.createdWith, m.createIndividual(null, PROV.Agent));
}
if (history.getLastModifiedDate() != null) {
Literal when = calendarAsLiteral(history.getLastModifiedDate().getValue(), m);
profileDoc.addLiteral(PAV.lastUpdateOn, when);
profileDoc.addLiteral(PROV.generatedAtTime, when);
}
if (history.getSubmissionDate() != null) {
profileDoc.addLiteral(PAV.createdOn, calendarAsLiteral(history.getSubmissionDate().getValue(), m));
}
if (history.getCompletionDate() != null) {
profileDoc.addLiteral(PAV.contributedOn, calendarAsLiteral(history.getCompletionDate().getValue(), m));
}
if (history.getDeactivationDate() != null) {
profileDoc.addLiteral(PROV.invalidatedAtTime, calendarAsLiteral(history.getDeactivationDate().getValue(), m));
}
}
return profileDoc;
}
use of org.orcid.jaxb.model.message.OrcidHistory in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method setWorkPrivacy.
private void setWorkPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultWorkVisibility) {
OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory();
boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false;
OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities();
if (incomingActivities != null) {
OrcidWorks incomingWorks = incomingActivities.getOrcidWorks();
if (incomingWorks != null) {
setWorkPrivacy(incomingWorks, defaultWorkVisibility, isClaimed);
}
}
}
use of org.orcid.jaxb.model.message.OrcidHistory in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method setFundingPrivacy.
private void setFundingPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultFundingVisibility) {
OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory();
boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false;
OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities();
if (incomingActivities != null) {
FundingList incomingFundingList = incomingActivities.getFundings();
if (incomingFundingList != null) {
setFundingPrivacy(incomingFundingList, defaultFundingVisibility, isClaimed);
}
}
}
Aggregations