├── .github
└── CODEOWNERS
├── assembly
├── plugin
│ ├── src
│ │ ├── main
│ │ │ └── resources
│ │ │ │ └── version.xml
│ │ └── assembly
│ │ │ └── assembly.xml
│ └── pom.xml
└── pom.xml
├── pentaho-mongodb-plugin
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── test-settings.properties
│ │ │ ├── job.properties
│ │ │ └── badJob.properties
│ │ └── java
│ │ │ └── org
│ │ │ └── pentaho
│ │ │ ├── mongo
│ │ │ └── wrapper
│ │ │ │ ├── KettleMongoUtilLoggerTest.java
│ │ │ │ ├── MongoFieldTest.java
│ │ │ │ └── MongoWrapperUtilTest.java
│ │ │ ├── di
│ │ │ └── trans
│ │ │ │ └── steps
│ │ │ │ ├── mongodbinput
│ │ │ │ ├── MongoDbInputDiscoverFieldsHolderTest.java
│ │ │ │ ├── BaseMongoDbStepTest.java
│ │ │ │ ├── MongoDbConnectionAnalyzerTest.java
│ │ │ │ ├── MongoDbInputMetaTest.java
│ │ │ │ ├── MongoDbResourceInfoTest.java
│ │ │ │ └── MongoDbInputMetaInjectionTest.java
│ │ │ │ └── mongodboutput
│ │ │ │ ├── MongoDbOutputMetaTest.java
│ │ │ │ └── MongoDbOutputMetaInjectionTest.java
│ │ │ └── reporting
│ │ │ └── ui
│ │ │ └── datasources
│ │ │ └── mongodb
│ │ │ └── MongoDbDatasourceDialogTest.java
│ └── main
│ │ ├── resources
│ │ ├── org
│ │ │ └── pentaho
│ │ │ │ └── di
│ │ │ │ ├── trans
│ │ │ │ └── steps
│ │ │ │ │ ├── mongodb
│ │ │ │ │ └── messages
│ │ │ │ │ │ └── messages_en_US.properties
│ │ │ │ │ └── mongodbinput
│ │ │ │ │ └── messages
│ │ │ │ │ ├── messages_ko_KR.properties
│ │ │ │ │ ├── messages_it_IT.properties
│ │ │ │ │ ├── messages_fr_FR.properties
│ │ │ │ │ └── messages_ja_JP.properties
│ │ │ │ └── ui
│ │ │ │ └── trans
│ │ │ │ └── steps
│ │ │ │ └── mongodbinput
│ │ │ │ └── xul
│ │ │ │ ├── mongodb_input.properties
│ │ │ │ ├── mongodb_input_en_US_zh_TW.properties
│ │ │ │ └── mongodb_input.xul
│ │ ├── mongodb-input.svg
│ │ ├── OSGI-INF
│ │ │ └── blueprint
│ │ │ │ └── blueprint.xml
│ │ └── MongoDB.svg
│ │ └── java
│ │ └── org
│ │ └── pentaho
│ │ ├── di
│ │ ├── trans
│ │ │ └── steps
│ │ │ │ ├── mongodbinput
│ │ │ │ ├── DiscoverFieldsCallback.java
│ │ │ │ ├── MongoDbInputExternalResourceConsumer.java
│ │ │ │ ├── MongoDbInputDiscoverFields.java
│ │ │ │ ├── MongoDbInputDiscoverFieldsHolder.java
│ │ │ │ ├── MongoDbConnectionAnalyzer.java
│ │ │ │ ├── MongoDbInputStepAnalyzer.java
│ │ │ │ ├── MongoDbResourceInfo.java
│ │ │ │ └── MongoDbInputData.java
│ │ │ │ ├── mongodb
│ │ │ │ └── MongoDBHelper.java
│ │ │ │ └── mongodboutput
│ │ │ │ ├── MongoDbOutputHelper.java
│ │ │ │ └── MongoDbOutputUtilHelper.java
│ │ ├── lifecycle
│ │ │ └── KettleMongoDbPluginLifecycleListener.java
│ │ └── ui
│ │ │ ├── trans
│ │ │ └── steps
│ │ │ │ └── mongodbinput
│ │ │ │ └── models
│ │ │ │ ├── MongoTag.java
│ │ │ │ └── MongoDocumentField.java
│ │ │ └── swing
│ │ │ └── preview
│ │ │ └── PreviewRowsSwingDialog.java
│ │ └── mongo
│ │ └── wrapper
│ │ ├── MongoWrapperClientFactory.java
│ │ ├── KettleMongoUtilLogger.java
│ │ ├── MongoWrapperUtil.java
│ │ └── field
│ │ └── MongoArrayExpansion.java
├── README.md
└── pom.xml
├── .gitignore
├── pom.xml
├── pentaho-mongo.iml
└── LICENSE.txt
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @pentaho/sp-branch-write
--------------------------------------------------------------------------------
/assembly/plugin/src/main/resources/version.xml:
--------------------------------------------------------------------------------
1 |
2 | ${project.version}
3 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/resources/test-settings.properties:
--------------------------------------------------------------------------------
1 | hostname=hadoop-vm1.pentaho.com
2 | hdfsPort=9000
3 | trackerPort=9001
4 | username=username
5 | password=password
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | dist/
3 | lib/
4 | lib-provided/
5 | lib-codegen/
6 | stage-pmr/
7 | test-lib/
8 | eclipse-bin/
9 | override.properties
10 | .settings/
11 | .classpath
12 | /dev-lib
13 | /pdi-null
14 | /pdi-bin
15 | target/
16 | .idea
17 | pentaho-mongodb-plugin.iml
18 | pentaho-mongodb-plugin/logs/pdi.log
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/trans/steps/mongodb/messages/messages_en_US.properties:
--------------------------------------------------------------------------------
1 | MongoDb.ErrorMessage.MissingConnectionDetails=Some connection/configuration details are missing: {0}
2 | MongoDb.ErrorMessage.MissingConnectionDetails.Title=Missing connection details
3 | MongoDb.ErrorMessage.UnableToConnect=Unable to connect to MongoDB - check connection details
4 | MongoDb.SuccessMessage.SuccessConnectionDetails.Title=Successfully connected
5 | MongoDb.SuccessMessage.SuccessConnectionDetails=Connection Test Successful with Mongo Database
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/trans/steps/mongodbinput/messages/messages_ko_KR.properties:
--------------------------------------------------------------------------------
1 | #File generated by Hitachi Vantara Translator for package 'org.pentaho.di.trans.steps.mongodbinput' in locale 'ko_KR'
2 | #
3 | #
4 | #Tue Apr 12 17:46:12 KST 2011
5 | MongoDbInputDialog.PreviewSize.DialogTitle=\uBBF8\uB9AC\uBCF4\uAE30 \uAC1C\uC218 \uC785\uB825
6 | MongoDbInputDialog.Hostname.Label=\uD638\uC2A4\uD2B8 \uC774\uB984 \uB610\uB294 IP \uC8FC\uC18C
7 | MongoDbInputDialog.Collection.Label=\uCEEC\uB809\uC158
8 | MongoDbInputDialog.Port.Label=\uD3EC\uD2B8
9 | MongoDbInputDialog.Stepname.Label=Step \uC774\uB984
10 | MongoDbInputDialog.DbName.Label=\uB370\uC774\uD130\uBCA0\uC774\uC2A4
11 | MongoDbInputDialog.JsonField.Label=JSON \uCD9C\uB825 \uD544\uB4DC \uC774\uB984
12 |
--------------------------------------------------------------------------------
/assembly/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | pentaho
9 | pentaho-mongo-plugin-parent
10 | 11.1.0.0-SNAPSHOT
11 |
12 |
13 | pentaho
14 | pentaho-mongo-plugin-assemblies
15 | pom
16 |
17 | Pentaho Mongo Plugin Assembly Parent
18 |
19 |
20 | plugin
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.pentaho
8 | pentaho-ce-jar-parent-pom
9 | 11.1.0.0-SNAPSHOT
10 |
11 |
12 | pentaho
13 | pentaho-mongo-plugin-parent
14 | 11.1.0.0-SNAPSHOT
15 | pom
16 |
17 | Pentaho Mongo Plugin Parent
18 |
19 |
20 | pentaho-mongodb-plugin
21 | assembly
22 |
23 |
24 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/trans/steps/mongodbinput/DiscoverFieldsCallback.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 | package org.pentaho.di.trans.steps.mongodbinput;
13 |
14 | import org.pentaho.mongo.wrapper.field.MongoField;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * Created by brendan on 12/30/14.
20 | */
21 | public interface DiscoverFieldsCallback {
22 | public void notifyFields( List fields );
23 | public void notifyException( Exception exception );
24 | }
25 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/mongo/wrapper/MongoWrapperClientFactory.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 | package org.pentaho.mongo.wrapper;
14 |
15 | import org.pentaho.mongo.MongoDbException;
16 | import org.pentaho.mongo.MongoProperties;
17 | import org.pentaho.mongo.MongoUtilLogger;
18 |
19 | /**
20 | * Created by bryan on 8/22/14.
21 | */
22 | public interface MongoWrapperClientFactory {
23 | MongoClientWrapper createMongoClientWrapper( MongoProperties props, MongoUtilLogger log ) throws MongoDbException;
24 |
25 | MongoClientWrapper createConnectionStringMongoClientWrapper( String connectionString, MongoUtilLogger log ) throws MongoDbException;
26 | }
27 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/resources/job.properties:
--------------------------------------------------------------------------------
1 | #
2 | # *******************************************************************************
3 | # Pentaho Big Data
4 | #
5 | # Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
6 | # *******************************************************************************
7 | #
8 | # Licensed under the Apache License, Version 2.0 (the "License");
9 | # you may not use this file except in compliance with
10 | # the License. You may obtain a copy of the License at
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | # ******************************************************************************
19 | #
20 |
21 | nameNode=hdfs://localhost:9000
22 | jobTracker=localhost:9001
23 | queueName=default
24 | examplesRoot=examples
25 |
26 | oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/map-reduce
27 | outputDir=map-reduce
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/resources/badJob.properties:
--------------------------------------------------------------------------------
1 | #
2 | # *******************************************************************************
3 | # Pentaho Big Data
4 | #
5 | # Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
6 | # *******************************************************************************
7 | #
8 | # Licensed under the Apache License, Version 2.0 (the "License");
9 | # you may not use this file except in compliance with
10 | # the License. You may obtain a copy of the License at
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | # ******************************************************************************
19 | #
20 | nameNode=hdfs://localhost:9000
21 | jobTracker=localhost:9001
22 | queueName=default
23 | examplesRoot=examples
24 |
25 | # comment this guy out so it is a bad property config
26 | #oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/apps/map-reduce
27 |
28 | outputDir=map-reduce
29 |
--------------------------------------------------------------------------------
/assembly/plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | pentaho
9 | pentaho-mongo-plugin-assemblies
10 | 11.1.0.0-SNAPSHOT
11 |
12 | com.pentaho.di.plugins
13 | mongodb-plugin
14 | pom
15 |
16 | Pentaho Mongo Plugin Distribution
17 |
18 |
19 |
20 | pentaho
21 | pentaho-mongodb-plugin
22 | ${project.version}
23 | runtime
24 |
25 |
26 |
27 |
28 |
29 |
30 | maven-assembly-plugin
31 |
32 |
33 | src/assembly/assembly.xml
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/assembly/plugin/src/assembly/assembly.xml:
--------------------------------------------------------------------------------
1 |
4 | pentaho-mongo-plugin-assembly
5 |
6 | zip
7 |
8 | mongodb-plugins
9 |
10 |
11 | src/main/resources
12 | .
13 | true
14 |
15 |
16 |
17 |
18 | runtime
19 | .
20 | false
21 | false
22 |
23 | pentaho:pentaho-mongodb-plugin:jar
24 |
25 |
26 |
27 | runtime
28 | false
29 | true
30 | lib
31 |
32 | pentaho:pentaho-mongodb-plugin:*
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/ui/trans/steps/mongodbinput/xul/mongodb_input.properties:
--------------------------------------------------------------------------------
1 | dialog-title=MongoDB Query
2 | simple-message=Simple Edit of a Kettle Transformation Step
3 | edit-query=Enter a new MongoDB query string:
4 | step-name=Step Name
5 | # Configure connection panel
6 | configure-connection=Configure connection
7 | options=Input Options
8 | query=Query
9 | fields=Fields
10 | host-name=Host name(s) or IP address(es)
11 | port=Port
12 | database=Database
13 | collection=Collection
14 | auth-database=Auth Database
15 | auth-user=User
16 | auth-password=Password
17 | connection-timeout=Connection timeout
18 | socket-timeout=Socket timeout
19 | read-preference=Read preference
20 | use-all-replicas=Use all replica set members
21 | use-kerberos=Authenticate using Kerberos
22 | column-tag=Tag Set
23 | max-preview-rows=Max Preview Rows
24 | preview=Preview
25 | get-dbs=Get DBs
26 | get-collections=Get collections
27 | dialog-title=MongoDB Input
28 | # Query panel
29 | query-expression=Query expression (JSON)
30 | fields-expression=Fields expression (JSON)
31 | is-agg-pipeline=Query is aggregation pipeline
32 | # Fields panel
33 | column-name=Name
34 | column-path=Path
35 | column-type=Type
36 | column-indexed-values=Indexed values
37 | column-sample-array=Sample: array min:max index
38 | column-sample-occurences=Sample: # occur/# docs
39 | column-sample-disparate-types=Sample: disparate types
40 | get-fields=Get fields
41 | get-tags=Get tags
42 | join-tags=Join tags
43 | test-tags=Test tag sets
44 |
45 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/trans/steps/mongodbinput/MongoDbInputExternalResourceConsumer.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import org.pentaho.metaverse.api.IAnalysisContext;
17 | import org.pentaho.metaverse.api.analyzer.kettle.step.BaseStepExternalResourceConsumer;
18 | import org.pentaho.metaverse.api.model.IExternalResourceInfo;
19 |
20 | import java.util.Collection;
21 | import java.util.HashSet;
22 | import java.util.Set;
23 |
24 | public class MongoDbInputExternalResourceConsumer
25 | extends BaseStepExternalResourceConsumer {
26 |
27 | @Override
28 | public Class getMetaClass() {
29 | return MongoDbInputMeta.class;
30 | }
31 |
32 | @Override
33 | public Collection getResourcesFromMeta( MongoDbInputMeta meta, IAnalysisContext context ) {
34 | Set resources = new HashSet();
35 | MongoDbResourceInfo mongoDbResourceInfo = new MongoDbResourceInfo( meta );
36 | mongoDbResourceInfo.setInput( true );
37 | resources.add( mongoDbResourceInfo );
38 | return resources;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/trans/steps/mongodbinput/MongoDbInputDiscoverFields.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import org.pentaho.di.core.exception.KettleException;
17 | import org.pentaho.di.core.variables.VariableSpace;
18 | import org.pentaho.mongo.MongoProperties;
19 | import org.pentaho.mongo.wrapper.field.MongoField;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * Created by brendan on 11/4/14.
25 | */
26 | public interface MongoDbInputDiscoverFields {
27 | List discoverFields( MongoProperties.Builder properties, String db, String collection,
28 | String query, String fields,
29 | boolean isPipeline, int docsToSample, MongoDbInputMeta step, VariableSpace vars )
30 | throws KettleException;
31 |
32 | void discoverFields( MongoProperties.Builder properties, String db, String collection, String query,
33 | String fields,
34 | boolean isPipeline, int docsToSample, MongoDbInputMeta step,
35 | VariableSpace vars, DiscoverFieldsCallback discoverFieldsCallback ) throws KettleException;
36 | }
37 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/trans/steps/mongodbinput/messages/messages_it_IT.properties:
--------------------------------------------------------------------------------
1 | #File generated by Hitachi Vantara Translator for package 'org.pentaho.di.trans.steps.mongodbinput' in locale 'it_IT'
2 | #
3 | #
4 | #Wed Jan 18 15:33:28 CET 2012
5 | MongoDbInputDialog.DbName.Label=Database
6 | MongoDbInputDialog.JsonField.Label=Nome del campo di output JSON
7 | MongoDbInput.ErrorAuthenticating.Exception=Non \u00E8 stato possibile autenticare l''utente fornito. Per favore guardare ai log di MongoDB per ulteriori informazioni.
8 | MongoDbInputDialog.PreviewSize.DialogMessage=Inserire il numero di righe per l''anteprima\:
9 | MongoDbInputDialog.AuthenticationPassword.Label=Password di autenticazione
10 | MongoDbInputMeta.Exception.UnableToSaveStepInfo=Impossibile salvare le informazioni del passo nel repository con id\=
11 | MongoDbInputDialog.JsonQuery.Label=Espressione Query (JSON)
12 | MongoDbInputDialog.PreviewSize.DialogTitle=Inserire la dimensione dell''anteprima
13 | MongoDbInputDialog.Collection.Label=Collezione
14 | MongoDbInputDialog.AuthenticationUser.Label=Utente di autenticazione
15 | MongoDbInputDialog.Shell.Title=Input MongoDB
16 | MongoDbInputMeta.Exception.UnableToLoadStepInfo=Impossibile caricare le informazioni del passo da XML\!
17 | MongoDbInputDialog.Hostname.Label=Nome host od indirizzo IP
18 | MongoDbInputDialog.Stepname.Label=Nome del passo
19 | MongoDbInputDialog.Port.Label=Porta
20 | MongoDbInput.ErrorConnectingToMongoDb.Exception=Errore di connessione a MongoDB con l''host {0}, porta {1}, database {2} e collezione {3}\:
21 | MongoDbInputMeta.Exception.UnexpectedErrorWhileReadingStepInfo=Impossibile leggere le informazioni del passo dal repository
22 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/trans/steps/mongodbinput/messages/messages_fr_FR.properties:
--------------------------------------------------------------------------------
1 | #File generated by Hitachi Vantara Translator for package 'org.pentaho.di.trans.steps.mongodbinput' in locale 'fr_FR'
2 | #
3 | #
4 | #Sat May 21 12:24:43 CEST 2011
5 | MongoDbInputDialog.DbName.Label=Base de donn\u00E9es
6 | MongoDbInputDialog.JsonField.Label=Champ en sortie JSON
7 | MongoDbInput.ErrorAuthenticating.Exception=Erreur lors de l''authentification avec le compte utilisateur\! Veuillez svp v\u00E9rifier la trace pour plus de d\u00E9tail.
8 | MongoDbInputDialog.PreviewSize.DialogMessage=Veuillez svp saisir le nombre de lignes max. \u00E0 retourner\:
9 | MongoDbInputDialog.AuthenticationPassword.Label=Mot de passe
10 | MongoDbInputMeta.Exception.UnableToSaveStepInfo=Erreur lors de la sauvegarde dans le r\u00E9f\u00E9rentiel, des informations de l''\u00E9tape identifi\u00E9e par l'id\=
11 | MongoDbInputDialog.Collection.Label=Collection
12 | MongoDbInputDialog.PreviewSize.DialogTitle=Limite pr\u00E9visualisation
13 | MongoDbInputMeta.Exception.UnableToLoadStepInfo=Erreur lors du chargement des informations de l''\u00E9tape depuis le fichier XML\!
14 | MongoDbInputDialog.Shell.Title=Extraction depuis une base Mongo
15 | MongoDbInputDialog.AuthenticationUser.Label=Compte utilisateur
16 | MongoDbInputDialog.Stepname.Label=Nom \u00E9tape
17 | MongoDbInputDialog.Hostname.Label=Nom ou adresse IP serveur
18 | MongoDbInputDialog.Port.Label=Port
19 | MongoDbInput.ErrorConnectingToMongoDb.Exception=Erreur lors de la connexion au serveur {0}, port {1}, base Mango {2} et collection [{3}\:
20 | MongoDbInputMeta.Exception.UnexpectedErrorWhileReadingStepInfo=Erreur lors de la lecture depuis le r\u00E9f\u00E9rentiel, des informations de l''\u00E9tape
21 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/java/org/pentaho/mongo/wrapper/KettleMongoUtilLoggerTest.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.mongo.wrapper;
15 |
16 | import org.junit.Before;
17 | import org.junit.Test;
18 | import org.mockito.Mock;
19 | import org.mockito.MockitoAnnotations;
20 | import org.pentaho.di.core.logging.LogChannelInterface;
21 |
22 | import static org.mockito.Mockito.times;
23 | import static org.mockito.Mockito.verify;
24 |
25 | /**
26 | * Created by matt on 10/30/15.
27 | */
28 | public class KettleMongoUtilLoggerTest {
29 |
30 | @Mock LogChannelInterface logChannelInterface;
31 | @Mock Exception exception;
32 | KettleMongoUtilLogger logger;
33 |
34 | @Before public void before() {
35 | MockitoAnnotations.initMocks( this );
36 | logger = new KettleMongoUtilLogger( logChannelInterface );
37 | }
38 |
39 | @Test public void testLoggingDelegates() throws Exception {
40 | logger.debug( "log" );
41 | verify( logChannelInterface ).logDebug( "log" );
42 | logger.info( "log" );
43 | verify( logChannelInterface ).logBasic( "log" );
44 | logger.warn( "log", exception );
45 | logger.error( "log", exception );
46 | // both warn and error are mapped to logError.
47 | verify( logChannelInterface, times( 2 ) ).logError( "log", exception );
48 | logger.isDebugEnabled();
49 | verify( logChannelInterface ).isDebug();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/trans/steps/mongodbinput/messages/messages_ja_JP.properties:
--------------------------------------------------------------------------------
1 | #File generated by Hitachi Vantara Translator for package 'org.pentaho.di.trans.steps.mongodbinput' in locale 'en_US'
2 | #
3 | #
4 | #Sat Apr 09 14:23:39 CEST 2011
5 | MongoDbInputDialog.DbName.Label=\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9
6 | MongoDbInputDialog.JsonField.Label=JSON\u51fa\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u540d
7 | MongoDbInputDialog.PreviewSize.DialogMessage=\u30d7\u30ec\u30d3\u30e5\u30fc\u3059\u308b\u884c\u6570\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\:
8 | MongoDbInputMeta.Exception.UnableToSaveStepInfo=Unable to save in repository step informations with id\=
9 | MongoDbInputDialog.Collection.Label=\u30b3\u30ec\u30af\u30b7\u30e7\u30f3
10 | MongoDbInputDialog.PreviewSize.DialogTitle=\u30d7\u30ec\u30d3\u30e5\u30fc\u30b5\u30a4\u30ba\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044
11 | MongoDbInputDialog.Shell.Title=MongoDB\u5165\u529b
12 | MongoDbInputMeta.Exception.UnableToLoadStepInfo=Unable to load step informations from XML\!
13 | MongoDbInputDialog.Hostname.Label=\u30db\u30b9\u30c8\u540d\u307e\u305f\u306fIP\u30a2\u30c9\u30ec\u30b9
14 | MongoDbInputDialog.Stepname.Label=\u30b9\u30c6\u30c3\u30d7\u540d
15 | MongoDbInputDialog.Port.Label=\u30dd\u30fc\u30c8
16 | MongoDbInput.ErrorConnectingToMongoDb.Exception=There was an error connecting to MongoDB with host {0}, port {1}, database {2} and collection {3}\:
17 | MongoDbInputMeta.Exception.UnexpectedErrorWhileReadingStepInfo=Unable to read step informations from repository
18 | MongoDbInputDialog.AuthenticationUser.Label=\u8a8d\u8a3c\u30e6\u30fc\u30b6\u30fc
19 | MongoDbInputDialog.AuthenticationPassword.Label=\u8a8d\u8a3c\u30d1\u30b9\u30ef\u30fc\u30c9
20 | MongoDbInput.ErrorAuthenticating.Exception=It was not possible to authenticate the supplied username. Please look at the MongoDB log for further information.
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/mongo/wrapper/KettleMongoUtilLogger.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.mongo.wrapper;
15 |
16 | import org.pentaho.di.core.logging.LogChannelInterface;
17 | import org.pentaho.mongo.MongoUtilLogger;
18 |
19 | /**
20 | * Created by bryan on 8/7/14.
21 | */
22 | public class KettleMongoUtilLogger implements MongoUtilLogger {
23 | private final LogChannelInterface logChannelInterface;
24 |
25 | public KettleMongoUtilLogger( LogChannelInterface logChannelInterface ) {
26 | this.logChannelInterface = logChannelInterface;
27 | }
28 |
29 | @Override public void debug( String s ) {
30 | if ( logChannelInterface != null ) {
31 | logChannelInterface.logDebug( s );
32 | }
33 | }
34 |
35 | @Override public void info( String s ) {
36 | if ( logChannelInterface != null ) {
37 | logChannelInterface.logBasic( s );
38 | }
39 | }
40 |
41 | @Override public void warn( String s, Throwable throwable ) {
42 | if ( logChannelInterface != null ) {
43 | logChannelInterface.logError( s, throwable );
44 | }
45 | }
46 |
47 | @Override public void error( String s, Throwable throwable ) {
48 | if ( logChannelInterface != null ) {
49 | logChannelInterface.logError( s, throwable );
50 | }
51 | }
52 |
53 | @Override public boolean isDebugEnabled() {
54 | if ( logChannelInterface != null ) {
55 | return logChannelInterface.isDebug();
56 | } else {
57 | return false;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/org/pentaho/di/ui/trans/steps/mongodbinput/xul/mongodb_input_en_US_zh_TW.properties:
--------------------------------------------------------------------------------
1 | dialog-title=MongoDB \u67e5\u8a62
2 | simple-message=\u5c0d Kettle \u8f49\u63db\u6b65\u9a5f\u9032\u884c\u7c21\u6613\u7de8\u8f2f
3 | edit-query=\u8f38\u5165\u65b0\u7684 MongoDB \u67e5\u8a62\u5b57\u4e32\uff1a
4 | step-name=\u6b65\u9a5f\u540d\u7a31
5 | # Configure connection panel
6 | configure-connection=\u8a2d\u5b9a\u9023\u7dda
7 | options=\u8f38\u5165\u9078\u9805
8 | query=\u67e5\u8a62
9 | fields=\u6b04\u4f4d
10 | host-name=\u4e3b\u6a5f\u540d\u7a31\u6216 IP \u4f4d\u5740
11 | port=\u9023\u63a5\u57e0
12 | database=\u8cc7\u6599\u5eab
13 | collection=\u96c6\u5408
14 | auth-database=\u9a57\u8b49\u8cc7\u6599\u5eab
15 | auth-user=\u4f7f\u7528\u8005
16 | auth-password=\u5bc6\u78bc
17 | connection-timeout=\u9023\u7dda\u903e\u6642
18 | socket-timeout=\u901a\u8a0a\u7aef\u903e\u6642
19 | read-preference=\u8b80\u53d6\u504f\u597d\u8a2d\u5b9a
20 | use-all-replicas=\u4f7f\u7528\u6240\u6709\u8907\u672c\u96c6\u6210\u54e1
21 | use-kerberos=\u4f7f\u7528 Kerberos \u9032\u884c\u9a57\u8b49
22 | column-tag=\u6a19\u8a18\u96c6\u5408
23 | max-preview-rows=\u9810\u89bd\u8cc7\u6599\u5217\u4e0a\u9650
24 | preview=\u9810\u89bd
25 | get-dbs=\u53d6\u5f97 DB
26 | get-collections=\u53d6\u5f97\u96c6\u5408
27 | dialog-title=MongoDB \u8f38\u5165
28 | # Query panel
29 | query-expression=\u67e5\u8a62\u904b\u7b97\u5f0f (JSON)
30 | fields-expression=\u6b04\u4f4d\u904b\u7b97\u5f0f (JSON)
31 | is-agg-pipeline=\u67e5\u8a62\u662f\u5f59\u7e3d\u7ba1\u7dda
32 | # Fields panel
33 | column-name=\u540d\u7a31
34 | column-path=\u8def\u5f91
35 | column-type=\u985e\u578b
36 | column-indexed-values=\u5df2\u7de8\u88fd\u7d22\u5f15\u7684\u503c
37 | column-sample-array=\u7bc4\u4f8b\uff1a\u9663\u5217 min:max \u7d22\u5f15
38 | column-sample-occurences=\u7bc4\u4f8b\uff1a\u767c\u751f\u6b21\u6578/\u6587\u4ef6\u6578\u76ee
39 | column-sample-disparate-types=\u7bc4\u4f8b\uff1a\u76f8\u7570\u985e\u578b
40 | get-fields=\u53d6\u5f97\u6b04\u4f4d
41 | get-tags=\u53d6\u5f97\u6a19\u8a18
42 | join-tags=\u806f\u7d50\u6a19\u8a18
43 | test-tags=\u6e2c\u8a66\u6a19\u8a18\u96c6\u5408
44 |
45 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/lifecycle/KettleMongoDbPluginLifecycleListener.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.lifecycle;
15 |
16 | import org.pentaho.di.core.annotations.LifecyclePlugin;
17 | import org.pentaho.di.core.lifecycle.LifeEventHandler;
18 | import org.pentaho.di.core.lifecycle.LifecycleException;
19 | import org.pentaho.di.core.lifecycle.LifecycleListener;
20 | import org.pentaho.di.trans.steps.mongodbinput.MongoDbConnectionAnalyzer;
21 | import org.pentaho.di.trans.steps.mongodbinput.MongoDbInputExternalResourceConsumer;
22 | import org.pentaho.di.trans.steps.mongodbinput.MongoDbInputStepAnalyzer;
23 | import org.pentaho.platform.engine.core.system.PentahoSystem;
24 |
25 | @LifecyclePlugin( id = "KettleMongoDbPlugin", name = "KettleMongoDbPlugin" )
26 | public class KettleMongoDbPluginLifecycleListener implements LifecycleListener {
27 |
28 | @Override
29 | public void onStart( LifeEventHandler handler ) throws LifecycleException {
30 | MongoDbInputStepAnalyzer mongoDbInputStepAnalyzer = new MongoDbInputStepAnalyzer();
31 | MongoDbInputExternalResourceConsumer mongoDbInputExternalResourceConsumer = new MongoDbInputExternalResourceConsumer();
32 | MongoDbConnectionAnalyzer mongoDbConnectionAnalyzer = new MongoDbConnectionAnalyzer();
33 | mongoDbInputStepAnalyzer.setConnectionAnalyzer( mongoDbConnectionAnalyzer );
34 | mongoDbInputStepAnalyzer.setExternalResourceConsumer( mongoDbInputExternalResourceConsumer );
35 |
36 | PentahoSystem.registerObject( mongoDbInputStepAnalyzer );
37 | PentahoSystem.registerObject( mongoDbInputExternalResourceConsumer );
38 | PentahoSystem.registerObject( mongoDbConnectionAnalyzer );
39 | }
40 |
41 | @Override public void onExit( LifeEventHandler handler ) throws LifecycleException {
42 | // no-op
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/java/org/pentaho/di/trans/steps/mongodbinput/MongoDbInputDiscoverFieldsHolderTest.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import com.google.common.collect.ImmutableMap;
17 | import org.junit.Before;
18 | import org.junit.Test;
19 | import org.mockito.Mock;
20 | import org.mockito.MockitoAnnotations;
21 |
22 | import java.util.Collections;
23 |
24 | import static org.hamcrest.Matchers.equalTo;
25 | import static org.junit.Assert.assertThat;
26 |
27 | public class MongoDbInputDiscoverFieldsHolderTest {
28 |
29 | @Mock MongoDbInputDiscoverFields discoverFields;
30 | @Mock MongoDbInputDiscoverFields discoverFields2;
31 | @Mock MongoDbInputDiscoverFields discoverFields3b;
32 | @Mock MongoDbInputDiscoverFields discoverFields3;
33 | MongoDbInputDiscoverFieldsHolder holder = MongoDbInputDiscoverFieldsHolder.getInstance();
34 |
35 | @Before public void before() {
36 | MockitoAnnotations.initMocks( this );
37 | }
38 |
39 | @Test public void testImplAddedRemoved() throws Exception {
40 | holder.implAdded( discoverFields, ImmutableMap.of( "service.ranking", 1 ) );
41 | holder.implAdded( discoverFields2, Collections.emptyMap() );
42 | holder.implAdded( discoverFields3, ImmutableMap.of( "service.ranking", 5 ) );
43 | holder.implAdded( discoverFields3b, ImmutableMap.of( "service.ranking", 5 ) ); // second impl at same rank
44 |
45 | assertThat( holder.getMongoDbInputDiscoverFields(), equalTo( discoverFields3 ) );
46 | holder.implRemoved( discoverFields3, ImmutableMap.of( "service.ranking", 5 ) );
47 | assertThat( holder.getMongoDbInputDiscoverFields(), equalTo( discoverFields3b ) );
48 | holder.implRemoved( discoverFields3b, ImmutableMap.of( "service.ranking", 5 ) );
49 | assertThat( holder.getMongoDbInputDiscoverFields(), equalTo( discoverFields ) );
50 | holder.implRemoved( discoverFields, ImmutableMap.of( "service.ranking", 1 ) );
51 | assertThat( holder.getMongoDbInputDiscoverFields(), equalTo( discoverFields2 ) );
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/README.md:
--------------------------------------------------------------------------------
1 | Pentaho MongoDB Plugin
2 | =======================
3 |
4 | The Pentaho MongoDB Plugin Project provides support for MongoDB support within the Pentaho ecosystem. It is a plugin for the Pentaho Kettle engine which can be used within Pentaho Data Integration (Kettle), Pentaho Reporting, and the Pentaho BI Platform.
5 |
6 |
7 | How to build
8 | --------------
9 |
10 | Pentaho MongoDB Plugin uses the maven framework.
11 |
12 |
13 | #### Pre-requisites for building the project:
14 | * Maven, version 3+
15 | * Java JDK 1.8
16 | * This [settings.xml](https://raw.githubusercontent.com/pentaho/maven-parent-poms/master/maven-support-files/settings.xml) in your /.m2 directory
17 |
18 | #### Building it
19 |
20 | This is a maven project, and to build it use the following command
21 |
22 | ```
23 | $ mvn clean install
24 | ```
25 | Optionally you can specify -Drelease to trigger obfuscation and/or uglification (as needed)
26 |
27 | Optionally you can specify -Dmaven.test.skip=true to skip the tests (even though
28 | you shouldn't as you know)
29 |
30 | The build result will be a Pentaho package located in ```target```.
31 |
32 | #### Running the tests
33 |
34 | __Unit tests__
35 |
36 | This will run all unit tests in the project (and sub-modules). To run integration tests as well, see Integration Tests below.
37 |
38 | ```
39 | $ mvn test
40 | ```
41 |
42 | If you want to remote debug a single java unit test (default port is 5005):
43 |
44 | ```
45 | $ cd core
46 | $ mvn test -Dtest=<> -Dmaven.surefire.debug
47 | ```
48 |
49 | __Integration tests__
50 |
51 | In addition to the unit tests, there are integration tests that test cross-module operation. This will run the integration tests.
52 |
53 | ```
54 | $ mvn verify -DrunITs
55 | ```
56 |
57 | To run a single integration test:
58 |
59 | ```
60 | $ mvn verify -DrunITs -Dit.test=<>
61 | ```
62 |
63 | To run a single integration test in debug mode (for remote debugging in an IDE) on the default port of 5005:
64 |
65 | ```
66 | $ mvn verify -DrunITs -Dit.test=<> -Dmaven.failsafe.debug
67 | ```
68 |
69 | To skip test
70 |
71 | ```
72 | $ mvn clean install -DskipTests
73 | ```
74 |
75 | To get log as text file
76 |
77 | ```
78 | $ mvn clean install test >log.txt
79 | ```
80 |
81 | License
82 | -------
83 | Licensed under the Apache License, Version 2.0. See LICENSE.txt for more information.
84 |
85 | __IntelliJ__
86 |
87 | * Don't use IntelliJ's built-in maven. Make it use the same one you use from the commandline.
88 | * Project Preferences -> Build, Execution, Deployment -> Build Tools -> Maven ==> Maven home directory
89 |
90 | ````
91 |
92 |
--------------------------------------------------------------------------------
/pentaho-mongo.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/ui/trans/steps/mongodbinput/models/MongoTag.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.ui.trans.steps.mongodbinput.models;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | import org.pentaho.ui.xul.XulEventSourceAdapter;
20 | import org.pentaho.ui.xul.util.AbstractModelList;
21 |
22 | public class MongoTag extends XulEventSourceAdapter {
23 |
24 | private String m_tagName = "";
25 |
26 | public MongoTag() {
27 |
28 | }
29 |
30 | public MongoTag( String name ) {
31 | m_tagName = name;
32 | }
33 |
34 | public String getTagName() {
35 | return this.m_tagName;
36 | }
37 |
38 | public void setTagName( String name ) {
39 | this.m_tagName = name;
40 | }
41 |
42 | public static void convertList( List tags, AbstractModelList docTags ) {
43 |
44 | if ( tags == null || tags.isEmpty() ) {
45 | return;
46 | }
47 | for ( String tag : tags ) {
48 | MongoTag docTag = new MongoTag();
49 |
50 | if ( tag.startsWith( "{" ) ) {
51 | tag = tag.substring( 1 );
52 | }
53 |
54 | if ( tag.endsWith( "}" ) ) {
55 | tag = tag.substring( 0, tag.length() - 1 );
56 | }
57 |
58 | docTag.setTagName( tag );
59 | docTags.add( docTag );
60 | }
61 | }
62 |
63 | public static void trimList( List tags, AbstractModelList docTags ) {
64 |
65 | if ( tags == null || tags.isEmpty() ) {
66 | return;
67 | }
68 |
69 | for ( int i = tags.size() - 1; i >= 0; i-- ) {
70 | String tag = tags.get( i );
71 | for ( MongoTag docTag : docTags.asList() ) {
72 | if ( tag.equalsIgnoreCase( docTag.getTagName() ) ) {
73 | tags.remove( tag );
74 | break;
75 | }
76 | }
77 | }
78 | }
79 |
80 | public static List convertFromList( AbstractModelList docTags ) {
81 | List tags = new ArrayList();
82 |
83 | if ( docTags == null || docTags.isEmpty() ) {
84 | return tags;
85 | }
86 | for ( MongoTag docTag : docTags ) {
87 |
88 | String tag = docTag.getTagName();
89 |
90 | if ( !tag.startsWith( "{" ) ) {
91 | tag = "{" + tag;
92 | }
93 |
94 | if ( !tag.endsWith( "}" ) ) {
95 | tag += "}";
96 | }
97 |
98 | tags.add( tag );
99 | }
100 | return tags;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Pentaho Developer Edition 10.3 Copyright 2024 Hitachi Vantara, LLC; licensed under the
2 | Business Source License 1.1 (BSL). This project may include third party components that
3 | are individually licensed per the terms indicated by their respective copyright owners
4 | included in text file or in the source code.
5 |
6 | License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
7 | "Business Source License" is a trademark of MariaDB Corporation Ab.
8 |
9 | Parameters
10 |
11 | Licensor: Hitachi Vantara, LLC.
12 | Licensed Work: Pentaho Developer Edition 10.3. The Licensed Work is (c) 2024
13 | Hitachi Vantara, LLC.
14 | Additional Use Grant: None
15 | Change Date: Four years from the date the Licensed Work is published.
16 | Change License: Apache 2.0
17 |
18 | For information about alternative licensing arrangements for the Licensed Work,
19 | please contact support@pentaho.com.
20 |
21 | Notice
22 |
23 | Business Source License 1.1
24 |
25 | Terms
26 |
27 | The Licensor hereby grants you the right to copy, modify, create derivative
28 | works, redistribute, and make non-production use of the Licensed Work. The
29 | Licensor may make an Additional Use Grant, above, permitting limited production use.
30 |
31 | Effective on the Change Date, or the fourth anniversary of the first publicly
32 | available distribution of a specific version of the Licensed Work under this
33 | License, whichever comes first, the Licensor hereby grants you rights under
34 | the terms of the Change License, and the rights granted in the paragraph
35 | above terminate.
36 |
37 | If your use of the Licensed Work does not comply with the requirements
38 | currently in effect as described in this License, you must purchase a
39 | commercial license from the Licensor, its affiliated entities, or authorized
40 | resellers, or you must refrain from using the Licensed Work.
41 |
42 | All copies of the original and modified Licensed Work, and derivative works
43 | of the Licensed Work, are subject to this License. This License applies
44 | separately for each version of the Licensed Work and the Change Date may vary
45 | for each version of the Licensed Work released by Licensor.
46 |
47 | You must conspicuously display this License on each original or modified copy
48 | of the Licensed Work. If you receive the Licensed Work in original or
49 | modified form from a third party, the terms and conditions set forth in this
50 | License apply to your use of that work.
51 |
52 | Any use of the Licensed Work in violation of this License will automatically
53 | terminate your rights under this License for the current and all other
54 | versions of the Licensed Work.
55 |
56 | This License does not grant you any right in any trademark or logo of
57 | Licensor or its affiliates (provided that you may use a trademark or logo of
58 | Licensor as expressly required by this License).
59 |
60 | TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
61 | AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
62 | EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
63 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/java/org/pentaho/reporting/ui/datasources/mongodb/MongoDbDatasourceDialogTest.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.reporting.ui.datasources.mongodb;
15 |
16 | import org.junit.Test;
17 | import org.pentaho.di.core.logging.KettleLogStore;
18 | import org.pentaho.di.trans.TransMeta;
19 | import org.pentaho.di.trans.step.StepMeta;
20 | import org.pentaho.di.trans.steps.mongodbinput.MongoDbInputMeta;
21 | import org.pentaho.di.ui.trans.steps.mongodbinput.MongoDbInputXulDialog;
22 |
23 | public class MongoDbDatasourceDialogTest {
24 |
25 | @Test public void dummyTest() {
26 | // Have to have at least one test method to run, otherwise JUnit packs a sad.
27 | // Main method contains the tests.
28 | }
29 |
30 | public static void main( String[] args ) {
31 |
32 | KettleLogStore.init();
33 |
34 | MongoDbInputMeta meta = new MongoDbInputMeta();
35 | meta.setJsonQuery( "{CITY:\"NYC\"}" );
36 | meta.setAuthenticationPassword( "password" );
37 | meta.setAuthenticationUser( "gmoran" );
38 | meta.setCollection( "big" );
39 | meta.setDbName( "data" );
40 | meta.setHostnames( "" );
41 | meta.setPort( "27017" );
42 | meta.setReadPreference( "Secondary preferred" );
43 | meta.setFieldsName( "{id:true}" );
44 | meta.setQueryIsPipeline( true );
45 |
46 | TransMeta trans = new TransMeta();
47 | StepMeta stepMeta = new StepMeta( "mongo_source", meta );
48 | trans.addStep( stepMeta );
49 |
50 | MongoDbInputXulDialog dlg = new MongoDbInputXulDialog( null, meta, trans, "mongo_source" );
51 |
52 | if ( dlg.open() != null ) {
53 | System.out.println( "Host name(s): ".concat( meta.getHostnames() != null ? meta.getHostnames() : "" ) );
54 | System.out.println( "Port: ".concat( meta.getPort() != null ? meta.getPort() : "" ) );
55 | System.out.println( "Database: ".concat( meta.getDbName() != null ? meta.getDbName() : "" ) );
56 | System.out.println( "Collection: ".concat( meta.getCollection() != null ? meta.getCollection() : "" ) );
57 | System.out.println( "User: ".concat( meta.getAuthenticationUser() != null ? meta.getAuthenticationUser() : "" ) );
58 | System.out.println(
59 | "Password: ".concat( meta.getAuthenticationPassword() != null ? meta.getAuthenticationPassword() : "" ) );
60 | System.out
61 | .println( "Connection Timeout: ".concat( meta.getConnectTimeout() != null ? meta.getConnectTimeout() : "" ) );
62 | System.out.println( "Socket Timeout: ".concat( meta.getSocketTimeout() != null ? meta.getSocketTimeout() : "" ) );
63 | System.out
64 | .println( "Read Preference: ".concat( meta.getReadPreference() != null ? meta.getReadPreference() : "" ) );
65 | System.out.println( "JSON Query: ".concat( meta.getJsonQuery() != null ? meta.getJsonQuery() : "" ) );
66 | System.out
67 | .println( "Is Agg Pipeline:".concat( meta.getQueryIsPipeline() ? "IS pipeline" : "IS NOT a pipeline" ) );
68 | System.out.println( "Field Expression: ".concat( meta.getFieldsName() != null ? meta.getFieldsName() : "" ) );
69 | }
70 |
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/trans/steps/mongodbinput/MongoDbInputDiscoverFieldsHolder.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import org.pentaho.mongo.wrapper.field.MongodbInputDiscoverFieldsImpl;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * Created by bryan on 11/10/14.
26 | */
27 | public class MongoDbInputDiscoverFieldsHolder {
28 | private static MongoDbInputDiscoverFieldsHolder INSTANCE = new MongoDbInputDiscoverFieldsHolder();
29 | private final Map> mongoDbInputDiscoverFieldsMap;
30 | private MongoDbInputDiscoverFields mongoDbInputDiscoverFields = new MongodbInputDiscoverFieldsImpl();
31 |
32 | private MongoDbInputDiscoverFieldsHolder() {
33 | mongoDbInputDiscoverFieldsMap = new HashMap>();
34 | }
35 |
36 | public static MongoDbInputDiscoverFieldsHolder getInstance() {
37 | return INSTANCE;
38 | }
39 |
40 | public MongoDbInputDiscoverFields getMongoDbInputDiscoverFields() {
41 | return mongoDbInputDiscoverFields;
42 | }
43 |
44 | public void implAdded( MongoDbInputDiscoverFields mongoDbInputDiscoverFields, Map properties ) {
45 | synchronized ( mongoDbInputDiscoverFieldsMap ) {
46 | Integer ranking = (Integer) properties.get( "service.ranking" );
47 | if ( ranking == null ) {
48 | ranking = 0;
49 | }
50 | List mongoDbInputDiscoverFieldsList = mongoDbInputDiscoverFieldsMap.get( ranking );
51 | if ( mongoDbInputDiscoverFieldsList == null ) {
52 | mongoDbInputDiscoverFieldsList = new ArrayList();
53 | mongoDbInputDiscoverFieldsMap.put( ranking, mongoDbInputDiscoverFieldsList );
54 | }
55 | mongoDbInputDiscoverFieldsList.add( mongoDbInputDiscoverFields );
56 | updateField();
57 | }
58 | }
59 |
60 | public void implRemoved( MongoDbInputDiscoverFields mongoDbInputDiscoverFields, Map properties ) {
61 | synchronized ( mongoDbInputDiscoverFieldsMap ) {
62 | Integer ranking = (Integer) properties.get( "service.ranking" );
63 | if ( ranking == null ) {
64 | ranking = 0;
65 | }
66 | List mongoDbInputDiscoverFieldsList = mongoDbInputDiscoverFieldsMap.get( ranking );
67 | if ( mongoDbInputDiscoverFieldsList != null ) {
68 | mongoDbInputDiscoverFieldsList.remove( mongoDbInputDiscoverFields );
69 | if ( mongoDbInputDiscoverFieldsList.size() == 0 ) {
70 | mongoDbInputDiscoverFieldsMap.remove( ranking );
71 | }
72 | updateField();
73 | }
74 | }
75 | }
76 |
77 | private void updateField() {
78 | List keys = new ArrayList( mongoDbInputDiscoverFieldsMap.keySet() );
79 | if ( keys.size() == 0 ) {
80 | mongoDbInputDiscoverFields = null;
81 | } else {
82 | Collections.sort( keys );
83 | mongoDbInputDiscoverFields = mongoDbInputDiscoverFieldsMap.get( keys.get( keys.size() - 1 ) ).get( 0 );
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/resources/mongodb-input.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
40 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/java/org/pentaho/di/trans/steps/mongodbinput/BaseMongoDbStepTest.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import com.mongodb.Cursor;
17 | import com.mongodb.DBObject;
18 | import org.junit.After;
19 | import org.junit.Before;
20 | import org.mockito.ArgumentCaptor;
21 | import org.mockito.Captor;
22 | import org.mockito.Mock;
23 | import org.mockito.Mockito;
24 | import org.mockito.MockitoAnnotations;
25 | import org.pentaho.di.core.logging.KettleLogStore;
26 | import org.pentaho.di.core.logging.LogChannelInterface;
27 | import org.pentaho.di.core.logging.LogChannelInterfaceFactory;
28 | import org.pentaho.di.core.row.RowMeta;
29 | import org.pentaho.di.trans.Trans;
30 | import org.pentaho.di.trans.TransMeta;
31 | import org.pentaho.di.trans.step.BaseStep;
32 | import org.pentaho.di.trans.step.StepMeta;
33 | import org.pentaho.mongo.MongoDbException;
34 | import org.pentaho.mongo.MongoProperties;
35 | import org.pentaho.mongo.MongoUtilLogger;
36 | import org.pentaho.mongo.wrapper.MongoClientWrapper;
37 | import org.pentaho.mongo.wrapper.MongoWrapperClientFactory;
38 | import org.pentaho.mongo.wrapper.MongoWrapperUtil;
39 | import org.pentaho.mongo.wrapper.collection.MongoCollectionWrapper;
40 |
41 | import static org.mockito.Mockito.*;
42 |
43 | /**
44 | * Common mock setup for MongoDbOutputTest and MongoDbInput
45 | */
46 | public class BaseMongoDbStepTest {
47 |
48 | @Mock protected StepMeta stepMeta;
49 | @Mock protected TransMeta transMeta;
50 | @Mock protected Trans trans;
51 | @Mock protected LogChannelInterface mockLog;
52 | @Mock protected MongoWrapperClientFactory mongoClientWrapperFactory;
53 | @Mock protected MongoClientWrapper mongoClientWrapper;
54 | @Mock protected MongoCollectionWrapper mongoCollectionWrapper;
55 | @Mock protected LogChannelInterfaceFactory logChannelFactory;
56 | @Mock protected Cursor cursor;
57 | @Captor protected ArgumentCaptor stringCaptor;
58 | @Captor protected ArgumentCaptor dbObjectCaptor;
59 | @Captor protected ArgumentCaptor throwableCaptor;
60 |
61 | protected RowMeta rowMeta = new RowMeta();
62 | protected Object[] rowData;
63 |
64 | private MongoWrapperClientFactory cachedFactory;
65 |
66 | @Before public void before() throws MongoDbException {
67 | MockitoAnnotations.openMocks( BaseMongoDbStepTest.class );
68 | cachedFactory = MongoWrapperUtil.getMongoWrapperClientFactory();
69 | MongoWrapperUtil.setMongoWrapperClientFactory( mongoClientWrapperFactory );
70 | when( mongoClientWrapperFactory
71 | .createMongoClientWrapper( Mockito.any(), Mockito.any() ) )
72 | .thenReturn( mongoClientWrapper );
73 |
74 | lenient().when( stepMeta.getName() ).thenReturn( "stepMetaName" );
75 | lenient().when( transMeta.findStep( anyString() ) ).thenReturn( stepMeta );
76 | lenient().when( logChannelFactory.create( any( BaseStep.class ), any( Trans.class ) ) ).thenReturn( mockLog );
77 | KettleLogStore.setLogChannelInterfaceFactory( logChannelFactory );
78 | }
79 |
80 | @After public void tearDown() {
81 | MongoWrapperUtil.setMongoWrapperClientFactory( cachedFactory );
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/test/java/org/pentaho/di/trans/steps/mongodbinput/MongoDbConnectionAnalyzerTest.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.trans.steps.mongodbinput;
15 |
16 | import org.junit.Before;
17 | import org.junit.Test;
18 | import org.junit.runner.RunWith;
19 | import org.mockito.Mock;
20 | import org.mockito.junit.MockitoJUnitRunner;
21 | import org.pentaho.di.trans.steps.mongodb.MongoDbMeta;
22 | import org.pentaho.dictionary.DictionaryConst;
23 | import org.pentaho.metaverse.api.IAnalysisContext;
24 | import org.pentaho.metaverse.api.IComponentDescriptor;
25 | import org.pentaho.metaverse.api.IMetaverseBuilder;
26 | import org.pentaho.metaverse.api.IMetaverseNode;
27 | import org.pentaho.metaverse.api.IMetaverseObjectFactory;
28 | import org.pentaho.metaverse.api.INamespace;
29 | import org.pentaho.metaverse.api.MetaverseObjectFactory;
30 |
31 | import java.util.List;
32 |
33 | import static org.junit.Assert.assertEquals;
34 | import static org.junit.Assert.assertNotNull;
35 | import static org.mockito.Mockito.mock;
36 | import static org.mockito.Mockito.when;
37 |
38 | /**
39 | * User: RFellows Date: 3/6/15
40 | */
41 | @RunWith( MockitoJUnitRunner.StrictStubs.class )
42 | public class MongoDbConnectionAnalyzerTest {
43 |
44 | MongoDbConnectionAnalyzer analyzer;
45 |
46 | @Mock private IMetaverseBuilder mockBuilder;
47 | @Mock private MongoDbMeta mongoDbMeta;
48 | @Mock private IComponentDescriptor mockDescriptor;
49 |
50 | @Before
51 | public void setUp() throws Exception {
52 | IMetaverseObjectFactory factory = new MetaverseObjectFactory();
53 | when( mockBuilder.getMetaverseObjectFactory() ).thenReturn( factory );
54 |
55 | analyzer = new MongoDbConnectionAnalyzer();
56 | analyzer.setMetaverseBuilder( mockBuilder );
57 |
58 | when( mockDescriptor.getNamespace() ).thenReturn( mock( INamespace.class) );
59 | when( mockDescriptor.getContext() ).thenReturn( mock( IAnalysisContext.class ) );
60 |
61 | when( mongoDbMeta.getHostnames() ).thenReturn( "localhost" );
62 | when( mongoDbMeta.getDbName() ).thenReturn( "db" );
63 | when( mongoDbMeta.getAuthenticationUser() ).thenReturn( "user" );
64 | when( mongoDbMeta.getPort() ).thenReturn( "12345" );
65 | when( mongoDbMeta.isUseLegacyOptions() ).thenReturn( true );
66 | }
67 |
68 | @Test
69 | public void testAnalyze() throws Exception {
70 | IMetaverseNode node = analyzer.analyze( mockDescriptor, mongoDbMeta );
71 | assertNotNull( node );
72 | assertEquals( "localhost", node.getProperty( MongoDbConnectionAnalyzer.HOST_NAMES ) );
73 | assertEquals( "db", node.getProperty( MongoDbConnectionAnalyzer.DATABASE_NAME ) );
74 | assertEquals( "user", node.getProperty( DictionaryConst.PROPERTY_USER_NAME ) );
75 | assertEquals( "12345", node.getProperty( DictionaryConst.PROPERTY_PORT ) );
76 |
77 | }
78 |
79 | @Test
80 | public void testGetUsedConnections() throws Exception {
81 | List dbMetaList = analyzer.getUsedConnections( mongoDbMeta );
82 | assertEquals( 1, dbMetaList.size() );
83 |
84 | // should just return the same MongoDbMeta object in list form as the only entry
85 | assertEquals( mongoDbMeta, dbMetaList.get( 0 ) );
86 | }
87 |
88 | @Test
89 | public void testBuildComponentDescriptor() throws Exception {
90 | IComponentDescriptor dbDesc = analyzer.buildComponentDescriptor( mockDescriptor, mongoDbMeta );
91 | assertNotNull( dbDesc );
92 | assertEquals( "db", dbDesc.getName() );
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/pentaho-mongodb-plugin/src/main/java/org/pentaho/di/ui/swing/preview/PreviewRowsSwingDialog.java:
--------------------------------------------------------------------------------
1 | /*! ******************************************************************************
2 | *
3 | * Pentaho
4 | *
5 | * Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com
6 | *
7 | * Use of this software is governed by the Business Source License included
8 | * in the LICENSE.TXT file.
9 | *
10 | * Change Date: 2029-07-20
11 | ******************************************************************************/
12 |
13 |
14 | package org.pentaho.di.ui.swing.preview;
15 |
16 | import java.util.Iterator;
17 | import java.util.List;
18 | import java.util.ResourceBundle;
19 |
20 | import org.pentaho.di.trans.step.BaseStepMeta;
21 | import org.pentaho.di.ui.xul.common.preview.AbstractPreviewRowsXulDialog;
22 | import org.pentaho.ui.xul.XulException;
23 | import org.pentaho.ui.xul.XulSettingsManager;
24 | import org.pentaho.ui.xul.containers.XulTree;
25 | import org.pentaho.ui.xul.containers.XulTreeRow;
26 | import org.pentaho.ui.xul.swing.SwingBindingFactory;
27 | import org.pentaho.ui.xul.swing.SwingXulLoader;
28 | import org.pentaho.ui.xul.swing.SwingXulRunner;
29 | import org.pentaho.ui.xul.swing.tags.SwingTreeCell;
30 | import org.pentaho.ui.xul.swing.tags.SwingTreeCol;
31 | import org.pentaho.ui.xul.swing.tags.SwingTreeCols;
32 |
33 | public class PreviewRowsSwingDialog extends AbstractPreviewRowsXulDialog {
34 |
35 | @Override public void init() {
36 | super.init();
37 | }
38 |
39 | public PreviewRowsSwingDialog( Object parent, BaseStepMeta meta, int previewRowCount ) {
40 | super( parent, meta, previewRowCount );
41 | }
42 |
43 | @Override public XulSettingsManager getSettingsManager() {
44 | return null;
45 | }
46 |
47 | @Override public ResourceBundle getResourceBundle() {
48 | return null;
49 | }
50 |
51 | protected void initializeXul() throws XulException {
52 |
53 | initializeXul( new SwingXulLoader(), new SwingBindingFactory(), new SwingXulRunner(), parent );
54 |
55 | }
56 |
57 | @Override public void onAccept() {
58 | close();
59 | dispose();
60 |
61 | }
62 |
63 | @Override public void onCancel() {
64 | close();
65 | dispose();
66 |
67 | }
68 |
69 | @Override protected Class> getClassForMessages() {
70 | return this.getClass();
71 | }
72 |
73 | @Override public void dispose() {
74 |
75 | }
76 |
77 | /**
78 | * TODO: replace this method with XUL bindings
79 | *
80 | * This is a bad bad method. We need a way to load the column definitions and
81 | * data through standard XUL bindings.
82 | *
83 | * @param data
84 | * @param columns
85 | */
86 | protected void createPreviewRows( List