Search in sources :

Example 1 with BusinessObjectDefinitionKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionKey in project herd by FINRAOS.

the class BusinessObjectDefinitionDaoHelper method createBusinessObjectDefinitionEntity.

/**
 * Create Business Object Definition Entity
 * @param request business object definition create request
 * @return Business Object Definition Entity
 */
public BusinessObjectDefinitionEntity createBusinessObjectDefinitionEntity(BusinessObjectDefinitionCreateRequest request) {
    // Perform the validation.
    validateBusinessObjectDefinitionCreateRequest(request);
    // Get the namespace and ensure it exists.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(request.getNamespace());
    // Get the data provider and ensure it exists.
    DataProviderEntity dataProviderEntity = dataProviderDaoHelper.getDataProviderEntity(request.getDataProviderName());
    // Get business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(request.getNamespace(), request.getBusinessObjectDefinitionName());
    // Ensure a business object definition with the specified key doesn't already exist.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey);
    if (businessObjectDefinitionEntity != null) {
        throw new AlreadyExistsException(String.format("Unable to create business object definition with name \"%s\" because it already exists for namespace \"%s\".", businessObjectDefinitionKey.getBusinessObjectDefinitionName(), businessObjectDefinitionKey.getNamespace()));
    }
    // Create a new entity.
    businessObjectDefinitionEntity = new BusinessObjectDefinitionEntity();
    businessObjectDefinitionEntity.setNamespace(namespaceEntity);
    businessObjectDefinitionEntity.setName(request.getBusinessObjectDefinitionName());
    businessObjectDefinitionEntity.setDescription(request.getDescription());
    businessObjectDefinitionEntity.setDataProvider(dataProviderEntity);
    businessObjectDefinitionEntity.setDisplayName(request.getDisplayName());
    // Create the attributes if they are specified.
    if (!CollectionUtils.isEmpty(request.getAttributes())) {
        List<BusinessObjectDefinitionAttributeEntity> attributeEntities = new ArrayList<>();
        businessObjectDefinitionEntity.setAttributes(attributeEntities);
        for (Attribute attribute : request.getAttributes()) {
            BusinessObjectDefinitionAttributeEntity attributeEntity = new BusinessObjectDefinitionAttributeEntity();
            attributeEntities.add(attributeEntity);
            attributeEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
            attributeEntity.setName(attribute.getName());
            attributeEntity.setValue(attribute.getValue());
        }
    }
    // Persist the change event entity
    saveBusinessObjectDefinitionChangeEvents(businessObjectDefinitionEntity);
    // Persist and return the new entity.
    return businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
}
Also used : BusinessObjectDefinitionAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionAttributeEntity) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) DataProviderEntity(org.finra.herd.model.jpa.DataProviderEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) ArrayList(java.util.ArrayList)

Example 2 with BusinessObjectDefinitionKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionKey in project herd by FINRAOS.

the class StorageUnitNotificationRegistrationServiceImpl method updateStorageUnitNotificationRegistration.

