use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataDaoHelper method cloneToLowerCase.
/**
* Returns a cloned version of the specified business object data key where all fields are made lowercase.
*
* @param businessObjectDataKey the business object data.
*
* @return the cloned business object data.
*/
private BusinessObjectDataKey cloneToLowerCase(BusinessObjectDataKey businessObjectDataKey) {
BusinessObjectDataKey businessObjectDataKeyClone = new BusinessObjectDataKey();
businessObjectDataKeyClone.setNamespace(businessObjectDataKey.getNamespace().toLowerCase());
businessObjectDataKeyClone.setBusinessObjectDefinitionName(businessObjectDataKey.getBusinessObjectDefinitionName().toLowerCase());
businessObjectDataKeyClone.setBusinessObjectFormatUsage(businessObjectDataKey.getBusinessObjectFormatUsage().toLowerCase());
businessObjectDataKeyClone.setBusinessObjectFormatFileType(businessObjectDataKey.getBusinessObjectFormatFileType().toLowerCase());
businessObjectDataKeyClone.setBusinessObjectFormatVersion(businessObjectDataKey.getBusinessObjectFormatVersion());
businessObjectDataKeyClone.setPartitionValue(businessObjectDataKey.getPartitionValue());
businessObjectDataKeyClone.setBusinessObjectDataVersion(businessObjectDataKey.getBusinessObjectDataVersion());
businessObjectDataKeyClone.setSubPartitionValues(businessObjectDataKey.getSubPartitionValues());
return businessObjectDataKeyClone;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataDaoHelper method createBusinessObjectDataEntity.
/**
* Creates a new business object data entity from the request information.
*
* @param request the request.
* @param businessObjectFormatEntity the business object format entity.
* @param businessObjectDataVersion the business object data version.
*
* @return the newly created business object data entity.
*/
private BusinessObjectDataEntity createBusinessObjectDataEntity(BusinessObjectDataCreateRequest request, BusinessObjectFormatEntity businessObjectFormatEntity, Integer businessObjectDataVersion, BusinessObjectDataStatusEntity businessObjectDataStatusEntity) {
// Create a new entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setBusinessObjectFormat(businessObjectFormatEntity);
businessObjectDataEntity.setPartitionValue(request.getPartitionValue());
int subPartitionValuesCount = CollectionUtils.size(request.getSubPartitionValues());
businessObjectDataEntity.setPartitionValue2(subPartitionValuesCount > 0 ? request.getSubPartitionValues().get(0) : null);
businessObjectDataEntity.setPartitionValue3(subPartitionValuesCount > 1 ? request.getSubPartitionValues().get(1) : null);
businessObjectDataEntity.setPartitionValue4(subPartitionValuesCount > 2 ? request.getSubPartitionValues().get(2) : null);
businessObjectDataEntity.setPartitionValue5(subPartitionValuesCount > 3 ? request.getSubPartitionValues().get(3) : null);
businessObjectDataEntity.setVersion(businessObjectDataVersion);
businessObjectDataEntity.setLatestVersion(true);
businessObjectDataEntity.setStatus(businessObjectDataStatusEntity);
// Create the storage unit entities.
businessObjectDataEntity.setStorageUnits(createStorageUnitEntitiesFromStorageUnits(request.getStorageUnits(), businessObjectDataEntity));
// Create the attributes.
List<BusinessObjectDataAttributeEntity> attributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(attributeEntities);
if (CollectionUtils.isNotEmpty(request.getAttributes())) {
for (Attribute attribute : request.getAttributes()) {
BusinessObjectDataAttributeEntity attributeEntity = new BusinessObjectDataAttributeEntity();
attributeEntities.add(attributeEntity);
attributeEntity.setBusinessObjectData(businessObjectDataEntity);
attributeEntity.setName(attribute.getName());
attributeEntity.setValue(attribute.getValue());
}
}
// Create the parents.
List<BusinessObjectDataEntity> businessObjectDataParents = new ArrayList<>();
businessObjectDataEntity.setBusinessObjectDataParents(businessObjectDataParents);
// Loop through all the business object data parents.
if (request.getBusinessObjectDataParents() != null) {
for (BusinessObjectDataKey businessObjectDataKey : request.getBusinessObjectDataParents()) {
// Look up the business object data for each parent.
BusinessObjectDataEntity businessObjectDataParent = getBusinessObjectDataEntity(businessObjectDataKey);
// Add our newly created entity as a dependent (i.e. child) of the looked up parent.
businessObjectDataParent.getBusinessObjectDataChildren().add(businessObjectDataEntity);
// Add the looked up parent as a parent of our newly created entity.
businessObjectDataParents.add(businessObjectDataParent);
}
}
// Return the newly created entity.
return businessObjectDataEntity;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelper method getBusinessObjectDataKey.
/**
* Constructs a {@link BusinessObjectDataKey} from the given request. The returned key does not contain a data version.
*
* @param businessObjectDataInvalidateUnregisteredRequest the request with key information
*
* @return {@link BusinessObjectDataKey}
*/
private BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) {
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey();
businessObjectDataKey.setNamespace(businessObjectDataInvalidateUnregisteredRequest.getNamespace());
businessObjectDataKey.setBusinessObjectDefinitionName(businessObjectDataInvalidateUnregisteredRequest.getBusinessObjectDefinitionName());
businessObjectDataKey.setBusinessObjectFormatUsage(businessObjectDataInvalidateUnregisteredRequest.getBusinessObjectFormatUsage());
businessObjectDataKey.setBusinessObjectFormatFileType(businessObjectDataInvalidateUnregisteredRequest.getBusinessObjectFormatFileType());
businessObjectDataKey.setBusinessObjectFormatVersion(businessObjectDataInvalidateUnregisteredRequest.getBusinessObjectFormatVersion());
businessObjectDataKey.setPartitionValue(businessObjectDataInvalidateUnregisteredRequest.getPartitionValue());
businessObjectDataKey.setSubPartitionValues(businessObjectDataInvalidateUnregisteredRequest.getSubPartitionValues());
if (CollectionUtils.isEmpty(businessObjectDataInvalidateUnregisteredRequest.getSubPartitionValues())) {
businessObjectDataKey.setSubPartitionValues(new ArrayList<>());
}
return businessObjectDataKey;
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataInvalidateUnregisteredHelper method getLatestBusinessObjectDataEntity.
/**
* Returns the latest version of the business object data registered. Returns null if no data is registered.
*
* @param businessObjectDataInvalidateUnregisteredRequest request containing business object data key
*
* @return {@link BusinessObjectDataEntity} or null
*/
private BusinessObjectDataEntity getLatestBusinessObjectDataEntity(BusinessObjectDataInvalidateUnregisteredRequest businessObjectDataInvalidateUnregisteredRequest) {
BusinessObjectDataKey businessObjectDataKey = getBusinessObjectDataKey(businessObjectDataInvalidateUnregisteredRequest);
businessObjectDataKey.setBusinessObjectDataVersion(null);
return businessObjectDataDao.getBusinessObjectDataByAltKey(businessObjectDataKey);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataKey in project herd by FINRAOS.
the class BusinessObjectDataAttributeDaoHelper method getBusinessObjectDataAttributeEntity.
/**
* Gets a business object data attribute entity on the key and makes sure that it exists.
*
* @param businessObjectDataAttributeKey the business object data attribute key
*
* @return the business object data attribute entity
* @throws ObjectNotFoundException if the business object data or the business object data attribute don't exist
*/
public BusinessObjectDataAttributeEntity getBusinessObjectDataAttributeEntity(BusinessObjectDataAttributeKey businessObjectDataAttributeKey) throws ObjectNotFoundException {
// Get the business object data and ensure it exists.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(new BusinessObjectDataKey(businessObjectDataAttributeKey.getNamespace(), businessObjectDataAttributeKey.getBusinessObjectDefinitionName(), businessObjectDataAttributeKey.getBusinessObjectFormatUsage(), businessObjectDataAttributeKey.getBusinessObjectFormatFileType(), businessObjectDataAttributeKey.getBusinessObjectFormatVersion(), businessObjectDataAttributeKey.getPartitionValue(), businessObjectDataAttributeKey.getSubPartitionValues(), businessObjectDataAttributeKey.getBusinessObjectDataVersion()));
// Load all existing business object data attribute entities into a map for quick access using lowercase attribute names.
Map<String, BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntityMap = getBusinessObjectDataAttributeEntityMap(businessObjectDataEntity.getAttributes());
// Get the relative entity using the attribute name in lowercase.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeEntityMap.get(businessObjectDataAttributeKey.getBusinessObjectDataAttributeName().toLowerCase());
if (businessObjectDataAttributeEntity == null) {
throw new ObjectNotFoundException(String.format("Attribute with name \"%s\" does not exist for business object data {%s}.", businessObjectDataAttributeKey.getBusinessObjectDataAttributeName(), businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity)));
}
return businessObjectDataAttributeEntity;
}
Aggregations