Search in sources :

Example 1 with LastModifiedDate

use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.

the class BiographyManagerReadOnlyImpl method getBiography.

@Override
@Cacheable(value = "biography", key = "#orcid.concat('-').concat(#lastModified)")
public Biography getBiography(String orcid, long lastModified) {
    BiographyEntity biographyEntity = null;
    try {
        biographyEntity = biographyDao.getBiography(orcid);
    } catch (Exception e) {
        LOGGER.warn("Couldn't find biography for " + orcid);
    }
    if (biographyEntity != null) {
        Biography bio = new Biography();
        bio.setContent(biographyEntity.getBiography());
        bio.setVisibility(biographyEntity.getVisibility());
        bio.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getLastModified())));
        bio.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(biographyEntity.getDateCreated())));
        return bio;
    }
    return null;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Biography(org.orcid.jaxb.model.record_v2.Biography) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) BiographyEntity(org.orcid.persistence.jpa.entities.BiographyEntity) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with LastModifiedDate

use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.

the class PersonalDetailsManagerReadOnlyImpl method getPublicPersonalDetails.

@Override
public PersonalDetails getPublicPersonalDetails(String orcid) {
    Date lastModified = getLastModifiedDate(orcid);
    long lastModifiedTime = (lastModified == null) ? 0 : lastModified.getTime();
    PersonalDetails personalDetails = new PersonalDetails();
    Biography bio = biographyManager.getPublicBiography(orcid, lastModifiedTime);
    if (bio != null) {
        personalDetails.setBiography(bio);
    }
    Name name = recordNameManager.getRecordName(orcid, lastModifiedTime);
    if (name != null && !Visibility.PUBLIC.equals(name.getVisibility())) {
        personalDetails.setName(null);
    } else {
        personalDetails.setName(name);
    }
    OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid, lastModifiedTime);
    OtherNames filteredOtherNames = new OtherNames();
    personalDetails.setOtherNames(filteredOtherNames);
    if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
        // Lets copy the list so we don't modify the cached collection
        List<OtherName> filteredList = new ArrayList<OtherName>(otherNames.getOtherNames());
        filteredOtherNames.setOtherNames(filteredList);
    }
    if (personalDetails.getLastModifiedDate() == null || personalDetails.getLastModifiedDate().getValue() == null) {
        personalDetails.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified)));
    }
    return personalDetails;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ArrayList(java.util.ArrayList) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonalDetails(org.orcid.jaxb.model.record_v2.PersonalDetails) Date(java.util.Date) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 3 with LastModifiedDate

use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(PersonExternalIdentifiers extIds) {
    if (extIds != null && extIds.getExternalIdentifiers() != null && !extIds.getExternalIdentifiers().isEmpty()) {
        LastModifiedDate latest = null;
        for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
            if (extId.getLastModifiedDate() != null && extId.getLastModifiedDate().after(latest)) {
                latest = extId.getLastModifiedDate();
            }
        }
        extIds.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier)

Example 4 with LastModifiedDate

use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(ActivitiesSummary activitiesSummary) {
    if (activitiesSummary != null) {
        calculateLastModified(activitiesSummary.getEducations());
        calculateLastModified(activitiesSummary.getEmployments());
        calculateLastModified(activitiesSummary.getFundings());
        calculateLastModified(activitiesSummary.getPeerReviews());
        calculateLastModified(activitiesSummary.getWorks());
        LastModifiedDate l1 = activitiesSummary.getEducations() == null ? null : activitiesSummary.getEducations().getLastModifiedDate();
        LastModifiedDate l2 = activitiesSummary.getEmployments() == null ? null : activitiesSummary.getEmployments().getLastModifiedDate();
        LastModifiedDate l3 = activitiesSummary.getFundings() == null ? null : activitiesSummary.getFundings().getLastModifiedDate();
        LastModifiedDate l4 = activitiesSummary.getPeerReviews() == null ? null : activitiesSummary.getPeerReviews().getLastModifiedDate();
        LastModifiedDate l5 = activitiesSummary.getWorks() == null ? null : activitiesSummary.getWorks().getLastModifiedDate();
        LastModifiedDate globalLatest = calculateLatest(l1, l2, l3, l4, l5);
        activitiesSummary.setLastModifiedDate(globalLatest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate)

Example 5 with LastModifiedDate

use of org.orcid.jaxb.model.common_v2.LastModifiedDate in project ORCID-Source by ORCID.

the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(OtherNames otherNames) {
    if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
        LastModifiedDate latest = null;
        for (OtherName otherName : otherNames.getOtherNames()) {
            if (otherName.getLastModifiedDate() != null && otherName.getLastModifiedDate().after(latest)) {
                latest = otherName.getLastModifiedDate();
            }
        }
        otherNames.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_rc4.LastModifiedDate) OtherName(org.orcid.jaxb.model.record_rc4.OtherName)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)34 Test (org.junit.Test)13 LastModifiedDate (org.orcid.jaxb.model.common_rc3.LastModifiedDate)13 LastModifiedDate (org.orcid.jaxb.model.common_rc4.LastModifiedDate)13 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)12 DBUnitTest (org.orcid.test.DBUnitTest)12 Date (java.util.Date)11 Response (javax.ws.rs.core.Response)10 LastModifiedDate (org.orcid.jaxb.model.common_rc2.LastModifiedDate)10 ArrayList (java.util.ArrayList)7 CreatedDate (org.orcid.jaxb.model.common_v2.CreatedDate)6 Url (org.orcid.jaxb.model.common_v2.Url)6 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 Title (org.orcid.jaxb.model.common_v2.Title)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 Work (org.orcid.jaxb.model.record_v2.Work)3 CreditName (org.orcid.jaxb.model.common_v2.CreditName)2 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 Source (org.orcid.jaxb.model.common_v2.Source)2