当前位置: 首页>>代码示例>>Java>>正文


Java Database.shareVariablesWith方法代码示例

本文整理汇总了Java中org.pentaho.di.core.database.Database.shareVariablesWith方法的典型用法代码示例。如果您正苦于以下问题:Java Database.shareVariablesWith方法的具体用法?Java Database.shareVariablesWith怎么用?Java Database.shareVariablesWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.database.Database的用法示例。


在下文中一共展示了Database.shareVariablesWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRequiredFields

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @see org.pentaho.di.trans.step.BaseStepMeta#getRequiredFields(org.pentaho.di.core.variables.VariableSpace)
 */
@Override
public RowMetaInterface getRequiredFields(final VariableSpace space) throws KettleException {
    if (!this.useControlFile.getValue()) {
        final Database database = connectToDatabase();
        database.shareVariablesWith(space);

        final String schemaTable = getQuotedSchemaTableName(space);
        RowMetaInterface fields = database.getTableFields(schemaTable);
        database.disconnect();
        if (fields == null) {
            throw new KettleException(MESSAGES.getString("TeraFastMeta.Exception.TableNotFound"));
        }
        return fields;
    }
    return null;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:TeraFastMeta.java

示例2: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, Repository repository) throws KettleStepException
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
               // Copy the row
               RowMetaInterface tableFields = new RowMeta();

               // Now change the field names
               for (int i=0;i<fieldTable.length;i++)
               {
                   ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
                   if (v!=null)
                   {
                       ValueMetaInterface tableField = v.clone();
                       tableField.setName(fieldTable[i]);
                       tableFields.addValueMeta(tableField);
                   }
                   else
                   {
                       throw new KettleStepException("Unable to find field ["+fieldStream[i]+"] in the input rows");
                   }
               }

			if (!Const.isEmpty(tableName))
			{
                   Database db = new Database(loggingObject, databaseMeta);
                   db.shareVariablesWith(transMeta);
				try
				{
					db.connect();

                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), 
                       		                                                          transMeta.environmentSubstitute(tableName));                        
					String cr_table = db.getDDL(schemaTable,
												tableFields,
												null,
												false,
												null,
												true
												);

					String sql = cr_table;
					if (sql.length()==0) retval.setSQL(null); else retval.setSQL(sql);
				}
				catch(KettleException e)
				{
					retval.setError(BaseMessages.getString(PKG, "TeraDataBulkLoaderMeta.GetSQL.ErrorOccurred")+e.getMessage()); 
				}
			}
			else
			{
				retval.setError(BaseMessages.getString(PKG, "TeraDataBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection")); 
			}
		}
		else
		{
			retval.setError(BaseMessages.getString(PKG, "TeraDataBulkLoaderMeta.GetSQL.NotReceivingAnyFields")); 
		}
	}
	else
	{
		retval.setError(BaseMessages.getString(PKG, "TeraDataBulkLoaderMeta.GetSQL.NoConnectionDefined")); 
	}

	return retval;
}
 
开发者ID:jbleuel,项目名称:pdi-teradata-tpt-plugin,代码行数:71,代码来源:TeraDataBulkLoaderMeta.java

