Skip to content

Commit

Permalink
Merge pull request #211 from GopiKrishnaAngadi/PDI-17853
Browse files Browse the repository at this point in the history
[PDI-17853] - Need support to connect with MongoDB Atlas using latest…
  • Loading branch information
peterrinehart authored Aug 24, 2021
2 parents e15f08e + c97b048 commit 9d05232
Show file tree
Hide file tree
Showing 24 changed files with 1,107 additions and 575 deletions.
22 changes: 21 additions & 1 deletion pentaho-mongodb-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
</scm>

<properties>
<mockito.version>1.9.5</mockito.version>
<mockito.version>1.10.19</mockito.version>
<junit.version>4.11</junit.version>
<mongo-driver.version>3.10.2</mongo-driver.version>
<powermock-module-junit4.version>1.7.3</powermock-module-junit4.version>
<powermock-api-mockito.version>1.7.3</powermock-api-mockito.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -84,6 +86,12 @@
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -115,6 +123,18 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock-module-junit4.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock-api-mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2010 - 2018 Hitachi Vantara. All rights reserved.
* Copyright 2010 - 2021 Hitachi Vantara. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -77,6 +77,25 @@ public abstract class MongoDbMeta extends BaseStepMeta implements StepMetaInterf
@Injection( name = "USE_SSL_SOCKET_FACTORY" )
private boolean m_useSSLSocketFactory;

/**
* parameter to differentiate between ConnectionString URI connections and normal connections
*/
@Injection( name = "USE_CONNECTION_STRING" )
private boolean m_useConnectionString;

/**
* parameter to differentiate between ConnectionString URI connections and normal connections
*/
@Injection( name = "USE_LEGACY_OPTIONS" )
private boolean m_useLegacyOptions;

/**
* ConnectionString URI parameter for ConnectionString URI connections
*/
@Injection( name = "CONNECTION_STRING" )
private String connectionString;


/**
* default = 1 (standalone or primary acknowledges writes; -1 no
* acknowledgement and all errors suppressed; 0 no acknowledgement, but
Expand Down Expand Up @@ -308,7 +327,7 @@ public void setWriteConcern( String concern ) {
/**
* Get the write concern to use
*
* @param co the write concern to use
* @return the write concern to use
*/
public String getWriteConcern() {
return m_writeConcern;
Expand Down Expand Up @@ -375,4 +394,60 @@ public void setUseSSLSocketFactory( boolean value ) {
this.m_useSSLSocketFactory = value;
}

/**
* Get whether Connection String URI mechanism is used
*
* @return true for connection String URI mechanism
*/
public boolean isUseConnectionString() {
return m_useConnectionString;
}

/**
* Set whether to use true for connection String URI mechanism
*
* @param m_useConnectionString true for connection String URI mechanism
*/
public void setUseConnectionString( boolean m_useConnectionString ) {
this.m_useConnectionString = m_useConnectionString;
}

/**
* Get whether Legacy Options (specifying hosts, port information individually) mechanism is used
*
* @return true for Legacy options mechanism
*/
public boolean isUseLegacyOptions() {
return m_useLegacyOptions;
}

/**
* Set whether to use Legacy Options (specifying hosts, port information individually) mechanism is used
*
* @param m_useLegacyOptions true for Legacy options mechanism
*/

public void setUseLegacyOptions( boolean m_useLegacyOptions ) {
this.m_useLegacyOptions = m_useLegacyOptions;
}

/**
* Get connection string
*
* @return connection sting
*/

public String getConnectionString() {
return connectionString;
}

/**
* Set connection string
*
* @param connectionString string used to connect
*/

public void setConnectionString( String connectionString ) {
this.connectionString = connectionString;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.util.List;

public class MongoDbInput extends BaseStep implements StepInterface {
private static Class<?> PKG = MongoDbInputMeta.class; // for i18n purposes,
private static final Class<?> PKG = MongoDbInputMeta.class; // for i18n purposes,
// needed by
// Translator2!!
// $NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2010 - 2017 Hitachi Vantara. All rights reserved.
* Copyright 2010 - 2021 Hitachi Vantara. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,11 +45,8 @@
public class MongoDbInputData extends BaseStepData implements StepDataInterface {

public static final int MONGO_DEFAULT_PORT = 27017;

public RowMetaInterface outputRowMeta;

public MongoClientWrapper clientWrapper;
// public DB db;
public MongoCollectionWrapper collection;

/**
Expand All @@ -71,7 +68,7 @@ public static MongoDbInputDiscoverFieldsHolder getMongoDbInputDiscoverFieldsHold
return mongoDbInputDiscoverFieldsHolder;
}

protected void setMongoDbInputDiscoverFieldsHolder( MongoDbInputDiscoverFieldsHolder holder ) {
protected static void setMongoDbInputDiscoverFieldsHolder( MongoDbInputDiscoverFieldsHolder holder ) {
mongoDbInputDiscoverFieldsHolder = holder;
}

Expand Down Expand Up @@ -286,7 +283,6 @@ public static String cleansePath( String path ) {
public void setMongoFields( List<MongoField> fields ) {
// copy this list
m_userFields = new ArrayList<MongoField>();

for ( MongoField f : fields ) {
m_userFields.add( f.copy() );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
/*!
* Copyright 2010 - 2021 Hitachi Vantara. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.pentaho.di.trans.steps.mongodbinput;

import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.variables.VariableSpace;
import org.pentaho.mongo.MongoProperties;
import org.pentaho.mongo.wrapper.field.MongoField;

Expand All @@ -10,13 +28,13 @@
* Created by brendan on 11/4/14.
*/
public interface MongoDbInputDiscoverFields {
public List<MongoField> discoverFields( MongoProperties.Builder properties, String db, String collection,
String query, String fields,
boolean isPipeline, int docsToSample, MongoDbInputMeta step )
List<MongoField> discoverFields( MongoProperties.Builder properties, String db, String collection,
String query, String fields,
boolean isPipeline, int docsToSample, MongoDbInputMeta step, VariableSpace vars )
throws KettleException;

public void discoverFields( MongoProperties.Builder properties, String db, String collection, String query,
String fields,
boolean isPipeline, int docsToSample, MongoDbInputMeta step,
DiscoverFieldsCallback discoverFieldsCallback ) throws KettleException;
void discoverFields( MongoProperties.Builder properties, String db, String collection, String query,
String fields,
boolean isPipeline, int docsToSample, MongoDbInputMeta step,
VariableSpace vars, DiscoverFieldsCallback discoverFieldsCallback ) throws KettleException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2010 - 2017 Hitachi Vantara. All rights reserved.
* Copyright 2010 - 2021 Hitachi Vantara. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 9d05232

Please sign in to comment.