Search in sources :

Example 1 with WorkType

use of org.orcid.jaxb.model.v3.dev1.record.WorkType in project ORCID-Source by ORCID.

the class WorksController method retriveWorkTypes.

/**
 * Return a list of work types based on the work category provided as a
 * parameter
 *
 * @param workCategoryName
 * @return a map containing the list of types associated with that type and
 *         his localized name
 */
@RequestMapping(value = "/loadWorkTypes.json", method = RequestMethod.GET)
@ResponseBody
public List<KeyValue> retriveWorkTypes(@RequestParam(value = "workCategory") String workCategoryName) {
    List<KeyValue> types = new ArrayList<KeyValue>();
    WorkCategory workCategory = null;
    if (!PojoUtil.isEmpty(workCategoryName))
        workCategory = WorkCategory.fromValue(workCategoryName);
    // Get work types based on category
    if (workCategory != null) {
        for (WorkType workType : workCategory.getSubTypes()) {
            // Dont put work type UNDEFINED
            if (!workType.equals(WorkType.UNDEFINED)) {
                types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
            }
        }
    } else {
        // Get all work types
        for (WorkType workType : WorkType.values()) {
            // Dont put work type UNDEFINED
            if (!workType.equals(WorkType.UNDEFINED)) {
                types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
            }
        }
    }
    return types;
}
Also used : KeyValue(org.orcid.pojo.KeyValue) WorkType(org.orcid.jaxb.model.v3.dev1.record.WorkType) ArrayList(java.util.ArrayList) WorkCategory(org.orcid.jaxb.model.v3.dev1.record.WorkCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with WorkType

use of org.orcid.jaxb.model.v3.dev1.record.WorkType in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getWorkMapperFacade.

public MapperFacade getWorkMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("workExternalIdentifiersConverterId", new JSONWorkExternalIdentifiersConverterV3(norm, localeManager));
    converterFactory.registerConverter("workContributorsConverterId", new JsonOrikaConverter<WorkContributors>());
    ClassMapBuilder<Work, WorkEntity> workClassMap = mapperFactory.classMap(Work.class, WorkEntity.class);
    workClassMap.byDefault();
    workClassMap.field("putCode", "id");
    addV3DateFields(workClassMap);
    registerSourceConverters(mapperFactory, workClassMap);
    workClassMap.field("journalTitle.content", "journalTitle");
    workClassMap.field("workTitle.title.content", "title");
    workClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
    workClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workClassMap.field("workTitle.subtitle.content", "subtitle");
    workClassMap.field("shortDescription", "description");
    workClassMap.field("workCitation.workCitationType", "citationType");
    workClassMap.field("workCitation.citation", "citation");
    workClassMap.field("workType", "workType");
    workClassMap.field("publicationDate", "publicationDate");
    workClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workClassMap.field("url.value", "workUrl");
    workClassMap.fieldMap("workContributors", "contributorsJson").converter("workContributorsConverterId").add();
    workClassMap.field("languageCode", "languageCode");
    workClassMap.field("country.value", "iso2Country");
    workClassMap.register();
    ClassMapBuilder<WorkSummary, WorkEntity> workSummaryClassMap = mapperFactory.classMap(WorkSummary.class, WorkEntity.class);
    registerSourceConverters(mapperFactory, workSummaryClassMap);
    workSummaryClassMap.field("putCode", "id");
    workSummaryClassMap.field("title.title.content", "title");
    workSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
    workSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workSummaryClassMap.field("journalTitle.content", "journalTitle");
    workSummaryClassMap.field("type", "workType");
    workSummaryClassMap.field("publicationDate", "publicationDate");
    workSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workSummaryClassMap.byDefault();
    workSummaryClassMap.register();
    ClassMapBuilder<WorkSummary, MinimizedWorkEntity> workSummaryMinimizedClassMap = mapperFactory.classMap(WorkSummary.class, MinimizedWorkEntity.class);
    addV3CommonFields(workSummaryMinimizedClassMap);
    registerSourceConverters(mapperFactory, workSummaryMinimizedClassMap);
    workSummaryMinimizedClassMap.field("title.title.content", "title");
    workSummaryMinimizedClassMap.field("title.translatedTitle.content", "translatedTitle");
    workSummaryMinimizedClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
    workSummaryMinimizedClassMap.field("type", "workType");
    workSummaryMinimizedClassMap.field("publicationDate.year.value", "publicationYear");
    workSummaryMinimizedClassMap.field("publicationDate.month.value", "publicationMonth");
    workSummaryMinimizedClassMap.field("publicationDate.day.value", "publicationDay");
    workSummaryMinimizedClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    workSummaryMinimizedClassMap.byDefault();
    workSummaryMinimizedClassMap.register();
    ClassMapBuilder<Work, MinimizedWorkEntity> minimizedWorkClassMap = mapperFactory.classMap(Work.class, MinimizedWorkEntity.class);
    minimizedWorkClassMap.byDefault();
    registerSourceConverters(mapperFactory, minimizedWorkClassMap);
    minimizedWorkClassMap.field("putCode", "id");
    minimizedWorkClassMap.field("journalTitle.content", "journalTitle");
    minimizedWorkClassMap.field("workTitle.title.content", "title");
    minimizedWorkClassMap.field("workTitle.translatedTitle.content", "translatedTitle");
    minimizedWorkClassMap.field("workTitle.translatedTitle.languageCode", "translatedTitleLanguageCode");
    minimizedWorkClassMap.field("workTitle.subtitle.content", "subtitle");
    minimizedWorkClassMap.field("shortDescription", "description");
    minimizedWorkClassMap.field("workType", "workType");
    minimizedWorkClassMap.field("publicationDate.year.value", "publicationYear");
    minimizedWorkClassMap.field("publicationDate.month.value", "publicationMonth");
    minimizedWorkClassMap.field("publicationDate.day.value", "publicationDay");
    minimizedWorkClassMap.fieldMap("workExternalIdentifiers", "externalIdentifiersJson").converter("workExternalIdentifiersConverterId").add();
    minimizedWorkClassMap.field("url.value", "workUrl");
    minimizedWorkClassMap.register();
    mapperFactory.classMap(PublicationDate.class, PublicationDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
    return mapperFactory.getMapperFacade();
}
Also used : WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) JSONWorkExternalIdentifiersConverterV3(org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV3) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) Work(org.orcid.jaxb.model.v3.dev1.record.Work)

