Search in sources :

Example 6 with IdentifierTypeEntity

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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest)

Example 7 with IdentifierTypeEntity

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());
}
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 8 with IdentifierTypeEntity

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);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) Date(java.util.Date) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 9 with IdentifierTypeEntity

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;
}
Also used : IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with IdentifierTypeEntity

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

Aggregations

IdentifierTypeEntity (org.orcid.persistence.jpa.entities.IdentifierTypeEntity)10 Date (java.util.Date)5 Test (org.junit.Test)4 IdentifierType (org.orcid.pojo.IdentifierType)4 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)3 BaseTest (org.orcid.core.BaseTest)2 IdentifierTypePOJOConverter (org.orcid.core.adapter.impl.IdentifierTypePOJOConverter)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 DBUnitTest (org.orcid.test.DBUnitTest)2 CacheEvict (org.springframework.cache.annotation.CacheEvict)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 HashMap (java.util.HashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1