BusinessObjectFormatServiceImpl implements BusinessObjectFormatService { @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 must be specified."); Assert.notNull(updateRequest.isRecordFlag(), "A record flag in business object format retention information update request must be specified."); businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, false); Assert.isNull(businessObjectFormatKey.getBusinessObjectFormatVersion(), "Business object format version must not be specified."); RetentionTypeEntity recordRetentionTypeEntity = null; if (updateRequest.getRetentionType() != null) { updateRequest.setRetentionType(updateRequest.getRetentionType().trim()); recordRetentionTypeEntity = businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(updateRequest.getRetentionType()); if (recordRetentionTypeEntity.getCode().equals(RetentionTypeEntity.PARTITION_VALUE)) { Assert.notNull(updateRequest.getRetentionPeriodInDays(), String.format("A retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE)); Assert.isTrue(updateRequest.getRetentionPeriodInDays() > 0, String.format("A positive retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE)); } else { Assert.isNull(updateRequest.getRetentionPeriodInDays(), String.format("A retention period in days cannot be specified for %s retention type.", recordRetentionTypeEntity.getCode())); } } else { Assert.isNull(updateRequest.getRetentionPeriodInDays(), "A retention period in days cannot be specified without retention type."); } BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey); businessObjectFormatEntity.setRecordFlag(BooleanUtils.isTrue(updateRequest.isRecordFlag())); businessObjectFormatEntity.setRetentionPeriodInDays(updateRequest.getRetentionPeriodInDays()); businessObjectFormatEntity.setRetentionType(recordRetentionTypeEntity); businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity); return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity); }  @PublishNotificationMessages @NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat createBusinessObjectFormat(BusinessObjectFormatCreateRequest request); @PublishNotificationMessages @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat updateBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatUpdateRequest request); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectFormat getBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat deleteBusinessObjectFormat(BusinessObjectFormatKey businessObjectFormatKey); @Override BusinessObjectFormatKeys getBusinessObjectFormats(BusinessObjectDefinitionKey businessObjectDefinitionKey, boolean latestBusinessObjectFormatVersion); @Override BusinessObjectFormatKeys getBusinessObjectFormatsWithFilters(BusinessObjectDefinitionKey businessObjectDefinitionKey,
        String businessObjectFormatUsage, boolean latestBusinessObjectFormatVersion); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectFormatDdl generateBusinessObjectFormatDdl(BusinessObjectFormatDdlRequest request); @NamespacePermission(fields = "#request?.businessObjectFormatDdlRequests?.![namespace]", permissions = NamespacePermissionEnum.READ) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectFormatDdlCollectionResponse generateBusinessObjectFormatDdlCollection(BusinessObjectFormatDdlCollectionRequest request); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = {NamespacePermissionEnum.WRITE, NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT}) @Override BusinessObjectFormat updateBusinessObjectFormatParents(BusinessObjectFormatKey businessObjectFormatKey,
        BusinessObjectFormatParentsUpdateRequest businessObjectFormatParentsUpdateRequest); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat updateBusinessObjectFormatAttributes(BusinessObjectFormatKey businessObjectFormatKey,
        BusinessObjectFormatAttributesUpdateRequest businessObjectFormatAttributesUpdateRequest); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat updateBusinessObjectFormatAttributeDefinitions(BusinessObjectFormatKey businessObjectFormatKey,
        BusinessObjectFormatAttributeDefinitionsUpdateRequest businessObjectFormatAttributeDefinitionsUpdateRequest); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat updateBusinessObjectFormatRetentionInformation(BusinessObjectFormatKey businessObjectFormatKey,
        BusinessObjectFormatRetentionInformationUpdateRequest updateRequest); @NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override BusinessObjectFormat updateBusinessObjectFormatSchemaBackwardsCompatibilityChanges(BusinessObjectFormatKey businessObjectFormatKey,
        BusinessObjectFormatSchemaBackwardsCompatibilityUpdateRequest businessObjectFormatSchemaBackwardsCompatibilityUpdateRequest); static final Set<String> SCHEMA_COLUMN_DATA_TYPES_WITH_ALLOWED_SIZE_INCREASE; }
