use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class BusinessObjectDataDaoTest method createBusinessObjectEntityForPartitionValueFilterTest.
private BusinessObjectDataEntity createBusinessObjectEntityForPartitionValueFilterTest() {
List<SchemaColumn> schemaColumns = new ArrayList<>();
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY);
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY + "1");
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY + "2");
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY + "3");
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY + "4");
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
NamespaceEntity namespaceEntity = super.namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
DataProviderEntity dataProviderEntity = super.dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = super.businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(namespaceEntity, BDEF_NAME, dataProviderEntity, NO_BDEF_DESCRIPTION, NO_BDEF_DISPLAY_NAME, NO_ATTRIBUTES, NO_SAMPLE_DATA_FILES);
FileTypeEntity fileTypeEntity = super.fileTypeDaoTestHelper.createFileTypeEntity(FORMAT_FILE_TYPE_CODE, FORMAT_DESCRIPTION);
BusinessObjectFormatEntity businessObjectFormatEntity = super.businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectDefinitionEntity, FORMAT_USAGE_CODE, fileTypeEntity, FORMAT_VERSION, null, true, PARTITION_KEY, null, NO_ATTRIBUTES, null, null, null, schemaColumns, schemaColumns);
BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS, DESCRIPTION, BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
return businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, true, businessObjectDataStatusEntity.getCode());
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderTest method testGetDataProviderByKey.
@Test
public void testGetDataProviderByKey() {
// Create a data provider entity.
DataProviderEntity dataProviderEntity = dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
// Retrieve the data provider entity.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME)));
// Test case insensitivity of data provider key.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME.toUpperCase())));
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByKey(new DataProviderKey(DATA_PROVIDER_NAME.toLowerCase())));
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderTest method testGetDataProviderByName.
@Test
public void testGetDataProviderByName() {
// Create a data provider entity.
DataProviderEntity dataProviderEntity = dataProviderDaoTestHelper.createDataProviderEntity(DATA_PROVIDER_NAME);
// Retrieve the data provider entity.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByName(DATA_PROVIDER_NAME));
// Test case insensitivity of data provider name.
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByName(DATA_PROVIDER_NAME.toUpperCase()));
assertEquals(dataProviderEntity, dataProviderDao.getDataProviderByName(DATA_PROVIDER_NAME.toLowerCase()));
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderDaoTestHelper method createDataProviderEntity.
/**
* Creates and persists a new data provider entity.
*
* @param dataProviderName the data provider name
*
* @return the newly created data provider entity.
*/
public DataProviderEntity createDataProviderEntity(String dataProviderName) {
DataProviderEntity dataProviderEntity = new DataProviderEntity();
dataProviderEntity.setName(dataProviderName);
return dataProviderDao.saveAndRefresh(dataProviderEntity);
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderDaoImpl method getDataProviderByName.
@Override
public DataProviderEntity getDataProviderByName(String dataProviderName) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<DataProviderEntity> criteria = builder.createQuery(DataProviderEntity.class);
// The criteria root is the data provider.
Root<DataProviderEntity> dataProviderEntity = criteria.from(DataProviderEntity.class);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate queryRestriction = builder.equal(builder.upper(dataProviderEntity.get(DataProviderEntity_.name)), dataProviderName.toUpperCase());
criteria.select(dataProviderEntity).where(queryRestriction);
return executeSingleResultQuery(criteria, String.format("Found more than one data provider with name=\"%s\".", dataProviderName));
}
Aggregations