Search in sources :

Example 1 with BusinessObjectDataSearchRequest

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

the class SearchBusinessObjectData method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
    String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataSearchRequest, execution, "BusinessObjectDataSearchRequest").trim();
    Integer pageNum = activitiHelper.getExpressionVariableAsInteger(this.pageNum, execution, "pageNum", false);
    Integer pageSize = activitiHelper.getExpressionVariableAsInteger(this.pageSize, execution, "pageSize", false);
    BusinessObjectDataSearchRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataSearchRequest.class);
    // Call the business object data search service.
    BusinessObjectDataSearchResultPagingInfoDto businessObjectDataSearchResultPagingInfoDto = businessObjectDataService.searchBusinessObjectData(pageNum, pageSize, request);
    // Set the JSON response as a workflow variable.
    setJsonResponseAsWorkflowVariable(businessObjectDataSearchResultPagingInfoDto.getBusinessObjectDataSearchResult(), execution);
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)

Example 2 with BusinessObjectDataSearchRequest

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

the class RetentionExpirationExporterController method performRetentionExpirationExport.

/**
 * Executes the retention expiration exporter workflow.
 *
 * @param namespace the namespace of business object data
 * @param businessObjectDefinitionName the business object definition name of business object data
 * @param localOutputFile the local output file
 * @param regServerAccessParamsDto the DTO for the parameters required to communicate with the registration server
 * @param udcServerHost the hostname of the UDC application server
 *
 * @throws Exception if any problems were encountered
 */
void performRetentionExpirationExport(String namespace, String businessObjectDefinitionName, File localOutputFile, RegServerAccessParamsDto regServerAccessParamsDto, String udcServerHost) throws Exception {
    // Fail if local output file already exists.
    if (localOutputFile.exists()) {
        throw new IllegalArgumentException(String.format("The specified local output file \"%s\" already exists.", localOutputFile.toString()));
    }
    // Initialize the web client.
    retentionExpirationExporterWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);
    // Validate that specified business object definition exists.
    BusinessObjectDefinition businessObjectDefinition = retentionExpirationExporterWebClient.getBusinessObjectDefinition(namespace, businessObjectDefinitionName);
    // Get business object display name.
    String businessObjectDefinitionDisplayName = getBusinessObjectDefinitionDisplayName(businessObjectDefinition);
    // Create a search request for business object data with the filter on retention expiration option.
    BusinessObjectDataSearchKey businessObjectDataSearchKey = new BusinessObjectDataSearchKey();
    businessObjectDataSearchKey.setNamespace(namespace);
    businessObjectDataSearchKey.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    businessObjectDataSearchKey.setFilterOnRetentionExpiration(true);
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    businessObjectDataSearchKeys.add(businessObjectDataSearchKey);
    BusinessObjectDataSearchFilter businessObjectDataSearchFilter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest(Collections.singletonList(businessObjectDataSearchFilter));
    // Create a result list for business object data.
    List<BusinessObjectData> businessObjectDataList = new ArrayList<>();
    // Fetch business object data from server until no records found.
    int pageNumber = 1;
    BusinessObjectDataSearchResult businessObjectDataSearchResult = retentionExpirationExporterWebClient.searchBusinessObjectData(request, pageNumber);
    while (CollectionUtils.isNotEmpty(businessObjectDataSearchResult.getBusinessObjectDataElements())) {
        LOGGER.info("Fetched {} business object data records from the registration server.", CollectionUtils.size(businessObjectDataSearchResult.getBusinessObjectDataElements()));
        businessObjectDataList.addAll(businessObjectDataSearchResult.getBusinessObjectDataElements());
        pageNumber++;
        businessObjectDataSearchResult = retentionExpirationExporterWebClient.searchBusinessObjectData(request, pageNumber);
    }
    // Write business object data to the output CSV file.
    writeToCsvFile(localOutputFile, businessObjectDefinition.getNamespace(), businessObjectDefinition.getBusinessObjectDefinitionName(), businessObjectDefinitionDisplayName, udcServerHost, businessObjectDataList);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) BusinessObjectDataSearchResult(org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)

