/** Load the Database Info */ public DatabaseMeta loadDatabaseMeta(ObjectId id_database) throws KettleException { DatabaseMeta databaseMeta = new DatabaseMeta(); try { RowMetaAndData r = getDatabase(id_database); if (r != null) { ObjectId id_database_type = new LongObjectId( r.getInteger( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE, 0)); // con_type String dbTypeDesc = getDatabaseTypeCode(id_database_type); if (dbTypeDesc != null) { databaseMeta.setDatabaseInterface(DatabaseMeta.getDatabaseInterface(dbTypeDesc)); databaseMeta.setAttributes(new Properties()); // new attributes } databaseMeta.setObjectId(id_database); databaseMeta.setName(r.getString(KettleDatabaseRepository.FIELD_DATABASE_NAME, "")); ObjectId id_database_contype = new LongObjectId( r.getInteger( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE, 0)); // con_access databaseMeta.setAccessType( DatabaseMeta.getAccessType(getDatabaseConTypeCode(id_database_contype))); databaseMeta.setHostname( r.getString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME, "")); databaseMeta.setDBName( r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME, "")); databaseMeta.setDBPort(r.getString(KettleDatabaseRepository.FIELD_DATABASE_PORT, "")); databaseMeta.setUsername(r.getString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME, "")); databaseMeta.setPassword( Encr.decryptPasswordOptionallyEncrypted( r.getString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, ""))); databaseMeta.setServername( r.getString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, "")); databaseMeta.setDataTablespace( r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, "")); databaseMeta.setIndexTablespace( r.getString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, "")); // Also, load all the properties we can find... final Collection<RowMetaAndData> attrs = repository.connectionDelegate.getDatabaseAttributes(id_database); for (RowMetaAndData row : attrs) { String code = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, ""); String attribute = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, ""); databaseMeta.getAttributes().put(code, Const.NVL(attribute, "")); } } return databaseMeta; } catch (KettleDatabaseException dbe) { throw new KettleException( "Error loading database connection from repository (id_database=" + id_database + ")", dbe); } }
public PaloDimOutputData(DatabaseMeta databaseMeta) throws KettleException { super(); if (!(databaseMeta.getDatabaseInterface() instanceof PALODatabaseMeta)) { throw new KettleException("A connection of type PALO is expected"); } // org.pentaho.di.core.logging. this.helper = new PaloHelper(databaseMeta, DefaultLogLevel.getLogLevel()); }
/** * Adds db connection text boxes for input * * @return the last control specified */ protected Control addDbConnectionInputs() { List<String> ibConnections = new ArrayList<String>(); for (DatabaseMeta dbMeta : transMeta.getDatabases()) { if (dbMeta.getDatabaseInterface() instanceof IngresDatabaseMeta) { ibConnections.add(dbMeta.getName()); } } serverConnection = addStandardSelect( "Connection", wStepname, ibConnections.toArray(new String[ibConnections.size()])); return serverConnection; }
public String open() { Shell parent = getParent(); Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN); props.setLook(shell); setShellImage(shell, input); if (!SAPLibraryTester.isJCoLibAvailable()) { int style = SWT.ICON_ERROR; MessageBox messageBox = new MessageBox(shell, style); messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoLibNotFound")); messageBox.open(); // dispose(); // return stepname; } if (!SAPLibraryTester.isJCoImplAvailable()) { int style = SWT.ICON_ERROR; MessageBox messageBox = new MessageBox(shell, style); messageBox.setMessage(BaseMessages.getString(PKG, "SapInputDialog.JCoImplNotFound")); messageBox.open(); // dispose(); // return stepname; } ModifyListener lsMod = new ModifyListener() { public void modifyText(ModifyEvent e) { input.setChanged(); } }; ModifyListener lsConnectionMod = new ModifyListener() { public void modifyText(ModifyEvent e) { input.setChanged(); } }; backupChanged = input.hasChanged(); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(PKG, "SapInputDialog.shell.Title")); int middle = props.getMiddlePct(); int margin = Const.MARGIN; // Stepname line wlStepname = new Label(shell, SWT.RIGHT); wlStepname.setText(BaseMessages.getString(PKG, "SapInputDialog.Stepname.Label")); props.setLook(wlStepname); fdlStepname = new FormData(); fdlStepname.left = new FormAttachment(0, 0); fdlStepname.right = new FormAttachment(middle, -margin); fdlStepname.top = new FormAttachment(0, margin); wlStepname.setLayoutData(fdlStepname); wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); wStepname.setText(stepname); props.setLook(wStepname); wStepname.addModifyListener(lsMod); fdStepname = new FormData(); fdStepname.left = new FormAttachment(middle, 0); fdStepname.top = new FormAttachment(0, margin); fdStepname.right = new FormAttachment(100, 0); wStepname.setLayoutData(fdStepname); Control lastControl = wStepname; // Connection line // wConnection = addConnectionLine(shell, lastControl, middle, margin); List<String> items = new ArrayList<String>(); for (DatabaseMeta dbMeta : transMeta.getDatabases()) { if (dbMeta.getDatabaseInterface() instanceof SAPR3DatabaseMeta) { items.add(dbMeta.getName()); } } wConnection.setItems(items.toArray(new String[items.size()])); if (input.getDatabaseMeta() == null && transMeta.nrDatabases() == 1) { wConnection.select(0); } wConnection.addModifyListener(lsConnectionMod); lastControl = wConnection; // Function // wlFunction = new Label(shell, SWT.RIGHT); wlFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.Function.Label")); props.setLook(wlFunction); FormData fdlFunction = new FormData(); fdlFunction.left = new FormAttachment(0, 0); fdlFunction.right = new FormAttachment(middle, -margin); fdlFunction.top = new FormAttachment(lastControl, margin); wlFunction.setLayoutData(fdlFunction); wbFunction = new Button(shell, SWT.PUSH); props.setLook(wbFunction); wbFunction.setText(BaseMessages.getString(PKG, "SapInputDialog.FindFunctionButton.Label")); FormData fdbFunction = new FormData(); fdbFunction.right = new FormAttachment(100, 0); fdbFunction.top = new FormAttachment(lastControl, margin); wbFunction.setLayoutData(fdbFunction); wbFunction.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { getFunction(); } }); wFunction = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER); props.setLook(wFunction); wFunction.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { function = new SAPFunction(((Text) e.widget).getText()); input.setChanged(); } }); FormData fdFunction = new FormData(); fdFunction.left = new FormAttachment(middle, 0); fdFunction.right = new FormAttachment(wbFunction, -margin); fdFunction.top = new FormAttachment(lastControl, margin); wFunction.setLayoutData(fdFunction); lastControl = wFunction; // The parameter input fields... // wlInput = new Label(shell, SWT.NONE); wlInput.setText(BaseMessages.getString(PKG, "SapInputDialog.Input.Label")); props.setLook(wlInput); FormData fdlInput = new FormData(); fdlInput.left = new FormAttachment(0, 0); fdlInput.top = new FormAttachment(lastControl, margin); wlInput.setLayoutData(fdlInput); ColumnInfo[] ciKey = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.Field"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {""}, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"), ColumnInfo.COLUMN_TYPE_CCOMBO, SapType.getDescriptions()), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPParameterName"), ColumnInfo.COLUMN_TYPE_TEXT, false, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.getTypes()), }; inputFieldColumns.add(ciKey[0]); wInput = new TableView( transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciKey, input.getParameters().size(), lsMod, props); FormData fdInput = new FormData(); fdInput.left = new FormAttachment(0, 0); fdInput.top = new FormAttachment(wlInput, margin); fdInput.right = new FormAttachment(100, 0); fdInput.bottom = new FormAttachment(40, 0); wInput.setLayoutData(fdInput); lastControl = wInput; // THE BUTTONS wOK = new Button(shell, SWT.PUSH); wOK.setText(BaseMessages.getString(PKG, "System.Button.OK")); // wPreview = new Button(shell, SWT.PUSH); // wPreview.setText(BaseMessages.getString(PKG, "System.Button.Preview")); wGet = new Button(shell, SWT.PUSH); wGet.setText(BaseMessages.getString(PKG, "SapInputDialog.GetFields.Button")); wCancel = new Button(shell, SWT.PUSH); wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel")); wAbout = new Button(shell, SWT.PUSH); wAbout.setText(BaseMessages.getString(PKG, "SapInputDialog.About.Button")); // Preview not possible without inputRowSets in BaseStep.getRow() // setButtonPositions(new Button[] { wOK, wPreview, wAbout , wGet, wCancel}, margin, null); setButtonPositions(new Button[] {wOK, wAbout, wGet, wCancel}, margin, null); // The output fields... // wlOutput = new Label(shell, SWT.NONE); wlOutput.setText(BaseMessages.getString(PKG, "SapInputDialog.Output.Label")); props.setLook(wlOutput); FormData fdlOutput = new FormData(); fdlOutput.left = new FormAttachment(0, 0); fdlOutput.top = new FormAttachment(wInput, margin); wlOutput.setLayoutData(fdlOutput); ColumnInfo[] ciReturn = new ColumnInfo[] { new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPField"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] {}, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.SAPType"), ColumnInfo.COLUMN_TYPE_CCOMBO, SapType.getDescriptions(), false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TableOrStruct"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.NewName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo( BaseMessages.getString(PKG, "SapInputDialog.ColumnInfo.TargetType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMeta.getTypes()), }; outputFieldColumns.add(ciReturn[0]); wOutput = new TableView( transMeta, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL, ciReturn, input.getOutputFields().size(), lsMod, props); FormData fdOutput = new FormData(); fdOutput.left = new FormAttachment(0, 0); fdOutput.top = new FormAttachment(wlOutput, margin); fdOutput.right = new FormAttachment(100, 0); fdOutput.bottom = new FormAttachment(wOK, -8 * margin); wOutput.setLayoutData(fdOutput); lastControl = wOutput; this.wAscLink = new Link(this.shell, SWT.NONE); FormData fdAscLink = new FormData(); fdAscLink.left = new FormAttachment(0, 0); fdAscLink.top = new FormAttachment(wOutput, margin); wAscLink.setLayoutData(fdAscLink); this.wAscLink.setText(BaseMessages.getString(PKG, "SapInputDialog.Provided.Info")); lastControl = wAscLink; // Add listeners lsOK = new Listener() { public void handleEvent(Event e) { ok(); } }; lsPreview = new Listener() { public void handleEvent(Event e) { preview(); } }; lsGet = new Listener() { public void handleEvent(Event e) { get(); } }; lsCancel = new Listener() { public void handleEvent(Event e) { cancel(); } }; Listener lsAbout = new Listener() { public void handleEvent(Event e) { about(); } }; wOK.addListener(SWT.Selection, lsOK); // wPreview.addListener(SWT.Selection, lsPreview); wGet.addListener(SWT.Selection, lsGet); wCancel.addListener(SWT.Selection, lsCancel); this.wAbout.addListener(SWT.Selection, lsAbout); this.wAscLink.addListener( SWT.Selection, new Listener() { public void handleEvent(final Event event) { Program.launch(event.text); } }); lsDef = new SelectionAdapter() { public void widgetDefaultSelected(SelectionEvent e) { ok(); } }; wStepname.addSelectionListener(lsDef); wFunction.addSelectionListener(lsDef); // Detect X or ALT-F4 or something that kills this window... shell.addShellListener( new ShellAdapter() { public void shellClosed(ShellEvent e) { cancel(); } }); getData(); // Set the shell size, based upon previous time... setSize(); input.setChanged(backupChanged); setComboValues(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } return stepname; }
/** * Create the command line for a sql process depending on the meta information supplied. * * @param meta The meta data to create the command line from * @return The string to execute. * @throws KettleException Upon any exception */ public String createCommandLine(IngresVectorwiseLoaderMeta meta) throws KettleException { StringBuffer sb = new StringBuffer(300); if (!Const.isEmpty(meta.getSqlPath())) { try { FileObject fileObject = KettleVFS.getFileObject(environmentSubstitute(meta.getSqlPath()), getTransMeta()); String sqlexec = Const.optionallyQuoteStringByOS(KettleVFS.getFilename(fileObject)); sb.append(sqlexec); // sql @tc-dwh-test.timocom.net,tcp_ip,VW[ingres,pwd]::dwh } catch (KettleFileException ex) { throw new KettleException("Error retrieving command string", ex); } } else { if (meta.isUsingVwload()) { if (isDetailed()) logDetailed("vwload defaults to system path"); sb.append("vwload"); } else { if (isDetailed()) logDetailed("sql defaults to system path"); sb.append("sql"); } } DatabaseMeta dm = meta.getDatabaseMeta(); if (dm != null) { String databaseName = environmentSubstitute(Const.NVL(dm.getDatabaseName(), "")); String password = Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute(Const.NVL(dm.getDatabaseInterface().getPassword(), ""))); String port = environmentSubstitute(Const.NVL(dm.getDatabasePortNumberString(), "")).replace("7", ""); String username = environmentSubstitute(Const.NVL(dm.getDatabaseInterface().getUsername(), "")); String hostname = environmentSubstitute(Const.NVL(dm.getDatabaseInterface().getHostname(), "")); String schemaTable = dm.getQuotedSchemaTableCombination(null, environmentSubstitute(meta.getTablename())); String encoding = environmentSubstitute(Const.NVL(meta.getEncoding(), "")); String fifoFile = Const.optionallyQuoteStringByOS( environmentSubstitute(Const.NVL(meta.getFifoFileName(), ""))); String errorFile = Const.optionallyQuoteStringByOS( environmentSubstitute(Const.NVL(meta.getErrorFileName(), ""))); int maxNrErrors = Const.toInt(environmentSubstitute(Const.NVL(meta.getMaxNrErrors(), "0")), 0); if (meta.isUsingVwload()) { sb.append(" -u ").append(username); sb.append(" -P ").append(password); sb.append(" -f ").append(meta.getDelimiter()).append(""); sb.append(" -t ").append(schemaTable); if (!Const.isEmpty(encoding)) { sb.append(" -C ").append(encoding); } if (!Const.isEmpty(errorFile)) { sb.append(" -l ").append(errorFile); } if (maxNrErrors > 0) { sb.append(" -x ").append(maxNrErrors); } sb.append(" ").append(databaseName); sb.append(" ").append(fifoFile); } else if (meta.isUseDynamicVNode()) { // logical portname in JDBC use a 7 sb.append(" @") .append(hostname) .append(",") .append(port) .append("[") .append(username) .append(",") .append(password) .append("]::") .append(databaseName); } else { // Database Name // sb.append(" ").append(databaseName); if (meta.isUseAuthentication()) { sb.append("-P").append(password); } } } else { throw new KettleException("No connection specified"); } return sb.toString(); }