Search in sources :

Example 26 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectDataNotificationRegistrationServiceImpl method getBusinessObjectDataNotificationRegistrationsByNotificationFilter.

@NamespacePermission(fields = "#businessObjectDataNotificationFilter?.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataNotificationRegistrationKeys getBusinessObjectDataNotificationRegistrationsByNotificationFilter(BusinessObjectDataNotificationFilter businessObjectDataNotificationFilter) {
    // Validate and trim the business object data notification filter parameters.
    validateBusinessObjectDataNotificationFilterBusinessObjectDefinitionFields(businessObjectDataNotificationFilter);
    trimBusinessObjectDataNotificationFilterBusinessObjectFormatFields(businessObjectDataNotificationFilter);
    // Create and populate a list of business object data notification registration keys.
    BusinessObjectDataNotificationRegistrationKeys businessObjectDataNotificationKeys = new BusinessObjectDataNotificationRegistrationKeys();
    businessObjectDataNotificationKeys.getBusinessObjectDataNotificationRegistrationKeys().addAll(businessObjectDataNotificationRegistrationDao.getBusinessObjectDataNotificationRegistrationKeysByNotificationFilter(businessObjectDataNotificationFilter));
    return businessObjectDataNotificationKeys;
}
Also used : BusinessObjectDataNotificationRegistrationKeys(org.finra.herd.model.api.xml.BusinessObjectDataNotificationRegistrationKeys) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 27 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectDataServiceImpl method getAllBusinessObjectDataByBusinessObjectFormat.

@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataKeys getAllBusinessObjectDataByBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey) {
    // Perform validation and trim. Please note that we specify business object format version parameter to be required.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, true);
    // Ensure that a business object definition already exists with the specified name.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    // Get the maximum number of records to return.
    Integer maxResults = configurationHelper.getProperty(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULTS, Integer.class);
    // Gets the list of business object data keys and return them.
    BusinessObjectDataKeys businessObjectDataKeys = new BusinessObjectDataKeys();
    businessObjectDataKeys.getBusinessObjectDataKeys().addAll(businessObjectDataDao.getBusinessObjectDataByBusinessObjectFormat(businessObjectFormatEntity, maxResults));
    return businessObjectDataKeys;
}
Also used : BusinessObjectDataKeys(org.finra.herd.model.api.xml.BusinessObjectDataKeys) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 28 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method updateBusinessObjectFormatRetentionInformation.

@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat updateBusinessObjectFormatRetentionInformation(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatRetentionInformationUpdateRequest updateRequest) {
    Assert.notNull(updateRequest, "A Business Object Format Retention Information Update Request is required.");
    Assert.notNull(updateRequest.isRecordFlag(), "A Record Flag in Business Object Format Retention Information Update Request is required.");
    // Perform validation and trim the alternate key parameters.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, false);
    Assert.isNull(businessObjectFormatKey.getBusinessObjectFormatVersion(), "Business object format version must not be specified.");
    // Retrieve and ensure that record retention type exists if the request's retention type is not null
    RetentionTypeEntity recordRetentionTypeEntity = null;
    if (updateRequest.getRetentionType() != null) {
        Assert.notNull(updateRequest.getRetentionPeriodInDays(), "A retention period in days must be specified when retention type is present.");
        Assert.isTrue(updateRequest.getRetentionPeriodInDays() > 0, "A positive retention period in days must be specified.");
        // Perform trim business object format retention in update request
        updateRequest.setRetentionType(updateRequest.getRetentionType().trim());
        // Retrieve the retention type entity
        recordRetentionTypeEntity = businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(updateRequest.getRetentionType());
    }
    // Retrieve and ensure that a business object format exists.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    businessObjectFormatEntity.setRecordFlag(BooleanUtils.isTrue(updateRequest.isRecordFlag()));
    businessObjectFormatEntity.setRetentionPeriodInDays(updateRequest.getRetentionPeriodInDays());
    businessObjectFormatEntity.setRetentionType(recordRetentionTypeEntity);
    // Persist and refresh the entity.
    businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    // Create and return the business object format object from the persisted entity.
    return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
}
Also used : BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) RetentionTypeEntity(org.finra.herd.model.jpa.RetentionTypeEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 29 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method deleteBusinessObjectFormat.

@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat deleteBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey) {
    // Perform validation and trim the alternate key parameters.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey);
    // Retrieve and ensure that a business object format exists.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    // Get the associated Business Object Definition so we can update the search index
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectFormatEntity.getBusinessObjectDefinition();
    // Check if we are allowed to delete this business object format.
    if (businessObjectDataDao.getBusinessObjectDataCount(businessObjectFormatKey) > 0L) {
        throw new IllegalArgumentException(String.format("Can not delete a business object format that has business object data associated with it. Business object format: {%s}", businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));
    }
    if (!businessObjectFormatEntity.getBusinessObjectFormatChildren().isEmpty()) {
        throw new IllegalArgumentException(String.format("Can not delete a business object format that has children associated with it. Business object format: {%s}", businessObjectFormatHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));
    }
    // Create and return the business object format object from the deleted entity.
    BusinessObjectFormat deletedBusinessObjectFormat = businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
    // Check if business object format being deleted is used as a descriptive format.
    if (businessObjectFormatEntity.equals(businessObjectFormatEntity.getBusinessObjectDefinition().getDescriptiveBusinessObjectFormat())) {
        businessObjectFormatEntity.getBusinessObjectDefinition().setDescriptiveBusinessObjectFormat(null);
        businessObjectDefinitionDao.saveAndRefresh(businessObjectFormatEntity.getBusinessObjectDefinition());
    }
    // Delete this business object format.
    businessObjectFormatDao.delete(businessObjectFormatEntity);
    // If this business object format version is the latest, set the latest flag on the previous version of this object format, if it exists.
    if (businessObjectFormatEntity.getLatestVersion()) {
        // Get the maximum version for this business object format, if it exists.
        Integer maxBusinessObjectFormatVersion = businessObjectFormatDao.getBusinessObjectFormatMaxVersion(businessObjectFormatKey);
        if (maxBusinessObjectFormatVersion != null) {
            // Retrieve the previous version business object format entity. Since we successfully got the maximum
            // version for this business object format, the retrieved entity is not expected to be null.
            BusinessObjectFormatEntity previousVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(new BusinessObjectFormatKey(businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), maxBusinessObjectFormatVersion));
            // Update the previous version business object format entity.
            previousVersionBusinessObjectFormatEntity.setLatestVersion(true);
            // Update the previous version retention information
            previousVersionBusinessObjectFormatEntity.setRecordFlag(businessObjectFormatEntity.isRecordFlag());
            previousVersionBusinessObjectFormatEntity.setRetentionPeriodInDays(businessObjectFormatEntity.getRetentionPeriodInDays());
            previousVersionBusinessObjectFormatEntity.setRetentionType(businessObjectFormatEntity.getRetentionType());
            businessObjectFormatDao.saveAndRefresh(previousVersionBusinessObjectFormatEntity);
        }
    }
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    return deletedBusinessObjectFormat;
}
Also used : 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) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 30 with NamespacePermission