@NamespacePermissions({ @NamespacePermission(fields = "#notificationRegistrationKey?.namespace", permissions = NamespacePermissionEnum.WRITE), @NamespacePermission(fields = "#request?.storageUnitNotificationFilter?.namespace", permissions = NamespacePermissionEnum.READ), @NamespacePermission(fields = "#request?.jobActions?.![namespace]", permissions = NamespacePermissionEnum.EXECUTE) })
@Override
public StorageUnitNotificationRegistration updateStorageUnitNotificationRegistration(NotificationRegistrationKey notificationRegistrationKey, StorageUnitNotificationRegistrationUpdateRequest request) {
    // Validate and trim the key.
    validateStorageUnitNotificationRegistrationKey(notificationRegistrationKey);
    // Validate and trim the request parameters.
    validateStorageUnitNotificationRegistrationUpdateRequest(request);
    // Retrieve and ensure that a storage unit notification exists with the specified key.
    StorageUnitNotificationRegistrationEntity oldStorageUnitNotificationRegistrationEntity = storageUnitNotificationRegistrationDaoHelper.getStorageUnitNotificationRegistrationEntity(notificationRegistrationKey);
    String oldStorageUnitNotificationRegistrationName = oldStorageUnitNotificationRegistrationEntity.getName();
    // Retrieve the namespace with the specified namespace code.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(notificationRegistrationKey.getNamespace());
    // Retrieve and validate the notification event type entity.
    NotificationEventTypeEntity notificationEventTypeEntity = getAndValidateNotificationEventTypeEntity(request.getStorageUnitEventType());
    // Get the storage unit notification filter.
    StorageUnitNotificationFilter filter = request.getStorageUnitNotificationFilter();
    // Retrieve and ensure that business object definition exists. Since namespace is specified, retrieve a business object definition by it's key.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(filter.getNamespace(), filter.getBusinessObjectDefinitionName()));
    // If specified, retrieve and ensure that file type exists.
    FileTypeEntity fileTypeEntity = null;
    if (StringUtils.isNotBlank(filter.getBusinessObjectFormatFileType())) {
        fileTypeEntity = fileTypeDaoHelper.getFileTypeEntity(filter.getBusinessObjectFormatFileType());
    }
    // Retrieve and ensure that storage exists.
    StorageEntity storageEntity = storageDaoHelper.getStorageEntity(filter.getStorageName());
    // If specified, retrieve and ensure that new storage unit status exists.
    StorageUnitStatusEntity newStorageUnitStatus = null;
    if (StringUtils.isNotBlank(filter.getNewStorageUnitStatus())) {
        newStorageUnitStatus = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(filter.getNewStorageUnitStatus());
    }
    // If specified, retrieve and ensure that old storage unit status exists.
    StorageUnitStatusEntity oldStorageUnitStatus = null;
    if (StringUtils.isNotBlank(filter.getOldStorageUnitStatus())) {
        oldStorageUnitStatus = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(filter.getOldStorageUnitStatus());
    }
    // TODO: We need to add a null/empty list check here, if/when list of job actions will become optional (due to addition of other action types).
    for (JobAction jobAction : request.getJobActions()) {
        // Ensure that job definition exists.
        jobDefinitionDaoHelper.getJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName());
    }
    // Retrieve and validate the notification registration status entity.
    NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDaoHelper.getNotificationRegistrationStatusEntity(request.getNotificationRegistrationStatus());
    // Delete the storage unit notification.
    storageUnitNotificationRegistrationDao.delete(oldStorageUnitNotificationRegistrationEntity);
    // Create a storage unit notification registration entity from the request information.
    StorageUnitNotificationRegistrationEntity newStorageUnitNotificationRegistrationEntity = createStorageUnitNotificationEntity(namespaceEntity, notificationEventTypeEntity, businessObjectDefinitionEntity, fileTypeEntity, storageEntity, newStorageUnitStatus, oldStorageUnitStatus, new NotificationRegistrationKey(namespaceEntity.getCode(), oldStorageUnitNotificationRegistrationName), request.getStorageUnitNotificationFilter(), request.getJobActions(), notificationRegistrationStatusEntity);
    // Persist the new entity.
    newStorageUnitNotificationRegistrationEntity = storageUnitNotificationRegistrationDao.saveAndRefresh(newStorageUnitNotificationRegistrationEntity);
    // Create and return the storage unit notification object from the persisted entity.
    return createStorageUnitNotificationFromEntity(newStorageUnitNotificationRegistrationEntity);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) NotificationEventTypeEntity(org.finra.herd.model.jpa.NotificationEventTypeEntity) JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) NotificationRegistrationStatusEntity(org.finra.herd.model.jpa.NotificationRegistrationStatusEntity) StorageUnitNotificationRegistrationEntity(org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) NamespacePermissions(org.finra.herd.model.annotation.NamespacePermissions)

Example 3 with BusinessObjectDefinitionKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionKey in project herd by FINRAOS.

the class StorageUnitNotificationRegistrationServiceImpl method createStorageUnitNotificationRegistration.

