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());
}
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;
}
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));
}
}
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);
}
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);
}
Aggregations