Example 3 with WorkType

use of org.orcid.jaxb.model.v3.dev1.record.WorkType in project ORCID-Source by ORCID.

the class WorkGroup method valueOf.

public static WorkGroup valueOf(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup workGroup, int id, String orcid) {
    WorkGroup group = new WorkGroup();
    group.setGroupId(id);
    group.setWorks(new ArrayList<>());
    WorkType workType = null;
    Long maxDisplayIndex = null;
    for (WorkSummary workSummary : workGroup.getWorkSummary()) {
        WorkForm workForm = getWorkForm(workSummary);
        group.getWorks().add(workForm);
        Long displayIndex = Long.parseLong(workSummary.getDisplayIndex());
        if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) {
            maxDisplayIndex = displayIndex;
            group.setActivePutCode(workSummary.getPutCode());
            group.setActiveVisibility(workSummary.getVisibility().name());
            group.setDefaultWork(workForm);
        }
        if (workSummary.getSource().retrieveSourcePath().equals(orcid)) {
            group.setUserVersionPresent(true);
        }
        workType = workSummary.getType();
    }
    if (workGroup.getIdentifiers() != null) {
        List<WorkExternalIdentifier> workExternalIdentifiersList = new ArrayList<WorkExternalIdentifier>();
        for (ExternalID extId : workGroup.getIdentifiers().getExternalIdentifier()) {
            if (extId.getRelationship() == null) {
                if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) {
                    if (WorkType.BOOK.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) {
                    if (WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else {
                    extId.setRelationship(Relationship.SELF);
                }
            }
            workExternalIdentifiersList.add(WorkExternalIdentifier.valueOf(extId));
        }
        group.setWorkExternalIdentifiers(workExternalIdentifiersList);
    }
    return group;
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) WorkForm(org.orcid.pojo.ajaxForm.WorkForm) WorkType(org.orcid.jaxb.model.v3.dev1.record.WorkType) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier)

Example 4 with WorkType

use of org.orcid.jaxb.model.v3.dev1.record.WorkType in project ORCID-Source by ORCID.

