use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildSearchBusinessObjectDataResponse.
/**
* Builds a business object definition response.
*
* @param response the response
* @param uri the URI of the incoming request
*
* @throws JAXBException if a JAXB error occurred
*/
private void buildSearchBusinessObjectDataResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
BusinessObjectDataSearchResult businessObjectDataSearchResult = new BusinessObjectDataSearchResult();
// Build the response based on the pageNum.
if (uri.getRawQuery().equals("pageNum=1")) {
List<BusinessObjectData> businessObjectDataElements = new ArrayList<>();
// Add business object data with sub-partitions.
BusinessObjectData businessObjectDataWithSubPartitions = new BusinessObjectData();
businessObjectDataWithSubPartitions.setNamespace("testNamespace");
businessObjectDataWithSubPartitions.setBusinessObjectDefinitionName("testBusinessObjectDefinitionName");
businessObjectDataWithSubPartitions.setBusinessObjectFormatUsage("testBusinessObjectFormatUsage");
businessObjectDataWithSubPartitions.setBusinessObjectFormatFileType("testBusinessObjectFormatFileType");
businessObjectDataWithSubPartitions.setBusinessObjectFormatVersion(9);
businessObjectDataWithSubPartitions.setPartitionValue("primaryPartitionValue");
businessObjectDataWithSubPartitions.setSubPartitionValues(Arrays.asList("subPartitionValue1", "subPartitionValue2", "subPartitionValue3", "subPartitionValue4"));
businessObjectDataWithSubPartitions.setVersion(5);
businessObjectDataElements.add(businessObjectDataWithSubPartitions);
// Add business object data without sub-partitions.
BusinessObjectData businessObjectDataWithoutSubPartitions = new BusinessObjectData();
businessObjectDataWithoutSubPartitions.setNamespace("testNamespace");
businessObjectDataWithoutSubPartitions.setBusinessObjectDefinitionName("testBusinessObjectDefinitionName");
businessObjectDataWithoutSubPartitions.setBusinessObjectFormatUsage("testBusinessObjectFormatUsage");
businessObjectDataWithoutSubPartitions.setBusinessObjectFormatFileType("testBusinessObjectFormatFileType");
businessObjectDataWithoutSubPartitions.setBusinessObjectFormatVersion(9);
businessObjectDataWithoutSubPartitions.setPartitionValue("primaryPartitionValue");
businessObjectDataWithoutSubPartitions.setSubPartitionValues(null);
businessObjectDataWithoutSubPartitions.setVersion(5);
businessObjectDataElements.add(businessObjectDataWithoutSubPartitions);
businessObjectDataSearchResult.setBusinessObjectDataElements(businessObjectDataElements);
}
response.setEntity(getHttpEntity(businessObjectDataSearchResult));
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildGetBusinessObjectDataResponse.
/**
* Builds a business object data response.
*
* @param response the response.
* @param uri the URI of the incoming request.
*
* @throws JAXBException if a JAXB error occurred.
*/
private void buildGetBusinessObjectDataResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
Pattern pattern = Pattern.compile("/herd-app/rest/businessObjectData/namespaces/(.*)/businessObjectDefinitionNames/(.*)/businessObjectFormatUsages/(.*)" + "/businessObjectFormatFileTypes/(.*).*");
Matcher matcher = pattern.matcher(uri.getPath());
if (matcher.find()) {
BusinessObjectData businessObjectData = new BusinessObjectData();
businessObjectData.setNamespace(matcher.group(1));
businessObjectData.setBusinessObjectDefinitionName(matcher.group(2));
businessObjectData.setBusinessObjectFormatUsage(matcher.group(3));
businessObjectData.setBusinessObjectFormatFileType(matcher.group(4));
businessObjectData.setPartitionValue("2014-01-31");
businessObjectData.setPartitionKey("PROCESS_DATE");
businessObjectData.setAttributes(new ArrayList<Attribute>());
businessObjectData.setBusinessObjectFormatVersion(0);
businessObjectData.setLatestVersion(true);
businessObjectData.setStatus(BusinessObjectDataStatusEntity.VALID);
List<StorageUnit> storageUnits = new ArrayList<>();
businessObjectData.setStorageUnits(storageUnits);
StorageUnit storageUnit = new StorageUnit();
storageUnits.add(storageUnit);
storageUnit.setStorage(getNewStorage(StorageEntity.MANAGED_STORAGE));
List<StorageFile> storageFiles = new ArrayList<>();
storageUnit.setStorageFiles(storageFiles);
storageUnit.setStorageUnitStatus(StorageUnitStatusEntity.ENABLED);
List<String> localFiles = Arrays.asList("foo1.dat", "Foo2.dat", "FOO3.DAT", "folder/foo3.dat", "folder/foo2.dat", "folder/foo1.dat");
for (String filename : localFiles) {
StorageFile storageFile = new StorageFile();
storageFiles.add(storageFile);
storageFile.setFilePath(businessObjectData.getNamespace().toLowerCase().replace('_', '-') + "/exchange-a/" + businessObjectData.getBusinessObjectFormatUsage().toLowerCase().replace('_', '-') + "/" + businessObjectData.getBusinessObjectFormatFileType().toLowerCase().replace('_', '-') + "/" + businessObjectData.getBusinessObjectDefinitionName().toLowerCase().replace('_', '-') + "/frmt-v" + businessObjectData.getBusinessObjectFormatVersion() + "/data-v" + businessObjectData.getVersion() + "/" + businessObjectData.getPartitionKey().toLowerCase().replace('_', '-') + "=" + businessObjectData.getPartitionValue() + "/" + filename);
storageFile.setFileSizeBytes(1024L);
storageFile.setRowCount(10L);
}
businessObjectData.setSubPartitionValues(new ArrayList<String>());
businessObjectData.setId(1234);
businessObjectData.setVersion(0);
response.setEntity(getHttpEntity(businessObjectData));
}
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class MockHttpClientOperationsImpl method buildPostBusinessObjectDataResponse.
/**
* Builds a business object data create response.
*
* @param response the response.
* @param uri the URI of the incoming request.
*
* @throws JAXBException if a JAXB error occurred.
*/
private void buildPostBusinessObjectDataResponse(MockCloseableHttpResponse response, URI uri) throws JAXBException {
BusinessObjectData businessObjectData = new BusinessObjectData();
List<StorageUnit> storageUnits = new ArrayList<>();
businessObjectData.setStorageUnits(storageUnits);
StorageUnit storageUnit = new StorageUnit();
storageUnit.setStorageDirectory(new StorageDirectory("app-a/exchange-a/prc/txt/new-orders/frmt-v0/data-v0/process-date=2014-01-31"));
storageUnits.add(storageUnit);
response.setEntity(getHttpEntity(businessObjectData));
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class StorageUnitStatusChangeNotificationJobActionServiceImpl method buildJobParameters.
private List<Parameter> buildJobParameters(StorageUnitNotificationEventParamsDto storageUnitNotificationEventParams) throws IOException {
List<Parameter> parameters = new ArrayList<>();
BusinessObjectData businessObjectData = storageUnitNotificationEventParams.getBusinessObjectData();
NotificationJobActionEntity notificationJobActionEntity = storageUnitNotificationEventParams.getNotificationJobAction();
parameters.add(new Parameter(PARAM_NAMESPACE, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getNamespace().getCode()));
parameters.add(new Parameter(PARAM_NOTIFICATION_NAME, storageUnitNotificationEventParams.getStorageUnitNotificationRegistration().getName()));
parameters.add(new Parameter(PARAM_STORAGE_UNIT_EVENT_TYPE, storageUnitNotificationEventParams.getEventType()));
parameters.add(new Parameter(PARAM_CORRELATION_DATA, notificationJobActionEntity.getCorrelationData()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA, jsonHelper.objectToJson(businessObjectData)));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAMESPACE, businessObjectData.getNamespace()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DEFINITION_NAME, businessObjectData.getBusinessObjectDefinitionName()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_USAGE, businessObjectData.getBusinessObjectFormatUsage()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_FILE_TYPE, businessObjectData.getBusinessObjectFormatFileType()));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_FORMAT_VERSION, Integer.toString(businessObjectData.getBusinessObjectFormatVersion())));
parameters.add(new Parameter(PARAM_PARTITION_COLUMN_NAMES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionColumnNames())));
parameters.add(new Parameter(PARAM_PARTITION_VALUES, herdStringHelper.buildStringWithDefaultDelimiter(storageUnitNotificationEventParams.getPartitionValues())));
parameters.add(new Parameter(PARAM_BUSINESS_OBJECT_DATA_VERSION, Integer.toString(businessObjectData.getVersion())));
parameters.add(new Parameter(PARAM_STORAGE_NAME, storageUnitNotificationEventParams.getStorageName()));
parameters.add(new Parameter(PARAM_NEW_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getNewStorageUnitStatus()));
parameters.add(new Parameter(PARAM_OLD_STORAGE_UNIT_STATUS, storageUnitNotificationEventParams.getOldStorageUnitStatus()));
return parameters;
}
use of org.finra.herd.model.api.xml.BusinessObjectData in project herd by FINRAOS.
the class RegisterBusinessObjectData method executeImpl.
@Override
public void executeImpl(DelegateExecution execution) throws Exception {
String contentTypeString = activitiHelper.getRequiredExpressionVariableAsString(contentType, execution, "ContentType").trim();
String requestString = activitiHelper.getRequiredExpressionVariableAsString(businessObjectDataCreateRequest, execution, "BusinessObjectDataCreateRequest").trim();
BusinessObjectDataCreateRequest request = getRequestObject(contentTypeString, requestString, BusinessObjectDataCreateRequest.class);
// Register the data.
BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Trigger notifications.
businessObjectDataDaoHelper.triggerNotificationsForCreateBusinessObjectData(businessObjectData);
// Set the JSON response as a workflow variable.
setJsonResponseAsWorkflowVariable(businessObjectData, execution);
setTaskWorkflowVariable(execution, VARIABLE_ID, businessObjectData.getId());
setTaskWorkflowVariable(execution, VARIABLE_VERSION, businessObjectData.getVersion());
setTaskWorkflowVariable(execution, VARIABLE_LATEST_VERSION, businessObjectData.isLatestVersion());
}
Aggregations