Search in sources :

Example 1 with BusinessObjectDataVersion

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

the class BusinessObjectDataServiceImpl method getBusinessObjectDataVersions.

@NamespacePermission(fields = "#businessObjectDataKey.namespace", permissions = NamespacePermissionEnum.READ)
@Override
public BusinessObjectDataVersions getBusinessObjectDataVersions(BusinessObjectDataKey businessObjectDataKey) {
    // Validate and trim the business object data key.
    businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, false, false);
    // Get the business object data versions based on the specified parameters.
    List<BusinessObjectDataEntity> businessObjectDataEntities = businessObjectDataDao.getBusinessObjectDataEntities(businessObjectDataKey);
    // Create the response.
    BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
    for (BusinessObjectDataEntity businessObjectDataEntity : businessObjectDataEntities) {
        BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
        BusinessObjectDataKey businessObjectDataVersionKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
        businessObjectDataVersion.setBusinessObjectDataKey(businessObjectDataVersionKey);
        businessObjectDataVersion.setStatus(businessObjectDataEntity.getStatus().getCode());
        businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
    }
    return businessObjectDataVersions;
}
Also used : BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 2 with BusinessObjectDataVersion

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

the class MockHttpClientOperationsImpl method buildGetBusinessObjectDataVersionsResponse.

/**
 * Builds a business object data get versions response.
 *
 * @param response the response.
 * @param uri the URI of the incoming request.
 *
 * @throws JAXBException if a JAXB error occurred.
 */
private void buildGetBusinessObjectDataVersionsResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
    Pattern pattern = Pattern.compile("/herd-app/rest/businessObjectData(/namespaces/(?<namespace>.*?))?" + "/businessObjectDefinitionNames/(?<businessObjectDefinitionName>.*?)/businessObjectFormatUsages/(?<businessObjectFormatUsage>.*?)" + "/businessObjectFormatFileTypes/(?<businessObjectFormatFileType>.*?)" + "/versions");
    Matcher matcher = pattern.matcher(uri.getPath());
    if (matcher.find()) {
        BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions();
        if (HOSTNAME_LATEST_BDATA_VERSION_EXISTS.equals(uri.getHost()) || HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost())) {
            BusinessObjectDataVersion businessObjectDataVersion = new BusinessObjectDataVersion();
            businessObjectDataVersions.getBusinessObjectDataVersions().add(businessObjectDataVersion);
            businessObjectDataVersion.setBusinessObjectDataKey(new BusinessObjectDataKey(getGroup(matcher, "namespace"), getGroup(matcher, "businessObjectDefinitionName"), getGroup(matcher, "businessObjectFormatUsage"), getGroup(matcher, "businessObjectFormatFileType"), 0, "2014-01-31", null, 0));
            businessObjectDataVersion.setStatus(HOSTNAME_LATEST_BDATA_VERSION_EXISTS_IN_UPLOADING_STATE.equals(uri.getHost()) ? BusinessObjectDataStatusEntity.UPLOADING : BusinessObjectDataStatusEntity.VALID);
        }
        response.setEntity(getHttpEntity(businessObjectDataVersions));
    }
}
Also used : Pattern(java.util.regex.Pattern) BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) Matcher(java.util.regex.Matcher) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey)

Example 3 with BusinessObjectDataVersion

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

the class BusinessObjectDataRestControllerTest method testGetBusinessObjectDataVersions.

@Test
public void testGetBusinessObjectDataVersions() {
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
    // Create a list of business object data versions.
    BusinessObjectDataVersions businessObjectDataVersions = new BusinessObjectDataVersions(Arrays.asList(new BusinessObjectDataVersion()));
    // Mock the external calls.
    when(businessObjectDataService.getBusinessObjectDataVersions(businessObjectDataKey)).thenReturn(businessObjectDataVersions);
    // Call the method under test.
    BusinessObjectDataVersions result = businessObjectDataRestController.getBusinessObjectDataVersions(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_VALUE, getDelimitedFieldValues(SUBPARTITION_VALUES), FORMAT_VERSION, DATA_VERSION);
    // Verify the external calls.
    verify(businessObjectDataService).getBusinessObjectDataVersions(businessObjectDataKey);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(businessObjectDataVersions, result);
}
Also used : BusinessObjectDataVersion(org.finra.herd.model.api.xml.BusinessObjectDataVersion) BusinessObjectDataVersions(org.finra.herd.model.api.xml.BusinessObjectDataVersions) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 BusinessObjectDataVersion (org.finra.herd.model.api.xml.BusinessObjectDataVersion)3 BusinessObjectDataVersions (org.finra.herd.model.api.xml.BusinessObjectDataVersions)3 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)1 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)1 Test (org.junit.Test)1