the class WorkForm method populateExternalIdentifiers.

public static void populateExternalIdentifiers(ExternalIDs extIds, WorkForm workForm, WorkType workType) {
    if (extIds != null) {
        List<WorkExternalIdentifier> workExternalIdentifiersList = new ArrayList<WorkExternalIdentifier>();
        for (ExternalID extId : extIds.getExternalIdentifier()) {
            if (extId.getRelationship() == null) {
                if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) {
                    if (WorkType.BOOK.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) {
                    if (WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else {
                    extId.setRelationship(Relationship.SELF);
                }
            }
            workExternalIdentifiersList.add(WorkExternalIdentifier.valueOf(extId));
        }
        workForm.setWorkExternalIdentifiers(workExternalIdentifiersList);
    }
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList)

Example 5 with WorkType

use of org.orcid.jaxb.model.v3.dev1.record.WorkType in project ORCID-Source by ORCID.

the class V3WorkToCiteprocTranslator method translateFromWorkMetadata.

/**
 * Use the ORCID work metadata to generate a *limited* citation. You'll most
 * likely get a title, doi, url, date and author.
 *
 * Translates type according to https://docs.google.com/spreadsheets/d/
 * 1h4nTF6DKNEpWcGNQVMDwt0ea09qmkBnkWisxkJE-li4/edit#gid=754644608
 *
 * Informed by mendley tranforms at
 * http://support.mendeley.com/customer/portal/articles/364144-csl-type-
 * mapping
 *
 * See also:
 * http://docs.citationstyles.org/en/stable/specification.html#appendix-iii-
 * types http://members.orcid.org/api/supported-work-types datacite and
 * crossref mappings here:
 * https://github.com/lagotto/lagotto/blob/master/config/initializers/
 * constants.rb
 * @param creditName
 *
 * @param worktype
 * @return a CSLItemData, default CSLType.ARTICLE if cannot map type
 */
private CSLItemData translateFromWorkMetadata(Work work, String creditName) {
    CSLItemDataBuilder builder = new CSLItemDataBuilder();
    builder.title((work.getWorkTitle() != null) ? StringUtils.stripAccents(work.getWorkTitle().getTitle().getContent()) : "No Title");
    String doi = extractID(work, WorkExternalIdentifierType.DOI);
    String url = extractID(work, WorkExternalIdentifierType.URI);
    if (doi != null) {
        builder.DOI(doi);
    }
    if (url != null) {
        builder.URL(url);
    } else if (doi != null) {
        builder.URL("http://doi.org/" + doi);
    } else {
        url = extractID(work, WorkExternalIdentifierType.HANDLE);
        if (url != null) {
            builder.URL(url);
        }
    }
    if (work.getJournalTitle() != null) {
        builder.containerTitle(StringUtils.stripAccents(work.getJournalTitle().getContent()));
    }
    List<String> names = new ArrayList<String>();
    // TODO: Pass in credit name
    names.add(creditName);
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor c : work.getWorkContributors().getContributor()) {
            if (c.getCreditName() != null && c.getCreditName().getContent() != null) {
                names.add(StringUtils.stripAccents(c.getCreditName().getContent()));
            }
        }
    }
    CSLNameBuilder name = new CSLNameBuilder();
    name.literal(Joiner.on(" and ").skipNulls().join(names));
    builder.author(name.build());
    // TODO: make it work with "Spring", "August", whatever...
    if (work.getPublicationDate() != null) {
        int year = 0;
        int month = 0;
        int day = 0;
        try {
            year = Integer.parseInt(work.getPublicationDate().getYear().getValue());
            month = Integer.parseInt(work.getPublicationDate().getMonth().getValue());
            day = Integer.parseInt(work.getPublicationDate().getDay().getValue());
        } catch (Exception e) {
        }
        if (year > 0 && month > 0 && day > 0) {
            builder.issued(year, month, day);
        } else if (year > 0 && month > 0) {
            builder.issued(year, month);
        } else if (year > 0) {
            builder.issued(year);
        }
    }
    switch(work.getWorkType()) {
        case ARTISTIC_PERFORMANCE:
            break;
        case BOOK:
            builder.type(CSLType.BOOK);
            break;
        case BOOK_CHAPTER:
            builder.type(CSLType.CHAPTER);
            break;
        case BOOK_REVIEW:
            builder.type(CSLType.REVIEW_BOOK);
            break;
        case CONFERENCE_ABSTRACT:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case CONFERENCE_PAPER:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case CONFERENCE_POSTER:
            builder.type(CSLType.PAPER_CONFERENCE);
            break;
        case DATA_SET:
            builder.type(CSLType.DATASET);
            break;
        case DICTIONARY_ENTRY:
            builder.type(CSLType.ENTRY_DICTIONARY);
            break;
        case DISSERTATION:
            builder.type(CSLType.THESIS);
            break;
        case ENCYCLOPEDIA_ENTRY:
            builder.type(CSLType.ENTRY_ENCYCLOPEDIA);
            break;
        case JOURNAL_ARTICLE:
            builder.type(CSLType.ARTICLE_JOURNAL);
            break;
        case MAGAZINE_ARTICLE:
            builder.type(CSLType.ARTICLE_MAGAZINE);
            break;
        case NEWSLETTER_ARTICLE:
            builder.type(CSLType.ARTICLE_NEWSPAPER);
            break;
        case NEWSPAPER_ARTICLE:
            builder.type(CSLType.ARTICLE_NEWSPAPER);
            break;
        case ONLINE_RESOURCE:
            builder.type(CSLType.WEBPAGE);
            break;
        case REPORT:
            builder.type(CSLType.REPORT);
            break;
        case WEBSITE:
            builder.type(CSLType.WEBPAGE);
            break;
        case WORKING_PAPER:
            builder.type(CSLType.ARTICLE);
            break;
        case DISCLOSURE:
        case EDITED_BOOK:
        case INVENTION:
        case JOURNAL_ISSUE:
        case LECTURE_SPEECH:
        case LICENSE:
        case MANUAL:
        case OTHER:
        case PATENT:
        case REGISTERED_COPYRIGHT:
        case RESEARCH_TECHNIQUE:
        case RESEARCH_TOOL:
        case SPIN_OFF_COMPANY:
        case STANDARDS_AND_POLICY:
        case SUPERVISED_STUDENT_PUBLICATION:
        case TECHNICAL_STANDARD:
        case TEST:
        case TRADEMARK:
        case TRANSLATION:
        case UNDEFINED:
        default:
            // builder.type(CSLType.ARTICLE);
            break;
    }
    return builder.build();
}
Also used : ArrayList(java.util.ArrayList) CSLNameBuilder(de.undercouch.citeproc.csl.CSLNameBuilder) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) CSLItemDataBuilder(de.undercouch.citeproc.csl.CSLItemDataBuilder) IOException(java.io.IOException) ParseException(org.jbibtex.ParseException)

