use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.
the class ValueMetaResolver method tryConversionWithMask.
private Object tryConversionWithMask(ValueMetaInterface valueMeta, int originalType, Object value, String mask) throws PushDownOptimizationException {
ValueMeta originalTypeMeta = new ValueMeta(null, originalType);
originalTypeMeta.setConversionMask(mask);
try {
return valueMeta.convertData(originalTypeMeta, value);
} catch (KettleValueException e) {
throw new PushDownOptimizationException("Failed to convert type", e);
}
}
use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.
the class MongodbPredicateTest method setup.
@Before
public void setup() {
for (int i = 0; i < 10; i++) {
rowMeta.addValueMeta(new ValueMeta("sField" + i, ValueMetaInterface.TYPE_STRING, 50));
rowMeta.addValueMeta(new ValueMeta("iField" + i, ValueMetaInterface.TYPE_INTEGER, 7));
}
resolver = new ValueMetaResolver(rowMeta);
fieldMappings = new HashMap<String, String>();
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testGetInputFieldsToIgnore.
@Test
public void testGetInputFieldsToIgnore() {
doReturn(true).when(analyzer).isInput();
// setup input fields
RowMetaInterface inputFieldRowMeta = mock(RowMetaInterface.class);
List<ValueMetaInterface> inputFields = new ArrayList<>();
inputFields.add(new ValueMeta("in_field_1"));
Map<String, RowMetaInterface> inputFieldRowMetaMap = new HashMap<>();
inputFieldRowMetaMap.put(ExternalResourceStepAnalyzer.RESOURCE, inputFieldRowMeta);
when(inputFieldRowMeta.getValueMetaList()).thenReturn(inputFields);
// setup output fields
List<ValueMetaInterface> outputFields = new ArrayList<>();
outputFields.addAll(inputFields);
outputFields.add(new ValueMeta("file_field_1"));
outputFields.add(new ValueMeta("additional_field"));
outputFields.add(new ValueMeta("file_field_2"));
RowMetaInterface outputFieldsRowMeta = mock(RowMetaInterface.class);
when(outputFieldsRowMeta.getValueMetaList()).thenReturn(outputFields);
// setup step "resource" fields
final BaseFileField[] resourceFields = new BaseFileField[2];
resourceFields[0] = new BaseFileField("file_field_1", 0, 0);
resourceFields[1] = new BaseFileField("file_field_2", 0, 0);
doReturn(resourceFields).when(fileMeta).getInputFields();
Set<String> fieldsToIgnore = analyzer.getInputFieldsToIgnore(fileMeta, inputFieldRowMetaMap, outputFieldsRowMeta);
assertEquals(2, fieldsToIgnore.size());
assertTrue(fieldsToIgnore.contains("in_field_1"));
assertTrue(fieldsToIgnore.contains("additional_field"));
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testCreateInputFieldNode_resource.
@Test
public void testCreateInputFieldNode_resource() throws Exception {
IAnalysisContext context = mock(IAnalysisContext.class);
doReturn("thisStepName").when(analyzer).getStepName();
analyzer.rootNode = node;
when(node.getLogicalId()).thenReturn("logical id");
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode inputFieldNode = analyzer.createInputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(inputFieldNode);
assertNotNull(inputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("thisStepName", inputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
assertEquals("INPUT_TYPE", inputFieldNode.getType());
// the input node should be added by this step
verify(builder).addNode(inputFieldNode);
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzerTest method testGetInputRowMetaInterfaces_isInputAndIncomingNodes.
@Test
public void testGetInputRowMetaInterfaces_isInputAndIncomingNodes() throws Exception {
Map<String, RowMetaInterface> inputs = new HashMap<>();
RowMetaInterface inputRmi = mock(RowMetaInterface.class);
List<ValueMetaInterface> vmis = new ArrayList<>();
ValueMetaInterface vmi = new ValueMeta("filename");
vmis.add(vmi);
when(inputRmi.getValueMetaList()).thenReturn(vmis);
inputs.put("test", inputRmi);
doReturn(inputs).when(analyzer).getInputFields(meta);
when(parentTransMeta.getPrevStepNames(parentStepMeta)).thenReturn(null);
RowMetaInterface rowMetaInterface = new RowMeta();
rowMetaInterface.addValueMeta(vmi);
ValueMetaInterface vmi2 = new ValueMeta("otherField");
rowMetaInterface.addValueMeta(vmi2);
doReturn(rowMetaInterface).when(analyzer).getOutputFields(meta);
doReturn(true).when(analyzer).isInput();
Map<String, RowMetaInterface> rowMetaInterfaces = analyzer.getInputRowMetaInterfaces(meta);
assertNotNull(rowMetaInterfaces);
assertEquals(2, rowMetaInterfaces.size());
RowMetaInterface metaInterface = rowMetaInterfaces.get(ExternalResourceStepAnalyzer.RESOURCE);
// the row meta interface should only have 1 value meta in it, and it should NOT be filename
assertEquals(1, metaInterface.size());
assertEquals("otherField", metaInterface.getFieldNames()[0]);
}
Aggregations