Search in sources :

Example 1 with WorkCategory

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

the class WorkFormTest method getWorkForm.

private WorkForm getWorkForm() {
    WorkForm form = new WorkForm();
    form.setCitation(new Citation("Citation", "formatted-unspecified"));
    List<Contributor> çontributors = new ArrayList<Contributor>();
    Contributor contributor = new Contributor();
    contributor.setContributorRole(Text.valueOf("co_inventor"));
    contributor.setContributorSequence(Text.valueOf("first"));
    contributor.setCreditName(Text.valueOf("Contributor credit name"));
    contributor.setEmail(null);
    contributor.setOrcid(Text.valueOf("Contributor orcid"));
    contributor.setUri(Text.valueOf("Contributor uri"));
    çontributors.add(contributor);
    form.setContributors(çontributors);
    form.setCountryCode(Text.valueOf("US"));
    Date createdDate = new Date();
    createdDate.setDay("1");
    createdDate.setMonth("1");
    createdDate.setYear("2015");
    form.setCreatedDate(createdDate);
    form.setJournalTitle(Text.valueOf("Journal title"));
    form.setLanguageCode(Text.valueOf("en"));
    Date lastModifiedDate = new Date();
    lastModifiedDate.setDay("2");
    lastModifiedDate.setMonth("2");
    lastModifiedDate.setYear("2015");
    form.setLastModified(lastModifiedDate);
    Date publicationDate = new Date();
    publicationDate.setDay("03");
    publicationDate.setMonth("03");
    publicationDate.setYear("2015");
    form.setPublicationDate(publicationDate);
    form.setDateSortString(PojoUtil.createDateSortString(null, FuzzyDate.valueOf(2015, 3, 3)));
    form.setPutCode(Text.valueOf("1"));
    form.setShortDescription(Text.valueOf("Short description"));
    form.setSource("0000-0000-0000-0000");
    form.setSubtitle(Text.valueOf("Subtitle"));
    form.setTitle(Text.valueOf("Title"));
    form.setTranslatedTitle(new TranslatedTitleForm("Translated Title", "es"));
    form.setUrl(Text.valueOf("http://myurl.com"));
    form.setVisibility(Visibility.valueOf(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC));
    List<WorkExternalIdentifier> extIds = new ArrayList<WorkExternalIdentifier>();
    WorkExternalIdentifier extId = new WorkExternalIdentifier();
    extId.setWorkExternalIdentifierId(Text.valueOf("External Identifier ID"));
    extId.setWorkExternalIdentifierType(Text.valueOf("asin"));
    extId.setRelationship(Text.valueOf(Relationship.SELF.value()));
    extIds.add(extId);
    form.setWorkExternalIdentifiers(extIds);
    form.setWorkType(Text.valueOf("artistic-performance"));
    WorkCategory category = WorkCategory.fromWorkType(WorkType.fromValue(form.getWorkType().getValue()));
    form.setWorkCategory(Text.valueOf(category.value()));
    return form;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Citation(org.orcid.pojo.ajaxForm.Citation) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) WorkCategory(org.orcid.jaxb.model.v3.dev1.record.WorkCategory) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) Date(org.orcid.pojo.ajaxForm.Date) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

Example 2 with WorkCategory

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

the class WorkForm method valueOf.