Example 3 with BusinessObjectDataSearchRequest

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

the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithAttributeFilterValuesWithMultipleFilters.

@Test
public void testSearchBusinessObjectDataWithAttributeFilterValuesWithMultipleFilters() {
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
    businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
    businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2);
    businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_3_MIXED_CASE, ATTRIBUTE_VALUE_3);
    businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
    BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
    List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
    key.setNamespace(NAMESPACE);
    key.setBusinessObjectDefinitionName(BDEF_NAME);
    List<AttributeValueFilter> attributeValueFilters = new ArrayList<>();
    attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1));
    attributeValueFilters.add(new AttributeValueFilter(ATTRIBUTE_NAME_2_MIXED_CASE, null));
    key.setAttributeValueFilters(attributeValueFilters);
    businessObjectDataSearchKeys.add(key);
    BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    filters.add(filter);
    request.setBusinessObjectDataSearchFilters(filters);
    BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
    List<BusinessObjectData> resultList = result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements();
    assertEquals(1, resultList.size());
    for (BusinessObjectData data : resultList) {
        assertEquals(NAMESPACE, data.getNamespace());
        assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
        assertEquals(2, data.getAttributes().size());
        boolean foundCase1 = false, foundCase2 = false;
        for (int i = 0; i < data.getAttributes().size(); i++) {
            if (ATTRIBUTE_NAME_1_MIXED_CASE.equals(data.getAttributes().get(i).getName())) {
                assertEquals(ATTRIBUTE_VALUE_1, data.getAttributes().get(i).getValue());
                foundCase1 = true;
            }
            if (ATTRIBUTE_NAME_2_MIXED_CASE.equals(data.getAttributes().get(i).getName())) {
                assertEquals(ATTRIBUTE_VALUE_2, data.getAttributes().get(i).getValue());
                foundCase2 = true;
            }
        }
        assertTrue(foundCase1 && foundCase2);
    }
    // Validate the paging information.
    assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
    assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
    assertEquals(Long.valueOf(1), result.getPageCount());
    assertEquals(Long.valueOf(1), result.getTotalRecordsOnPage());
    assertEquals(Long.valueOf(1), result.getTotalRecordCount());
    assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) AttributeValueFilter(org.finra.herd.model.api.xml.AttributeValueFilter) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) Test(org.junit.Test)

Example 4 with BusinessObjectDataSearchRequest

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

the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectDataWithMaxRecordsExceeded.

@Test
public void testSearchBusinessObjectDataWithMaxRecordsExceeded() throws Exception {
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, true, "VALID");
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, null, DATA_VERSION, true, "INVALID");
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION_2, PARTITION_VALUE, null, DATA_VERSION, true, "INVALID");
    businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, PARTITION_VALUE, null, DATA_VERSION, true, "VALID");
    // Override configuration.
    int maxBusinessObjectDataSearchResultCount = 2;
    Map<String, Object> overrideMap = new HashMap<>();
    overrideMap.put(ConfigurationValue.BUSINESS_OBJECT_DATA_SEARCH_MAX_RESULT_COUNT.getKey(), maxBusinessObjectDataSearchResultCount);
    modifyPropertySourceInEnvironment(overrideMap);
    try {
        businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, DEFAULT_PAGE_SIZE, new BusinessObjectDataSearchRequest(Collections.singletonList(new BusinessObjectDataSearchFilter(Collections.singletonList(new BusinessObjectDataSearchKey(NAMESPACE, BDEF_NAME, NO_FORMAT_USAGE_CODE, NO_FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION, NO_PARTITION_VALUE_FILTERS, NO_ATTRIBUTE_VALUE_FILTERS, NO_FILTER_ON_LATEST_VALID_VERSION, NO_FILTER_ON_RETENTION_EXPIRATION))))));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Result limit of %d exceeded. Total result size %d. Modify filters to further limit results.", maxBusinessObjectDataSearchResultCount, 3), e.getMessage());
    } finally {
        // Restore the property sources so we don't affect other tests.
        restorePropertySourceInEnvironment();
    }
}
Also used : BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) HashMap(java.util.HashMap) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Example 5 with BusinessObjectDataSearchRequest

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

