Skip to content

Allow mongodb steps connect to mongodb atlas #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public abstract class MongoDbMeta extends BaseStepMeta implements StepMetaInterf
@Injection( name = "USE_ALL_REPLICA_SET_MEMBERS" )
private boolean m_useAllReplicaSetMembers;

/**
* whether is to connect to MongoDB Atlas
*/
@Injection( name = "USE_MONGODB_ATLAS" )
private boolean mongoDBAtlas;

/**
* optional tag sets to use with read preference settings
*/
Expand Down Expand Up @@ -112,6 +118,14 @@ public boolean getUseAllReplicaSetMembers() {
return m_useAllReplicaSetMembers;
}

public void setMongoDBAtlas( boolean mongoDBAtlas ) {
this.mongoDBAtlas = mongoDBAtlas;
}

public boolean getMongoDBAtlas() {
return mongoDBAtlas;
}

/**
* @return the hostnames (comma separated: host:<port>)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private void readData( Node stepnode ) throws KettleXMLException {
}

setUseAllReplicaSetMembers( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_all_replica_members" ) ) ); //$NON-NLS-1$
setMongoDBAtlas( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_mongo_db_atlas" ) ) );

String queryIsPipe = XMLHandler.getTagValue( stepnode, "query_is_pipeline" ); //$NON-NLS-1$
if ( !Const.isEmpty( queryIsPipe ) ) {
Expand Down Expand Up @@ -248,6 +249,7 @@ public String getXML() {
retval.append( " " ).append( XMLHandler.addTagValue( "hostname", getHostnames() ) ); //$NON-NLS-1$ //$NON-NLS-2$
retval.append( " " ).append( XMLHandler.addTagValue( "port", getPort() ) ); //$NON-NLS-1$ //$NON-NLS-2$
retval.append( " " ).append( XMLHandler.addTagValue( "use_all_replica_members", getUseAllReplicaSetMembers() ) ); //$NON-NLS-1$ //$NON-NLS-2$
retval.append( " " ).append( XMLHandler.addTagValue( "use_mongo_db_atlas", getMongoDBAtlas() ) );
retval.append( " " ).append( XMLHandler.addTagValue( "db_name", getDbName() ) ); //$NON-NLS-1$ //$NON-NLS-2$
retval.append( " " ).append( XMLHandler.addTagValue( "fields_name", fields ) ); //$NON-NLS-1$ //$NON-NLS-2$
retval.append( " " ).append( XMLHandler.addTagValue( "collection", getCollection() ) ); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down Expand Up @@ -314,6 +316,7 @@ public String getXML() {
setHostnames( rep.getStepAttributeString( id_step, "hostname" ) ); //$NON-NLS-1$
setPort( rep.getStepAttributeString( id_step, "port" ) ); //$NON-NLS-1$
setUseAllReplicaSetMembers( rep.getStepAttributeBoolean( id_step, 0, "use_all_replica_members" ) ); //$NON-NLS-1$
setMongoDBAtlas( rep.getStepAttributeBoolean( id_step, 0, "use_mongo_db_atlas" ) );
setDbName( rep.getStepAttributeString( id_step, "db_name" ) ); //$NON-NLS-1$
fields = rep.getStepAttributeString( id_step, "fields_name" ); //$NON-NLS-1$
setCollection( rep.getStepAttributeString( id_step, "collection" ) ); //$NON-NLS-1$
Expand Down Expand Up @@ -375,6 +378,7 @@ public void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_transform
rep.saveStepAttribute( id_transformation, id_step, "hostname", getHostnames() ); //$NON-NLS-1$
rep.saveStepAttribute( id_transformation, id_step, "port", getPort() ); //$NON-NLS-1$
rep.saveStepAttribute( id_transformation, id_step, "use_all_replica_members", getUseAllReplicaSetMembers() ); //$NON-NLS-1$
rep.saveStepAttribute( id_transformation, id_step, "use_mongo_db_atlas", getMongoDBAtlas() );
rep.saveStepAttribute( id_transformation, id_step, "db_name", getDbName() ); //$NON-NLS-1$
rep.saveStepAttribute( id_transformation, id_step, "fields_name", fields ); //$NON-NLS-1$
rep.saveStepAttribute( id_transformation, id_step, "collection", getCollection() ); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public class MongoDbOutputDialog extends BaseStepDialog implements StepDialogInt
private TextVar m_hostnameField;
private TextVar m_portField;
private Button m_useAllReplicaSetMembersBut;
private Button m_useMongoDBAtlasBut;
private TextVar m_authDbName;
private TextVar m_usernameField;
private TextVar m_passField;
Expand Down Expand Up @@ -285,13 +286,35 @@ public MongoDbOutputDialog( Shell parent, Object in, TransMeta tr, String name )
fd.top = new FormAttachment( m_portField, margin );
m_useAllReplicaSetMembersBut.setLayoutData( fd );

// Use mongodbAtlas check box

Label useMongoDBAtlasLab = new Label( wConfigComp, SWT.RIGHT );
useMongoDBAtlasLab
.setText( getString( "MongoDbOutputDialog.UseMongoDBAtlas.Label" ) ); //$NON-NLS-1$
useAllReplicaLab.setToolTipText( getString( "MongoDbOutputDialog.UseMongoDBAtlas.TipText" ) ); //$NON-NLS-1$
props.setLook( useMongoDBAtlasLab );
fd = new FormData();
fd.left = new FormAttachment( 0, 0 );
fd.right = new FormAttachment( middle, -margin );
fd.top = new FormAttachment( m_useAllReplicaSetMembersBut, margin );
useMongoDBAtlasLab.setLayoutData( fd );

m_useMongoDBAtlasBut = new Button( wConfigComp, SWT.CHECK );
props.setLook( m_useMongoDBAtlasBut );
fd = new FormData();
fd.left = new FormAttachment( middle, 0 );
fd.right = new FormAttachment( 100, 0 );
fd.top = new FormAttachment( m_useAllReplicaSetMembersBut, margin );
m_useMongoDBAtlasBut.setLayoutData( fd );


// authentication database field
Label authBdLab = new Label( wConfigComp, SWT.RIGHT );
authBdLab.setText( getString( "MongoDbOutputDialog.AuthenticationDatabaseName.Label" ) ); //$NON-NLS-1$
props.setLook( authBdLab );
fd = new FormData();
fd.left = new FormAttachment( 0, 0 );
fd.top = new FormAttachment( m_useAllReplicaSetMembersBut, margin );
fd.top = new FormAttachment( m_useMongoDBAtlasBut, margin );
fd.right = new FormAttachment( middle, -margin );
authBdLab.setLayoutData( fd );

Expand All @@ -300,7 +323,7 @@ public MongoDbOutputDialog( Shell parent, Object in, TransMeta tr, String name )
m_authDbName.addModifyListener( lsMod );
fd = new FormData();
fd.right = new FormAttachment( 100, 0 );
fd.top = new FormAttachment( m_useAllReplicaSetMembersBut, margin );
fd.top = new FormAttachment( m_useMongoDBAtlasBut, margin );
fd.left = new FormAttachment( middle, 0 );
m_authDbName.setLayoutData( fd );

Expand Down Expand Up @@ -1139,6 +1162,7 @@ private void getInfo( MongoDbOutputMeta meta ) {
meta.setHostnames( m_hostnameField.getText() );
meta.setPort( m_portField.getText() );
meta.setUseAllReplicaSetMembers( m_useAllReplicaSetMembersBut.getSelection() );
meta.setMongoDBAtlas( m_useMongoDBAtlasBut.getSelection() );
meta.setAuthenticationDatabaseName( m_authDbName.getText() );
meta.setAuthenticationUser( m_usernameField.getText() );
meta.setAuthenticationPassword( m_passField.getText() );
Expand Down Expand Up @@ -1230,6 +1254,7 @@ private void getData() {
m_hostnameField.setText( Const.NVL( m_currentMeta.getHostnames(), "" ) ); //$NON-NLS-1$
m_portField.setText( Const.NVL( m_currentMeta.getPort(), "" ) ); //$NON-NLS-1$
m_useAllReplicaSetMembersBut.setSelection( m_currentMeta.getUseAllReplicaSetMembers() );
m_useMongoDBAtlasBut.setSelection( m_currentMeta.getMongoDBAtlas() );
m_authDbName.setText( Const.NVL( m_currentMeta.getAuthenticationDatabaseName(), "" ) ); //$NON-NLS-1$
m_usernameField.setText( Const.NVL( m_currentMeta.getAuthenticationUser(), "" ) ); //$NON-NLS-1$
m_passField.setText( Const.NVL( m_currentMeta.getAuthenticationPassword(), "" ) ); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ public String getXML() {

retval.append( " " ).append( XMLHandler.addTagValue( "use_all_replica_members", getUseAllReplicaSetMembers() ) ); //$NON-NLS-1$ //$NON-NLS-2$

retval.append( " " ).append( XMLHandler.addTagValue( "use_mongo_db_atlas", getMongoDBAtlas() ) );

if ( !Const.isEmpty( getAuthenticationDatabaseName() ) ) {
retval.append( "\n " ).append( //$NON-NLS-1$
XMLHandler.addTagValue( "mongo_auth_database", getAuthenticationDatabaseName() ) ); //$NON-NLS-1$
Expand Down Expand Up @@ -691,6 +693,8 @@ public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore met

setUseAllReplicaSetMembers( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_all_replica_members" ) ) ); //$NON-NLS-1$ //$NON-NLS-2$

setMongoDBAtlas( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_mongo_db_atlas" ) ) );

String writeRetries = XMLHandler.getTagValue( stepnode, "write_retries" ); //$NON-NLS-1$
if ( !Const.isEmpty( writeRetries ) ) {
m_writeRetries = writeRetries;
Expand Down Expand Up @@ -762,6 +766,7 @@ public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, Lis
setHostnames( rep.getStepAttributeString( id_step, 0, "mongo_host" ) ); //$NON-NLS-1$
setPort( rep.getStepAttributeString( id_step, 0, "mongo_port" ) ); //$NON-NLS-1$
setUseAllReplicaSetMembers( rep.getStepAttributeBoolean( id_step, 0, "use_all_replica_members" ) ); //$NON-NLS-1$
setMongoDBAtlas( rep.getStepAttributeBoolean( id_step, 0, "use_mongo_db_atlas" ) );
setAuthenticationDatabaseName( rep.getStepAttributeString( id_step, 0, "mongo_auth_database" ) ); //$NON-NLS-1$
setAuthenticationUser( rep.getStepAttributeString( id_step, 0, "mongo_user" ) ); //$NON-NLS-1$
setAuthenticationPassword( rep.getStepAttributeString( id_step, 0, "mongo_password" ) ); //$NON-NLS-1$
Expand Down Expand Up @@ -854,6 +859,8 @@ public void readRep( Repository rep, IMetaStore metaStore, ObjectId id_step, Lis

rep.saveStepAttribute( id_transformation, id_step, "use_all_replica_members", getUseAllReplicaSetMembers() ); //$NON-NLS-1$

rep.saveStepAttribute( id_transformation, id_step, "use_mongo_db_atlas", getMongoDBAtlas() );

if ( !Const.isEmpty( getAuthenticationDatabaseName() ) ) {
rep.saveStepAttribute( id_transformation, id_step, 0, "mongo_auth_database", //$NON-NLS-1$
getAuthenticationDatabaseName() );
Expand Down
Loading