Search in sources :

Example 1 with IdentifierType

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

the class IdentifierTypeManagerImpl method fetchIdentifierTypeByDatabaseName.

/**
     * Null locale will result in Locale.ENGLISH
     */
@Override
@Cacheable("identifier-types")
public IdentifierType fetchIdentifierTypeByDatabaseName(String name, Locale loc) {
    loc = (loc == null) ? Locale.ENGLISH : loc;
    IdentifierTypeEntity entity = idTypeDao.getEntityByName(name);
    IdentifierType type = adapter.fromEntity(entity);
    type.setDescription(getMessage(type.getName(), loc));
    return type;
}
Also used : IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) IdentifierType(org.orcid.pojo.IdentifierType) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with IdentifierType

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

the class IdentifierTypeManagerImpl method fetchIdentifierTypesByAPITypeName.

/**
     * Returns an immutable map of API Type Name->identifierType objects.
     * Null locale will result in Locale.ENGLISH
     * 
     */
@Override
@Cacheable("identifier-types-map")
public Map<String, IdentifierType> fetchIdentifierTypesByAPITypeName(Locale loc) {
    loc = (loc == null) ? Locale.ENGLISH : loc;
    List<IdentifierTypeEntity> entities = idTypeDao.getEntities();
    Map<String, IdentifierType> ids = new HashMap<String, IdentifierType>();
    for (IdentifierTypeEntity e : entities) {
        IdentifierType id = adapter.fromEntity(e);
        id.setDescription(getMessage(id.getName(), loc));
        ids.put(id.getName(), id);
    }
    return Collections.unmodifiableMap(ids);
}
Also used : HashMap(java.util.HashMap) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) IdentifierType(org.orcid.pojo.IdentifierType) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 3 with IdentifierType

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

the class IdentifierTypeConverterTest method testToPojo.

@Test
public void testToPojo() {
    IdentifierTypeEntity entity1 = new IdentifierTypeEntity();
    entity1.setId(1l);
    entity1.setName("NAME_TEST");
    entity1.setIsDeprecated(true);
    entity1.setResolutionPrefix("prefix");
    entity1.setValidationRegex("validation");
    entity1.setDateCreated(new Date(10, 10, 10));
    entity1.setLastModified(new Date(11, 11, 11));
    ClientDetailsEntity client = new ClientDetailsEntity();
    client.setClientName("clientName");
    entity1.setSourceClient(client);
    IdentifierType id = new IdentifierTypePOJOConverter().fromEntity(entity1);
    assertEquals(Long.valueOf(1l), id.getPutCode());
    assertEquals("name-test", id.getName());
    assertEquals(true, id.getDeprecated());
    assertEquals("prefix", id.getResolutionPrefix());
    assertEquals("validation", id.getValidationRegex());
    assertEquals(new Date(10, 10, 10), id.getDateCreated());
    assertEquals(new Date(11, 11, 11), id.getLastModified());
    assertEquals("clientName", id.getSourceClient().getClientName());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) IdentifierTypePOJOConverter(org.orcid.core.adapter.impl.IdentifierTypePOJOConverter) IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date) BaseTest(org.orcid.core.BaseTest) Test(org.junit.Test)

Example 4 with IdentifierType

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

the class IdentifierTypeManagerTest method createIdentifierType.

private IdentifierType createIdentifierType(int seed) {
    IdentifierType id = new IdentifierType();
    id.setName("test" + seed);
    id.setDeprecated(true);
    id.setResolutionPrefix("prefix" + seed);
    id.setValidationRegex("validation" + seed);
    id.setDateCreated(new Date(10, 10, 10));
    id.setLastModified(new Date(11, 11, 11));
    ClientDetailsEntity client = new ClientDetailsEntity();
    client.setClientName(CLIENT_1_ID);
    id.setSourceClient(client);
    id.setPrimaryUse("pu" + seed);
    id.setCaseSensitive(true);
    return id;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date)

Example 5 with IdentifierType

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

the class IdentifierApiServiceDelegatorTest method testviewIdentifierTypes.

@Test
public void testviewIdentifierTypes() {
    assertEquals(service.viewIdentifierTypes(null).getStatus(), 200);
    Response r = service.viewIdentifierTypes(null);
    @SuppressWarnings("unchecked") GenericEntity<List<IdentifierType>> types = (GenericEntity<List<IdentifierType>>) r.getEntity();
    Boolean found = false;
    for (IdentifierType t : types.getEntity()) {
        if (t.getName().equals("doi")) {
            assertEquals("doi: Digital object identifier", t.getDescription());
            found = true;
        }
    }
    assertTrue("no description for DOI found", found);
}
Also used : Response(javax.ws.rs.core.Response) GenericEntity(javax.ws.rs.core.GenericEntity) ArrayList(java.util.ArrayList) List(java.util.List) IdentifierType(org.orcid.pojo.IdentifierType) Test(org.junit.Test)

Aggregations

IdentifierType (org.orcid.pojo.IdentifierType)14 Test (org.junit.Test)6 Date (java.util.Date)5 BaseTest (org.orcid.core.BaseTest)4 IdentifierTypeEntity (org.orcid.persistence.jpa.entities.IdentifierTypeEntity)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 List (java.util.List)2 GenericEntity (javax.ws.rs.core.GenericEntity)2 Response (javax.ws.rs.core.Response)2 IdentifierTypePOJOConverter (org.orcid.core.adapter.impl.IdentifierTypePOJOConverter)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Builder (com.google.common.collect.ImmutableList.Builder)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1