@NamespacePermissions({ @NamespacePermission(fields = "#request?.storageUnitNotificationRegistrationKey?.namespace", permissions = NamespacePermissionEnum.WRITE), @NamespacePermission(fields = "#request?.storageUnitNotificationFilter?.namespace", permissions = NamespacePermissionEnum.READ), @NamespacePermission(fields = "#request?.jobActions?.![namespace]", permissions = NamespacePermissionEnum.EXECUTE) })
@Override
public StorageUnitNotificationRegistration createStorageUnitNotificationRegistration(StorageUnitNotificationRegistrationCreateRequest request) {
    // Validate and trim the request parameters.
    validateStorageUnitNotificationRegistrationCreateRequest(request);
    // Get the notification registration key.
    NotificationRegistrationKey notificationRegistrationKey = request.getStorageUnitNotificationRegistrationKey();
    // Retrieve and ensure that notification registration namespace exists.
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(notificationRegistrationKey.getNamespace());
    // Retrieve and validate the notification event type entity.
    NotificationEventTypeEntity notificationEventTypeEntity = getAndValidateNotificationEventTypeEntity(request.getStorageUnitEventType());
    // Validate the notification event type.
    Assert.isTrue(NotificationEventTypeEntity.EventTypesStorageUnit.STRGE_UNIT_STTS_CHG.name().equalsIgnoreCase(request.getStorageUnitEventType()), String.format("Notification event type \"%s\" is not supported for storage unit notification registration.", request.getStorageUnitEventType()));
    // Get the storage unit notification filter.
    StorageUnitNotificationFilter filter = request.getStorageUnitNotificationFilter();
    // Retrieve and ensure that business object definition exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(filter.getNamespace(), filter.getBusinessObjectDefinitionName()));
    // If specified, retrieve and ensure that file type exists.
    FileTypeEntity fileTypeEntity = null;
    if (StringUtils.isNotBlank(filter.getBusinessObjectFormatFileType())) {
        fileTypeEntity = fileTypeDaoHelper.getFileTypeEntity(filter.getBusinessObjectFormatFileType());
    }
    // Retrieve and ensure that storage exists.
    StorageEntity storageEntity = storageDaoHelper.getStorageEntity(filter.getStorageName());
    // If specified, retrieve and ensure that new storage unit status exists.
    StorageUnitStatusEntity newStorageUnitStatus = null;
    if (StringUtils.isNotBlank(filter.getNewStorageUnitStatus())) {
        newStorageUnitStatus = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(filter.getNewStorageUnitStatus());
    }
    // If specified, retrieve and ensure that old storage unit status exists.
    StorageUnitStatusEntity oldStorageUnitStatus = null;
    if (StringUtils.isNotBlank(filter.getOldStorageUnitStatus())) {
        oldStorageUnitStatus = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(filter.getOldStorageUnitStatus());
    }
    // TODO: We need to add a null/empty list check here, if/when list of job actions will become optional (due to addition of other action types).
    for (JobAction jobAction : request.getJobActions()) {
        // Ensure that job definition exists.
        jobDefinitionDaoHelper.getJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName());
    }
    // If specified, retrieve and validate the notification registration status entity. Otherwise, default it to ENABLED.
    NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDaoHelper.getNotificationRegistrationStatusEntity(StringUtils.isNotBlank(request.getNotificationRegistrationStatus()) ? request.getNotificationRegistrationStatus() : NotificationRegistrationStatusEntity.ENABLED);
    // Ensure a storage unit notification with the specified name doesn't already exist for the specified namespace.
    StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = storageUnitNotificationRegistrationDao.getStorageUnitNotificationRegistrationByAltKey(notificationRegistrationKey);
    if (storageUnitNotificationRegistrationEntity != null) {
        throw new AlreadyExistsException(String.format("Unable to create storage unit notification with name \"%s\" because it already exists for namespace \"%s\".", notificationRegistrationKey.getNotificationName(), notificationRegistrationKey.getNamespace()));
    }
    // Create a storage unit notification registration entity from the request information.
    storageUnitNotificationRegistrationEntity = createStorageUnitNotificationEntity(namespaceEntity, notificationEventTypeEntity, businessObjectDefinitionEntity, fileTypeEntity, storageEntity, newStorageUnitStatus, oldStorageUnitStatus, request.getStorageUnitNotificationRegistrationKey(), request.getStorageUnitNotificationFilter(), request.getJobActions(), notificationRegistrationStatusEntity);
    // Persist the new entity.
    storageUnitNotificationRegistrationEntity = storageUnitNotificationRegistrationDao.saveAndRefresh(storageUnitNotificationRegistrationEntity);
    // Create and return the storage unit notification object from the persisted entity.
    return createStorageUnitNotificationFromEntity(storageUnitNotificationRegistrationEntity);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) NotificationEventTypeEntity(org.finra.herd.model.jpa.NotificationEventTypeEntity) JobAction(org.finra.herd.model.api.xml.JobAction) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) StorageUnitStatusEntity(org.finra.herd.model.jpa.StorageUnitStatusEntity) NotificationRegistrationStatusEntity(org.finra.herd.model.jpa.NotificationRegistrationStatusEntity) StorageUnitNotificationFilter(org.finra.herd.model.api.xml.StorageUnitNotificationFilter) StorageUnitNotificationRegistrationEntity(org.finra.herd.model.jpa.StorageUnitNotificationRegistrationEntity) NotificationRegistrationKey(org.finra.herd.model.api.xml.NotificationRegistrationKey) NamespacePermissions(org.finra.herd.model.annotation.NamespacePermissions)

Example 4 with BusinessObjectDefinitionKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionKey in project herd by FINRAOS.

the class UploadDownloadServiceImpl method initiateDownloadSingleSampleFile.

@Override
public DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse initiateDownloadSingleSampleFile(DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest request) {
    // Validate and trim the request parameters.
    validateDownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(request);
    // Get the business object definition sample data file key.
    BusinessObjectDefinitionSampleDataFileKey businessObjectDefinitionSampleDataFileKey = request.getBusinessObjectDefinitionSampleDataFileKey();
    // Get the business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(businessObjectDefinitionSampleDataFileKey.getNamespace(), businessObjectDefinitionSampleDataFileKey.getBusinessObjectDefinitionName());
    // Get the business object definition entity and ensure it exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
    // Get the sample data file exists for the business object definition and ensure it exists.
    BusinessObjectDefinitionSampleDataFileEntity businessObjectDefinitionSampleDataFileEntity = getBusinessObjectDefinitionSampleDataFileEntity(businessObjectDefinitionEntity, businessObjectDefinitionSampleDataFileKey);
    // Retrieve the storage related information.
    StorageEntity storageEntity = businessObjectDefinitionSampleDataFileEntity.getStorage();
    String s3BucketName = storageHelper.getStorageBucketName(storageEntity);
    String s3ObjectKey = businessObjectDefinitionSampleDataFileKey.getDirectoryPath() + businessObjectDefinitionSampleDataFileKey.getFileName();
    String sessionID = UUID.randomUUID().toString();
    // Get the temporary credentials.
    Credentials downloaderCredentials = getDownloaderCredentialsNoKmsKey(storageEntity, sessionID, s3ObjectKey);
    // Generate a pre-signed URL.
    Date expiration = downloaderCredentials.getExpiration();
    S3FileTransferRequestParamsDto s3BucketAccessParams = storageHelper.getS3BucketAccessParams(storageEntity);
    String presignedUrl = s3Dao.generateGetObjectPresignedUrl(s3BucketName, s3ObjectKey, expiration, s3BucketAccessParams);
    // Create the download business object definition sample data file single initiation response.
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse response = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse();
    response.setBusinessObjectDefinitionSampleDataFileKey(new BusinessObjectDefinitionSampleDataFileKey(businessObjectDefinitionEntity.getNamespace().getCode(), businessObjectDefinitionEntity.getName(), businessObjectDefinitionSampleDataFileEntity.getDirectoryPath(), businessObjectDefinitionSampleDataFileEntity.getFileName()));
    response.setAwsS3BucketName(s3BucketName);
    response.setAwsAccessKey(downloaderCredentials.getAccessKeyId());
    response.setAwsSecretKey(downloaderCredentials.getSecretAccessKey());
    response.setAwsSessionToken(downloaderCredentials.getSessionToken());
    response.setAwsSessionExpirationTime(HerdDateUtils.getXMLGregorianCalendarValue(expiration));
    response.setPreSignedUrl(presignedUrl);
    // Return the response.
    return response;
}
Also used : BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse) S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectDefinitionSampleDataFileEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSampleDataFileEntity) Credentials(com.amazonaws.services.securitytoken.model.Credentials) Date(java.util.Date)

Example 5 with BusinessObjectDefinitionKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionKey in project herd by FINRAOS.

the class RelationalTableRegistrationHelperServiceImpl method getRelationalStorageAttributesImpl.

/**
 * Gets storage attributes required to perform relation table registration. This method also validates database entities per specified relational table
 * registration create request.
 *
 * @param relationalTableRegistrationCreateRequest the relational table registration create request
 * @param appendToExistingBusinessObjectDefinition boolean flag that determines if the format should be appended to an existing business object definition
 *
 * @return the relational storage attributes DtO
 */
