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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations