use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypePOJOConverter method fromPojo.
public IdentifierTypeEntity fromPojo(IdentifierType id) {
IdentifierTypeEntity entity = new IdentifierTypeEntity();
entity.setId(id.getPutCode());
entity.setName(externalIdentifierTypeConverter.convertTo(id.getName(), null));
entity.setIsDeprecated(id.getDeprecated());
entity.setResolutionPrefix(id.getResolutionPrefix());
entity.setValidationRegex(id.getValidationRegex());
entity.setDateCreated(id.getDateCreated());
entity.setLastModified(id.getLastModified());
entity.setSourceClient(id.getSourceClient());
entity.setPrimaryUse(id.getPrimaryUse());
entity.setIsCaseSensitive(id.getCaseSensitive());
return entity;
}
use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity 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.persistence.jpa.entities.IdentifierTypeEntity 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.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeManagerImpl method updateIdentifierType.
@Override
@CacheEvict(value = { "identifier-types", "identifier-types-map" }, allEntries = true)
public IdentifierType updateIdentifierType(IdentifierType id) {
IdentifierTypeEntity entity = idTypeDao.getEntityByName(externalIdentifierTypeConverter.convertTo(id.getName(), null));
SourceEntity sourceEntity = new SourceEntity();
sourceEntity.setSourceClient(entity.getSourceClient());
securityManager.checkSource(entity);
entity.setIsDeprecated(id.getDeprecated());
entity.setResolutionPrefix(id.getResolutionPrefix());
entity.setValidationRegex(id.getValidationRegex());
entity.setLastModified(new Date());
entity.setIsCaseSensitive(id.getCaseSensitive());
entity.setPrimaryUse(id.getPrimaryUse());
entity = idTypeDao.updateIdentifierType(entity);
return adapter.fromEntity(entity);
}
use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeDaoTest method test1AddUpdateFetchID.
@Test
public void test1AddUpdateFetchID() {
IdentifierTypeEntity e1 = new IdentifierTypeEntity();
e1.setName("TEST_A");
e1.setResolutionPrefix("http://whatever.com/{id}");
e1.setValidationRegex("blah");
e1.setSourceClient(clientDetailsDao.findByClientId("APP-6666666666666666", new Date().getTime()));
e1.setIsCaseSensitive(true);
e1.setPrimaryUse("pu");
IdentifierTypeEntity e2 = idTypeDao.addIdentifierType(e1);
assertNotNull(e2.getId());
e1 = idTypeDao.getEntityByName("TEST_A");
assertEquals("TEST_A", e1.getName());
assertEquals("http://whatever.com/{id}", e1.getResolutionPrefix());
assertEquals("blah", e1.getValidationRegex());
assertFalse(e1.getIsDeprecated());
assertNotNull(e1.getId());
assertEquals("APP-6666666666666666", e1.getSourceClient().getClientId());
assertTrue((new Date()).after(e1.getDateCreated()));
assertTrue((new Date()).after(e1.getLastModified()));
assertEquals("APP-6666666666666666", e1.getSourceClient().getId());
assertTrue(e1.getIsCaseSensitive());
assertEquals("pu", e1.getPrimaryUse());
//update
//e1 = idTypeDao.getEntityByName("TEST_A");
Date last = e1.getLastModified();
e1.setResolutionPrefix("http://whatever2.com/{id}");
e1.setValidationRegex("blah2");
e1.setIsDeprecated(true);
e1 = idTypeDao.updateIdentifierType(e1);
assertEquals("TEST_A", e1.getName());
assertEquals("http://whatever2.com/{id}", e1.getResolutionPrefix());
assertEquals("blah2", e1.getValidationRegex());
assertTrue(e1.getIsDeprecated());
assertNotNull(e1.getId());
assertEquals("APP-6666666666666666", e1.getSourceClient().getClientId());
assertTrue((new Date()).after(e1.getDateCreated()));
assertTrue(last.before(e1.getLastModified()));
e1 = idTypeDao.getEntityByName("TEST_A");
e1 = idTypeDao.getEntityByName("TEST_A");
}
Aggregations