Search in sources :

Example 1 with ExpectedPartitionValueKey

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

the class GetExpectedPartitionValue method executeImpl.

@Override
public void executeImpl(DelegateExecution execution) throws Exception {
    String partitionKeyGroupName = activitiHelper.getExpressionVariableAsString(this.partitionKeyGroupName, execution);
    String expectedPartitionValue = activitiHelper.getExpressionVariableAsString(this.expectedPartitionValue, execution);
    Integer offset = activitiHelper.getExpressionVariableAsInteger(this.offset, execution, VARIABLE_OFFSET, false);
    ExpectedPartitionValueInformation expectedPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(partitionKeyGroupName, expectedPartitionValue), offset);
    // Set workflow variables based on the result expected partition value information.
    setTaskWorkflowVariable(execution, VARIABLE_PARTITION_KEY_GROUP_NAME, expectedPartitionValueInformation.getExpectedPartitionValueKey().getPartitionKeyGroupName());
    setTaskWorkflowVariable(execution, VARIABLE_EXPECTED_PARTITION_VALUE, expectedPartitionValueInformation.getExpectedPartitionValueKey().getExpectedPartitionValue());
}
Also used : ExpectedPartitionValueInformation(org.finra.herd.model.api.xml.ExpectedPartitionValueInformation) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey)

Example 2 with ExpectedPartitionValueKey

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

the class ExpectedPartitionValueServiceImpl method createExpectedPartitionValueInformationFromEntity.

/**
 * Creates the expected partition value information from the persisted entity.
 *
 * @param expectedPartitionValueEntity the expected partition value entity
 *
 * @return the expected partition value information
 */
private ExpectedPartitionValueInformation createExpectedPartitionValueInformationFromEntity(ExpectedPartitionValueEntity expectedPartitionValueEntity) {
    // Create an expected partition values information instance.
    ExpectedPartitionValueInformation expectedPartitionValueInformation = new ExpectedPartitionValueInformation();
    // Add the expected partition value key.
    ExpectedPartitionValueKey expectedPartitionValueKey = new ExpectedPartitionValueKey();
    expectedPartitionValueInformation.setExpectedPartitionValueKey(expectedPartitionValueKey);
    expectedPartitionValueKey.setPartitionKeyGroupName(expectedPartitionValueEntity.getPartitionKeyGroup().getPartitionKeyGroupName());
    expectedPartitionValueKey.setExpectedPartitionValue(expectedPartitionValueEntity.getPartitionValue());
    return expectedPartitionValueInformation;
}
Also used : ExpectedPartitionValueInformation(org.finra.herd.model.api.xml.ExpectedPartitionValueInformation) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey)

Example 3 with ExpectedPartitionValueKey

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

the class ExpectedPartitionValueDaoTest method testGetExpectedPartitionValue.

@Test
public void testGetExpectedPartitionValue() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP);
    // Create and persist a list of test expected partition values.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, expectedPartitionValueDaoTestHelper.getTestUnsortedExpectedPartitionValues());
    // Get expected partition value for different offset values.
    List<String> testSortedExpectedPartitionValues = expectedPartitionValueDaoTestHelper.getTestSortedExpectedPartitionValues();
    int testExpectedPartitionValueIndex = 3;
    for (Integer offset : Arrays.asList(-2, 0, 2)) {
        ExpectedPartitionValueEntity resultExpectedPartitionValueEntity = expectedPartitionValueDao.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP, testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex)), offset);
        // Validate the returned object.
        resultExpectedPartitionValueEntity.getPartitionValue().equals(testSortedExpectedPartitionValues.get(testExpectedPartitionValueIndex + offset));
    }
}
Also used : ExpectedPartitionValueEntity(org.finra.herd.model.jpa.ExpectedPartitionValueEntity) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey) Test(org.junit.Test)

Example 4 with ExpectedPartitionValueKey

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValueLowerCaseParameters.

@Test
public void testGetExpectedPartitionValueLowerCaseParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toUpperCase());
    // Create and persist a single test expected partition value.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toUpperCase()));
    // Get expected partition value with offset set to null using relative input parameters in lower case.
    ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP.toLowerCase(), PARTITION_VALUE.toUpperCase()), null);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP.toUpperCase(), PARTITION_VALUE.toUpperCase(), resultPartitionValueInformation);
}
Also used : ExpectedPartitionValueInformation(org.finra.herd.model.api.xml.ExpectedPartitionValueInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey) Test(org.junit.Test)

Example 5 with ExpectedPartitionValueKey

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

the class ExpectedPartitionValueServiceTest method testGetExpectedPartitionValueUpperCaseParameters.

@Test
public void testGetExpectedPartitionValueUpperCaseParameters() {
    // Create and persist a partition key group entity.
    PartitionKeyGroupEntity partitionKeyGroupEntity = partitionKeyGroupDaoTestHelper.createPartitionKeyGroupEntity(PARTITION_KEY_GROUP.toLowerCase());
    // Create and persist a single test expected partition value.
    expectedPartitionValueDaoTestHelper.createExpectedPartitionValueEntities(partitionKeyGroupEntity, Arrays.asList(PARTITION_VALUE.toLowerCase()));
    // Get expected partition value with offset set to null using relative input parameters in upper case.
    ExpectedPartitionValueInformation resultPartitionValueInformation = expectedPartitionValueService.getExpectedPartitionValue(new ExpectedPartitionValueKey(PARTITION_KEY_GROUP.toUpperCase(), PARTITION_VALUE.toLowerCase()), null);
    // Validate the returned object.
    expectedPartitionValueServiceTestHelper.validateExpectedPartitionValueInformation(PARTITION_KEY_GROUP.toLowerCase(), PARTITION_VALUE.toLowerCase(), resultPartitionValueInformation);
}
Also used : ExpectedPartitionValueInformation(org.finra.herd.model.api.xml.ExpectedPartitionValueInformation) PartitionKeyGroupEntity(org.finra.herd.model.jpa.PartitionKeyGroupEntity) ExpectedPartitionValueKey(org.finra.herd.model.api.xml.ExpectedPartitionValueKey) Test(org.junit.Test)

Aggregations

ExpectedPartitionValueKey (org.finra.herd.model.api.xml.ExpectedPartitionValueKey)16 Test (org.junit.Test)13 ExpectedPartitionValueInformation (org.finra.herd.model.api.xml.ExpectedPartitionValueInformation)9 PartitionKeyGroupEntity (org.finra.herd.model.jpa.PartitionKeyGroupEntity)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)3 ExpectedPartitionValuesCreateRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesCreateRequest)1 ExpectedPartitionValuesDeleteRequest (org.finra.herd.model.api.xml.ExpectedPartitionValuesDeleteRequest)1 ExpectedPartitionValuesInformation (org.finra.herd.model.api.xml.ExpectedPartitionValuesInformation)1 PartitionKeyGroupKey (org.finra.herd.model.api.xml.PartitionKeyGroupKey)1 PartitionValueRange (org.finra.herd.model.api.xml.PartitionValueRange)1 ExpectedPartitionValueEntity (org.finra.herd.model.jpa.ExpectedPartitionValueEntity)1 Secured (org.springframework.security.access.annotation.Secured)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1