Search in sources :

Example 11 with DataProviderEntity

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;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) ArrayList(java.util.ArrayList) DataProviderKey(org.finra.herd.model.api.xml.DataProviderKey)

Example 12 with DataProviderEntity

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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) 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) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Example 13 with DataProviderEntity

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

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

Example 15 with 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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) StorageUnitEntity(org.finra.herd.model.jpa.StorageUnitEntity) ArrayList(java.util.ArrayList) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) StorageFileEntity(org.finra.herd.model.jpa.StorageFileEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) StoragePlatformEntity(org.finra.herd.model.jpa.StoragePlatformEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity)

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