use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeDaoTest method test4FetchIDList.
@Test
public void test4FetchIDList() {
List<IdentifierTypeEntity> list = idTypeDao.getEntities();
int startSize = list.size();
IdentifierTypeEntity e1 = new IdentifierTypeEntity();
e1.setName("TEST_B");
ClientDetailsEntity sourceClient = new ClientDetailsEntity();
sourceClient.setId("APP-6666666666666666");
e1.setSourceClient(sourceClient);
idTypeDao.addIdentifierType(e1);
list = idTypeDao.getEntities();
assertEquals(startSize + 1, list.size());
}
use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity 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.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeManagerImpl method createIdentifierType.
@Override
@CacheEvict(value = { "identifier-types", "identifier-types-map" }, allEntries = true)
public IdentifierType createIdentifierType(IdentifierType id) {
IdentifierTypeEntity entity = adapter.fromPojo(id);
SourceEntity source = sourceManager.retrieveSourceEntity();
entity.setSourceClient(source.getSourceClient());
Date now = new Date();
entity.setDateCreated(now);
entity.setLastModified(now);
entity = idTypeDao.addIdentifierType(entity);
return adapter.fromEntity(entity);
}
use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeDaoImpl method updateIdentifierType.
/**
* Updates id_resolution_prefix, id_validation_regex, id_deprecated
*
* Ignores name (cannot be modified)
*
*/
@Override
@Transactional
public IdentifierTypeEntity updateIdentifierType(IdentifierTypeEntity identifierType) {
IdentifierTypeEntity id = this.find(identifierType.getId());
id.setResolutionPrefix(identifierType.getResolutionPrefix());
id.setValidationRegex(identifierType.getValidationRegex());
id.setIsDeprecated(identifierType.getIsDeprecated());
id.setIsDeprecated(identifierType.getIsDeprecated());
id.setIsCaseSensitive(identifierType.getIsCaseSensitive());
id.setPrimaryUse(identifierType.getPrimaryUse());
id = this.merge(id);
this.flush();
return id;
}
use of org.orcid.persistence.jpa.entities.IdentifierTypeEntity in project ORCID-Source by ORCID.
the class IdentifierTypeConverterTest method testFromPojo.
@Test
public void testFromPojo() {
IdentifierType id = new IdentifierType();
id.setPutCode(1l);
id.setName("name-test");
id.setDeprecated(true);
id.setResolutionPrefix("prefix");
id.setValidationRegex("validation");
id.setDateCreated(new Date(10, 10, 10));
id.setLastModified(new Date(11, 11, 11));
ClientDetailsEntity client = new ClientDetailsEntity();
client.setClientName("clientName");
id.setSourceClient(client);
IdentifierTypeEntity entity = new IdentifierTypePOJOConverter().fromPojo(id);
assertEquals(Long.valueOf(1l), entity.getId());
assertEquals("NAME_TEST", entity.getName());
assertEquals(true, entity.getIsDeprecated());
assertEquals("prefix", entity.getResolutionPrefix());
assertEquals("validation", entity.getValidationRegex());
assertEquals(new Date(10, 10, 10), entity.getDateCreated());
assertEquals(new Date(11, 11, 11), entity.getLastModified());
assertEquals("clientName", entity.getSourceClient().getClientName());
}
Aggregations