/** * Creates a new business object data attribute entity from the business object data entity and * the request information. * * @param businessObjectDataEntity the business object data entity * @param request the business object data attribute create request * @return the newly created business object data attribute entity */ private BusinessObjectDataAttributeEntity createBusinessObjectDataAttributeEntity( BusinessObjectDataEntity businessObjectDataEntity, BusinessObjectDataAttributeCreateRequest request) { // Create a new entity. BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity(); businessObjectDataAttributeEntity.setBusinessObjectData(businessObjectDataEntity); businessObjectDataAttributeEntity.setName( request.getBusinessObjectDataAttributeKey().getBusinessObjectDataAttributeName()); businessObjectDataAttributeEntity.setValue(request.getBusinessObjectDataAttributeValue()); return businessObjectDataAttributeEntity; }
/** * Updates an existing business object data attribute by key. * * @param businessObjectDataAttributeKey the business object data attribute key * @return the business object data attribute information */ @Override public BusinessObjectDataAttribute updateBusinessObjectDataAttribute( BusinessObjectDataAttributeKey businessObjectDataAttributeKey, BusinessObjectDataAttributeUpdateRequest request) { // Validate and trim the key. dmHelper.validateBusinessObjectDataAttributeKey(businessObjectDataAttributeKey); // If namespace is not specified, get the namespace code by locating the legacy business object // definition. populateLegacyNamespace(businessObjectDataAttributeKey); // Get the business object format and ensure it exists. BusinessObjectFormatEntity businessObjectFormatEntity = dmDaoHelper.getBusinessObjectFormatEntity( new BusinessObjectFormatKey( businessObjectDataAttributeKey.getNamespace(), businessObjectDataAttributeKey.getBusinessObjectDefinitionName(), businessObjectDataAttributeKey.getBusinessObjectFormatUsage(), businessObjectDataAttributeKey.getBusinessObjectFormatFileType(), businessObjectDataAttributeKey.getBusinessObjectFormatVersion())); // Validate the attribute value. if (dmDaoHelper.isBusinessObjectDataAttributeRequired( businessObjectDataAttributeKey.getBusinessObjectDataAttributeName(), businessObjectFormatEntity)) { Assert.hasText( request.getBusinessObjectDataAttributeValue(), String.format( "A business object data attribute value must be specified since \"%s\" is a required attribute for business object format {%s}.", businessObjectDataAttributeKey.getBusinessObjectDataAttributeName(), dmDaoHelper.businessObjectFormatEntityAltKeyToString(businessObjectFormatEntity))); } // Retrieve and ensure that a business object data attribute exists with the specified key. BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = dmDaoHelper.getBusinessObjectDataAttributeEntity(businessObjectDataAttributeKey); // Update the entity with the new values. businessObjectDataAttributeEntity.setValue(request.getBusinessObjectDataAttributeValue()); // Persist the entity. businessObjectDataAttributeEntity = dmDao.saveAndRefresh(businessObjectDataAttributeEntity); // Create and return the business object data attribute object from the persisted entity. return createBusinessObjectDataAttributeFromEntity(businessObjectDataAttributeEntity); }