Search in sources :

Example 6 with WorkForm

use of org.orcid.pojo.ajaxForm.WorkForm in project ORCID-Source by ORCID.

the class WorksController method getWork.

/**
     * Returns a blank work
     */
@RequestMapping(value = "/work.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWork(HttpServletRequest request) {
    WorkForm w = new WorkForm();
    initializeFields(w);
    return w;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with WorkForm

use of org.orcid.pojo.ajaxForm.WorkForm in project ORCID-Source by ORCID.

the class WorksController method createWorksIdList.

/**
     * created a work id list and sorts a map associated with the list in in the
     * session
     * 
     */
private List<String> createWorksIdList(HttpServletRequest request) {
    String orcid = getEffectiveUserOrcid();
    List<Work> works = workManager.findWorks(orcid, profileEntityManager.getLastModified(orcid));
    HashMap<Long, WorkForm> worksMap = new HashMap<Long, WorkForm>();
    List<String> workIds = new ArrayList<String>();
    if (works != null) {
        for (Work work : works) {
            try {
                worksMap.put(work.getPutCode(), WorkForm.valueOf(work));
                workIds.add(String.valueOf(work.getPutCode()));
            } catch (Exception e) {
                LOGGER.error("ProfileWork failed to parse as Work. Put code" + work.getPutCode());
            }
        }
        request.getSession().setAttribute(WORKS_MAP, worksMap);
    }
    return workIds;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) HashMap(java.util.HashMap) Work(org.orcid.jaxb.model.record_v2.Work) ArrayList(java.util.ArrayList)

Example 8 with WorkForm

use of org.orcid.pojo.ajaxForm.WorkForm in project ORCID-Source by ORCID.

the class WorkFormTest method testSerializeWork.

@Test
public void testSerializeWork() throws Exception {
    Work work = getWork();
    WorkForm workForm = WorkForm.valueOf(work);
    MemoryEfficientByteArrayOutputStream.serialize(workForm);
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 9 with WorkForm

use of org.orcid.pojo.ajaxForm.WorkForm in project ORCID-Source by ORCID.

the class WorkFormTest method testValueOfAndBack.

@Test
public void testValueOfAndBack() throws Exception {
    Work work = getWork();
    WorkForm workForm = WorkForm.valueOf(work);
    Work backToWork = workForm.toWork();
    assertEquals(work, backToWork);
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 10 with WorkForm

use of org.orcid.pojo.ajaxForm.WorkForm in project ORCID-Source by ORCID.

the class WorksControllerTest method testGetWorkInfoWithContributors.

@Test
public void testGetWorkInfoWithContributors() throws Exception {
    WorkForm work = worksController.getWorkInfo(Long.valueOf("5"));
    assertNotNull(work);
    assertNotNull(work.getContributors());
    assertEquals(4, work.getContributors().size());
    Contributor contributor = work.getContributors().get(0);
    assertNull(contributor.getEmail());
    assertEquals("Jaylen Kessler", contributor.getCreditName().getValue());
    contributor = work.getContributors().get(1);
    assertNull(contributor.getEmail());
    assertEquals("John Smith", contributor.getCreditName().getValue());
    contributor = work.getContributors().get(2);
    assertNull(contributor.getEmail());
    assertEquals("Credit Name", contributor.getCreditName().getValue());
    // contributor is an ORCID user with private name
    contributor = work.getContributors().get(3);
    assertNull(contributor.getEmail());
    assertNull(contributor.getCreditName().getValue());
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Contributor(org.orcid.pojo.ajaxForm.Contributor) WorkFormTest(orcid.pojo.ajaxForm.WorkFormTest) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Aggregations

WorkForm (org.orcid.pojo.ajaxForm.WorkForm)20 Test (org.junit.Test)12 Work (org.orcid.jaxb.model.record_v2.Work)9 WorkFormTest (orcid.pojo.ajaxForm.WorkFormTest)6 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ArrayList (java.util.ArrayList)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 HttpSession (javax.servlet.http.HttpSession)4 Contributor (org.orcid.pojo.ajaxForm.Contributor)4 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)4 HashMap (java.util.HashMap)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)3 Text (org.orcid.pojo.ajaxForm.Text)3 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1