Search in sources :

Example 6 with DataProviderEntity

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());
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDataStatusEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusEntity) SchemaColumn(org.finra.herd.model.api.xml.SchemaColumn) ArrayList(java.util.ArrayList) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Example 7 with DataProviderEntity

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())));
}
Also used : DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) DataProviderKey(org.finra.herd.model.api.xml.DataProviderKey) Test(org.junit.Test)

Example 8 with DataProviderEntity

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()));
}
Also used : DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) Test(org.junit.Test)

Example 9 with DataProviderEntity

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);
}
Also used : DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity)

Example 10 with 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));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) Predicate(javax.persistence.criteria.Predicate)

Aggregations

DataProviderEntity (org.finra.herd.model.jpa.DataProviderEntity)15 ArrayList (java.util.ArrayList)6 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)6 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)5 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)4 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)4 DataProviderKey (org.finra.herd.model.api.xml.DataProviderKey)3 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)2 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)2 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)2 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)2 StorageEntity (org.finra.herd.model.jpa.StorageEntity)2 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)2 Test (org.junit.Test)2 Predicate (javax.persistence.criteria.Predicate)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 BusinessObjectDefinitionAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionAttributeEntity)1 SchemaColumnEntity (org.finra.herd.model.jpa.SchemaColumnEntity)1