Search in sources :

Example 11 with BusinessObjectDefinitionSubjectMatterExpertEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionSubjectMatterExpertServiceTest method testDeleteBusinessObjectDefinitionSubjectMatterExpertLowerCaseParameters.

@Test
public void testDeleteBusinessObjectDefinitionSubjectMatterExpertLowerCaseParameters() {
    // Create a business object definition subject matter expert key.
    BusinessObjectDefinitionSubjectMatterExpertKey key = new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE, BDEF_NAME, USER_ID);
    // Create and persist a business object definition subject matter expert.
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoTestHelper.createBusinessObjectDefinitionSubjectMatterExpertEntity(key);
    // Validate that this business object definition subject matter expert exists.
    assertNotNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
    // Delete this business object definition subject matter expert using lower case parameter values.
    BusinessObjectDefinitionSubjectMatterExpert deletedBusinessObjectDefinitionSubjectMatterExpert = businessObjectDefinitionSubjectMatterExpertService.deleteBusinessObjectDefinitionSubjectMatterExpert(new BusinessObjectDefinitionSubjectMatterExpertKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), USER_ID.toLowerCase()));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinitionSubjectMatterExpert(businessObjectDefinitionSubjectMatterExpertEntity.getId(), key), deletedBusinessObjectDefinitionSubjectMatterExpert);
    // Ensure that this business object definition subject matter expert is no longer there.
    assertNull(businessObjectDefinitionSubjectMatterExpertDao.getBusinessObjectDefinitionSubjectMatterExpertByKey(key));
}
Also used : BusinessObjectDefinitionSubjectMatterExpertKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey) BusinessObjectDefinitionSubjectMatterExpert(org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) Test(org.junit.Test)

Example 12 with BusinessObjectDefinitionSubjectMatterExpertEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionSubjectMatterExpertServiceImpl method createBusinessObjectDefinitionSubjectMatterExpertEntity.

/**
 * Creates and persists a new business object definition subject matter expert entity from the business object definition entity and the request
 * information.
 *
 * @param businessObjectDefinitionEntity the business object definition entity
 * @param request the business object definition subject matter expert create request
 *
 * @return the newly created business object definition subject matter expert entity
 */
private BusinessObjectDefinitionSubjectMatterExpertEntity createBusinessObjectDefinitionSubjectMatterExpertEntity(BusinessObjectDefinitionEntity businessObjectDefinitionEntity, BusinessObjectDefinitionSubjectMatterExpertCreateRequest request) {
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = new BusinessObjectDefinitionSubjectMatterExpertEntity();
    businessObjectDefinitionSubjectMatterExpertEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
    businessObjectDefinitionSubjectMatterExpertEntity.setUserId(request.getBusinessObjectDefinitionSubjectMatterExpertKey().getUserId());
    return businessObjectDefinitionSubjectMatterExpertDao.saveAndRefresh(businessObjectDefinitionSubjectMatterExpertEntity);
}
Also used : BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)

Example 13 with BusinessObjectDefinitionSubjectMatterExpertEntity

use of org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity in project herd by FINRAOS.

the class BusinessObjectDefinitionSubjectMatterExpertServiceImpl method deleteBusinessObjectDefinitionSubjectMatterExpert.

@NamespacePermission(fields = "#key.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionSubjectMatterExpert deleteBusinessObjectDefinitionSubjectMatterExpert(BusinessObjectDefinitionSubjectMatterExpertKey key) {
    // Validate and trim the business object definition subject matter expert key.
    validateBusinessObjectDefinitionSubjectMatterExpertKey(key);
    // Retrieve and ensure that a business object definition subject matter expert exists.
    BusinessObjectDefinitionSubjectMatterExpertEntity businessObjectDefinitionSubjectMatterExpertEntity = businessObjectDefinitionSubjectMatterExpertDaoHelper.getBusinessObjectDefinitionSubjectMatterExpertEntity(key);
    // Delete the business object definition subject matter expert.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionSubjectMatterExpertEntity.getBusinessObjectDefinition();
    businessObjectDefinitionEntity.getSubjectMatterExperts().remove(businessObjectDefinitionSubjectMatterExpertEntity);
    businessObjectDefinitionDao.saveAndRefresh(businessObjectDefinitionEntity);
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionEntity, SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Create and return the business object definition subject matter expert object from the deleted entity.
    return createBusinessObjectDefinitionSubjectMatterExpertFromEntity(businessObjectDefinitionSubjectMatterExpertEntity);
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionSubjectMatterExpertEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Aggregations

BusinessObjectDefinitionSubjectMatterExpertEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionSubjectMatterExpertEntity)13 Test (org.junit.Test)6 BusinessObjectDefinitionSubjectMatterExpertKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKey)5 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)5 BusinessObjectDefinitionSubjectMatterExpert (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpert)4 ArrayList (java.util.ArrayList)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 Predicate (javax.persistence.criteria.Predicate)2 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 BusinessObjectDefinitionSubjectMatterExpertKeys (org.finra.herd.model.api.xml.BusinessObjectDefinitionSubjectMatterExpertKeys)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1