@Test public void testUpdateBusinessObjectFormatRetentionInformationMissingRequiredParameters() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, null); fail(); } catch (IllegalArgumentException e) { assertEquals("A business object format retention information update request must be specified.", e.getMessage()); } try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(null, RETENTION_PERIOD_DAYS, RetentionTypeEntity.PARTITION_VALUE)); fail(); } catch (IllegalArgumentException e) { assertEquals("A record flag in business object format retention information update request must be specified.", e.getMessage()); } verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationNoRetentionType() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); BusinessObjectFormatRetentionInformationUpdateRequest businessObjectFormatRetentionInformationUpdateRequest = new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, NO_RETENTION_PERIOD_IN_DAYS, NO_RETENTION_TYPE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(); businessObjectFormat.setId(ID); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity)).thenReturn(businessObjectFormat); BusinessObjectFormat result = businessObjectFormatServiceImpl .updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, businessObjectFormatRetentionInformationUpdateRequest); verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectFormatDao).saveAndRefresh(businessObjectFormatEntity); verify(businessObjectFormatHelper).createBusinessObjectFormatFromEntity(businessObjectFormatEntity); verifyNoMoreInteractionsHelper(); assertEquals(businessObjectFormat, result); assertEquals(businessObjectFormatEntity.isRecordFlag(), RECORD_FLAG_SET); assertEquals(businessObjectFormatEntity.getRetentionPeriodInDays(), NO_RETENTION_PERIOD_IN_DAYS); assertNull(businessObjectFormatEntity.getRetentionType()); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationNoRetentionTypeWithRetentionPeriodInDays() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, RETENTION_PERIOD_DAYS, NO_RETENTION_TYPE)); fail(); } catch (IllegalArgumentException e) { assertEquals("A retention period in days cannot be specified without retention type.", e.getMessage()); } verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationPartitionValueRetentionType() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); BusinessObjectFormatRetentionInformationUpdateRequest businessObjectFormatRetentionInformationUpdateRequest = new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, RETENTION_PERIOD_DAYS, RetentionTypeEntity.PARTITION_VALUE); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(); businessObjectFormat.setId(ID); when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE)).thenReturn(retentionTypeEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity)).thenReturn(businessObjectFormat); BusinessObjectFormat result = businessObjectFormatServiceImpl .updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, businessObjectFormatRetentionInformationUpdateRequest); verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectFormatDao).saveAndRefresh(businessObjectFormatEntity); verify(businessObjectFormatHelper).createBusinessObjectFormatFromEntity(businessObjectFormatEntity); verifyNoMoreInteractionsHelper(); assertEquals(businessObjectFormat, result); assertEquals(businessObjectFormatEntity.isRecordFlag(), RECORD_FLAG_SET); assertEquals(businessObjectFormatEntity.getRetentionPeriodInDays(), RETENTION_PERIOD_DAYS); assertEquals(businessObjectFormatEntity.getRetentionType(), retentionTypeEntity); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationPartitionValueRetentionTypeMissingRetentionPeriodInDays() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE); when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE)).thenReturn(retentionTypeEntity); try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, NO_RETENTION_PERIOD_IN_DAYS, RetentionTypeEntity.PARTITION_VALUE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE), e.getMessage()); } verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationPartitionValueRetentionTypeNonPositiveRetentionPeriodInDays() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE); when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE)).thenReturn(retentionTypeEntity); try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, 0, RetentionTypeEntity.PARTITION_VALUE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A positive retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE), e.getMessage()); } verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationRetentionDateRetentionType() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); BusinessObjectFormatRetentionInformationUpdateRequest businessObjectFormatRetentionInformationUpdateRequest = new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, NO_RETENTION_PERIOD_IN_DAYS, RetentionTypeEntity.BDATA_RETENTION_DATE); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity(); BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat(); businessObjectFormat.setId(ID); when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE)).thenReturn(retentionTypeEntity); when(businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity)).thenReturn(businessObjectFormatEntity); when(businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity)).thenReturn(businessObjectFormat); BusinessObjectFormat result = businessObjectFormatServiceImpl .updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, businessObjectFormatRetentionInformationUpdateRequest); verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE); verify(businessObjectFormatDaoHelper).getBusinessObjectFormatEntity(businessObjectFormatKey); verify(businessObjectFormatDao).saveAndRefresh(businessObjectFormatEntity); verify(businessObjectFormatHelper).createBusinessObjectFormatFromEntity(businessObjectFormatEntity); verifyNoMoreInteractionsHelper(); assertEquals(businessObjectFormat, result); assertEquals(businessObjectFormatEntity.isRecordFlag(), RECORD_FLAG_SET); assertEquals(businessObjectFormatEntity.getRetentionPeriodInDays(), NO_RETENTION_PERIOD_IN_DAYS); assertEquals(businessObjectFormatEntity.getRetentionType(), retentionTypeEntity); }
@Test public void testUpdateBusinessObjectFormatRetentionInformationRetentionDateRetentionTypeWithRetentionPeriodInDays() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE)).thenReturn(retentionTypeEntity); try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, RETENTION_PERIOD_DAYS, RetentionTypeEntity.BDATA_RETENTION_DATE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A retention period in days cannot be specified for %s retention type.", RetentionTypeEntity.BDATA_RETENTION_DATE), e.getMessage()); } verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE); verifyNoMoreInteractionsHelper(); }