Search in sources :

Example 61 with Keyword

use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.

the class Utils method getKeyword.

public static Keyword getKeyword() {
    Keyword keyword = new Keyword();
    keyword.setContent("New keyword");
    keyword.setVisibility(Visibility.LIMITED);
    return keyword;
}
Also used : Keyword(org.orcid.jaxb.model.record_v2.Keyword)

Example 62 with Keyword

use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.

the class Api2_0_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(Keywords keywords) {
    if (keywords != null && keywords.getKeywords() != null && !keywords.getKeywords().isEmpty()) {
        LastModifiedDate latest = null;
        for (Keyword keyword : keywords.getKeywords()) {
            if (keyword.getLastModifiedDate() != null && keyword.getLastModifiedDate().after(latest)) {
                latest = keyword.getLastModifiedDate();
            }
        }
        keywords.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_v2.Keyword)

Example 63 with Keyword

use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.

the class JpaJaxbKeywordAdapterTest method getKeyword.

private Keyword getKeyword() throws JAXBException {
    JAXBContext context = JAXBContext.newInstance(new Class[] { Keyword.class });
    Unmarshaller unmarshaller = context.createUnmarshaller();
    String name = "/record_2.0/samples/read_samples/keyword-2.0.xml";
    InputStream inputStream = getClass().getResourceAsStream(name);
    return (Keyword) unmarshaller.unmarshal(inputStream);
}
Also used : Keyword(org.orcid.jaxb.model.record_v2.Keyword) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 64 with Keyword

use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.

the class JpaJaxbKeywordAdapterTest method fromProfileKeywordEntityToKeywordTest.

@Test
public void fromProfileKeywordEntityToKeywordTest() {
    ProfileKeywordEntity entity = getProfileKeywordEntity();
    Keyword keyword = adapter.toKeyword(entity);
    assertNotNull(keyword);
    assertEquals("keyword-1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertNotNull(keyword.getLastModifiedDate());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertNotNull(keyword.getSource());
    assertEquals("APP-000000000000", keyword.getSource().retrieveSourcePath());
    assertEquals(Visibility.LIMITED, keyword.getVisibility());
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Test(org.junit.Test)

Example 65 with Keyword

use of org.orcid.jaxb.model.record_rc4.Keyword in project ORCID-Source by ORCID.

the class ProfileKeywordManagerTest method displayIndexIsSetTo_0_FromAPI.

@Test
public void displayIndexIsSetTo_0_FromAPI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Keyword keyword = getKeyword();
    keyword.setContent(keyword.getContent() + " fromAPI1");
    keyword = profileKeywordManager.createKeyword(claimedOrcid, keyword, true);
    keyword = profileKeywordManager.getKeyword(claimedOrcid, keyword.getPutCode());
    assertNotNull(keyword);
    assertEquals(Long.valueOf(0), keyword.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Keyword(org.orcid.jaxb.model.record_v2.Keyword) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)88 Keyword (org.orcid.jaxb.model.record_v2.Keyword)82 Address (org.orcid.jaxb.model.record_v2.Address)44 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)44 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Keywords (org.orcid.jaxb.model.record_v2.Keywords)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Person (org.orcid.jaxb.model.record_v2.Person)30 Name (org.orcid.jaxb.model.record_v2.Name)29 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 DBUnitTest (org.orcid.test.DBUnitTest)20 Keyword (org.orcid.jaxb.model.record_rc3.Keyword)19 Response (javax.ws.rs.core.Response)18