use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryTransDelegate method readPartitionSchemas.
/**
* Read the partitions in the repository and add them to this transformation if they are not yet present.
*
* @param transMeta
* The transformation to load into.
* @param overWriteShared
* if an object with the same name exists, overwrite
* @throws KettleException
*/
public void readPartitionSchemas(TransMeta transMeta, boolean overWriteShared) throws KettleException {
try {
ObjectId[] dbids = repository.getPartitionSchemaIDs(false);
for (int i = 0; i < dbids.length; i++) {
// Load last version
PartitionSchema partitionSchema = repository.loadPartitionSchema(dbids[i], null);
// Check if there already is
PartitionSchema check = transMeta.findPartitionSchema(partitionSchema.getName());
// one in the transformation
if (check == null || overWriteShared) {
if (!Utils.isEmpty(partitionSchema.getName())) {
transMeta.addOrReplacePartitionSchema(partitionSchema);
if (!overWriteShared) {
partitionSchema.setChanged(false);
}
}
}
}
} catch (KettleException dbe) {
throw new KettleException(BaseMessages.getString(PKG, "TransMeta.Log.UnableToReadPartitionSchemaFromRepository"), dbe);
}
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method editPartitionSchema.
public void editPartitionSchema(String partitionSchemaName) {
try {
ObjectId id = rep.getPartitionSchemaID(partitionSchemaName);
// Load the last version
PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
PartitionSchemaDialog dd = new PartitionSchemaDialog(shell, partitionSchema, rep.readDatabases(), variableSpace);
if (dd.open()) {
rep.insertLogEntry("Updating partition schema '" + partitionSchema.getName() + "'");
rep.save(partitionSchema, Const.VERSION_COMMENT_EDIT_VERSION, null);
if (!partitionSchemaName.equalsIgnoreCase(partitionSchema.getName())) {
refreshTree();
}
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Edit.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Edit.UnexpectedError.Message") + partitionSchemaName + "]", e);
}
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method newPartitionSchema.
public void newPartitionSchema() {
try {
PartitionSchema partitionSchema = new PartitionSchema();
PartitionSchemaDialog dd = new PartitionSchemaDialog(shell, partitionSchema, rep.readDatabases(), variableSpace);
if (dd.open()) {
// See if this slave server already exists...
ObjectId idPartitionSchema = rep.getPartitionSchemaID(partitionSchema.getName());
if (idPartitionSchema == null) {
rep.insertLogEntry("Creating new partition schema '" + partitionSchema.getName() + "'");
rep.save(partitionSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.AlreadyExists.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.AlreadyExists.Title"));
mb.open();
}
// Refresh tree...
refreshTree();
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.PartitionSchema.Create.UnexpectedError.Message"), e);
}
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class PartitionsController method refreshPartitions.
public void refreshPartitions() {
if (repository != null) {
final List<UIPartition> tmpList = new ArrayList<UIPartition>();
Runnable r = () -> {
try {
if (repository instanceof RepositoryExtended) {
List<PartitionSchema> partitionSchemas = ((RepositoryExtended) repository).getPartitions(false);
partitionSchemas.forEach(partitionSchema -> tmpList.add(new UIPartition(partitionSchema)));
} else {
ObjectId[] partitionIdList = repository.getPartitionSchemaIDs(false);
for (ObjectId partitionId : partitionIdList) {
PartitionSchema partition = repository.loadPartitionSchema(partitionId, null);
// Add the partition schema to the list
tmpList.add(new UIPartition(partition));
}
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
// convert to runtime exception so it bubbles up through the UI
throw new RuntimeException(e);
}
}
};
doWithBusyIndicator(r);
partitionList.setChildren(tmpList);
}
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class KettleFileRepository method readTransSharedObjects.
@Override
public SharedObjects readTransSharedObjects(TransMeta transMeta) throws KettleException {
// First the normal shared objects...
//
SharedObjects sharedObjects = transMeta.readSharedObjects();
//
for (ObjectId id : getDatabaseIDs(false)) {
// Load last version
DatabaseMeta databaseMeta = loadDatabaseMeta(id, null);
databaseMeta.shareVariablesWith(transMeta);
transMeta.addOrReplaceDatabase(databaseMeta);
}
for (ObjectId id : getSlaveIDs(false)) {
// Load last version
SlaveServer slaveServer = loadSlaveServer(id, null);
slaveServer.shareVariablesWith(transMeta);
transMeta.addOrReplaceSlaveServer(slaveServer);
}
for (ObjectId id : getClusterIDs(false)) {
// Load last version
ClusterSchema clusterSchema = loadClusterSchema(id, transMeta.getSlaveServers(), null);
clusterSchema.shareVariablesWith(transMeta);
transMeta.addOrReplaceClusterSchema(clusterSchema);
}
for (ObjectId id : getPartitionSchemaIDs(false)) {
// Load last version
PartitionSchema partitionSchema = loadPartitionSchema(id, null);
transMeta.addOrReplacePartitionSchema(partitionSchema);
}
return sharedObjects;
}
Aggregations