Search in sources :

Example 1 with BusinessObjectDataKey

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;
}
Also used : BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 2 with BusinessObjectDataKey

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;
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 3 with BusinessObjectDataKey

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;
}
Also used : BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 4 with 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);
}
Also used : BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 5 with 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;
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Aggregations

BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)444 Test (org.junit.Test)378 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)138 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)93 ArrayList (java.util.ArrayList)92 StorageUnitEntity (org.finra.herd.model.jpa.StorageUnitEntity)78 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)62 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)50 HashMap (java.util.HashMap)43 StorageFile (org.finra.herd.model.api.xml.StorageFile)38 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)36 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)33 Attribute (org.finra.herd.model.api.xml.Attribute)32 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)32 StoragePolicySelection (org.finra.herd.model.dto.StoragePolicySelection)32 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)32 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)30 Parameter (org.finra.herd.model.api.xml.Parameter)30 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)29 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)29