use of org.finra.herd.model.jpa.CustomDdlEntity in project herd by FINRAOS.
the class CustomDdlServiceImpl method updateCustomDdl.
/**
* Updates an existing custom DDL by key.
*
* @param customDdlKey the custom DDL key
*
* @return the custom DDL information
*/
@NamespacePermission(fields = "#customDdlKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public CustomDdl updateCustomDdl(CustomDdlKey customDdlKey, CustomDdlUpdateRequest request) {
// Validate and trim the key.
customDdlHelper.validateCustomDdlKey(customDdlKey);
// Validate and trim the DDL.
Assert.hasText(request.getDdl(), "DDL must be specified.");
request.setDdl(request.getDdl().trim());
// Retrieve and ensure that a custom DDL exists with the specified key.
CustomDdlEntity customDdlEntity = customDdlDaoHelper.getCustomDdlEntity(customDdlKey);
// Update the entity with the new values.
customDdlEntity.setDdl(request.getDdl());
// Persist the entity.
customDdlEntity = customDdlDao.saveAndRefresh(customDdlEntity);
// Create and return the custom DDL object from the persisted entity.
return createCustomDdlFromEntity(customDdlEntity);
}
use of org.finra.herd.model.jpa.CustomDdlEntity in project herd by FINRAOS.
the class CustomDdlServiceTest method testUpdateCustomDdlLowerCaseParameters.
@Test
public void testUpdateCustomDdlLowerCaseParameters() {
// Create and persist a custom DDL entity using upper case values.
CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase(), TEST_DDL.toUpperCase());
// Update the custom DDL using lower case input parameters.
CustomDdl updatedCustomDdl = customDdlService.updateCustomDdl(new CustomDdlKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toLowerCase()), customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL_2.toLowerCase()));
// Validate the returned object.
customDdlServiceTestHelper.validateCustomDdl(customDdlEntity.getId(), NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase(), TEST_DDL_2.toLowerCase(), updatedCustomDdl);
}
use of org.finra.herd.model.jpa.CustomDdlEntity in project herd by FINRAOS.
the class CustomDdlServiceTest method testGetCustomDdlUpperCaseParameters.
@Test
public void testGetCustomDdlUpperCaseParameters() {
// Create and persist a custom DDL entity using lower case values.
CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toLowerCase(), TEST_DDL.toLowerCase());
// Get the custom DDL using upper case input parameters.
CustomDdl resultCustomDdl = customDdlService.getCustomDdl(new CustomDdlKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase()));
// Validate the returned object.
customDdlServiceTestHelper.validateCustomDdl(customDdlEntity.getId(), NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toLowerCase(), TEST_DDL.toLowerCase(), resultCustomDdl);
}
use of org.finra.herd.model.jpa.CustomDdlEntity in project herd by FINRAOS.
the class CustomDdlServiceTest method testGetCustomDdl.
@Test
public void testGetCustomDdl() {
// Create and persist a custom DDL entity.
CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, TEST_DDL);
// Retrieve the custom DDL.
CustomDdl resultCustomDdl = customDdlService.getCustomDdl(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME));
// Validate the returned object.
customDdlServiceTestHelper.validateCustomDdl(customDdlEntity.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, TEST_DDL, resultCustomDdl);
}
use of org.finra.herd.model.jpa.CustomDdlEntity in project herd by FINRAOS.
the class CustomDdlServiceTest method testDeleteCustomDdlLowerCaseParameters.
@Test
public void testDeleteCustomDdlLowerCaseParameters() {
// Create and persist a custom DDL entity using upper case values.
CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase(), TEST_DDL.toUpperCase());
// Validate that this custom DDL exists.
CustomDdlKey customDdlKey = new CustomDdlKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase());
assertNotNull(customDdlDao.getCustomDdlByKey(customDdlKey));
// Delete the custom DDL using lower case input parameters.
CustomDdl deletedCustomDdl = customDdlService.deleteCustomDdl(new CustomDdlKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toLowerCase()));
// Validate the returned object.
customDdlServiceTestHelper.validateCustomDdl(customDdlEntity.getId(), NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), FORMAT_VERSION, CUSTOM_DDL_NAME.toUpperCase(), TEST_DDL.toUpperCase(), deletedCustomDdl);
// Ensure that this custom DDL is no longer there.
assertNull(customDdlDao.getCustomDdlByKey(customDdlKey));
}
Aggregations