use of org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog in project pentaho-kettle by pentaho.
the class SpoonPartitionsDelegate method newPartitioningSchema.
public void newPartitioningSchema(TransMeta transMeta) {
PartitionSchema partitionSchema = new PartitionSchema();
PartitionSchemaDialog dialog = new PartitionSchemaDialog(spoon.getShell(), partitionSchema, transMeta.getPartitionSchemas(), transMeta.getDatabases(), transMeta);
if (dialog.open()) {
List<PartitionSchema> partitions = transMeta.getPartitionSchemas();
if (isDuplicate(partitions, partitionSchema)) {
new ErrorDialog(spoon.getShell(), getMessage("Spoon.Dialog.ErrorSavingPartition.Title"), getMessage("Spoon.Dialog.ErrorSavingPartition.Message", partitionSchema.getName()), new KettleException(getMessage("Spoon.Dialog.ErrorSavingPartition.NotUnique")));
return;
}
partitions.add(partitionSchema);
if (spoon.rep != null) {
try {
if (!spoon.rep.getSecurityProvider().isReadOnly()) {
spoon.rep.save(partitionSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
if (sharedObjectSyncUtil != null) {
sharedObjectSyncUtil.reloadTransformationRepositoryObjects(false);
}
} else {
throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
}
} catch (KettleException e) {
showSaveErrorDialog(partitionSchema, e);
}
}
spoon.refreshTree();
}
}
use of org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog in project pentaho-kettle by pentaho.
the class PartitionsController method editPartition.
public void editPartition() {
String partitionSchemaName = "";
try {
Collection<UIPartition> partitions = partitionsTable.getSelectedItems();
if (partitions != null && !partitions.isEmpty()) {
// Grab the first item in the list & send it to the partition schema dialog
PartitionSchema partitionSchema = ((UIPartition) partitions.toArray()[0]).getPartitionSchema();
partitionSchemaName = partitionSchema.getName();
// Make sure the partition already exists
ObjectId partitionId = repository.getPartitionSchemaID(partitionSchema.getName());
if (partitionId == null) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.DoesNotExists.Message", partitionSchemaName));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title"));
mb.open();
} else {
PartitionSchemaDialog partitionDialog = new PartitionSchemaDialog(shell, partitionSchema, repository.readDatabases(), variableSpace);
if (partitionDialog.open()) {
if (partitionSchema.getName() != null && !partitionSchema.getName().equals("")) {
repository.insertLogEntry(BaseMessages.getString(RepositoryExplorer.class, "PartitionsController.Message.UpdatingPartition", partitionSchema.getName()));
repository.save(partitionSchema, Const.VERSION_COMMENT_EDIT_VERSION, null);
if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
mainController.getSharedObjectSyncUtil().synchronizePartitionSchemas(partitionSchema, partitionSchemaName);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.InvalidName.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title"));
mb.open();
}
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.NoItemSelected.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.UnexpectedError.Message") + partitionSchemaName + "]", e);
}
} finally {
refreshPartitions();
}
}
use of org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog in project pentaho-kettle by pentaho.
the class PartitionsController method createPartition.
public void createPartition() {
try {
PartitionSchema partition = new PartitionSchema();
PartitionSchemaDialog partitionDialog = new PartitionSchemaDialog(shell, partition, repository.readDatabases(), variableSpace);
if (partitionDialog.open()) {
// See if this partition already exists...
ObjectId idPartition = repository.getPartitionSchemaID(partition.getName());
if (idPartition == null) {
if (partition.getName() != null && !partition.getName().equals("")) {
repository.insertLogEntry(BaseMessages.getString(RepositoryExplorer.class, "PartitionsController.Message.CreatingPartition", partition.getName()));
repository.save(partition, Const.VERSION_COMMENT_INITIAL_VERSION, null);
if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
mainController.getSharedObjectSyncUtil().reloadTransformationRepositoryObjects(true);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Edit.InvalidName.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.Title"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.AlreadyExists.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.AlreadyExists.Title"));
mb.open();
}
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Create.UnexpectedError.Message"), e);
}
} finally {
refreshPartitions();
}
}
use of org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog in project pentaho-kettle by pentaho.
the class SpoonPartitionsDelegate method editPartitionSchema.
public void editPartitionSchema(TransMeta transMeta, PartitionSchema partitionSchema) {
String originalName = partitionSchema.getName();
PartitionSchemaDialog dialog = new PartitionSchemaDialog(spoon.getShell(), partitionSchema, transMeta.getPartitionSchemas(), transMeta.getDatabases(), transMeta);
if (dialog.open()) {
if (spoon.rep != null && partitionSchema.getObjectId() != null) {
try {
saveSharedObjectToRepository(partitionSchema, null);
if (sharedObjectSyncUtil != null) {
sharedObjectSyncUtil.synchronizePartitionSchemas(partitionSchema, originalName);
}
} catch (KettleException e) {
showSaveErrorDialog(partitionSchema, e);
}
}
spoon.refreshTree();
}
}
use of org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog 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);
}
}
Aggregations