use of org.pentaho.di.cluster.ClusterSchema in project pentaho-kettle by pentaho.
the class TransDelegate method dataNodeToElement.
public void dataNodeToElement(final DataNode rootNode, final RepositoryElementInterface element) throws KettleException {
TransMeta transMeta = (TransMeta) element;
Set<String> privateDatabases = null;
// read the private databases
DataNode privateDbsNode = rootNode.getNode(NODE_TRANS_PRIVATE_DATABASES);
// BACKLOG-6635
if (privateDbsNode != null) {
privateDatabases = new HashSet<String>();
if (privateDbsNode.hasProperty(PROP_TRANS_PRIVATE_DATABASE_NAMES)) {
for (String privateDatabaseName : getString(privateDbsNode, PROP_TRANS_PRIVATE_DATABASE_NAMES).split(TRANS_PRIVATE_DATABASE_DELIMITER)) {
if (!privateDatabaseName.isEmpty()) {
privateDatabases.add(privateDatabaseName);
}
}
} else {
for (DataNode privateDatabase : privateDbsNode.getNodes()) {
privateDatabases.add(privateDatabase.getName());
}
}
}
transMeta.setPrivateDatabases(privateDatabases);
// read the steps...
//
DataNode stepsNode = rootNode.getNode(NODE_STEPS);
for (DataNode stepNode : stepsNode.getNodes()) {
StepMeta stepMeta = new StepMeta(new StringObjectId(stepNode.getId().toString()));
// for tracing, retain hierarchy
stepMeta.setParentTransMeta(transMeta);
// Read the basics
//
stepMeta.setName(getString(stepNode, PROP_NAME));
if (stepNode.hasProperty(PROP_DESCRIPTION)) {
stepMeta.setDescription(getString(stepNode, PROP_DESCRIPTION));
}
stepMeta.setDistributes(stepNode.getProperty(PROP_STEP_DISTRIBUTE).getBoolean());
DataProperty rowDistributionProperty = stepNode.getProperty(PROP_STEP_ROW_DISTRIBUTION);
String rowDistributionCode = rowDistributionProperty == null ? null : rowDistributionProperty.getString();
RowDistributionInterface rowDistribution = PluginRegistry.getInstance().loadClass(RowDistributionPluginType.class, rowDistributionCode, RowDistributionInterface.class);
stepMeta.setRowDistribution(rowDistribution);
stepMeta.setDraw(stepNode.getProperty(PROP_STEP_GUI_DRAW).getBoolean());
int copies = (int) stepNode.getProperty(PROP_STEP_COPIES).getLong();
String copiesString = stepNode.getProperty(PROP_STEP_COPIES_STRING) != null ? stepNode.getProperty(PROP_STEP_COPIES_STRING).getString() : StringUtils.EMPTY;
if (!Utils.isEmpty(copiesString)) {
stepMeta.setCopiesString(copiesString);
} else {
// for backward compatibility
stepMeta.setCopies(copies);
}
int x = (int) stepNode.getProperty(PROP_STEP_GUI_LOCATION_X).getLong();
int y = (int) stepNode.getProperty(PROP_STEP_GUI_LOCATION_Y).getLong();
stepMeta.setLocation(x, y);
// Load the group attributes map
//
AttributesMapUtil.loadAttributesMap(stepNode, stepMeta);
String stepType = getString(stepNode, PROP_STEP_TYPE);
// Create a new StepMetaInterface object...
//
PluginRegistry registry = PluginRegistry.getInstance();
PluginInterface stepPlugin = registry.findPluginWithId(StepPluginType.class, stepType);
StepMetaInterface stepMetaInterface = null;
if (stepPlugin != null) {
stepMetaInterface = (StepMetaInterface) registry.loadClass(stepPlugin);
// revert to the default in case we loaded an alternate version
stepType = stepPlugin.getIds()[0];
} else {
stepMeta.setStepMetaInterface((StepMetaInterface) new MissingTrans(stepMeta.getName(), stepType));
transMeta.addMissingTrans((MissingTrans) stepMeta.getStepMetaInterface());
}
stepMeta.setStepID(stepType);
// Read the metadata from the repository too...
//
RepositoryProxy proxy = new RepositoryProxy(stepNode.getNode(NODE_STEP_CUSTOM));
if (!stepMeta.isMissing()) {
readRepCompatibleStepMeta(stepMetaInterface, proxy, null, transMeta.getDatabases());
stepMetaInterface.readRep(proxy, transMeta.getMetaStore(), null, transMeta.getDatabases());
stepMeta.setStepMetaInterface(stepMetaInterface);
}
// Get the partitioning as well...
StepPartitioningMeta stepPartitioningMeta = new StepPartitioningMeta();
if (stepNode.hasProperty(PROP_PARTITIONING_SCHEMA)) {
String partSchemaId = stepNode.getProperty(PROP_PARTITIONING_SCHEMA).getRef().getId().toString();
String schemaName = repo.loadPartitionSchema(new StringObjectId(partSchemaId), null).getName();
stepPartitioningMeta.setPartitionSchemaName(schemaName);
String methodCode = getString(stepNode, PROP_PARTITIONING_METHOD);
stepPartitioningMeta.setMethod(StepPartitioningMeta.getMethod(methodCode));
if (stepPartitioningMeta.getPartitioner() != null) {
proxy = new RepositoryProxy(stepNode.getNode(NODE_PARTITIONER_CUSTOM));
stepPartitioningMeta.getPartitioner().loadRep(proxy, null);
}
stepPartitioningMeta.hasChanged(true);
}
stepMeta.setStepPartitioningMeta(stepPartitioningMeta);
stepMeta.getStepPartitioningMeta().setPartitionSchemaAfterLoading(transMeta.getPartitionSchemas());
// Get the cluster schema name
String clusterSchemaName = getString(stepNode, PROP_CLUSTER_SCHEMA);
stepMeta.setClusterSchemaName(clusterSchemaName);
if (clusterSchemaName != null && transMeta.getClusterSchemas() != null) {
// Get the cluster schema from the given name
for (ClusterSchema clusterSchema : transMeta.getClusterSchemas()) {
if (clusterSchema.getName().equals(clusterSchemaName)) {
stepMeta.setClusterSchema(clusterSchema);
break;
}
}
}
transMeta.addStep(stepMeta);
}
for (DataNode stepNode : stepsNode.getNodes()) {
ObjectId stepObjectId = new StringObjectId(stepNode.getId().toString());
StepMeta stepMeta = StepMeta.findStep(transMeta.getSteps(), stepObjectId);
//
if (stepNode.hasProperty(PROP_STEP_ERROR_HANDLING_SOURCE_STEP)) {
StepErrorMeta meta = new StepErrorMeta(transMeta, stepMeta);
meta.setTargetStep(StepMeta.findStep(transMeta.getSteps(), stepNode.getProperty(PROP_STEP_ERROR_HANDLING_TARGET_STEP).getString()));
meta.setEnabled(stepNode.getProperty(PROP_STEP_ERROR_HANDLING_IS_ENABLED).getBoolean());
meta.setNrErrorsValuename(getString(stepNode, PROP_STEP_ERROR_HANDLING_NR_VALUENAME));
meta.setErrorDescriptionsValuename(getString(stepNode, PROP_STEP_ERROR_HANDLING_DESCRIPTIONS_VALUENAME));
meta.setErrorFieldsValuename(getString(stepNode, PROP_STEP_ERROR_HANDLING_FIELDS_VALUENAME));
meta.setErrorCodesValuename(getString(stepNode, PROP_STEP_ERROR_HANDLING_CODES_VALUENAME));
meta.setMaxErrors(getString(stepNode, PROP_STEP_ERROR_HANDLING_MAX_ERRORS));
meta.setMaxPercentErrors(getString(stepNode, PROP_STEP_ERROR_HANDLING_MAX_PCT_ERRORS));
meta.setMinPercentRows(getString(stepNode, PROP_STEP_ERROR_HANDLING_MIN_PCT_ROWS));
// a bit of a trick, I know.
meta.getSourceStep().setStepErrorMeta(meta);
}
}
//
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
StepMetaInterface sii = stepMeta.getStepMetaInterface();
if (sii != null) {
sii.searchInfoAndTargetSteps(transMeta.getSteps());
}
}
// Read the notes...
//
DataNode notesNode = rootNode.getNode(NODE_NOTES);
int nrNotes = (int) notesNode.getProperty(PROP_NR_NOTES).getLong();
for (DataNode noteNode : notesNode.getNodes()) {
String xml = getString(noteNode, PROP_XML);
transMeta.addNote(new NotePadMeta(XMLHandler.getSubNode(XMLHandler.loadXMLString(xml), NotePadMeta.XML_TAG)));
}
if (transMeta.nrNotes() != nrNotes) {
throw new KettleException("The number of notes read [" + transMeta.nrNotes() + "] was not the number we expected [" + nrNotes + "]");
}
// Read the hops...
//
DataNode hopsNode = rootNode.getNode(NODE_HOPS);
int nrHops = (int) hopsNode.getProperty(PROP_NR_HOPS).getLong();
for (DataNode hopNode : hopsNode.getNodes()) {
String stepFromName = getString(hopNode, TRANS_HOP_FROM);
String stepToName = getString(hopNode, TRANS_HOP_TO);
boolean enabled = true;
if (hopNode.hasProperty(TRANS_HOP_ENABLED)) {
enabled = hopNode.getProperty(TRANS_HOP_ENABLED).getBoolean();
}
StepMeta stepFrom = StepMeta.findStep(transMeta.getSteps(), stepFromName);
StepMeta stepTo = StepMeta.findStep(transMeta.getSteps(), stepToName);
//
if (stepFrom != null && stepTo != null) {
transMeta.addTransHop(new TransHopMeta(stepFrom, stepTo, enabled));
}
}
if (transMeta.nrTransHops() != nrHops) {
throw new KettleException("The number of hops read [" + transMeta.nrTransHops() + "] was not the number we expected [" + nrHops + "]");
}
// Load the details at the end, to make sure we reference the databases correctly, etc.
//
loadTransformationDetails(rootNode, transMeta);
transMeta.eraseParameters();
DataNode paramsNode = rootNode.getNode(NODE_PARAMETERS);
int count = (int) paramsNode.getProperty(PROP_NR_PARAMETERS).getLong();
for (int idx = 0; idx < count; idx++) {
DataNode paramNode = paramsNode.getNode(TRANS_PARAM_PREFIX + idx);
String key = getString(paramNode, PARAM_KEY);
String def = getString(paramNode, PARAM_DEFAULT);
String desc = getString(paramNode, PARAM_DESC);
transMeta.addParameterDefinition(key, def, desc);
}
transMeta.activateParameters();
}
use of org.pentaho.di.cluster.ClusterSchema in project pentaho-kettle by pentaho.
the class Spoon method doubleClickedInTree.
/**
* Reaction to double click
*/
private void doubleClickedInTree(Tree tree, boolean shift) {
TreeSelection[] objects = getTreeObjects(tree);
if (objects.length != 1) {
// not yet supported, we can do this later when the OSX bug
return;
// goes away
}
TreeSelection object = objects[0];
final Object selection = object.getSelection();
final Object parent = object.getParent();
if (selection instanceof Class<?>) {
if (selection.equals(TransMeta.class)) {
newTransFile();
}
if (selection.equals(JobMeta.class)) {
newJobFile();
}
if (selection.equals(TransHopMeta.class)) {
newHop((TransMeta) parent);
}
if (selection.equals(DatabaseMeta.class)) {
delegates.db.newConnection();
}
if (selection.equals(PartitionSchema.class)) {
newPartitioningSchema((TransMeta) parent);
}
if (selection.equals(ClusterSchema.class)) {
newClusteringSchema((TransMeta) parent);
}
if (selection.equals(SlaveServer.class)) {
newSlaveServer((HasSlaveServersInterface) parent);
}
} else {
if (selection instanceof TransMeta) {
TransGraph.editProperties((TransMeta) selection, this, rep, true);
}
if (selection instanceof JobMeta) {
JobGraph.editProperties((JobMeta) selection, this, rep, true);
}
if (selection instanceof PluginInterface) {
PluginInterface plugin = (PluginInterface) selection;
if (plugin.getPluginType().equals(StepPluginType.class)) {
TransGraph transGraph = getActiveTransGraph();
if (transGraph != null) {
transGraph.addStepToChain(plugin, shift);
}
}
if (plugin.getPluginType().equals(JobEntryPluginType.class)) {
JobGraph jobGraph = getActiveJobGraph();
if (jobGraph != null) {
jobGraph.addJobEntryToChain(object.getItemText(), shift);
}
}
}
if (selection instanceof DatabaseMeta) {
DatabaseMeta database = (DatabaseMeta) selection;
delegates.db.editConnection(database);
}
if (selection instanceof StepMeta) {
StepMeta step = (StepMeta) selection;
delegates.steps.editStep((TransMeta) parent, step);
sharedObjectSyncUtil.synchronizeSteps(step);
}
if (selection instanceof JobEntryCopy) {
editJobEntry((JobMeta) parent, (JobEntryCopy) selection);
}
if (selection instanceof TransHopMeta) {
editHop((TransMeta) parent, (TransHopMeta) selection);
}
if (selection instanceof PartitionSchema) {
editPartitionSchema((TransMeta) parent, (PartitionSchema) selection);
}
if (selection instanceof ClusterSchema) {
delegates.clusters.editClusterSchema((TransMeta) parent, (ClusterSchema) selection);
}
if (selection instanceof SlaveServer) {
editSlaveServer((SlaveServer) selection);
}
editSelectionTreeExtension(selection);
}
}
use of org.pentaho.di.cluster.ClusterSchema in project pentaho-kettle by pentaho.
the class Spoon method setMenu.
private synchronized void setMenu(Tree tree) {
TreeSelection[] objects = getTreeObjects(tree);
if (objects.length != 1) {
// not yet supported, we can do this later when the OSX bug
return;
// goes away
}
TreeSelection object = objects[0];
selectionObject = object.getSelection();
Object selection = selectionObject;
selectionObjectParent = object.getParent();
// Not clicked on a real object: returns a class
XulMenupopup spoonMenu = null;
if (selection instanceof Class<?>) {
if (selection.equals(TransMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("trans-class");
} else if (selection.equals(JobMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("job-class");
} else if (selection.equals(TransHopMeta.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("trans-hop-class");
} else if (selection.equals(DatabaseMeta.class)) {
spoonMenu = (XulMenupopup) menuMap.get("database-class");
} else if (selection.equals(PartitionSchema.class)) {
// New
spoonMenu = (XulMenupopup) menuMap.get("partition-schema-class");
} else if (selection.equals(ClusterSchema.class)) {
spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-class");
} else if (selection.equals(SlaveServer.class)) {
spoonMenu = (XulMenupopup) menuMap.get("slave-cluster-class");
} else {
spoonMenu = null;
}
} else {
if (selection instanceof TransMeta) {
spoonMenu = (XulMenupopup) menuMap.get("trans-inst");
} else if (selection instanceof JobMeta) {
spoonMenu = (XulMenupopup) menuMap.get("job-inst");
} else if (selection instanceof PluginInterface) {
spoonMenu = (XulMenupopup) menuMap.get("step-plugin");
} else if (selection instanceof DatabaseMeta) {
spoonMenu = (XulMenupopup) menuMap.get("database-inst");
// disable for now if the connection is an SAP ERP type of database...
//
XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-explore");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
item.setDisabled(!databaseMeta.isExplorable());
}
item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-clear-cache");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selectionObject;
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.ClearDBCache") + // Clear
databaseMeta.getName());
}
item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-share");
if (item != null) {
final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
if (databaseMeta.isShared()) {
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.UnShare"));
} else {
item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.Share"));
}
}
} else if (selection instanceof StepMeta) {
spoonMenu = (XulMenupopup) menuMap.get("step-inst");
} else if (selection instanceof JobEntryCopy) {
spoonMenu = (XulMenupopup) menuMap.get("job-entry-copy-inst");
} else if (selection instanceof TransHopMeta) {
spoonMenu = (XulMenupopup) menuMap.get("trans-hop-inst");
} else if (selection instanceof PartitionSchema) {
spoonMenu = (XulMenupopup) menuMap.get("partition-schema-inst");
} else if (selection instanceof ClusterSchema) {
spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-inst");
} else if (selection instanceof SlaveServer) {
spoonMenu = (XulMenupopup) menuMap.get("slave-server-inst");
}
}
if (spoonMenu != null) {
ConstUI.displayMenu(spoonMenu, tree);
} else {
tree.setMenu(null);
}
createPopUpMenuExtension();
}
use of org.pentaho.di.cluster.ClusterSchema in project pentaho-kettle by pentaho.
the class Spoon method monitorClusterSchema.
public void monitorClusterSchema() throws KettleException {
final ClusterSchema clusterSchema = (ClusterSchema) selectionObject;
monitorClusterSchema(clusterSchema);
}
use of org.pentaho.di.cluster.ClusterSchema in project pentaho-kettle by pentaho.
the class Spoon method delClusterSchema.
public void delClusterSchema() {
final TransMeta transMeta = (TransMeta) selectionObjectParent;
final ClusterSchema clusterSchema = (ClusterSchema) selectionObject;
delegates.clusters.delClusterSchema(transMeta, clusterSchema);
}
Aggregations