示例3: endProcessing

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public boolean endProcessing(String status, Result res) throws KettleJobException
{
	try
	{
		long read=res.getNrLinesRead();
        long written=res.getNrLinesWritten();
        long updated=res.getNrLinesUpdated();
        long errors=res.getNrErrors();
        long input=res.getNrLinesInput();
        long output=res.getNrLinesOutput();
        
        if (errors==0 && !res.getResult()) errors=1;
		
		logDate     = new Date();

        // Change the logging back to stream...
        String log_string = null;
        
        if (jobMeta.isLogfieldUsed())
        {
            log_string = stringAppender.getBuffer().append(Const.CR+"END"+Const.CR).toString();
            log.removeAppender(stringAppender);
        }
        
		/*
		 * Sums errors, read, written, etc.
		 */		

		DatabaseMeta logcon = jobMeta.getLogConnection();
		if (logcon!=null)
		{
			Database ldb = new Database(logcon);
			ldb.shareVariablesWith(this);
			try
			{
				ldb.connect();
				ldb.writeLogRecord(jobMeta.getLogTable(), jobMeta.isBatchIdUsed(), getBatchId(), true, jobMeta.getName(), status, 
				                   read,written,updated,input,output,errors, 
				                   startDate, endDate, logDate, depDate, currentDate,
								   log_string
								   );
			}
			catch(KettleDatabaseException dbe)
			{
				addErrors(1);
				throw new KettleJobException("Unable to end processing by writing log record to table "+jobMeta.getLogTable(), dbe);
			}
			finally
			{
				ldb.disconnect();
			}
		}
        
		return true;
	}
	catch(Exception e)
	{
		throw new KettleJobException(e); // In case something else goes wrong.
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:61,代码来源:Job.java

示例4: getSchemaNames

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
private void getSchemaNames()
{
	if(wSchemaname.isDisposed()) return; 
	DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
	if (databaseMeta!=null)
	{
		Database database = new Database(loggingObject, databaseMeta);
		database.shareVariablesWith(jobMeta);
		try
		{
			database.connect();
			String schemas[] = database.getSchemas();
			
			if (null != schemas && schemas.length>0) {
				schemas=Const.sortStrings(schemas);	
				EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, 
						BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Title", wConnection.getText()), 
						BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Message"));
				String d=dialog.open();
				if (d!=null) 
				{
					wSchemaname.setText(Const.NVL(d.toString(), ""));
				}

			}else
			{
				MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
				mb.setMessage(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Message"));
				mb.setText(BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.Empty.Title"));
				mb.open(); 
			}
		}
		catch(Exception e)
		{
			new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), 
					BaseMessages.getString(PKG, "System.Dialog.AvailableSchemas.ConnectionError"), e);
		}
		finally
		{
			if(database!=null) 
			{
				database.disconnect();
				database=null;
			}
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:48,代码来源:JobEntryTableExistsDialog.java

示例5: getListColumns

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get a list of columns
 */
private void getListColumns()
{
	if (!Const.isEmpty(wTablename.getText()))
	{
		DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
		if (databaseMeta!=null)
		{
			Database database = new Database(loggingObject, databaseMeta);
			database.shareVariablesWith(jobMeta);
			try
			{
				database.connect();
				String schemaTable = databaseMeta.getQuotedSchemaTableCombination(jobMeta.environmentSubstitute(wSchemaname.getText()), jobMeta.environmentSubstitute(wTablename.getText()));
				RowMetaInterface row = database.getTableFields(schemaTable);
				if(row!=null)
				{
					String available[] = row.getFieldNames();
			
					wFields.removeAll();
					for (int i=0;i<available.length;i++) 
					{
						wFields.add(available[i]);
					}
					wFields.removeEmptyRows();
					wFields.setRowNums();
				}else
				{
					MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
					mb.setMessage(BaseMessages.getString(PKG, "JobEntryColumnsExist.GetListColumsNoRow.DialogMessage"));
					mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
					mb.open(); 
				}
			}
			catch(Exception e)
			{
				new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobEntryColumnsExist.ConnectionError2.DialogMessage",wTablename.getText()), e);
			}
			finally
			{
				database.disconnect();
			}
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:48,代码来源:JobEntryColumnsExistDialog.java

示例6: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
			if (!Const.isEmpty(tablename))
			{
				Database db = new Database(databaseMeta);
				db.shareVariablesWith(transMeta);
				try
				{
					db.connect();
					
                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tablename);
                       String cr_table = db.getDDL(schemaTable, prev);
					
					// Empty string means: nothing to do: set it to null...
					if (cr_table==null || cr_table.length()==0) cr_table=null;
					
					retval.setSQL(cr_table);
				}
				catch(KettleDatabaseException dbe)
				{
					retval.setError(Messages.getString("SQLFileOutputMeta.Error.ErrorConnecting", dbe.getMessage()));
				}
				finally
				{
					db.disconnect();
				}
			}
			else
			{
				retval.setError(Messages.getString("SQLFileOutputMeta.Exception.TableNotSpecified"));
			}
		}
		else
		{
			retval.setError(Messages.getString("SQLFileOutputMeta.Error.NoInput"));
		}
	}
	else
	{
		retval.setError(Messages.getString("SQLFileOutputMeta.Error.NoConnection"));
	}

	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:51,代码来源:SQLFileOutputMeta.java

示例7: getListColumns

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get a list of columns, comma separated, allow the user to select from it.
 */
private void getListColumns()
{
	if (!Const.isEmpty(wTablename.getText()))
	{
		DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
		if (databaseMeta!=null)
		{
			Database database = new Database(loggingObject, databaseMeta);
			database.shareVariablesWith(jobMeta);
			try
			{
				database.connect();
				String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
				RowMetaInterface row = database.getTableFields(schemaTable);
				String available[] = row.getFieldNames();
                   
				String source[] = wOrderBy.getText().split(",");
				for (int i=0;i<source.length;i++) source[i] = Const.trim(source[i]);
				int idxSource[] = Const.indexsOfStrings(source, available);
				EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobMssqlBulkLoad.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMssqlBulkLoad.SelectColumns.Message"));
				dialog.setMulti(true);
				dialog.setAvoidQuickSearch();
				dialog.setSelectedNrs(idxSource);
				if (dialog.open()!=null)
				{
					String columns="";
					int idx[] = dialog.getSelectionIndeces();
					for (int i=0;i<idx.length;i++)
					{
						if (i>0) columns+=", ";
						columns+=available[idx[i]];
					}
					wOrderBy.setText(columns);
				}
			}
			catch(KettleDatabaseException e)
			{
				new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMssqlBulkLoad.ConnectionError2.DialogMessage"), e);
			}
			finally
			{
				database.disconnect();
			}
		}
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:50,代码来源:JobEntryMssqlBulkLoadDialog.java

示例8: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
			if (!Const.isEmpty(tableName))
			{
                   Database db = new Database(databaseMeta);
                   db.shareVariablesWith(transMeta);
				try
				{
					db.connect();
					
                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName);
					String cr_table = db.getDDL(schemaTable, 
												prev, 
												null, 
												false, 
												null,
												true
												);
					
					String cr_index = ""; //$NON-NLS-1$
					String idx_fields[] = null;
					
					if (keyLookup!=null && keyLookup.length>0)
					{
						idx_fields = new String[keyLookup.length];
						for (int i=0;i<keyLookup.length;i++) idx_fields[i] = keyLookup[i];
					}
					else
					{
						retval.setError(Messages.getString("DeleteMeta.CheckResult.KeyFieldsRequired")); //$NON-NLS-1$
					}

					// Key lookup dimensions...
					if (idx_fields!=null && idx_fields.length>0 && 
						!db.checkIndexExists(schemaTable, idx_fields)
					   )
					{
						String indexname = "idx_"+tableName+"_lookup"; //$NON-NLS-1$ //$NON-NLS-2$
						cr_index = db.getCreateIndexStatement(schemaName, tableName, indexname, idx_fields, false, false, false, true);
					}
					
					String sql = cr_table+cr_index;
					if (sql.length()==0) retval.setSQL(null); else retval.setSQL(sql);
				}
				catch(KettleException e)
				{
					retval.setError(Messages.getString("DeleteMeta.Returnvalue.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
				}
			}
			else
			{
				retval.setError(Messages.getString("DeleteMeta.Returnvalue.NoTableDefinedOnConnection")); //$NON-NLS-1$
			}
		}
		else
		{
			retval.setError(Messages.getString("DeleteMeta.Returnvalue.NoReceivingAnyFields")); //$NON-NLS-1$
		}
	}
	else
	{
		retval.setError(Messages.getString("DeleteMeta.Returnvalue.NoConnectionDefined")); //$NON-NLS-1$
	}

	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:73,代码来源:DeleteMeta.java

示例9: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
			if (!Const.isEmpty(tableName))
			{
                   String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName);

				Database db = new Database(databaseMeta);
				db.shareVariablesWith(transMeta);
				try
				{
					db.connect();
					
					if ( getIgnoreFlagField()!=null && 
						 getIgnoreFlagField().length()>0)
					{
					    prev.addValueMeta(new ValueMeta(getIgnoreFlagField(), ValueMetaInterface.TYPE_BOOLEAN));
					}
					
					String cr_table = db.getDDL(schemaTable, 
												prev, 
												null, 
												false, 
												null,
												true
												);
					
					String cr_index = ""; //$NON-NLS-1$
					String idx_fields[] = null;
					
					if (keyLookup!=null && keyLookup.length>0)
					{
						idx_fields = new String[keyLookup.length];
						for (int i=0;i<keyLookup.length;i++) idx_fields[i] = keyLookup[i];
					}
					else
					{
						retval.setError(Messages.getString("UpdateMeta.CheckResult.MissingKeyFields")); //$NON-NLS-1$
					}

					// Key lookup dimensions...
					if (idx_fields!=null && idx_fields.length>0 && !db.checkIndexExists(schemaName, tableName, idx_fields)
					   )
					{
						String indexname = "idx_"+tableName+"_lookup"; //$NON-NLS-1$ //$NON-NLS-2$
						cr_index = db.getCreateIndexStatement(schemaName, tableName, indexname, idx_fields, false, false, false, true);
					}
					
					String sql = cr_table+cr_index;
					if (sql.length()==0) retval.setSQL(null); else retval.setSQL(sql);
				}
				catch(KettleException e)
				{
					retval.setError(Messages.getString("UpdateMeta.ReturnValue.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
				}
			}
			else
			{
				retval.setError(Messages.getString("UpdateMeta.ReturnValue.NoTableDefinedOnConnection")); //$NON-NLS-1$
			}
		}
		else
		{
			retval.setError(Messages.getString("UpdateMeta.ReturnValue.NotReceivingAnyFields")); //$NON-NLS-1$
		}
	}
	else
	{
		retval.setError(Messages.getString("UpdateMeta.ReturnValue.NoConnectionDefined")); //$NON-NLS-1$
	}

	return retval;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:79,代码来源:UpdateMeta.java

示例10: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
    SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

    if (databaseMeta!=null)
    {
        if (prev!=null && prev.size()>0)
        {
            if (!Const.isEmpty(tablename))
            {
                Database db = new Database(loggingObject, databaseMeta);
                db.shareVariablesWith(transMeta);
                try
                {
                    db.connect();
                    
                    String schemaTable = databaseMeta.getQuotedSchemaTableCombination(null, tablename);
                    String cr_table = db.getDDL(schemaTable, prev);
                    
                    // Squeeze in the VECTORWISE col store clause...
                    // TODO: move this to the database dialog and make it user configurable.
                    //
                    String VW_CLAUSE="WITH STRUCTURE=VECTORWISE";
                    
                    if (cr_table.toUpperCase().contains("CREATE TABLE")) {
                      int scIndex = cr_table.indexOf(';');
                      if (scIndex<0) {
                        cr_table +=VW_CLAUSE;
                      } else {
                        cr_table = cr_table.substring(0, scIndex)+ VW_CLAUSE + cr_table.substring(scIndex);
                      }
                    }
                    
                    // Empty string means: nothing to do: set it to null...
                    if (cr_table==null || cr_table.length()==0) cr_table=null;
                    
                    retval.setSQL(cr_table);
                }
                catch(KettleDatabaseException dbe)
                {
                    retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.ErrorConnecting", dbe.getMessage()));
                }
                finally
                {
                    db.disconnect();
                }
            }
            else
            {
                retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoTable"));
            }
        }
        else
        {
            retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoInput"));
        }
    }
    else
    {
        retval.setError(BaseMessages.getString(PKG, "IngresVectorWiseLoaderMeta.Error.NoConnection"));
    }

    return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:65,代码来源:IngresVectorwiseLoaderMeta.java

示例11: getSQLStatements

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev) throws KettleStepException
{
	SQLStatement retval = new SQLStatement(stepMeta.getName(), databaseMeta, null); // default: nothing to do!

	if (databaseMeta!=null)
	{
		if (prev!=null && prev.size()>0)
		{
               // Copy the row
               RowMetaInterface tableFields = new RowMeta();

               // Now change the field names
               for (int i=0;i<fieldTable.length;i++)
               {
                   ValueMetaInterface v = prev.searchValueMeta(fieldStream[i]);
                   if (v!=null)
                   {
                       ValueMetaInterface tableField = v.clone();
                       tableField.setName(fieldTable[i]);
                       tableFields.addValueMeta(tableField);
                   }
                   else
                   {
                       throw new KettleStepException("Unable to find field ["+fieldStream[i]+"] in the input rows");
                   }
               }

			if (!Const.isEmpty(tableName))
			{
                   Database db = new Database(loggingObject, databaseMeta);
                   db.shareVariablesWith(transMeta);
				try
				{
					db.connect();

                       String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), 
                       		                                                          transMeta.environmentSubstitute(tableName));                        
					String sql = db.getDDL(schemaTable,
												tableFields,
												null,
												false,
												null,
												true
												);

					if (sql.length()==0) retval.setSQL(null); else retval.setSQL(sql);
				}
				catch(KettleException e)
				{
					retval.setError(BaseMessages.getString(PKG, "GPBulkLoaderMeta.GetSQL.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
				}
			}
			else
			{
				retval.setError(BaseMessages.getString(PKG, "GPBulkLoaderMeta.GetSQL.NoTableDefinedOnConnection")); //$NON-NLS-1$
			}
		}
		else
		{
			retval.setError(BaseMessages.getString(PKG, "GPBulkLoaderMeta.GetSQL.NotReceivingAnyFields")); //$NON-NLS-1$
		}
	}
	else
	{
		retval.setError(BaseMessages.getString(PKG, "GPBulkLoaderMeta.GetSQL.NoConnectionDefined")); //$NON-NLS-1$
	}

	return retval;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:70,代码来源:GPBulkLoaderMeta.java

示例12: getListColumns

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get a list of columns, comma separated, allow the user to select from it.
 *
 */
private void getListColumns()
{
    if (!Const.isEmpty(wTablename.getText()))
    {
        DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
        if (databaseMeta!=null)
        {
            Database database = new Database(databaseMeta);
            database.shareVariablesWith(jobMeta);
            try
            {
                database.connect();
                String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
                RowMetaInterface row = database.getTableFields(schemaTable);
                String available[] = row.getFieldNames();
                
                String source[] = wListColumn.getText().split(",");
                for (int i=0;i<source.length;i++) source[i] = Const.trim(source[i]);
                int idxSource[] = Const.indexsOfStrings(source, available);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, Messages.getString("JobMysqlBulkFile.SelectColumns.Title"), Messages.getString("JobMysqlBulkFile.SelectColumns.Message"));
                dialog.setMulti(true);
                dialog.setSelectedNrs(idxSource);
                if (dialog.open()!=null)
                {
                    String columns="";
                    int idx[] = dialog.getSelectionIndeces();
                    for (int i=0;i<idx.length;i++)
                    {
                        if (i>0) columns+=", ";
                        columns+=available[idx[i]];
                    }
                    wListColumn.setText(columns);
                }
            }
            catch(KettleDatabaseException e)
            {
                new ErrorDialog(shell, Messages.getString("System.Dialog.Error.Title"), Messages.getString("JobMysqlBulkFile.ConnectionError2.DialogMessage"), e);
            }
            finally
            {
                database.disconnect();
            }
        }
    }
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:50,代码来源:JobEntryMysqlBulkFileDialog.java

示例13: getListColumns

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get a list of columns
 */
private void getListColumns()
{
	if (!Const.isEmpty(wTablename.getText()))
	{
		DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
		if (databaseMeta!=null)
		{
			Database database = new Database(databaseMeta);
			database.shareVariablesWith(jobMeta);
			try
			{
				database.connect();
				String schemaTable = databaseMeta.getQuotedSchemaTableCombination(jobMeta.environmentSubstitute(wSchemaname.getText()), jobMeta.environmentSubstitute(wTablename.getText()));
				RowMetaInterface row = database.getTableFields(schemaTable);
				if(row!=null)
				{
					String available[] = row.getFieldNames();
			
					wFields.removeAll();
					for (int i=0;i<available.length;i++) 
					{
						wFields.add(available[i]);
					}
					wFields.removeEmptyRows();
					wFields.setRowNums();
				}else
				{
					MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
					mb.setMessage(Messages.getString("JobEntryColumnsExist.GetListColumsNoRow.DialogMessage"));
					mb.setText(Messages.getString("System.Dialog.Error.Title"));
					mb.open(); 
				}
			}
			catch(Exception e)
			{
				new ErrorDialog(shell, Messages.getString("System.Dialog.Error.Title"), Messages.getString("JobEntryColumnsExist.ConnectionError2.DialogMessage",wTablename.getText()), e);
			}
			finally
			{
				database.disconnect();
			}
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:48,代码来源:JobEntryColumnsExistDialog.java

示例14: getLookup

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
/**
 * Get the fields from the table in the database and use them as lookup 
 * keys. Only get the the fields which are not yet in use as key, or in 
 * the field table. Also ignore technical key, version, fromdate, todate.
 */
private void getLookup()
{
	DatabaseMeta databaseMeta = transMeta.findDatabase(wConnection.getText());
	if (databaseMeta!=null)
	{
		Database db = new Database(databaseMeta);
		db.shareVariablesWith(transMeta);
		try
		{
			db.connect();
               String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchema.getText(), wTable.getText()); 
			RowMetaInterface r = db.getTableFields(schemaTable);
			if (r!=null && !r.isEmpty())
			{
                   BaseStepDialog.getFieldsFromPrevious(r, wUpIns, 2, new int[] { 1, 2 }, new int[] { 3 }, -1, -1, new TableItemInsertListener()
                       {
                           public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v)
                           {
                               int idx = wKey.indexOfString(v.getName(), 2);
                               if ( idx<0 &&
                                   !v.getName().equalsIgnoreCase(wTk.getText()) &&
                                   !v.getName().equalsIgnoreCase(wVersion.getText()) &&
                                   !v.getName().equalsIgnoreCase(wFromdate.getText()) &&
                                   !v.getName().equalsIgnoreCase(wTodate.getText())
                                   )
                               {
                                   return true;
                               }
                               return false;
                           }
                       }
                   );
			}
		}
		catch(KettleException e)
		{
			MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR );
			mb.setText(Messages.getString("DimensionLookupDialog.ErrorOccurred.DialogTitle")); //$NON-NLS-1$
			mb.setMessage(Messages.getString("DimensionLookupDialog.ErrorOccurred.DialogMessage")+Const.CR+e.getMessage()); //$NON-NLS-1$
			mb.open();
		}
		finally
		{
			db.disconnect();
		}
	}
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:53,代码来源:DimensionLookupDialog.java

示例15: endProcessing

import org.pentaho.di.core.database.Database; //导入方法依赖的package包/类
private boolean endProcessing() throws KettleJobException
{
	LogStatus status;
	if (!isActive()) {
		if (isStopped()) {
			status = LogStatus.STOP;
		} else {
			status = LogStatus.END;
		}
	} else {
		status = LogStatus.RUNNING;
	}
	try
	{
        if (errors.get()==0 && result!=null && !result.getResult()) {
        	errors.incrementAndGet();
        }
		
		logDate     = new Date();

		/*
		 * Sums errors, read, written, etc.
		 */		
		
		JobLogTable jobLogTable = jobMeta.getJobLogTable();
		if (jobLogTable.isDefined()) {

			String tableName = jobMeta.getJobLogTable().getActualTableName();
			DatabaseMeta logcon = jobMeta.getJobLogTable().getDatabaseMeta();

			Database ldb = new Database(this, logcon);
			ldb.shareVariablesWith(this);
			try
			{
				ldb.connect();
 	            ldb.setCommit(logCommitSize);
				ldb.writeLogRecord(jobMeta.getJobLogTable(), status, this, null);
			}
			catch(KettleDatabaseException dbe)
			{
				addErrors(1);
				throw new KettleJobException("Unable to end processing by writing log record to table "+tableName, dbe);
			}
			finally
			{
			  if (!ldb.isAutoCommit()) ldb.commit(true);
				ldb.disconnect();
			}
		}
        
		return true;
	}
	catch(Exception e)
	{
		throw new KettleJobException(e); // In case something else goes wrong.
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:58,代码来源:Job.java


注:本文中的org.pentaho.di.core.database.Database.shareVariablesWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。