use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.
the class RepositoryImporter method loadSharedObjects.
/**
* Load the shared objects up front, replace them in the xforms/jobs loaded from XML. We do this for performance
* reasons.
*
* @throws KettleException
*/
protected void loadSharedObjects() throws KettleException {
sharedObjects = new SharedObjects();
for (ObjectId id : rep.getDatabaseIDs(false)) {
DatabaseMeta databaseMeta = rep.loadDatabaseMeta(id, null);
validateImportedElement(importRules, databaseMeta);
sharedObjects.storeObject(databaseMeta);
}
ObjectId[] slaveIDs = rep.getSlaveIDs(false);
List<SlaveServer> slaveServers = new ArrayList<SlaveServer>(slaveIDs.length);
for (ObjectId id : slaveIDs) {
SlaveServer slaveServer = rep.loadSlaveServer(id, null);
validateImportedElement(importRules, slaveServer);
sharedObjects.storeObject(slaveServer);
slaveServers.add(slaveServer);
}
for (ObjectId id : rep.getClusterIDs(false)) {
ClusterSchema clusterSchema = rep.loadClusterSchema(id, slaveServers, null);
validateImportedElement(importRules, clusterSchema);
sharedObjects.storeObject(clusterSchema);
}
for (ObjectId id : rep.getPartitionSchemaIDs(false)) {
PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
validateImportedElement(importRules, partitionSchema);
sharedObjects.storeObject(partitionSchema);
}
}
use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.
the class RepositoriesMeta method clone.
public RepositoriesMeta clone() {
RepositoriesMeta meta = new RepositoriesMeta();
meta.clear();
for (DatabaseMeta dbMeta : databases) {
meta.addDatabase(dbMeta);
}
for (RepositoryMeta repMeta : repositories) {
meta.addRepository(repMeta.clone());
}
return meta;
}
use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.
the class RepositoriesMeta method clear.
public void clear() {
errorMessage = null;
databases = new ArrayList<DatabaseMeta>();
repositories = new ArrayList<RepositoryMeta>();
LogLevel level = null;
if (log != null) {
level = log.getLogLevel();
}
setLog(newLogChannel());
if (level != null) {
log.setLogLevel(level);
}
}
use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.
the class RepositoriesMeta method parseRepositoriesDoc.
protected void parseRepositoriesDoc(Document doc) throws Exception {
// Get the <repositories> node:
Node repsnode = XMLHandler.getSubNode(doc, "repositories");
// Handle connections
int nrconn = XMLHandler.countNodes(repsnode, "connection");
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ConnectionNumber", nrconn));
}
for (int i = 0; i < nrconn; i++) {
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingConnection", i));
}
Node dbnode = XMLHandler.getSubNodeByNr(repsnode, "connection", i);
DatabaseMeta dbcon = null;
try {
dbcon = new DatabaseMeta(dbnode);
addDatabase(dbcon);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadConnection", dbcon.getName()));
}
} catch (Exception kpe) {
log.logError(BaseMessages.getString(PKG, "RepositoryMeta.Error.CreatingDatabaseMeta", dbcon.getName()));
}
}
// Handle repositories...
int nrreps = XMLHandler.countNodes(repsnode, RepositoryMeta.XML_TAG);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.RepositoryNumber", nrreps));
}
StringBuilder unableToReadIds = new StringBuilder();
KettleException kettleException = null;
for (int i = 0; i < nrreps; i++) {
Node repnode = XMLHandler.getSubNodeByNr(repsnode, RepositoryMeta.XML_TAG, i);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingRepository", i));
}
String id = XMLHandler.getTagValue(repnode, "id");
if (Utils.isEmpty(id)) {
// Backward compatibility : if the id is not defined, it's the database repository!
//
id = KettleDatabaseRepositoryMeta.REPOSITORY_TYPE_ID;
}
try {
RepositoryMeta repositoryMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
if (repositoryMeta != null) {
repositoryMeta.loadXML(repnode, databases);
// repositories dialog
if (repositoryMeta.getDescription() == null || repositoryMeta.getDescription().equals("")) {
repositoryMeta.setDescription(repositoryMeta.getName());
}
addRepository(repositoryMeta);
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadRepository", repositoryMeta.getName()));
}
} else {
unableToReadIds.append(id);
unableToReadIds.append(",");
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryId", id));
}
}
} catch (KettleException ex) {
// Get to the root cause
Throwable cause = ex;
kettleException = ex;
while (cause.getCause() != null) {
cause = cause.getCause();
}
if (cause instanceof KettleRepositoryNotSupportedException) {
// If the root cause is a KettleRepositoryNotSupportedException, do not fail
if (log.isDebug()) {
log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.UnrecognizedRepositoryType", id));
}
}
}
}
if (unableToReadIds != null && unableToReadIds.length() > 0) {
errorMessage = BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryIdNotAvailable", unableToReadIds.substring(0, unableToReadIds.lastIndexOf(",")));
}
if (kettleException != null) {
throw kettleException;
}
}
use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMeta method populate.
@Override
public void populate(Map<String, Object> properties, RepositoriesMeta repositoriesMeta) {
super.populate(properties, repositoriesMeta);
String databaseConnection = (String) properties.get(DATABASE_CONNECTION);
DatabaseMeta databaseMeta = repositoriesMeta.searchDatabase(databaseConnection);
if (databaseMeta != null) {
setConnection(databaseMeta);
}
}
Aggregations