public static WorkForm valueOf(Work work) {
    if (work == null)
        return null;
    WorkForm w = new WorkForm();
    // Set work id
    if (work.getPutCode() != null) {
        w.setPutCode(Text.valueOf(work.getPutCode()));
    }
    // Set language
    if (!PojoUtil.isEmpty(work.getLanguageCode())) {
        w.setLanguageCode(Text.valueOf(work.getLanguageCode()));
    }
    // Set type
    if (work.getWorkType() != null) {
        w.setWorkType(Text.valueOf(work.getWorkType().value()));
        // Set category
        WorkCategory category = WorkCategory.fromWorkType(work.getWorkType());
        w.setWorkCategory(Text.valueOf(category.value()));
    }
    if (work.getWorkTitle() != null) {
        // Set title
        if (work.getWorkTitle().getTitle() != null) {
            w.setTitle(Text.valueOf(work.getWorkTitle().getTitle().getContent()));
        }
        // Set translated title
        if (work.getWorkTitle().getTranslatedTitle() != null) {
            TranslatedTitleForm tt = new TranslatedTitleForm();
            tt.setContent(work.getWorkTitle().getTranslatedTitle().getContent());
            tt.setLanguageCode(work.getWorkTitle().getTranslatedTitle().getLanguageCode());
            w.setTranslatedTitle(tt);
        }
        // Set subtitle
        if (work.getWorkTitle().getSubtitle() != null) {
            w.setSubtitle(Text.valueOf(work.getWorkTitle().getSubtitle().getContent()));
        }
    }
    // Set journal title
    if (work.getJournalTitle() != null) {
        w.setJournalTitle(Text.valueOf(work.getJournalTitle().getContent()));
    }
    // Set description
    if (work.getShortDescription() != null) {
        w.setShortDescription(Text.valueOf(work.getShortDescription()));
    }
    // Set url
    if (work.getUrl() != null) {
        w.setUrl(Text.valueOf(work.getUrl().getValue()));
    }
    // Set visibility
    if (work.getVisibility() != null) {
        w.setVisibility(Visibility.valueOf(work.getVisibility()));
    }
    // Set country
    if (work.getCountry() != null && work.getCountry().getValue() != null) {
        w.setCountryCode(Text.valueOf(work.getCountry().getValue().value()));
    }
    // Set publication date
    FuzzyDate fuzzyPublicationDate = null;
    if (work.getPublicationDate() != null) {
        org.orcid.jaxb.model.v3.dev1.common.PublicationDate publicationDate = work.getPublicationDate();
        Integer year = PojoUtil.isEmpty(publicationDate.getYear()) ? null : Integer.valueOf(publicationDate.getYear().getValue());
        Integer month = PojoUtil.isEmpty(publicationDate.getMonth()) ? null : Integer.valueOf(publicationDate.getMonth().getValue());
        Integer day = PojoUtil.isEmpty(publicationDate.getDay()) ? null : Integer.valueOf(publicationDate.getDay().getValue());
        if (year != null && year == 0) {
            year = null;
        }
        if (month != null && month == 0) {
            month = null;
        }
        if (day != null && day == 0) {
            day = null;
        }
        fuzzyPublicationDate = FuzzyDate.valueOf(year, month, day);
        w.setPublicationDate(Date.valueOf(fuzzyPublicationDate));
    }
    w.setDateSortString(PojoUtil.createDateSortString(null, fuzzyPublicationDate));
    // Set citation
    if (work.getWorkCitation() != null) {
        Citation citation = new Citation();
        if (!PojoUtil.isEmpty(work.getWorkCitation().getCitation())) {
            citation.setCitation(Text.valueOf(work.getWorkCitation().getCitation()));
        }
        if (work.getWorkCitation().getWorkCitationType() != null) {
            citation.setCitationType(Text.valueOf(work.getWorkCitation().getWorkCitationType().value()));
        }
        w.setCitation(citation);
    }
    // Set contributors
    populateContributors(work, w);
    // Set external identifiers
    populateExternalIdentifiers(work, w);
    // Set created date
    w.setCreatedDate(Date.valueOf(work.getCreatedDate()));
    // Set last modified
    w.setLastModified(Date.valueOf(work.getLastModifiedDate()));
    if (work.getSource() != null) {
        // Set source
        w.setSource(work.getSource().retrieveSourcePath());
        if (work.getSource().getSourceName() != null) {
            w.setSourceName(work.getSource().getSourceName().getContent());
        }
    }
    return w;
}
Also used : FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) WorkCategory(org.orcid.jaxb.model.v3.dev1.record.WorkCategory)

Example 3 with WorkCategory

use of org.orcid.jaxb.model.v3.dev1.record.WorkCategory 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)

Aggregations

WorkCategory (org.orcid.jaxb.model.v3.dev1.record.WorkCategory)3 ArrayList (java.util.ArrayList)2 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)2 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)1 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)1 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)1 WorkType (org.orcid.jaxb.model.v3.dev1.record.WorkType)1 KeyValue (org.orcid.pojo.KeyValue)1 Citation (org.orcid.pojo.ajaxForm.Citation)1 Contributor (org.orcid.pojo.ajaxForm.Contributor)1 Date (org.orcid.pojo.ajaxForm.Date)1 TranslatedTitleForm (org.orcid.pojo.ajaxForm.TranslatedTitleForm)1 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)1 WorkForm (org.orcid.pojo.ajaxForm.WorkForm)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1