Search in sources :

Example 16 with BusinessObjectDefinitionTagEntity

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

the class BusinessObjectDefinitionTagServiceTest method testDeleteBusinessObjectDefinitionTagLowerCaseParameters.

@Test
public void testDeleteBusinessObjectDefinitionTagLowerCaseParameters() {
    // Create a business object definition tag key.
    BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey = new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
    // Create and persist a business object definition tag entity.
    BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = businessObjectDefinitionTagDaoTestHelper.createBusinessObjectDefinitionTagEntity(new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME), new TagKey(TAG_TYPE, TAG_CODE));
    // Validate that this business object definition tag exists.
    assertNotNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(businessObjectDefinitionTagKey));
    // Delete this business object definition tag using lower case parameter values.
    BusinessObjectDefinitionTag result = businessObjectDefinitionTagService.deleteBusinessObjectDefinitionTag(new BusinessObjectDefinitionTagKey(new BusinessObjectDefinitionKey(BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase()), new TagKey(TAG_TYPE.toLowerCase(), TAG_CODE.toLowerCase())));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinitionTag(businessObjectDefinitionTagEntity.getId(), businessObjectDefinitionTagKey), result);
    // Ensure that this business object definition tag is no longer there.
    assertNull(businessObjectDefinitionTagDao.getBusinessObjectDefinitionTagByKey(businessObjectDefinitionTagKey));
}
Also used : BusinessObjectDefinitionTag(org.finra.herd.model.api.xml.BusinessObjectDefinitionTag) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionTagKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) Test(org.junit.Test)

Example 17 with BusinessObjectDefinitionTagEntity

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

the class BusinessObjectDefinitionHelperTest method testProcessTagSearchScoreMultiplierTagsEmpty.

@Test
public void testProcessTagSearchScoreMultiplierTagsEmpty() {
    // Create a business object definition entity
    final BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes2());
    // Associate business object definition entity with no tag entities
    List<BusinessObjectDefinitionTagEntity> businessObjectDefinitionTagEntities = new ArrayList<>();
    businessObjectDefinitionEntity.setBusinessObjectDefinitionTags(businessObjectDefinitionTagEntities);
    // Call the method under test
    businessObjectDefinitionHelper.processTagSearchScoreMultiplier(businessObjectDefinitionEntity);
    // Validate the result
    assertEquals(businessObjectDefinitionEntity.getTagSearchScoreMultiplier(), BigDecimal.ONE.setScale(3, RoundingMode.HALF_UP));
}
Also used : BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) ArrayList(java.util.ArrayList) BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 18 with BusinessObjectDefinitionTagEntity

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

the class BusinessObjectDefinitionTagServiceImpl method deleteBusinessObjectDefinitionTag.

@NamespacePermission(fields = "#businessObjectDefinitionTagKey.businessObjectDefinitionKey.namespace", permissions = { NamespacePermissionEnum.WRITE_DESCRIPTIVE_CONTENT, NamespacePermissionEnum.WRITE })
@Override
public BusinessObjectDefinitionTag deleteBusinessObjectDefinitionTag(BusinessObjectDefinitionTagKey businessObjectDefinitionTagKey) {
    // Validate and trim the business object definition tag key.
    validateBusinessObjectDefinitionTagKey(businessObjectDefinitionTagKey);
    // Retrieve and ensure that a business object definition tag exists.
    BusinessObjectDefinitionTagEntity businessObjectDefinitionTagEntity = getBusinessObjectDefinitionTagEntity(businessObjectDefinitionTagKey);
    // Delete this business object format.
    businessObjectDefinitionTagDao.delete(businessObjectDefinitionTagEntity);
    // Notify the search index that a business object definition must be updated.
    searchIndexUpdateHelper.modifyBusinessObjectDefinitionInSearchIndex(businessObjectDefinitionDaoHelper.getBusinessObjectDefinitionEntity(businessObjectDefinitionTagKey.getBusinessObjectDefinitionKey()), SEARCH_INDEX_UPDATE_TYPE_UPDATE);
    // Create and return the business object definition tag object from the deleted entity.
    return createBusinessObjectDefinitionTagFromEntity(businessObjectDefinitionTagEntity);
}
Also used : BusinessObjectDefinitionTagEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Aggregations

BusinessObjectDefinitionTagEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionTagEntity)18 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)9 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 Test (org.junit.Test)8 BusinessObjectDefinitionTagKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionTagKey)7 TagKey (org.finra.herd.model.api.xml.TagKey)7 TagEntity (org.finra.herd.model.jpa.TagEntity)7 ArrayList (java.util.ArrayList)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)5 Predicate (javax.persistence.criteria.Predicate)5 BusinessObjectDefinitionTag (org.finra.herd.model.api.xml.BusinessObjectDefinitionTag)4 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)3 TagTypeEntity (org.finra.herd.model.jpa.TagTypeEntity)3 Tuple (javax.persistence.Tuple)2 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2 Order (javax.persistence.criteria.Order)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1