the class BusinessObjectDataSearchServiceTest method testSearchBusinessObjectData.

@Test
public void testSearchBusinessObjectData() {
    businessObjectDataServiceTestHelper.createDatabaseEntitiesForBusinessObjectDataSearchTesting();
    BusinessObjectDataSearchRequest request = new BusinessObjectDataSearchRequest();
    List<BusinessObjectDataSearchFilter> filters = new ArrayList<>();
    List<BusinessObjectDataSearchKey> businessObjectDataSearchKeys = new ArrayList<>();
    BusinessObjectDataSearchKey key = new BusinessObjectDataSearchKey();
    key.setNamespace(NAMESPACE);
    key.setBusinessObjectDefinitionName(BDEF_NAME);
    businessObjectDataSearchKeys.add(key);
    BusinessObjectDataSearchFilter filter = new BusinessObjectDataSearchFilter(businessObjectDataSearchKeys);
    filters.add(filter);
    request.setBusinessObjectDataSearchFilters(filters);
    BusinessObjectDataSearchResultPagingInfoDto result = businessObjectDataService.searchBusinessObjectData(DEFAULT_PAGE_NUMBER, PAGE_SIZE, request);
    assertTrue(result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements().size() == 2);
    for (BusinessObjectData data : result.getBusinessObjectDataSearchResult().getBusinessObjectDataElements()) {
        assertEquals(NAMESPACE, data.getNamespace());
        assertEquals(BDEF_NAME, data.getBusinessObjectDefinitionName());
    }
    // Validate the paging information.
    assertEquals(Long.valueOf(DEFAULT_PAGE_NUMBER), result.getPageNum());
    assertEquals(Long.valueOf(PAGE_SIZE), result.getPageSize());
    assertEquals(Long.valueOf(1), result.getPageCount());
    assertEquals(Long.valueOf(2), result.getTotalRecordsOnPage());
    assertEquals(Long.valueOf(2), result.getTotalRecordCount());
    assertEquals(Long.valueOf(DEFAULT_PAGE_SIZE), result.getMaxResultsPerPage());
}
Also used : BusinessObjectDataSearchResultPagingInfoDto(org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto) BusinessObjectDataSearchFilter(org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) ArrayList(java.util.ArrayList) BusinessObjectDataSearchKey(org.finra.herd.model.api.xml.BusinessObjectDataSearchKey) BusinessObjectDataSearchRequest(org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDataSearchRequest (org.finra.herd.model.api.xml.BusinessObjectDataSearchRequest)21 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)13 BusinessObjectDataSearchFilter (org.finra.herd.model.api.xml.BusinessObjectDataSearchFilter)12 BusinessObjectDataSearchKey (org.finra.herd.model.api.xml.BusinessObjectDataSearchKey)12 BusinessObjectDataSearchResultPagingInfoDto (org.finra.herd.model.dto.BusinessObjectDataSearchResultPagingInfoDto)10 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)6 BusinessObjectDataSearchResult (org.finra.herd.model.api.xml.BusinessObjectDataSearchResult)5 HashMap (java.util.HashMap)4 AttributeValueFilter (org.finra.herd.model.api.xml.AttributeValueFilter)4 FieldExtension (org.activiti.bpmn.model.FieldExtension)3 Parameter (org.finra.herd.model.api.xml.Parameter)3 PartitionValueFilter (org.finra.herd.model.api.xml.PartitionValueFilter)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1