Search in sources :

Example 1 with MongoField

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));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) MongoField(org.pentaho.mongo.wrapper.field.MongoField) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 2 with MongoField

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;
}
Also used : HashMap(java.util.HashMap) MongoDbInput(org.pentaho.di.trans.steps.mongodbinput.MongoDbInput) MongoDbInputMeta(org.pentaho.di.trans.steps.mongodbinput.MongoDbInputMeta) MongoField(org.pentaho.mongo.wrapper.field.MongoField)

Example 3 with MongoField

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;
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MongoField(org.pentaho.mongo.wrapper.field.MongoField)

Aggregations

MongoField (org.pentaho.mongo.wrapper.field.MongoField)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 ValueMeta (org.pentaho.di.core.row.ValueMeta)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 MongoDbInput (org.pentaho.di.trans.steps.mongodbinput.MongoDbInput)1 MongoDbInputMeta (org.pentaho.di.trans.steps.mongodbinput.MongoDbInputMeta)1 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)1