Search in sources :

Example 11 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity 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 12 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionSubjectMatterExpertServiceImpl method getBusinessObjectDefinitionSubjectMatterExpertsByBusinessObjectDefinition.

@Override
public BusinessObjectDefinitionSubjectMatterExpertKeys getBusinessObjectDefinitionSubjectMatterExpertsByBusinessObjectDefinition(BusinessObjectDefinitionKey businessObjectDefinitionKey) {
    // Validate and trim the business object definition key.
    businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey);
    // Retrieve the business object definition and ensure it exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
    // Create and populate a list of business object definition subject matter expert keys.
    BusinessObjectDefinitionSubjectMatterExpertKeys businessObjectDefinitionSubjectMatterExpertKeys = new BusinessObjectDefinitionSubjectMatterExpertKeys();
    for (BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity : businessObjectDefinitionEntity.getSubjectMatterExperts()) {
        businessObjectDefinitionSubjectMatterExpertKeys.getBusinessObjectDefinitionSubjectMatterExpertKeys().add(getBusinessObjectDefinitionSubjectMatterExpertKey(businessObjectDefinitionSubjectMatterExpertEntity));
    }
    return businessObjectDefinitionSubjectMatterExpertKeys;
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionSubjectMatterExpertKeys(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKeys) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)

Example 13 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionSubjectMatterExpertServiceImpl method createBusinessObjectDefinitionSubjectMatterExpert.

@NamespacePermission(fields = "#request.businessObjectDefinitionSubjectMatterExpertKey.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionSubjectMatterExpert createBusinessObjectDefinitionSubjectMatterExpert(BusinessObjectDefinitionSubjectMatterExpertCreateRequest request) {
    // Validate and trim the business object definition subject matter expert create request.
    validateBusinessObjectDefinitionSubjectMatterExpertCreateRequest(request);
    // Get the business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(request.getBusinessObjectDefinitionSubjectMatterExpertKey().getNamespace(), request.getBusinessObjectDefinitionSubjectMatterExpertKey().getBusinessObjectDefinitionName());
    // Get the business object definition and ensure it exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
    // Ensure a business object definition subject matter expert with the specified name doesn't already exist for the business object definition.
    if (businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionEntity, request.getBusinessObjectDefinitionSubjectMatterExpertKey().getUserId()) != null) {
        throw new AlreadyExistsException(String.format("Unable to create business object definition subject matter expert with user id \"%s\" " + "because it already exists for the business object definition {%s}.", request.getBusinessObjectDefinitionSubjectMatterExpertKey().getUserId(), businessObjectDefinitionHelper.businessObjectDefinitionKeyToString(businessObjectDefinitionKey)));
    }
    // Create a business object definition subject matter expert entity from the request information.
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = createBusinessObjectDefinitionSubjectMatterExpertEntity(businessObjectDefinitionEntity, request);
    // Persist the new entity.
    businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDao.saveAndRefresh(businessObjectDefinitionSubjectMatterExpertEntity);
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Create and return the business object definition subject matter expert object from the persisted entity.
    return createBusinessObjectDefinitionSubjectMatterExpertFromEntity(businessObjectDefinitionSubjectMatterExpertEntity);
}
Also used : AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 14 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method createBusinessObjectFormat.

