Search in sources :

Example 1 with BusinessObjectDataStatusChangeEvent

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

the class GetBusinessObjectDataTest method testGetBusinessObjectDataIncludeBusinessObjectDataStatusHistory.

@Test
public void testGetBusinessObjectDataIncludeBusinessObjectDataStatusHistory() throws Exception {
    // 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 business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
    fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
    fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataStatus", "${businessObjectDataStatus}"));
    fieldExtensionList.add(buildFieldExtension("includeBusinessObjectDataStatusHistory", "${includeBusinessObjectDataStatusHistory}"));
    fieldExtensionList.add(buildFieldExtension("includeStorageUnitStatusHistory", "${includeStorageUnitStatusHistory}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
    parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
    parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
    parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
    parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
    parameters.add(buildParameter("subPartitionValues", herdStringHelper.buildStringWithDefaultDelimiter(SUBPARTITION_VALUES)));
    parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
    parameters.add(buildParameter("businessObjectDataStatus", BusinessObjectDataStatusEntity.VALID));
    parameters.add(buildParameter("includeBusinessObjectDataStatusHistory", INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY.toString()));
    parameters.add(buildParameter("includeStorageUnitStatusHistory", NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY.toString()));
    // Build the expected response object. The business object data history record is expected to have system username for the createdBy auditable field.
    BusinessObjectData expectedBusinessObjectData = new BusinessObjectData(businessObjectDataEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, NO_STORAGE_UNITS, NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, Arrays.asList(new BusinessObjectDataStatusChangeEvent(BusinessObjectDataStatusEntity.VALID, HerdDateUtils.getXMLGregorianCalendarValue(IterableUtils.get(businessObjectDataEntity.getHistoricalStatuses(), 0).getCreatedOn()), HerdDaoSecurityHelper.SYSTEM_USER)));
    // Run the activiti task and validate the returned response object.
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(GetBusinessObjectDataStatus.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectData));
    testActivitiServiceTaskSuccess(GetBusinessObjectData.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataStatusChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDataStatusChangeEvent) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) FieldExtension(org.activiti.bpmn.model.FieldExtension) Parameter(org.finra.herd.model.api.xml.Parameter) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) Test(org.junit.Test)

Example 2 with BusinessObjectDataStatusChangeEvent

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

the class BusinessObjectDataHelper method createBusinessObjectDataFromEntity.

/**
 * Creates the business object data from the persisted entity.
 *
 * @param businessObjectDataEntity the newly persisted business object data entity.
 * @param includeBusinessObjectDataStatusHistory specifies to include business object data status history in the response
 * @param includeStorageUnitStatusHistory specifies to include storage unit status history for each storage unit in the response
 *
 * @return the business object data.
 */
