Search in sources :

Example 1 with WorkToCiteprocTranslator

use of org.orcid.api.common.writer.citeproc.WorkToCiteprocTranslator in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewWorkCitation.

@Override
public Response viewWorkCitation(String orcid, Long putCode) {
    Work w = (Work) this.viewWork(orcid, putCode).getEntity();
    ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
    String creditName = null;
    RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
    if (recordNameEntity != null) {
        if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(Visibility.PUBLIC)) {
            creditName = recordNameEntity.getCreditName();
            if (StringUtils.isBlank(creditName)) {
                creditName = recordNameEntity.getGivenNames();
                String familyName = recordNameEntity.getFamilyName();
                if (StringUtils.isNotBlank(familyName)) {
                    creditName += " " + familyName;
                }
            }
        }
    }
    WorkToCiteprocTranslator tran = new WorkToCiteprocTranslator();
    CSLItemData item = tran.toCiteproc(w, creditName, true);
    return Response.ok(item).build();
}
Also used : CSLItemData(de.undercouch.citeproc.csl.CSLItemData) Work(org.orcid.jaxb.model.record_v2.Work) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) WorkToCiteprocTranslator(org.orcid.api.common.writer.citeproc.WorkToCiteprocTranslator) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Aggregations

CSLItemData (de.undercouch.citeproc.csl.CSLItemData)1 WorkToCiteprocTranslator (org.orcid.api.common.writer.citeproc.WorkToCiteprocTranslator)1 Work (org.orcid.jaxb.model.record_v2.Work)1 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)1 RecordNameEntity (org.orcid.persistence.jpa.entities.RecordNameEntity)1