use of org.finra.herd.model.jpa.StoragePolicyTransitionTypeEntity in project herd by FINRAOS.
the class StoragePolicyTransitionTypeDaoTestHelper method createStoragePolicyTransitionTypeEntity.
/**
* Creates and persists a new storage policy rule type entity.
*
* @param code the storage policy rule type code
*
* @return the newly created storage policy rule type entity
*/
public StoragePolicyTransitionTypeEntity createStoragePolicyTransitionTypeEntity(String code) {
StoragePolicyTransitionTypeEntity storagePolicyTransitionTypeEntity = new StoragePolicyTransitionTypeEntity();
storagePolicyTransitionTypeEntity.setCode(code);
return storagePolicyTransitionTypeDao.saveAndRefresh(storagePolicyTransitionTypeEntity);
}
use of org.finra.herd.model.jpa.StoragePolicyTransitionTypeEntity in project herd by FINRAOS.
the class StoragePolicyTransitionTypeDaoImpl method getStoragePolicyTransitionTypeByCode.
@Override
public StoragePolicyTransitionTypeEntity getStoragePolicyTransitionTypeByCode(String code) {
// Create the criteria builder and the criteria.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<StoragePolicyTransitionTypeEntity> criteria = builder.createQuery(StoragePolicyTransitionTypeEntity.class);
// The criteria root is the storage policy transition type.
Root<StoragePolicyTransitionTypeEntity> storagePolicyTransitionTypeEntity = criteria.from(StoragePolicyTransitionTypeEntity.class);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate queryRestriction = builder.equal(builder.upper(storagePolicyTransitionTypeEntity.get(StoragePolicyTransitionTypeEntity_.code)), code.toUpperCase());
criteria.select(storagePolicyTransitionTypeEntity).where(queryRestriction);
return executeSingleResultQuery(criteria, String.format("Found more than one storage policy transition type with code \"%s\".", code));
}
use of org.finra.herd.model.jpa.StoragePolicyTransitionTypeEntity in project herd by FINRAOS.
the class StoragePolicyTransitionTypeDaoTest method testGetStoragePolicyTransitionTypeByCode.
@Test
public void testGetStoragePolicyTransitionTypeByCode() {
// Create and persist a storage policy rule type entity.
StoragePolicyTransitionTypeEntity storagePolicyTransitionTypeEntity = storagePolicyTransitionTypeDaoTestHelper.createStoragePolicyTransitionTypeEntity(STORAGE_POLICY_TRANSITION_TYPE);
// Retrieve this storage policy rule type entity by code.
StoragePolicyTransitionTypeEntity resultStoragePolicyTransitionTypeEntity = storagePolicyTransitionTypeDao.getStoragePolicyTransitionTypeByCode(STORAGE_POLICY_TRANSITION_TYPE);
// Validate the returned object.
assertNotNull(resultStoragePolicyTransitionTypeEntity);
assertEquals(storagePolicyTransitionTypeEntity.getCode(), resultStoragePolicyTransitionTypeEntity.getCode());
// Retrieve this storage policy rule type entity by code in upper case.
resultStoragePolicyTransitionTypeEntity = storagePolicyTransitionTypeDao.getStoragePolicyTransitionTypeByCode(STORAGE_POLICY_TRANSITION_TYPE.toUpperCase());
// Validate the returned object.
assertNotNull(resultStoragePolicyTransitionTypeEntity);
assertEquals(storagePolicyTransitionTypeEntity.getCode(), resultStoragePolicyTransitionTypeEntity.getCode());
// Retrieve this storage policy rule type entity by code in lower case.
resultStoragePolicyTransitionTypeEntity = storagePolicyTransitionTypeDao.getStoragePolicyTransitionTypeByCode(STORAGE_POLICY_TRANSITION_TYPE.toLowerCase());
// Validate the returned object.
assertNotNull(resultStoragePolicyTransitionTypeEntity);
assertEquals(storagePolicyTransitionTypeEntity.getCode(), resultStoragePolicyTransitionTypeEntity.getCode());
}
use of org.finra.herd.model.jpa.StoragePolicyTransitionTypeEntity in project herd by FINRAOS.
the class StoragePolicyDaoTestHelper method createStoragePolicyTransitionTypeEntity.
/**
* Creates and persists a new storage policy transition type entity.
*
* @param storagePolicyTransitionType the transition type of the storage policy
*
* @return the newly created storage policy transition type entity
*/
public StoragePolicyTransitionTypeEntity createStoragePolicyTransitionTypeEntity(String storagePolicyTransitionType) {
StoragePolicyTransitionTypeEntity storagePolicyTransitionTypeEntity = new StoragePolicyTransitionTypeEntity();
storagePolicyTransitionTypeEntity.setCode(storagePolicyTransitionType);
return storagePolicyTransitionTypeDao.saveAndRefresh(storagePolicyTransitionTypeEntity);
}
use of org.finra.herd.model.jpa.StoragePolicyTransitionTypeEntity in project herd by FINRAOS.
the class StoragePolicyDaoTestHelper method createStoragePolicyEntity.
/**
* Creates and persists a storage policy entity.
*
* @param storagePolicyKey the storage policy key
* @param storagePolicyRuleType the storage policy rule type
* @param storagePolicyRuleValue the storage policy rule value
* @param businessObjectDefinitionNamespace the business object definition namespace
* @param businessObjectDefinitionName the business object definition name
* @param businessObjectFormatUsage the business object usage
* @param businessObjectFormatFileType the business object format file type
* @param storageName the storage name
* @param storagePolicyTransitionType the transition type of the storage policy
* @param storagePolicyStatus the storage policy status
* @param storagePolicyVersion the storage policy version
* @param storagePolicyLatestVersion specifies if this storage policy is flagged as latest version or not
*
* @return the newly created storage policy entity
*/
public StoragePolicyEntity createStoragePolicyEntity(StoragePolicyKey storagePolicyKey, String storagePolicyRuleType, Integer storagePolicyRuleValue, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, String storageName, String storagePolicyTransitionType, String storagePolicyStatus, Integer storagePolicyVersion, Boolean storagePolicyLatestVersion) {
// Create a storage policy namespace entity if needed.
NamespaceEntity storagePolicyNamespaceEntity = namespaceDao.getNamespaceByCd(storagePolicyKey.getNamespace());
if (storagePolicyNamespaceEntity == null) {
storagePolicyNamespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(storagePolicyKey.getNamespace());
}
// Create a storage policy rule type type entity if needed.
StoragePolicyRuleTypeEntity storagePolicyRuleTypeEntity = storagePolicyRuleTypeDao.getStoragePolicyRuleTypeByCode(storagePolicyRuleType);
if (storagePolicyRuleTypeEntity == null) {
storagePolicyRuleTypeEntity = storagePolicyRuleTypeDaoTestHelper.createStoragePolicyRuleTypeEntity(storagePolicyRuleType, AbstractDaoTest.DESCRIPTION);
}
// Create a business object definition entity if needed.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = null;
if (StringUtils.isNotBlank(businessObjectDefinitionName)) {
businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace, businessObjectDefinitionName));
if (businessObjectDefinitionEntity == null) {
// Create a business object definition.
businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace, businessObjectDefinitionName, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.BDEF_DESCRIPTION);
}
}
// Create a business object format file type entity if needed.
FileTypeEntity fileTypeEntity = null;
if (StringUtils.isNotBlank(businessObjectFormatFileType)) {
fileTypeEntity = fileTypeDao.getFileTypeByCode(businessObjectFormatFileType);
if (fileTypeEntity == null) {
fileTypeEntity = fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
}
}
// Create a storage entity of S3 storage platform type if needed.
StorageEntity storageEntity = storageDao.getStorageByName(storageName);
if (storageEntity == null) {
storageEntity = storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
}
// Create a storage policy transition type entity, if not exists.
StoragePolicyTransitionTypeEntity storagePolicyTransitionTypeEntity = storagePolicyTransitionTypeDao.getStoragePolicyTransitionTypeByCode(storagePolicyTransitionType);
if (storagePolicyTransitionTypeEntity == null) {
storagePolicyTransitionTypeEntity = createStoragePolicyTransitionTypeEntity(storagePolicyTransitionType);
}
// Create a storage policy status entity, if not exists.
StoragePolicyStatusEntity storagePolicyStatusEntity = storagePolicyStatusDao.getStoragePolicyStatusByCode(storagePolicyStatus);
if (storagePolicyStatusEntity == null) {
storagePolicyStatusEntity = createStoragePolicyStatusEntity(storagePolicyStatus);
}
// Create a storage policy entity.
StoragePolicyEntity storagePolicyEntity = new StoragePolicyEntity();
storagePolicyEntity.setNamespace(storagePolicyNamespaceEntity);
storagePolicyEntity.setName(storagePolicyKey.getStoragePolicyName());
storagePolicyEntity.setStoragePolicyRuleType(storagePolicyRuleTypeEntity);
storagePolicyEntity.setStoragePolicyRuleValue(storagePolicyRuleValue);
storagePolicyEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
storagePolicyEntity.setUsage(businessObjectFormatUsage);
storagePolicyEntity.setFileType(fileTypeEntity);
storagePolicyEntity.setStorage(storageEntity);
storagePolicyEntity.setStoragePolicyTransitionType(storagePolicyTransitionTypeEntity);
storagePolicyEntity.setStatus(storagePolicyStatusEntity);
storagePolicyEntity.setVersion(storagePolicyVersion);
storagePolicyEntity.setLatestVersion(storagePolicyLatestVersion);
return storagePolicyDao.saveAndRefresh(storagePolicyEntity);
}
Aggregations