RelationalStorageAttributesDto getRelationalStorageAttributesImpl(RelationalTableRegistrationCreateRequest relationalTableRegistrationCreateRequest, Boolean appendToExistingBusinessObjectDefinition) {
    // Validate that specified namespace exists.
    namespaceDaoHelper.getNamespaceEntity(relationalTableRegistrationCreateRequest.getNamespace());
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(relationalTableRegistrationCreateRequest.getNamespace(), relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionName());
    // Ensure that a business object definition with the specified key doesn't already exist.
    if (BooleanUtils.isNotTrue(appendToExistingBusinessObjectDefinition) && businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(businessObjectDefinitionKey) != null) {
        throw new AlreadyExistsException(String.format("Business object definition with name \"%s\" already exists for namespace \"%s\".", businessObjectDefinitionKey.getBusinessObjectDefinitionName(), businessObjectDefinitionKey.getNamespace()));
    }
    // Get the latest format version for this business format, if it exists.
    BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(relationalTableRegistrationCreateRequest.getNamespace(), relationalTableRegistrationCreateRequest.getBusinessObjectDefinitionName(), relationalTableRegistrationCreateRequest.getBusinessObjectFormatUsage(), FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, null));
    // If the latest version exists, fail with an already exists exception.
    if (latestVersionBusinessObjectFormatEntity != null) {
        throw new AlreadyExistsException(String.format("Format with file type \"%s\" and usage \"%s\" already exists for business object definition \"%s\".", latestVersionBusinessObjectFormatEntity.getFileType().getCode(), latestVersionBusinessObjectFormatEntity.getUsage(), latestVersionBusinessObjectFormatEntity.getBusinessObjectDefinition().getName()));
    }
    // Validate that specified data provider exists.
    dataProviderDaoHelper.getDataProviderEntity(relationalTableRegistrationCreateRequest.getDataProviderName());
    // Get the storage.
    StorageEntity storageEntity = storageDaoHelper.getStorageEntity(relationalTableRegistrationCreateRequest.getStorageName());
    // Only RELATIONAL storage platform is supported for the relational table registration feature.
    Assert.isTrue(storageEntity.getStoragePlatform().getName().equals(StoragePlatformEntity.RELATIONAL), String.format("Cannot register relational table in \"%s\" storage of %s storage platform type. Only %s storage platform type is supported by this feature.", storageEntity.getName(), storageEntity.getStoragePlatform().getName(), StoragePlatformEntity.RELATIONAL));
    // Get JDBC URL for this storage. This storage attribute is required and must have a non-blank value.
    String jdbcUrl = storageHelper.getStorageAttributeValueByName(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_URL), storageEntity, true, true);
    // Get JDBC username for this storage. This storage attribute is not required and it is allowed to have a blank value.
    String jdbcUsername = storageHelper.getStorageAttributeValueByName(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_USERNAME), storageEntity, false, false);
    // Get JDBC user credential name for this storage. This storage attribute is not required and it is allowed to have a blank value.
    String jdbcUserCredentialName = storageHelper.getStorageAttributeValueByName(configurationHelper.getProperty(ConfigurationValue.STORAGE_ATTRIBUTE_NAME_JDBC_USER_CREDENTIAL_NAME), storageEntity, false, false);
    // Create and initialize a relational storage attributes DTO.
    RelationalStorageAttributesDto relationalStorageAttributesDto = new RelationalStorageAttributesDto();
    relationalStorageAttributesDto.setJdbcUrl(jdbcUrl);
    relationalStorageAttributesDto.setJdbcUsername(jdbcUsername);
    relationalStorageAttributesDto.setJdbcUserCredentialName(jdbcUserCredentialName);
    return relationalStorageAttributesDto;
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) RelationalStorageAttributesDto(org.finra.herd.model.dto.RelationalStorageAttributesDto) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) StorageEntity(org.finra.herd.model.jpa.StorageEntity) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity)

Aggregations

BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)187 Test (org.junit.Test)152 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)73 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)44 TagKey (org.finra.herd.model.api.xml.TagKey)39 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)34 Attribute (org.finra.herd.model.api.xml.Attribute)32 ArrayList (java.util.ArrayList)21 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)16 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)16 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)15 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)14 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)13 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)13 StorageEntity (org.finra.herd.model.jpa.StorageEntity)13 BusinessObjectDefinitionTagKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKeys)12 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)11 BusinessObjectDefinitionUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest)11 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)11 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)11