Search in sources :

Example 11 with BusinessObjectDefinitionSearchResponse

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionsOnlyShortDescriptionAndDataProviderName.

@Test
public void testSearchBusinessObjectDefinitionsOnlyShortDescriptionAndDataProviderName() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = setUpTestEntitiesForSearchTesting();
    // Remove fields which are not expected from the expected business object definition objects.
    for (BusinessObjectDefinition businessObjectDefinition : expectedBusinessObjectDefinitions) {
        businessObjectDefinition.setDisplayName(null);
    }
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_SHORT_DESCRIPTION, FIELD_DATA_PROVIDER_NAME));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(actualBusinessObjectDefinitions, expectedBusinessObjectDefinitions);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with BusinessObjectDefinitionSearchResponse

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionsUpperCaseParams.

@Test
public void testSearchBusinessObjectDefinitionsUpperCaseParams() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = setUpTestEntitiesForSearchTesting();
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_DATA_PROVIDER_NAME.toUpperCase(), FIELD_DISPLAY_NAME.toUpperCase(), FIELD_SHORT_DESCRIPTION.toUpperCase()));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(expectedBusinessObjectDefinitions, actualBusinessObjectDefinitions);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with BusinessObjectDefinitionSearchResponse

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceTest method testSearchBusinessObjectDefinitionsOnlyDisplayName.

@Test
public void testSearchBusinessObjectDefinitionsOnlyDisplayName() {
    // Set up test data.
    Set<BusinessObjectDefinition> expectedBusinessObjectDefinitions = setUpTestEntitiesForSearchTesting();
    // Remove fields which are not expected from the expected business object definition objects.
    for (BusinessObjectDefinition businessObjectDefinition : expectedBusinessObjectDefinitions) {
        businessObjectDefinition.setShortDescription(null);
        businessObjectDefinition.setDataProviderName(null);
    }
    // Retrieve the actual business object definition objects from the search response.
    BusinessObjectDefinitionSearchResponse searchResponse = businessObjectDefinitionService.searchBusinessObjectDefinitions(new BusinessObjectDefinitionSearchRequest(Arrays.asList(new BusinessObjectDefinitionSearchFilter(NO_EXCLUSION_SEARCH_FILTER, Arrays.asList(new BusinessObjectDefinitionSearchKey(new TagKey(TAG_TYPE, TAG_CODE), INCLUDE_TAG_HIERARCHY))))), Sets.newHashSet(FIELD_DISPLAY_NAME));
    Set<BusinessObjectDefinition> actualBusinessObjectDefinitions = new HashSet<>(searchResponse.getBusinessObjectDefinitions());
    assertEquals(actualBusinessObjectDefinitions, expectedBusinessObjectDefinitions);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) TagKey(org.finra.herd.model.api.xml.TagKey) BusinessObjectDefinitionSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest) BusinessObjectDefinitionSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 14 with BusinessObjectDefinitionSearchResponse

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceImpl method searchBusinessObjectDefinitions.

@Override
public BusinessObjectDefinitionSearchResponse searchBusinessObjectDefinitions(BusinessObjectDefinitionSearchRequest request, Set<String> fields) {
    // Validate the business object definition search fields.
    validateSearchResponseFields(fields);
    List<TagEntity> tagEntities = new ArrayList<>();
    if (!CollectionUtils.isEmpty(request.getBusinessObjectDefinitionSearchFilters())) {
        // Validate the search request.
        validateBusinessObjectDefinitionSearchRequest(request);
        BusinessObjectDefinitionSearchKey businessObjectDefinitionSearchKey = request.getBusinessObjectDefinitionSearchFilters().get(0).getBusinessObjectDefinitionSearchKeys().get(0);
        TagEntity tagEntity = tagDaoHelper.getTagEntity(businessObjectDefinitionSearchKey.getTagKey());
        // If includeTagHierarchy is true, get list of children tag entities down the hierarchy of the specified tag.
        tagEntities.add(tagEntity);
        if (BooleanUtils.isTrue(businessObjectDefinitionSearchKey.isIncludeTagHierarchy())) {
            tagEntities.addAll(tagDaoHelper.getTagChildrenEntities(tagEntity));
        }
    }
    // Construct business object search response.
    BusinessObjectDefinitionSearchResponse searchResponse = new BusinessObjectDefinitionSearchResponse();
    List<BusinessObjectDefinition> businessObjectDefinitions = new ArrayList<>();
    searchResponse.setBusinessObjectDefinitions(businessObjectDefinitions);
    // Retrieve all unique business object definition entities and construct a list of business object definitions based on the requested fields.
    for (BusinessObjectDefinitionEntity businessObjectDefinition : ImmutableSet.copyOf(businessObjectDefinitionDao.getBusinessObjectDefinitions(tagEntities))) {
        businessObjectDefinitions.add(createBusinessObjectDefinitionFromEntity(businessObjectDefinition, fields));
    }
    return searchResponse;
}
Also used : BusinessObjectDefinitionSearchKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey) BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) ArrayList(java.util.ArrayList) BusinessObjectDefinitionSearchResponse(org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)

Aggregations

BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)14 BusinessObjectDefinitionSearchResponse (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchResponse)14 BusinessObjectDefinitionSearchKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchKey)13 BusinessObjectDefinitionSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchRequest)13 Test (org.junit.Test)13 HashSet (java.util.HashSet)12 BusinessObjectDefinitionSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDefinitionSearchFilter)12 TagKey (org.finra.herd.model.api.xml.TagKey)12 ArrayList (java.util.ArrayList)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)1 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)1 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)1 TagEntity (org.finra.herd.model.jpa.TagEntity)1