use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class StepMetaTest method createStepPartitioningMeta.
private static StepPartitioningMeta createStepPartitioningMeta(String method, String schemaName) throws Exception {
StepPartitioningMeta meta = new StepPartitioningMeta(method, new PartitionSchema(schemaName, Collections.<String>emptyList()));
meta.setPartitionSchemaName("schema_name");
return meta;
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class PurRepositoryIT method testNewNonAmbiguousNaming.
@Test
public void testNewNonAmbiguousNaming() throws Exception {
PurRepository repo = (PurRepository) repository;
System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "N");
// $NON-NLS-1$
PartitionSchema partSchema1 = createPartitionSchema("find.me");
// $NON-NLS-1$
PartitionSchema partSchema2 = createPartitionSchema("find|me");
repository.save(partSchema1, VERSION_COMMENT_V1, null);
repository.save(partSchema2, VERSION_COMMENT_V1, null);
Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
List<PartitionSchema> partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
assertEquals(2, partitionSchemas.size());
System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "Y");
// $NON-NLS-1$
PartitionSchema partSchema3 = createPartitionSchema("another.one");
// $NON-NLS-1$
PartitionSchema partSchema4 = createPartitionSchema("another|one");
repository.save(partSchema3, VERSION_COMMENT_V1, null);
repository.save(partSchema4, VERSION_COMMENT_V1, null);
sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
assertEquals(3, partitionSchemas.size());
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class TransDelegate method loadSharedObjects.
@SuppressWarnings("unchecked")
public SharedObjects loadSharedObjects(final RepositoryElementInterface element, final Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType) throws KettleException {
TransMeta transMeta = (TransMeta) element;
transMeta.setSharedObjects(transMeta.readSharedObjects());
// Repository objects take priority so let's overwrite them...
//
readDatabases(transMeta, true, (List<DatabaseMeta>) sharedObjectsByType.get(RepositoryObjectType.DATABASE));
readPartitionSchemas(transMeta, true, (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA));
readSlaves(transMeta, true, (List<SlaveServer>) sharedObjectsByType.get(RepositoryObjectType.SLAVE_SERVER));
readClusters(transMeta, true, (List<ClusterSchema>) sharedObjectsByType.get(RepositoryObjectType.CLUSTER_SCHEMA));
return transMeta.getSharedObjects();
}
use of org.pentaho.di.partition.PartitionSchema in project pentaho-kettle by pentaho.
the class PartitionsController method removePartition.
public void removePartition() {
String partitionSchemaName = "";
try {
Collection<UIPartition> partitions = partitionsTable.getSelectedItems();
if (partitions != null && !partitions.isEmpty()) {
for (Object obj : partitions) {
if (obj != null && obj instanceof UIPartition) {
UIPartition partition = (UIPartition) obj;
PartitionSchema partitionSchema = partition.getPartitionSchema();
partitionSchemaName = partitionSchema.getName();
// Make sure the partition to delete exists in the repository
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.Delete.Title"));
mb.open();
} else {
repository.deletePartitionSchema(partitionId);
if (mainController != null && mainController.getSharedObjectSyncUtil() != null) {
mainController.getSharedObjectSyncUtil().deletePartitionSchema(partitionSchema);
}
}
}
}
} 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.Delete.Title"));
mb.open();
}
} catch (KettleException e) {
if (mainController == null || !mainController.handleLostRepository(e)) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Partition.Delete.UnexpectedError.Message") + partitionSchemaName + "]", e);
}
} finally {
refreshPartitions();
}
}
use of org.pentaho.di.partition.PartitionSchema 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();
}
}
Aggregations