public BusinessObjectData createBusinessObjectDataFromEntity(BusinessObjectDataEntity businessObjectDataEntity, Boolean includeBusinessObjectDataStatusHistory, Boolean includeStorageUnitStatusHistory) {
    // Make the business object format associated with this data easily accessible.
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectDataEntity.getBusinessObjectFormat();
    // Create the core business object data information.
    BusinessObjectData businessObjectData = new BusinessObjectData();
    businessObjectData.setNamespace(businessObjectFormatEntity.getBusinessObjectDefinition().getNamespace().getCode());
    businessObjectData.setBusinessObjectDefinitionName(businessObjectFormatEntity.getBusinessObjectDefinition().getName());
    businessObjectData.setId(businessObjectDataEntity.getId());
    businessObjectData.setBusinessObjectFormatUsage(businessObjectFormatEntity.getUsage());
    businessObjectData.setBusinessObjectFormatFileType(businessObjectFormatEntity.getFileType().getCode());
    businessObjectData.setBusinessObjectFormatVersion(businessObjectFormatEntity.getBusinessObjectFormatVersion());
    businessObjectData.setPartitionKey(businessObjectDataEntity.getBusinessObjectFormat().getPartitionKey());
    businessObjectData.setPartitionValue(businessObjectDataEntity.getPartitionValue());
    businessObjectData.setSubPartitionValues(getSubPartitionValues(businessObjectDataEntity));
    businessObjectData.setStatus(businessObjectDataEntity.getStatus().getCode());
    businessObjectData.setVersion(businessObjectDataEntity.getVersion());
    businessObjectData.setLatestVersion(businessObjectDataEntity.getLatestVersion());
    // Add in the storage units.
    businessObjectData.setStorageUnits(storageUnitHelper.createStorageUnitsFromEntities(businessObjectDataEntity.getStorageUnits(), includeStorageUnitStatusHistory));
    // Add in the attributes.
    List<Attribute> attributes = new ArrayList<>();
    businessObjectData.setAttributes(attributes);
    for (BusinessObjectDataAttributeEntity attributeEntity : businessObjectDataEntity.getAttributes()) {
        Attribute attribute = new Attribute();
        attributes.add(attribute);
        attribute.setName(attributeEntity.getName());
        attribute.setValue(attributeEntity.getValue());
    }
    // Add in the parents - sorted.
    List<BusinessObjectDataKey> businessObjectDataKeys = new ArrayList<>();
    businessObjectData.setBusinessObjectDataParents(businessObjectDataKeys);
    for (BusinessObjectDataEntity parent : businessObjectDataEntity.getBusinessObjectDataParents()) {
        businessObjectDataKeys.add(createBusinessObjectDataKeyFromEntity(parent));
    }
    Collections.sort(businessObjectDataKeys, new BusinessObjectDataKeyComparator());
    // Add in the children - sorted.
    businessObjectDataKeys = new ArrayList<>();
    businessObjectData.setBusinessObjectDataChildren(businessObjectDataKeys);
    for (BusinessObjectDataEntity parent : businessObjectDataEntity.getBusinessObjectDataChildren()) {
        businessObjectDataKeys.add(createBusinessObjectDataKeyFromEntity(parent));
    }
    Collections.sort(businessObjectDataKeys, new BusinessObjectDataKeyComparator());
    // If specified, add business object data status history.
    if (BooleanUtils.isTrue(includeBusinessObjectDataStatusHistory)) {
        List<BusinessObjectDataStatusChangeEvent> businessObjectDataStatusChangeEvents = new ArrayList<>();
        businessObjectData.setBusinessObjectDataStatusHistory(businessObjectDataStatusChangeEvents);
        for (BusinessObjectDataStatusHistoryEntity businessObjectDataStatusHistoryEntity : businessObjectDataEntity.getHistoricalStatuses()) {
            businessObjectDataStatusChangeEvents.add(new BusinessObjectDataStatusChangeEvent(businessObjectDataStatusHistoryEntity.getStatus().getCode(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDataStatusHistoryEntity.getCreatedOn()), businessObjectDataStatusHistoryEntity.getCreatedBy()));
        }
    }
    return businessObjectData;
}
Also used : BusinessObjectDataAttributeEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity) BusinessObjectDataStatusChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDataStatusChangeEvent) BusinessObjectDataStatusHistoryEntity(org.finra.herd.model.jpa.BusinessObjectDataStatusHistoryEntity) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity)

Example 3 with BusinessObjectDataStatusChangeEvent

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

the class BusinessObjectDataServiceGetBusinessObjectDataTest method testGetBusinessObjectDataIncludeBusinessObjectDataStatusHistory.

@Test
public void testGetBusinessObjectDataIncludeBusinessObjectDataStatusHistory() {
    // 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 business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    // Retrieve the business object data with enabled include business object data status history flag.
    BusinessObjectData resultBusinessObjectData = businessObjectDataService.getBusinessObjectData(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION), PARTITION_KEY, BusinessObjectDataStatusEntity.VALID, INCLUDE_BUSINESS_OBJECT_DATA_STATUS_HISTORY, NO_INCLUDE_STORAGE_UNIT_STATUS_HISTORY);
    // Build the expected response object. The business object data history record is expected to have system username for the createdBy auditable field.
    BusinessObjectData expectedBusinessObjectData = new BusinessObjectData(businessObjectDataEntity.getId(), BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, NO_STORAGE_UNITS, NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, Arrays.asList(new BusinessObjectDataStatusChangeEvent(BusinessObjectDataStatusEntity.VALID, HerdDateUtils.getXMLGregorianCalendarValue(IterableUtils.get(businessObjectDataEntity.getHistoricalStatuses(), 0).getCreatedOn()), HerdDaoSecurityHelper.SYSTEM_USER)));
    // Validate the returned response object.
    assertEquals(expectedBusinessObjectData, resultBusinessObjectData);
}
Also used : BusinessObjectDataStatusChangeEvent(org.finra.herd.model.api.xml.BusinessObjectDataStatusChangeEvent) BusinessObjectData(org.finra.herd.model.api.xml.BusinessObjectData) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)3 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)3 BusinessObjectDataStatusChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDataStatusChangeEvent)3 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 FieldExtension (org.activiti.bpmn.model.FieldExtension)1 Attribute (org.finra.herd.model.api.xml.Attribute)1 Parameter (org.finra.herd.model.api.xml.Parameter)1 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)1 BusinessObjectDataStatusHistoryEntity (org.finra.herd.model.jpa.BusinessObjectDataStatusHistoryEntity)1 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)1