/** * Gets a business object format entity based on the alternate key and makes sure that it exists. If a format version isn't specified in the business object * format alternate key, the latest available format version will be used. * * @param businessObjectFormatKey the business object format key * * @return the business object format entity * @throws ObjectNotFoundException if the business object format entity doesn't exist */ public BusinessObjectFormatEntity getBusinessObjectFormatEntity(BusinessObjectFormatKey businessObjectFormatKey) throws ObjectNotFoundException { BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey); if (businessObjectFormatEntity == null) { throw new ObjectNotFoundException(String.format("Business object format with namespace \"%s\", business object definition name \"%s\", " + "format usage \"%s\", format file type \"%s\", and format version \"%d\" doesn't exist.", businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), businessObjectFormatKey.getBusinessObjectFormatVersion())); } return businessObjectFormatEntity; }
@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override public BusinessObjectFormat updateBusinessObjectFormatAttributes(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatAttributesUpdateRequest businessObjectFormatAttributesUpdateRequest) { // Perform validation and trim the alternate key parameters. businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey); Assert.notNull(businessObjectFormatAttributesUpdateRequest, "A business object format attributes update request is required."); Assert.notNull(businessObjectFormatAttributesUpdateRequest.getAttributes(), "A business object format attributes list is required."); List<Attribute> attributes = businessObjectFormatAttributesUpdateRequest.getAttributes(); // Validate optional attributes. This is also going to trim the attribute names. attributeHelper.validateFormatAttributes(attributes); // Retrieve and ensure that a business object format exists. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey); // Update the business object format attributes updateBusinessObjectFormatAttributesHelper(businessObjectFormatEntity, attributes); // 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); }
/** * Deletes an existing partition key group by key. * * @param partitionKeyGroupKey the partition key group key * * @return the partition key group that got deleted */ @Override public PartitionKeyGroup deletePartitionKeyGroup(PartitionKeyGroupKey partitionKeyGroupKey) { // Perform validation and trim. partitionKeyGroupHelper.validatePartitionKeyGroupKey(partitionKeyGroupKey); // Retrieve and ensure that a partition key group already exists with the specified name. PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoHelper.getPartitionKeyGroupEntity(partitionKeyGroupKey); // Check if we are allowed to delete this business object format. if (businessObjectFormatDao.getBusinessObjectFormatCountByPartitionKeyGroup(partitionKeyGroupEntity) > 0L) { throw new IllegalArgumentException(String.format("Can not delete \"%s\" partition key group since it is being used by a business object format.", partitionKeyGroupKey.getPartitionKeyGroupName())); } // Delete the partition key group. partitionKeyGroupDao.delete(partitionKeyGroupEntity); // Create and return the partition key group object from the deleted entity. return createPartitionKeyGroupFromEntity(partitionKeyGroupEntity); }
businessObjectFormatDao.delete(businessObjectFormatEntity); Integer maxBusinessObjectFormatVersion = businessObjectFormatDao.getBusinessObjectFormatMaxVersion(businessObjectFormatKey); BusinessObjectFormatEntity previousVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey( new BusinessObjectFormatKey(businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), businessObjectFormatDao.saveAndRefresh(previousVersionBusinessObjectFormatEntity);
BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey); businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity); childFormatEntity.getBusinessObjectFormatParents().add(newBusinessObjectFormatEntity); newBusinessObjectFormatEntity.getBusinessObjectFormatChildren().add(childFormatEntity); businessObjectFormatDao.saveAndRefresh(childFormatEntity); parentFormatEntity.getBusinessObjectFormatChildren().add(newBusinessObjectFormatEntity); newBusinessObjectFormatEntity.getBusinessObjectFormatParents().add(parentFormatEntity); businessObjectFormatDao.saveAndRefresh(parentFormatEntity); businessObjectFormatDao.saveAndRefresh(newBusinessObjectFormatEntity); businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity);
@Override public BusinessObjectFormatKeys getBusinessObjectFormats(BusinessObjectDefinitionKey businessObjectDefinitionKey, boolean latestBusinessObjectFormatVersion) { // Perform validation and trim. businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey); // Ensure that a business object definition already exists with the specified name. businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey); // Gets the list of keys and return them. BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys(); businessObjectFormatKeys.getBusinessObjectFormatKeys() .addAll(businessObjectFormatDao.getBusinessObjectFormats(businessObjectDefinitionKey, latestBusinessObjectFormatVersion)); return businessObjectFormatKeys; }
@Override public BusinessObjectFormatKeys getBusinessObjectFormatsWithFilters(BusinessObjectDefinitionKey businessObjectDefinitionKey, String businessObjectFormatUsage, boolean latestBusinessObjectFormatVersion) { // Perform validation and trim. businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey); // Perform Validation and trim of businessObjectFormatUsage businessObjectFormatUsage = alternateKeyHelper.validateStringParameter("business object format usage", businessObjectFormatUsage); // Ensure that a business object definition already exists with the specified name. businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey); // Gets the list of keys and return them. BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys(); businessObjectFormatKeys.getBusinessObjectFormatKeys().addAll(businessObjectFormatDao .getBusinessObjectFormatsWithFilters(businessObjectDefinitionKey, businessObjectFormatUsage, latestBusinessObjectFormatVersion)); return businessObjectFormatKeys; }
@Test public void testGetBusinessObjectFormatIdsByBusinessObjectDefinition() { // Create two business object definition entities. List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Arrays .asList(businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION), businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME_2, DATA_PROVIDER_NAME, BDEF_DESCRIPTION)); // Create two business object formats under the first business object definition. List<BusinessObjectFormatEntity> businessObjectFormatEntities = Arrays.asList(businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, NO_FORMAT_DOCUMENT_SCHEMA, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY), businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION_2, FORMAT_DESCRIPTION_2, NO_FORMAT_DOCUMENT_SCHEMA, NO_LATEST_VERSION_FLAG_SET, PARTITION_KEY)); // Test "less than", "equal", and "greater than" scenario for all three business object definitions. assertEquals(Arrays.asList(businessObjectFormatEntities.get(0).getId(), businessObjectFormatEntities.get(1).getId()), businessObjectFormatDao.getBusinessObjectFormatIdsByBusinessObjectDefinition(businessObjectDefinitionEntities.get(0))); assertEquals(Collections.emptyList(), businessObjectFormatDao.getBusinessObjectFormatIdsByBusinessObjectDefinition(businessObjectDefinitionEntities.get(1))); }
businessObjectFormatDao.getLatestVersionBusinessObjectFormatsByBusinessObjectDefinition(businessObjectDefinitionKey); assertEquals(businessObjectFormatList.size(), 1); assertEquals(businessObjectFormatList.get(0), businessObjectFormatEntityV1);
.getBusinessObjectFormatCountByPartitionKeys(businessObjectDataSearchKey.getNamespace(), businessObjectDataSearchKey.getBusinessObjectDefinitionName(), businessObjectDataSearchKey.getBusinessObjectFormatUsage(), businessObjectDataSearchKey.getBusinessObjectFormatFileType(), businessObjectDataSearchKey.getBusinessObjectFormatVersion(), null); businessObjectFormatRecordCount = businessObjectFormatDao.getBusinessObjectFormatCountByPartitionKeys(businessObjectDataSearchKey.getNamespace(), businessObjectDataSearchKey.getBusinessObjectDefinitionName(), businessObjectDataSearchKey.getBusinessObjectFormatUsage(), businessObjectDataSearchKey.getBusinessObjectFormatFileType(), businessObjectDataSearchKey.getBusinessObjectFormatVersion(), partitionKeys);
@Test public void testGetBusinessObjectFormatMaxVersion() { // Create and persist two versions of the business object format. for (Integer version : Arrays.asList(INITIAL_FORMAT_VERSION, SECOND_FORMAT_VERSION)) { businessObjectFormatDaoTestHelper .createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, version, FORMAT_DESCRIPTION, FORMAT_DOCUMENT_SCHEMA, false, PARTITION_KEY); } // Retrieve the latest (maximum available) business object format version. Integer resultLatestVersion = businessObjectFormatDao .getBusinessObjectFormatMaxVersion(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null)); // Validate the results. assertEquals(SECOND_DATA_VERSION, resultLatestVersion); }
businessObjectFormatDao.delete(businessObjectFormatEntity); Integer maxBusinessObjectFormatVersion = businessObjectFormatDao.getBusinessObjectFormatMaxVersion(businessObjectFormatKey); BusinessObjectFormatEntity previousVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey( new BusinessObjectFormatKey(businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), businessObjectFormatDao.saveAndRefresh(previousVersionBusinessObjectFormatEntity);
BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey); businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity); childFormatEntity.getBusinessObjectFormatParents().add(newBusinessObjectFormatEntity); newBusinessObjectFormatEntity.getBusinessObjectFormatChildren().add(childFormatEntity); businessObjectFormatDao.saveAndRefresh(childFormatEntity); parentFormatEntity.getBusinessObjectFormatChildren().add(newBusinessObjectFormatEntity); newBusinessObjectFormatEntity.getBusinessObjectFormatParents().add(parentFormatEntity); businessObjectFormatDao.saveAndRefresh(parentFormatEntity); businessObjectFormatDao.saveAndRefresh(newBusinessObjectFormatEntity); businessObjectFormatDao.saveAndRefresh(latestVersionBusinessObjectFormatEntity);
@Override public BusinessObjectFormatKeys getBusinessObjectFormats(BusinessObjectDefinitionKey businessObjectDefinitionKey, boolean latestBusinessObjectFormatVersion) { // Perform validation and trim. businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey); // Ensure that a business object definition already exists with the specified name. businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey); // Gets the list of keys and return them. BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys(); businessObjectFormatKeys.getBusinessObjectFormatKeys() .addAll(businessObjectFormatDao.getBusinessObjectFormats(businessObjectDefinitionKey, latestBusinessObjectFormatVersion)); return businessObjectFormatKeys; }
@Override public BusinessObjectFormatKeys getBusinessObjectFormatsWithFilters(BusinessObjectDefinitionKey businessObjectDefinitionKey, String businessObjectFormatUsage, boolean latestBusinessObjectFormatVersion) { // Perform validation and trim. businessObjectDefinitionHelper.validateBusinessObjectDefinitionKey(businessObjectDefinitionKey); // Perform Validation and trim of businessObjectFormatUsage businessObjectFormatUsage = alternateKeyHelper.validateStringParameter("business object format usage", businessObjectFormatUsage); // Ensure that a business object definition already exists with the specified name. businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionKey); // Gets the list of keys and return them. BusinessObjectFormatKeys businessObjectFormatKeys = new BusinessObjectFormatKeys(); businessObjectFormatKeys.getBusinessObjectFormatKeys().addAll(businessObjectFormatDao .getBusinessObjectFormatsWithFilters(businessObjectDefinitionKey, businessObjectFormatUsage, latestBusinessObjectFormatVersion)); return businessObjectFormatKeys; }
List<Integer> businessObjectFormatIds = businessObjectFormatDao.getBusinessObjectFormatIdsByBusinessObjectDefinition(businessObjectDefinitionEntity);
businessObjectFormatDao.getLatestVersionBusinessObjectFormatsByBusinessObjectDefinition(businessObjectDefinitionKey);
.getBusinessObjectFormatCountByPartitionKeys(businessObjectDataSearchKey.getNamespace(), businessObjectDataSearchKey.getBusinessObjectDefinitionName(), businessObjectDataSearchKey.getBusinessObjectFormatUsage(), businessObjectDataSearchKey.getBusinessObjectFormatFileType(), businessObjectDataSearchKey.getBusinessObjectFormatVersion(), null); businessObjectFormatRecordCount = businessObjectFormatDao.getBusinessObjectFormatCountByPartitionKeys(businessObjectDataSearchKey.getNamespace(), businessObjectDataSearchKey.getBusinessObjectDefinitionName(), businessObjectDataSearchKey.getBusinessObjectFormatUsage(), businessObjectDataSearchKey.getBusinessObjectFormatFileType(), businessObjectDataSearchKey.getBusinessObjectFormatVersion(), partitionKeys);
/** * Gets a business object format entity based on the alternate key and makes sure that it exists. If a format version isn't specified in the business object * format alternate key, the latest available format version will be used. * * @param businessObjectFormatKey the business object format key * * @return the business object format entity * @throws ObjectNotFoundException if the business object format entity doesn't exist */ public BusinessObjectFormatEntity getBusinessObjectFormatEntity(BusinessObjectFormatKey businessObjectFormatKey) throws ObjectNotFoundException { BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey); if (businessObjectFormatEntity == null) { throw new ObjectNotFoundException(String.format("Business object format with namespace \"%s\", business object definition name \"%s\", " + "format usage \"%s\", format file type \"%s\", and format version \"%d\" doesn't exist.", businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), businessObjectFormatKey.getBusinessObjectFormatVersion())); } return businessObjectFormatEntity; }
@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override public BusinessObjectFormat updateBusinessObjectFormatAttributes(BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatAttributesUpdateRequest businessObjectFormatAttributesUpdateRequest) { // Perform validation and trim the alternate key parameters. businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey); Assert.notNull(businessObjectFormatAttributesUpdateRequest, "A business object format attributes update request is required."); Assert.notNull(businessObjectFormatAttributesUpdateRequest.getAttributes(), "A business object format attributes list is required."); List<Attribute> attributes = businessObjectFormatAttributesUpdateRequest.getAttributes(); // Validate optional attributes. This is also going to trim the attribute names. attributeHelper.validateFormatAttributes(attributes); // Retrieve and ensure that a business object format exists. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper.getBusinessObjectFormatEntity(businessObjectFormatKey); // Update the business object format attributes updateBusinessObjectFormatAttributesHelper(businessObjectFormatEntity, attributes); // 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); }