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;
}
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);
}
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());
}
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;
}
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);
}
Aggregations