本文整理汇总了Java中org.pentaho.di.core.database.DatabaseMeta.shareVariablesWith方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMeta.shareVariablesWith方法的具体用法?Java DatabaseMeta.shareVariablesWith怎么用?Java DatabaseMeta.shareVariablesWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.database.DatabaseMeta
的用法示例。
在下文中一共展示了DatabaseMeta.shareVariablesWith方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readSharedObjects
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public SharedObjects readSharedObjects() throws KettleException {
// Extract the shared steps, connections, etc. using the SharedObjects
// class
//
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
Map<?, SharedObjectInterface> objectsMap = sharedObjects.getObjectsMap();
// First read the databases...
// We read databases & slaves first because there might be dependencies
// that need to be resolved.
//
for (SharedObjectInterface object : objectsMap.values()) {
if (object instanceof DatabaseMeta) {
DatabaseMeta databaseMeta = (DatabaseMeta) object;
databaseMeta.shareVariablesWith(this);
addOrReplaceDatabase(databaseMeta);
} else if (object instanceof SlaveServer) {
SlaveServer slaveServer = (SlaveServer) object;
slaveServer.shareVariablesWith(this);
addOrReplaceSlaveServer(slaveServer);
}
}
return sharedObjects;
}
示例2: readDatabases
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void readDatabases(Repository rep, boolean overWriteShared) throws KettleException {
try {
long dbids[] = rep.getDatabaseIDs();
for (int i = 0; i < dbids.length; i++) {
DatabaseMeta databaseMeta = RepositoryUtil.loadDatabaseMeta(rep, dbids[i]);
databaseMeta.shareVariablesWith(this);
DatabaseMeta check = findDatabase(databaseMeta.getName()); // Check
// if
// there
// already
// is
// one
// in
// the
// transformation
if (check == null || overWriteShared) // We only add, never
// overwrite database
// connections.
{
if (databaseMeta.getName() != null) {
addOrReplaceDatabase(databaseMeta);
if (!overWriteShared)
databaseMeta.setChanged(false);
}
}
}
setChanged(false);
} catch (KettleDatabaseException dbe) {
throw new KettleException(Messages.getString("JobMeta.Log.UnableToReadDatabaseIDSFromRepository"), dbe); //$NON-NLS-1$
} catch (KettleException ke) {
throw new KettleException(Messages.getString("JobMeta.Log.UnableToReadDatabasesFromRepository"), ke); //$NON-NLS-1$
}
}
示例3: readSharedObjects
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public SharedObjects readSharedObjects(Repository rep) throws KettleException {
// Extract the shared steps, connections, etc. using the SharedObjects
// class
//
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
Map<?, SharedObjectInterface> objectsMap = sharedObjects.getObjectsMap();
// First read the databases...
// We read databases & slaves first because there might be dependencies
// that need to be resolved.
//
for (SharedObjectInterface object : objectsMap.values()) {
if (object instanceof DatabaseMeta) {
DatabaseMeta databaseMeta = (DatabaseMeta) object;
databaseMeta.shareVariablesWith(this);
addOrReplaceDatabase(databaseMeta);
} else if (object instanceof SlaveServer) {
SlaveServer slaveServer = (SlaveServer) object;
slaveServer.shareVariablesWith(this);
addOrReplaceSlaveServer(slaveServer);
}
}
if (rep != null) {
readDatabases(rep, true);
readSlaves(rep, true);
}
return sharedObjects;
}
示例4: readDatabases
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void readDatabases(Repository rep, boolean overWriteShared) throws KettleException
{
try
{
long dbids[] = rep.getDatabaseIDs();
for (int i = 0; i < dbids.length; i++)
{
DatabaseMeta databaseMeta = RepositoryUtil.loadDatabaseMeta(rep, dbids[i]);
databaseMeta.shareVariablesWith(this);
DatabaseMeta check = findDatabase(databaseMeta.getName()); // Check if there already is one in the transformation
if (check==null || overWriteShared) // We only add, never overwrite database connections.
{
if (databaseMeta.getName() != null)
{
addOrReplaceDatabase(databaseMeta);
if (!overWriteShared) databaseMeta.setChanged(false);
}
}
}
changed_databases = false;
}
catch (KettleDatabaseException dbe)
{
throw new KettleException(Messages.getString("TransMeta.Log.UnableToReadDatabaseIDSFromRepository"), dbe); //$NON-NLS-1$
}
catch (KettleException ke)
{
throw new KettleException(Messages.getString("TransMeta.Log.UnableToReadDatabasesFromRepository"), ke); //$NON-NLS-1$
}
}
示例5: readDatabases
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
/**
* Read the database connections in the repository and add them to this job
* if they are not yet present.
*
* @param jobMeta the job to put the database connections in
* @param overWriteShared set to true if you want to overwrite shared connections while loading.
* @throws KettleException
*/
public void readDatabases(JobMeta jobMeta, boolean overWriteShared) throws KettleException {
try {
ObjectId dbids[] = repository.getDatabaseIDs(false);
for (int i = 0; i < dbids.length; i++) {
DatabaseMeta databaseMeta = repository.loadDatabaseMeta(dbids[i], null); // reads last version
databaseMeta.shareVariablesWith(jobMeta);
// See if there already is one in the transformation
//
DatabaseMeta check = jobMeta.findDatabase(databaseMeta.getName());
// We only add, never overwrite database connections.
//
if (check == null || overWriteShared)
{
if (databaseMeta.getName() != null) {
jobMeta.addOrReplaceDatabase(databaseMeta);
if (!overWriteShared)
databaseMeta.setChanged(false);
}
}
}
jobMeta.setChanged(false);
} catch (KettleDatabaseException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "JobMeta.Log.UnableToReadDatabaseIDSFromRepository"), dbe); //$NON-NLS-1$
} catch (KettleException ke) {
throw new KettleException(BaseMessages.getString(PKG, "JobMeta.Log.UnableToReadDatabasesFromRepository"), ke); //$NON-NLS-1$
}
}
示例6: readDatabases
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
/**
* Read all the databases from the repository, insert into the TransMeta object, overwriting optionally
*
* @param TransMeta The transformation to load into.
* @param overWriteShared if an object with the same name exists, overwrite
* @throws KettleException
*/
public void readDatabases(TransMeta transMeta, boolean overWriteShared) throws KettleException
{
try
{
ObjectId dbids[] = repository.getDatabaseIDs(false);
for (int i = 0; i < dbids.length; i++)
{
DatabaseMeta databaseMeta = repository.loadDatabaseMeta(dbids[i], null); // reads last version
databaseMeta.shareVariablesWith(transMeta);
DatabaseMeta check = transMeta.findDatabase(databaseMeta.getName()); // Check if there already is one in the transformation
if (check==null || overWriteShared) // We only add, never overwrite database connections.
{
if (databaseMeta.getName() != null)
{
transMeta.addOrReplaceDatabase(databaseMeta);
if (!overWriteShared) databaseMeta.setChanged(false);
}
}
}
transMeta.clearChangedDatabases();
}
catch (KettleDatabaseException dbe)
{
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Log.UnableToReadDatabaseIDSFromRepository"), dbe); //$NON-NLS-1$
}
catch (KettleException ke)
{
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Log.UnableToReadDatabasesFromRepository"), ke); //$NON-NLS-1$
}
}
示例7: readDatabases
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
/**
* Read all the databases from the repository, insert into the has databases object, overwriting optionally
*
* @param TransMeta The transformation to load into.
* @param overWriteShared if an object with the same name exists, overwrite
* @throws KettleException
*/
public void readDatabases(HasDatabasesInterface transMeta, boolean overWriteShared) throws KettleException
{
try
{
ObjectId dbids[] = getDatabaseIDs(false);
for (int i = 0; i < dbids.length; i++)
{
DatabaseMeta databaseMeta = loadDatabaseMeta(dbids[i], null); // reads last version
if (transMeta instanceof VariableSpace) {
databaseMeta.shareVariablesWith((VariableSpace)transMeta);
}
DatabaseMeta check = transMeta.findDatabase(databaseMeta.getName()); // Check if there already is one in the transformation
if (check==null || overWriteShared) // We only add, never overwrite database connections.
{
if (databaseMeta.getName() != null)
{
transMeta.addOrReplaceDatabase(databaseMeta);
if (!overWriteShared) databaseMeta.setChanged(false);
}
}
}
}
catch (KettleException e)
{
throw e;
}
}
示例8: newConnection
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void newConnection(HasDatabasesInterface hasDatabasesInterface) {
DatabaseMeta databaseMeta = new DatabaseMeta();
if (hasDatabasesInterface instanceof VariableSpace) {
databaseMeta.shareVariablesWith((VariableSpace) hasDatabasesInterface);
} else {
databaseMeta.initializeVariablesFrom(null);
}
getDatabaseDialog().setDatabaseMeta(databaseMeta);
String con_name = getDatabaseDialog().open();
if (!Const.isEmpty(con_name)) {
databaseMeta = getDatabaseDialog().getDatabaseMeta();
databaseMeta.verifyAndModifyDatabaseName(hasDatabasesInterface.getDatabases(), null);
hasDatabasesInterface.addDatabase(databaseMeta);
spoon.addUndoNew((UndoInterface) hasDatabasesInterface, new DatabaseMeta[] { (DatabaseMeta) databaseMeta.clone() }, new int[] { hasDatabasesInterface.indexOfDatabase(databaseMeta) });
if (spoon.rep!=null) {
try {
if (!spoon.rep.getSecurityProvider().isReadOnly()) {
spoon.rep.save(databaseMeta, Const.VERSION_COMMENT_INITIAL_VERSION, null);
} else {
throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
}
} catch (KettleException e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingConnection.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingConnection.Message", databaseMeta.getName()), e);
}
}
spoon.refreshTree();
}
}
示例9: fireToDB
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public static Object fireToDB(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext){
Object oRC = new Object();
if(ArgList.length==2){
try{
Object scmO = actualObject.get("_step_", actualObject);
ScriptValuesMod scm = (ScriptValuesMod)Context.jsToJava(scmO, ScriptValuesMod.class);
String strDBName = Context.toString(ArgList[0]);
String strSQL = Context.toString(ArgList[1]);
DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
ci.shareVariablesWith(scm);
Database db=new Database(ci);
db.setQueryLimit(0);
try{
db.connect();
ResultSet rs = db.openQuery(strSQL);
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int columnCount = resultSetMetaData.getColumnCount();
if(rs!=null){
List<Object[]> list = new ArrayList<Object[]>();
while(rs.next()){
Object[] objRow = new Object[columnCount];
for(int i=0;i<columnCount;i++){
objRow[i] = rs.getObject(i+1);
}
list.add(objRow);
}
Object[][] resultArr = new Object[list.size()][];
list.toArray(resultArr);
db.disconnect();
return resultArr;
}
}catch(Exception er){
throw Context.reportRuntimeError(er.toString());
}
}catch(Exception e){
}
}else{
throw Context.reportRuntimeError("The function call fireToDB requires 2 arguments.");
}
return oRC;
}
示例10: readSharedObjects
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public SharedObjects readSharedObjects(Repository rep) throws KettleException
{
if ( rep != null )
{
sharedObjectsFile = rep.getTransAttributeString(getId(), 0, "SHARED_FILE");
}
// Extract the shared steps, connections, etc. using the SharedObjects class
//
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
if (sharedObjects.getObjectsMap().isEmpty()) {
log.logDetailed(toString(), Messages.getString("TransMeta.Log.EmptySharedObjectsFile", soFile));
}
// First read the databases...
// We read databases & slaves first because there might be dependencies that need to be resolved.
//
for (SharedObjectInterface object : sharedObjects.getObjectsMap().values())
{
if (object instanceof DatabaseMeta)
{
DatabaseMeta databaseMeta = (DatabaseMeta) object;
databaseMeta.shareVariablesWith(this);
addOrReplaceDatabase(databaseMeta);
}
else if (object instanceof SlaveServer)
{
SlaveServer slaveServer = (SlaveServer) object;
slaveServer.shareVariablesWith(this);
addOrReplaceSlaveServer(slaveServer);
}
else if (object instanceof StepMeta)
{
StepMeta stepMeta = (StepMeta) object;
addOrReplaceStep(stepMeta);
}
else if (object instanceof PartitionSchema)
{
PartitionSchema partitionSchema = (PartitionSchema) object;
addOrReplacePartitionSchema(partitionSchema);
}
else if (object instanceof ClusterSchema)
{
ClusterSchema clusterSchema = (ClusterSchema) object;
clusterSchema.shareVariablesWith(this);
addOrReplaceClusterSchema(clusterSchema);
}
}
if (rep!=null)
{
readDatabases(rep, true);
readPartitionSchemas(rep, true);
readSlaves(rep, true);
readClusters(rep, true);
}
return sharedObjects;
}
示例11: newConnection
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void newConnection()
{
HasDatabasesInterface hasDatabasesInterface = spoon.getActiveHasDatabasesInterface();
if (hasDatabasesInterface == null && spoon.rep==null)
{
return;
}
DatabaseMeta databaseMeta = new DatabaseMeta();
if (hasDatabasesInterface instanceof VariableSpace) {
databaseMeta.shareVariablesWith((VariableSpace)hasDatabasesInterface);
}
else {
databaseMeta.initializeVariablesFrom(null);
}
// DatabaseDialog con = new DatabaseDialog(spoon.getShell(), databaseMeta);
XulDatabaseDialog con = new XulDatabaseDialog(spoon.getShell(), databaseMeta);
String con_name = con.open();
if (!Const.isEmpty(con_name))
{
databaseMeta = con.getDatabaseMeta();
if (hasDatabasesInterface!=null)
{
databaseMeta.verifyAndModifyDatabaseName(hasDatabasesInterface.getDatabases(), null);
hasDatabasesInterface.addDatabase(databaseMeta);
spoon.addUndoNew((UndoInterface) hasDatabasesInterface,
new DatabaseMeta[] { (DatabaseMeta) databaseMeta.clone() },
new int[] { hasDatabasesInterface.indexOfDatabase(databaseMeta) });
saveConnection(databaseMeta);
spoon.refreshTree();
}
else
{
// Save it in the repository...
try
{
if (!spoon.rep.userinfo.isReadonly())
{
RepositoryUtil.saveDatabaseMeta(databaseMeta,spoon.rep);
}
else
{
throw new KettleException(Messages.getString("Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
}
}
catch (KettleException e)
{
new ErrorDialog(spoon.getShell(), Messages.getString("Spoon.Dialog.ErrorSavingConnection.Title"), Messages.getString("Spoon.Dialog.ErrorSavingConnection.Message", databaseMeta.getName()), e);
}
}
}
}
示例12: fireToDB
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public static Object fireToDB(ScriptEngine actualContext, Bindings actualObject, Object[] ArgList, Object FunctionContext){
Object oRC = new Object();
if(ArgList.length==2){
try{
Object scmO = actualObject.get("_step_");
Script scm = (Script) scmO;
String strDBName = (String) ArgList[0];
String strSQL = (String) ArgList[1];
DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
if(ci==null) throw new RuntimeException("Database connection not found: "+strDBName);
ci.shareVariablesWith(scm);
Database db=new Database(scm, ci);
db.setQueryLimit(0);
try{
if (scm.getTransMeta().isUsingUniqueConnections())
{
synchronized (scm.getTrans()) { db.connect(scm.getTrans().getThreadName(), scm.getPartitionID()); }
}
else
{
db.connect(scm.getPartitionID());
}
ResultSet rs = db.openQuery(strSQL);
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int columnCount = resultSetMetaData.getColumnCount();
if(rs!=null){
List<Object[]> list = new ArrayList<Object[]>();
while(rs.next()){
Object[] objRow = new Object[columnCount];
for(int i=0;i<columnCount;i++){
objRow[i] = rs.getObject(i+1);
}
list.add(objRow);
}
Object[][] resultArr = new Object[list.size()][];
list.toArray(resultArr);
db.disconnect();
return resultArr;
}
}catch(Exception er){
throw new RuntimeException(er.toString());
}
}catch(Exception e){
throw new RuntimeException(e.toString());
}
}else{
throw new RuntimeException("The function call fireToDB requires 2 arguments.");
}
return oRC;
}
示例13: fireToDB
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public static Object fireToDB(Context actualContext, Scriptable actualObject, Object[] ArgList, Function FunctionContext){
Object oRC = new Object();
if(ArgList.length==2){
try{
Object scmO = actualObject.get("_step_", actualObject);
ScriptValuesMod scm = (ScriptValuesMod)Context.jsToJava(scmO, ScriptValuesMod.class);
String strDBName = Context.toString(ArgList[0]);
String strSQL = Context.toString(ArgList[1]);
DatabaseMeta ci = DatabaseMeta.findDatabase(scm.getTransMeta().getDatabases(), strDBName);
if(ci==null) throw Context.reportRuntimeError("Database connection not found: "+strDBName);
ci.shareVariablesWith(scm);
Database db=new Database(scm, ci);
db.setQueryLimit(0);
try{
if (scm.getTransMeta().isUsingUniqueConnections())
{
synchronized (scm.getTrans()) { db.connect(scm.getTrans().getThreadName(), scm.getPartitionID()); }
}
else
{
db.connect(scm.getPartitionID());
}
ResultSet rs = db.openQuery(strSQL);
ResultSetMetaData resultSetMetaData = rs.getMetaData();
int columnCount = resultSetMetaData.getColumnCount();
if(rs!=null){
List<Object[]> list = new ArrayList<Object[]>();
while(rs.next()){
Object[] objRow = new Object[columnCount];
for(int i=0;i<columnCount;i++){
objRow[i] = rs.getObject(i+1);
}
list.add(objRow);
}
Object[][] resultArr = new Object[list.size()][];
list.toArray(resultArr);
db.disconnect();
return resultArr;
}
}catch(Exception er){
throw Context.reportRuntimeError(er.toString());
}
}catch(Exception e){
throw Context.reportRuntimeError(e.toString());
}
}else{
throw Context.reportRuntimeError("The function call fireToDB requires 2 arguments.");
}
return oRC;
}
示例14: readSharedObjects
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public SharedObjects readSharedObjects() throws KettleException
{
// Extract the shared steps, connections, etc. using the SharedObjects class
//
String soFile = environmentSubstitute(sharedObjectsFile);
SharedObjects sharedObjects = new SharedObjects(soFile);
if (sharedObjects.getObjectsMap().isEmpty()) {
log.logDetailed(BaseMessages.getString(PKG, "TransMeta.Log.EmptySharedObjectsFile", soFile));
}
// First read the databases...
// We read databases & slaves first because there might be dependencies that need to be resolved.
//
for (SharedObjectInterface object : sharedObjects.getObjectsMap().values())
{
if (object instanceof DatabaseMeta)
{
DatabaseMeta databaseMeta = (DatabaseMeta) object;
databaseMeta.shareVariablesWith(this);
addOrReplaceDatabase(databaseMeta);
}
else if (object instanceof SlaveServer)
{
SlaveServer slaveServer = (SlaveServer) object;
slaveServer.shareVariablesWith(this);
addOrReplaceSlaveServer(slaveServer);
}
else if (object instanceof StepMeta)
{
StepMeta stepMeta = (StepMeta) object;
addOrReplaceStep(stepMeta);
}
else if (object instanceof PartitionSchema)
{
PartitionSchema partitionSchema = (PartitionSchema) object;
addOrReplacePartitionSchema(partitionSchema);
}
else if (object instanceof ClusterSchema)
{
ClusterSchema clusterSchema = (ClusterSchema) object;
clusterSchema.shareVariablesWith(this);
addOrReplaceClusterSchema(clusterSchema);
}
}
return sharedObjects;
}