use of org.finra.herd.model.annotation.NamespacePermission in project herd by FINRAOS.

the class BusinessObjectFormatServiceImpl method updateBusinessObjectFormat.

@PublishNotificationMessages
@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public BusinessObjectFormat updateBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatUpdateRequest request) {
    // Perform validation and trim the alternate key parameters.
    businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey);
    // Validate optional attributes. This is also going to trim the attribute names.
    attributeHelper.validateFormatAttributes(request.getAttributes());
    // Retrieve and ensure that a business object format exists.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey);
    // Update business object format description.
    businessObjectFormatEntity.setDescription(request.getDescription());
    // Validate optional schema information.  This is also going to trim the relative schema column field values.
    validateBusinessObjectFormatSchema(request.getSchema(), businessObjectFormatEntity.getPartitionKey());
    // Update business object format attributes
    updateBusinessObjectFormatAttributesHelper(businessObjectFormatEntity, request.getAttributes());
    // Get business object format model object.
    BusinessObjectFormat businessObjectFormat = businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
    // Check if we need to update business object format schema information.
    if ((request.getSchema() != null && !request.getSchema().equals(businessObjectFormat.getSchema())) || (request.getSchema() == null && businessObjectFormat.getSchema() != null)) {
        // TODO: Check if we are allowed to update schema information for this business object format.
        // if (businessObjectFormat.getSchema() != null && herdDao.getBusinessObjectDataCount(businessObjectFormatKey) > 0L)
        // {
        // throw new IllegalArgumentException(String
        // .format("Can not update schema information for a business object format that has an existing schema " +
        // "defined and business object data associated with it. Business object format: {%s}",
        // herdDaoHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity)));
        // }
        // Update schema information by clearing and setting the relative business object
        // format entity fields and by re-creating schema column entities.  Please note that
        // this approach results in changing all schema column Id's which could have
        // ramifications down the road if other entities have relations to schema columns.
        // Also, performance will be slightly slower doing a bunch of deletes followed by a bunch
        // of inserts for what could otherwise be a single SQL statement if only one column was changed.
        // Nevertheless, the below approach results in a simpler code.
        // Removes business object format schema information from the business object format entity.
        clearBusinessObjectFormatSchema(businessObjectFormatEntity);
        // In order to avoid INSERT-then-DELETE, we need to flush the session before we add new schema column entities.
        businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
        // Populates schema information within the business object format entity.
        populateBusinessObjectFormatSchema(businessObjectFormatEntity, request.getSchema());
    }
    // Persist and refresh the entity.
    businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity);
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectFormatEntity.getBusinessObjectDefinition(), SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Create a version change notification to be sent on create business object format event.
    messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity), businessObjectFormatEntity.getBusinessObjectFormatVersion().toString());
    // Create and return the business object format object from the persisted entity.
    return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity);
}
Also used : 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)

Aggregations

NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)63 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)10 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)10 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)10 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)9 AttributeValueListEntity (org.finra.herd.model.jpa.AttributeValueListEntity)6 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)5 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)5 CustomDdlEntity (org.finra.herd.model.jpa.CustomDdlEntity)5 Credentials (com.amazonaws.services.securitytoken.model.Credentials)4 ArrayList (java.util.ArrayList)4 PublishNotificationMessages (org.finra.herd.model.annotation.PublishNotificationMessages)4 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)4 IamRole (org.finra.herd.model.api.xml.IamRole)4 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)4 UserNamespaceAuthorizationEntity (org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)3 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3