Aggregations

ArrayList (java.util.ArrayList)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)2 WorkType (org.orcid.jaxb.model.v3.dev1.record.WorkType)2 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)2 CSLItemDataBuilder (de.undercouch.citeproc.csl.CSLItemDataBuilder)1 CSLNameBuilder (de.undercouch.citeproc.csl.CSLNameBuilder)1 IOException (java.io.IOException)1 MapperFactory (ma.glasnost.orika.MapperFactory)1 ConverterFactory (ma.glasnost.orika.converter.ConverterFactory)1 DefaultMapperFactory (ma.glasnost.orika.impl.DefaultMapperFactory)1 ParseException (org.jbibtex.ParseException)1 JSONWorkExternalIdentifiersConverterV3 (org.orcid.core.adapter.jsonidentifier.converter.JSONWorkExternalIdentifiersConverterV3)1 Contributor (org.orcid.jaxb.model.v3.dev1.common.Contributor)1 Work (org.orcid.jaxb.model.v3.dev1.record.Work)1 WorkCategory (org.orcid.jaxb.model.v3.dev1.record.WorkCategory)1 WorkContributors (org.orcid.jaxb.model.v3.dev1.record.WorkContributors)1 MinimizedWorkEntity (org.orcid.persistence.jpa.entities.MinimizedWorkEntity)1 NotificationWorkEntity (org.orcid.persistence.jpa.entities.NotificationWorkEntity)1 WorkEntity (org.orcid.persistence.jpa.entities.WorkEntity)1 KeyValue (org.orcid.pojo.KeyValue)1