@PublishNotificationMessages
@NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat createBusinessObjectFormat(BusinessObjectFormatCreateRequest request) {
    // Perform the validation of the request parameters, except for the alternate key.
    validateBusinessObjectFormatCreateRequest(request);
    // Get business object format key from the request.
    BusinessObjectFormatKey businessObjectFormatKey = getBusinessObjectFormatKey(request);
    // Get the business object definition and ensure it exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(new BusinessObjectDefinitionKey(businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName()));
    // Get business object format file type and ensure it exists.
    FileTypeEntity fileTypeEntity = fileTypeDaoHelper.getFileTypeEntity(request.getBusinessObjectFormatFileType());
    // Get the latest format version for this business format, if it exists.
    BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey);
    // If the latest version exists, perform the additive schema validation and update the latest entity.
    if (latestVersionBusinessObjectFormatEntity != null) {
        // Get the latest version business object format model object.
        BusinessObjectFormat latestVersionBusinessObjectFormat = businessObjectFormatHelper.createBusinessObjectFormatFromEntity(latestVersionBusinessObjectFormatEntity);
        // If the latest version format has schema, check the new format version schema is "additive" to the previous format version.
        if (latestVersionBusinessObjectFormat.getSchema() != null) {
            validateNewSchemaIsAdditiveToOldSchema(request.getSchema(), latestVersionBusinessObjectFormat.getSchema());
        }
        // Update the latest entity.
        latestVersionBusinessObjectFormatEntity.setLatestVersion(false);
        businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity);
    }
    // Create a business object format entity from the request information.
    Integer businessObjectFormatVersion = latestVersionBusinessObjectFormatEntity == null ? 0 : latestVersionBusinessObjectFormatEntity.getBusinessObjectFormatVersion() + 1;
    BusinessObjectFormatEntity newBusinessObjectFormatEntity = createBusinessObjectFormatEntity(request, businessObjectDefinitionEntity, fileTypeEntity, businessObjectFormatVersion, null);
    // latest version format is the descriptive format for the bdef, update the bdef descriptive format to the newly created one
    if (latestVersionBusinessObjectFormatEntity != null && latestVersionBusinessObjectFormatEntity.equals(businessObjectDefinitionEntity.getDescriptiveBusinessObjectFormat())) {
        businessObjectDefinitionEntity.setDescriptiveBusinessObjectFormat(newBusinessObjectFormatEntity);
        businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
    }
    // latest version business object exists, carry the retention information to the new entity
    if (latestVersionBusinessObjectFormatEntity != null) {
        // for each of the previous version's  child, remove the parent link to the previous version and set the parent to the new version
        for (BusinessObjectFormatEntity childFormatEntity : latestVersionBusinessObjectFormatEntity.getBusinessObjectFormatChildren()) {
            childFormatEntity.getBusinessObjectFormatParents().remove(latestVersionBusinessObjectFormatEntity);
            childFormatEntity.getBusinessObjectFormatParents().add(newBusinessObjectFormatEntity);
            newBusinessObjectFormatEntity.getBusinessObjectFormatChildren().add(childFormatEntity);
            businessObjectFormatDao.saveAndRefresh(childFormatEntity);
        }
        // for each of the previous version's parent, remove the child link to the previous version and set the child link to the new version
        for (BusinessObjectFormatEntity parentFormatEntity : latestVersionBusinessObjectFormatEntity.getBusinessObjectFormatParents()) {
            parentFormatEntity.getBusinessObjectFormatChildren().remove(latestVersionBusinessObjectFormatEntity);
            parentFormatEntity.getBusinessObjectFormatChildren().add(newBusinessObjectFormatEntity);
            newBusinessObjectFormatEntity.getBusinessObjectFormatParents().add(parentFormatEntity);
            businessObjectFormatDao.saveAndRefresh(parentFormatEntity);
        }
        // mark the latest version business object format
        latestVersionBusinessObjectFormatEntity.setBusinessObjectFormatParents(null);
        latestVersionBusinessObjectFormatEntity.setBusinessObjectFormatChildren(null);
        // carry the retention information from the latest entity to the new entity
        newBusinessObjectFormatEntity.setRetentionPeriodInDays(latestVersionBusinessObjectFormatEntity.getRetentionPeriodInDays());
        newBusinessObjectFormatEntity.setRecordFlag(latestVersionBusinessObjectFormatEntity.isRecordFlag());
        newBusinessObjectFormatEntity.setRetentionType(latestVersionBusinessObjectFormatEntity.getRetentionType());
        businessObjectFormatDao.saveAndRefresh(newBusinessObjectFormatEntity);
        // reset the retention information of the latest version business object format
        latestVersionBusinessObjectFormatEntity.setRetentionType(null);
        latestVersionBusinessObjectFormatEntity.setRecordFlag(null);
        latestVersionBusinessObjectFormatEntity.setRetentionPeriodInDays(null);
        businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity);
    }
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Create a version change notification to be sent on create business object format event.
    messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatHelper.getBusinessObjectFormatKey(newBusinessObjectFormatEntity), latestVersionBusinessObjectFormatEntity != null ? latestVersionBusinessObjectFormatEntity.getBusinessObjectFormatVersion().toString() : "");
    // Create and return the business object format object from the persisted entity.
    return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(newBusinessObjectFormatEntity);
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) FileTypeEntity(org.finra.herd.model.jpa.FileTypeEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) PublishNotificationMessages(org.finra.herd.model.annotation.PublishNotificationMessages) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 15 with BusinessObjectDefinitionEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionColumnServiceImpl method getBusinessObjectDefinitionColumns.

@Override
public BusinessObjectDefinitionColumnKeys getBusinessObjectDefinitionColumns(BusinessObjectDefinitionKey businessObjectDefinitionKey) {
    // Validate and trim the business object definition key.
    businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey);
    // Retrieve the business object definition and ensure it exists.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey);
    // Create and populate a list of business object definition column keys.
    BusinessObjectDefinitionColumnKeys businessObjectDefinitionColumnKeys = new BusinessObjectDefinitionColumnKeys();
    for (BusinessObjectDefinitionColumnEntity businessObjectDefinitionColumnEntity : businessObjectDefinitionEntity.getColumns()) {
        businessObjectDefinitionColumnKeys.getBusinessObjectDefinitionColumnKeys().add(getBusinessObjectDefinitionColumnKey(businessObjectDefinitionColumnEntity));
    }
    return businessObjectDefinitionColumnKeys;
}
Also used : BusinessObjectDefinitionColumnKeys(org.finra.herd.model.api.xml.BusinessObjectDefinitionColumnKeys) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionColumnEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionColumnEntity)

Aggregations

BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)164 Test (org.junit.Test)78 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)75 ArrayList (java.util.ArrayList)54 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)40 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)39 FileTypeEntity (org.finra.herd.model.jpa.FileTypeEntity)38 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)33 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)32 Predicate (javax.persistence.criteria.Predicate)31 StorageEntity (org.finra.herd.model.jpa.StorageEntity)23 Attribute (org.finra.herd.model.api.xml.Attribute)19 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)15 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)15 TagEntity (org.finra.herd.model.jpa.TagEntity)15 SearchIndexUpdateDto (org.finra.herd.model.dto.SearchIndexUpdateDto)13 BusinessObjectDataStatusEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusEntity)12 BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)12 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)12 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)10