use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderDaoImpl method getDataProviders.
@Override
public List<DataProviderKey> getDataProviders() {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = builder.createQuery(String.class);
// The criteria root is the data provider.
Root<DataProviderEntity> dataProviderEntity = criteria.from(DataProviderEntity.class);
// Get the columns.
Path<String> dataProviderNameColumn = dataProviderEntity.get(DataProviderEntity_.name);
// Add the select clause.
criteria.select(dataProviderNameColumn);
// Add the order by clause.
criteria.orderBy(builder.asc(dataProviderNameColumn));
// Run the query to get a list of data provider names back.
List<String> dataProviderNames = entityManager.createQuery(criteria).getResultList();
// Populate the "keys" objects from the returned data provider names.
List<DataProviderKey> dataProviderKeys = new ArrayList<>();
for (String dataProviderName : dataProviderNames) {
dataProviderKeys.add(new DataProviderKey(dataProviderName));
}
return dataProviderKeys;
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class BusinessObjectDataStorageFileServiceTest method createDataWithSubPartitions.
private void createDataWithSubPartitions() {
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);
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_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);
}
{
SchemaColumn schemaColumn = new SchemaColumn();
schemaColumn.setName(PARTITION_KEY_5);
schemaColumn.setType("STRING");
schemaColumns.add(schemaColumn);
}
BusinessObjectFormatEntity businessObjectFormatEntity = super.businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(businessObjectDefinitionEntity, FORMAT_USAGE_CODE, fileTypeEntity, FORMAT_VERSION, null, true, PARTITION_KEY, null, NO_ATTRIBUTES, null, null, null, schemaColumns, null);
BusinessObjectDataStatusEntity businessObjectDataStatusEntity = businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS, DESCRIPTION, BDATA_STATUS_PRE_REGISTRATION_FLAG_SET);
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectFormatEntity, PARTITION_VALUE, SUB_PARTITION_VALUES, DATA_VERSION, true, businessObjectDataStatusEntity.getCode());
StorageEntity storageEntity = super.storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
StorageUnitEntity storageUnitEntity = super.storageUnitDaoTestHelper.createStorageUnitEntity(storageEntity, businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, NO_STORAGE_DIRECTORY_PATH);
super.storageFileDaoTestHelper.createStorageFileEntity(storageUnitEntity, FILE_PATH_1, FILE_SIZE_1_KB, null);
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderServiceImpl method getDataProvider.
@Override
public DataProvider getDataProvider(DataProviderKey dataProviderKey) {
// Perform validation and trim.
validateDataProviderKey(dataProviderKey);
// Retrieve and ensure that a data provider already exists with the specified key.
DataProviderEntity dataProviderEntity = dataProviderDaoHelper.getDataProviderEntity(dataProviderKey.getDataProviderName());
// Create and return the data provider object from the persisted entity.
return createDataProviderFromEntity(dataProviderEntity);
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class DataProviderServiceImpl method createDataProviderEntity.
/**
* Creates a new data provider entity from the request information.
*
* @param request the request
*
* @return the newly created data provider entity
*/
private DataProviderEntity createDataProviderEntity(DataProviderCreateRequest request) {
// Create a new entity.
DataProviderEntity dataProviderEntity = new DataProviderEntity();
dataProviderEntity.setName(request.getDataProviderName());
return dataProviderEntity;
}
use of org.finra.herd.model.jpa.DataProviderEntity in project herd by FINRAOS.
the class GetBusinessObjectDataTest method setupDatabase.
/**
* Inserts a business object data and their FK relationships into the database.
*
* @param dataProviderName the data provider name.
* @param businessObjectDefinitionName the business object definition name.
* @param fileTypeCode the file type code.
* @param businessObjectFormatUsage the business object format usage.
* @param businessObjectFormatVersion the business object format version.
* @param businessObjectDataVersion the business object data version.
* @param partitionKey the partition key.
* @param partitionValues the partition values.
*/
private void setupDatabase(String namespace, String dataProviderName, String businessObjectDefinitionName, String fileTypeCode, String businessObjectFormatUsage, Integer businessObjectFormatVersion, Integer businessObjectDataVersion, String partitionKey, String[] partitionValues) {
DataProviderEntity dataProviderEntity = new DataProviderEntity();
dataProviderEntity.setName(dataProviderName);
herdDao.saveAndRefresh(dataProviderEntity);
NamespaceEntity namespaceEntity = new NamespaceEntity();
namespaceEntity.setCode(namespace);
herdDao.saveAndRefresh(namespaceEntity);
BusinessObjectDefinitionEntity businessObjectDefinition = new BusinessObjectDefinitionEntity();
businessObjectDefinition.setDataProvider(dataProviderEntity);
businessObjectDefinition.setName(businessObjectDefinitionName);
businessObjectDefinition.setNamespace(namespaceEntity);
herdDao.saveAndRefresh(businessObjectDefinition);
FileTypeEntity fileTypeEntity = new FileTypeEntity();
fileTypeEntity.setCode(fileTypeCode);
herdDao.saveAndRefresh(fileTypeEntity);
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
businessObjectFormatEntity.setBusinessObjectDefinition(businessObjectDefinition);
businessObjectFormatEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
businessObjectFormatEntity.setFileType(fileTypeEntity);
businessObjectFormatEntity.setLatestVersion(true);
businessObjectFormatEntity.setNullValue("#");
businessObjectFormatEntity.setPartitionKey(partitionKey);
businessObjectFormatEntity.setUsage(businessObjectFormatUsage);
herdDao.saveAndRefresh(businessObjectFormatEntity);
StoragePlatformEntity storagePlatformEntity = new StoragePlatformEntity();
storagePlatformEntity.setName(randomString());
herdDao.saveAndRefresh(storagePlatformEntity);
StorageEntity storageEntity = new StorageEntity();
storageEntity.setName(randomString());
storageEntity.setStoragePlatform(storagePlatformEntity);
herdDao.saveAndRefresh(storageEntity);
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setBusinessObjectFormat(businessObjectFormatEntity);
businessObjectDataEntity.setLatestVersion(true);
businessObjectDataEntity.setPartitionValue(partitionValues[0]);
businessObjectDataEntity.setPartitionValue2(partitionValues[1]);
businessObjectDataEntity.setPartitionValue3(partitionValues[2]);
businessObjectDataEntity.setPartitionValue4(partitionValues[3]);
businessObjectDataEntity.setPartitionValue5(partitionValues[4]);
businessObjectDataEntity.setStatus(businessObjectDataStatusDao.getBusinessObjectDataStatusByCode(BusinessObjectDataStatusEntity.VALID));
Collection<StorageUnitEntity> storageUnits = new ArrayList<>();
StorageUnitEntity storageUnitEntity = new StorageUnitEntity();
storageUnitEntity.setStorage(storageEntity);
Collection<StorageFileEntity> storageFiles = new ArrayList<>();
StorageFileEntity storageFileEntity = new StorageFileEntity();
storageFileEntity.setPath(randomString());
storageFileEntity.setFileSizeBytes(1000l);
storageFileEntity.setStorageUnit(storageUnitEntity);
storageFiles.add(storageFileEntity);
storageUnitEntity.setStorageFiles(storageFiles);
storageUnitEntity.setBusinessObjectData(businessObjectDataEntity);
storageUnitEntity.setStatus(storageUnitStatusDao.getStorageUnitStatusByCode(StorageUnitStatusEntity.ENABLED));
storageUnits.add(storageUnitEntity);
businessObjectDataEntity.setStorageUnits(storageUnits);
businessObjectDataEntity.setVersion(businessObjectDataVersion);
herdDao.saveAndRefresh(businessObjectDataEntity);
}
Aggregations