use of org.pentaho.mongo.wrapper.field.MongoField in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzerTest method testCreateOutputFieldNode.
@Test
public void testCreateOutputFieldNode() throws Exception {
IAnalysisContext context = mock(IAnalysisContext.class);
ValueMetaInterface vmi = new ValueMeta("field1");
MongoField mongoField1 = new MongoField();
mongoField1.m_fieldName = "field1";
mongoField1.m_fieldPath = "$.field1";
mongoField1.m_arrayIndexInfo = "range";
mongoField1.m_occurenceFraction = "occurence";
mongoField1.m_indexedVals = Arrays.asList(new String[] { "one", "two" });
mongoField1.m_disparateTypes = true;
mongoField1.m_kettleType = "ValueMetaString";
mongoField1.m_outputIndex = 0;
List<MongoField> mongoFields = Arrays.asList(mongoField1);
when(meta.getMongoFields()).thenReturn(mongoFields);
doReturn("thisStepName").when(analyzer).getStepName();
when(node.getLogicalId()).thenReturn("logical id");
IMetaverseNode node = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(node);
assertEquals("field1", node.getName());
assertEquals(mongoField1.m_fieldPath, node.getProperty(MongoDbInputStepAnalyzer.JSON_PATH));
assertEquals(mongoField1.m_arrayIndexInfo, node.getProperty(MongoDbInputStepAnalyzer.MINMAX_RANGE));
assertEquals(mongoField1.m_occurenceFraction, node.getProperty(MongoDbInputStepAnalyzer.OCCUR_RATIO));
assertEquals(mongoField1.m_indexedVals, node.getProperty(MongoDbInputStepAnalyzer.INDEXED_VALS));
assertEquals(mongoField1.m_disparateTypes, node.getProperty(MongoDbInputStepAnalyzer.DISPARATE_TYPES));
}
use of org.pentaho.mongo.wrapper.field.MongoField in project pdi-dataservice-server-plugin by pentaho.
the class MongodbInputParameterGeneration method getFieldMappings.
protected Map<String, String> getFieldMappings(StepInterface stepInterface) {
Map<String, String> fieldMap = new HashMap<String, String>();
MongoDbInput mongoDbInput = (MongoDbInput) stepInterface;
MongoDbInputMeta mongoDbInputMeta = (MongoDbInputMeta) mongoDbInput.getStepMeta().getStepMetaInterface();
for (MongoField mongoField : mongoDbInputMeta.getMongoFields()) {
fieldMap.put(mongoField.getName(), mongoField.getPath());
}
return fieldMap;
}
use of org.pentaho.mongo.wrapper.field.MongoField in project pentaho-metaverse by pentaho.
the class MongoDbInputStepAnalyzer method createOutputFieldNode.
@Override
protected IMetaverseNode createOutputFieldNode(IAnalysisContext context, ValueMetaInterface fieldMeta, String targetStepName, String nodeType) {
IMetaverseNode mongoFieldNode = super.createOutputFieldNode(context, fieldMeta, targetStepName, nodeType);
List<MongoField> mongoFields = baseStepMeta.getMongoFields();
if (mongoFields != null) {
for (MongoField mongoField : mongoFields) {
if (fieldMeta.getName().equals(mongoField.getName())) {
mongoFieldNode.setProperty(JSON_PATH, mongoField.m_fieldPath);
mongoFieldNode.setProperty(MINMAX_RANGE, mongoField.m_arrayIndexInfo);
mongoFieldNode.setProperty(OCCUR_RATIO, mongoField.m_occurenceFraction);
mongoFieldNode.setProperty(INDEXED_VALS, mongoField.m_indexedVals);
mongoFieldNode.setProperty(DISPARATE_TYPES, mongoField.m_disparateTypes);
break;
}
}
}
return mongoFieldNode;
}
Aggregations