use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class TransMeta method realClone.
/**
* Perform a real clone of the transformation meta-data object, including cloning all lists and copying all values. If
* the doClear parameter is true, the clone will be cleared of ALL values before the copy. If false, only the copied
* fields will be cleared.
*
* @param doClear
* Whether to clear all of the clone's data before copying from the source object
* @return a real clone of the calling object
*/
public Object realClone(boolean doClear) {
try {
TransMeta transMeta = (TransMeta) super.clone();
if (doClear) {
transMeta.clear();
} else {
// Clear out the things we're replacing below
transMeta.databases = new ArrayList<>();
transMeta.steps = new ArrayList<>();
transMeta.hops = new ArrayList<>();
transMeta.notes = new ArrayList<>();
transMeta.dependencies = new ArrayList<>();
transMeta.partitionSchemas = new ArrayList<>();
transMeta.slaveServers = new ArrayList<>();
transMeta.clusterSchemas = new ArrayList<>();
transMeta.namedParams = new NamedParamsDefault();
transMeta.stepChangeListeners = new ArrayList<>();
}
for (DatabaseMeta db : databases) {
transMeta.addDatabase((DatabaseMeta) db.clone());
}
for (StepMeta step : steps) {
transMeta.addStep((StepMeta) step.clone());
}
// PDI-15799: Step references are original yet. Set them to the clones.
for (StepMeta step : transMeta.getSteps()) {
final StepMetaInterface stepMetaInterface = step.getStepMetaInterface();
if (stepMetaInterface != null) {
final StepIOMetaInterface stepIOMeta = stepMetaInterface.getStepIOMeta();
if (stepIOMeta != null) {
for (StreamInterface stream : stepIOMeta.getInfoStreams()) {
String streamStepName = stream.getStepname();
if (streamStepName != null) {
StepMeta streamStepMeta = transMeta.findStep(streamStepName);
stream.setStepMeta(streamStepMeta);
}
}
}
}
}
for (TransHopMeta hop : hops) {
transMeta.addTransHop((TransHopMeta) hop.clone());
}
for (NotePadMeta note : notes) {
transMeta.addNote((NotePadMeta) note.clone());
}
for (TransDependency dep : dependencies) {
transMeta.addDependency((TransDependency) dep.clone());
}
for (SlaveServer slave : slaveServers) {
transMeta.getSlaveServers().add((SlaveServer) slave.clone());
}
for (ClusterSchema schema : clusterSchemas) {
transMeta.getClusterSchemas().add(schema.clone());
}
for (PartitionSchema schema : partitionSchemas) {
transMeta.getPartitionSchemas().add((PartitionSchema) schema.clone());
}
for (String key : listParameters()) {
transMeta.addParameterDefinition(key, getParameterDefault(key), getParameterDescription(key));
}
return transMeta;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class TransMeta method selectAll.
/**
* Mark all steps in the transformation as selected.
*/
public void selectAll() {
int i;
for (i = 0; i < nrSteps(); i++) {
StepMeta stepMeta = getStep(i);
stepMeta.setSelected(true);
}
for (i = 0; i < nrNotes(); i++) {
NotePadMeta ni = getNote(i);
ni.setSelected(true);
}
setChanged();
notifyObservers("refreshGraph");
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class TransMeta method unselectAll.
/**
* Clear the selection of all steps.
*/
public void unselectAll() {
int i;
for (i = 0; i < nrSteps(); i++) {
StepMeta stepMeta = getStep(i);
stepMeta.setSelected(false);
}
for (i = 0; i < nrNotes(); i++) {
NotePadMeta ni = getNote(i);
ni.setSelected(false);
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class TransPainter method drawTrans.
private void drawTrans(Point thumb) {
if (!shadow && gridSize > 1) {
drawGrid();
}
if (hori != null && vert != null) {
hori.setThumb(thumb.x);
vert.setThumb(thumb.y);
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterStart.id, this);
} catch (KettleException e) {
LogChannel.GENERAL.logError("Error in TransPainterStart extension point", e);
}
gc.setFont(EFont.NOTE);
// First the notes
for (int i = 0; i < transMeta.nrNotes(); i++) {
NotePadMeta ni = transMeta.getNote(i);
drawNote(ni);
}
gc.setFont(EFont.GRAPH);
gc.setBackground(EColor.BACKGROUND);
for (int i = 0; i < transMeta.nrTransHops(); i++) {
TransHopMeta hi = transMeta.getTransHop(i);
drawHop(hi);
}
EImage arrow;
if (candidate != null) {
drawHop(candidate, true);
} else {
if (startHopStep != null && endHopLocation != null) {
Point fr = startHopStep.getLocation();
Point to = endHopLocation;
if (endHopStep == null) {
gc.setForeground(EColor.GRAY);
arrow = EImage.ARROW_DISABLED;
} else {
gc.setForeground(EColor.BLUE);
arrow = EImage.ARROW_DEFAULT;
}
Point start = real2screen(fr.x + iconsize / 2, fr.y + iconsize / 2);
Point end = real2screen(to.x, to.y);
drawArrow(arrow, start.x, start.y, end.x, end.y, theta, calcArrowLength(), 1.2, null, startHopStep, endHopStep == null ? endHopLocation : endHopStep);
} else if (endHopStep != null && endHopLocation != null) {
Point fr = endHopLocation;
Point to = endHopStep.getLocation();
if (startHopStep == null) {
gc.setForeground(EColor.GRAY);
arrow = EImage.ARROW_DISABLED;
} else {
gc.setForeground(EColor.BLUE);
arrow = EImage.ARROW_DEFAULT;
}
Point start = real2screen(fr.x, fr.y);
Point end = real2screen(to.x + iconsize / 2, to.y + iconsize / 2);
drawArrow(arrow, start.x, start.y, end.x, end.y, theta, calcArrowLength(), 1.2, null, startHopStep == null ? endHopLocation : startHopStep, endHopStep);
}
}
// Draw regular step appearance
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isDrawn()) {
drawStep(stepMeta);
}
}
if (slowStepIndicatorEnabled) {
// Highlight possible bottlenecks
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isDrawn()) {
checkDrawSlowStepIndicator(stepMeta);
}
}
}
// Draw step status indicators (running vs. done)
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isDrawn()) {
drawStepStatusIndicator(stepMeta);
}
}
// Draw performance table for selected step(s)
for (int i = 0; i < transMeta.nrSteps(); i++) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isDrawn()) {
drawStepPerformanceTable(stepMeta);
}
}
int selectedStepsCount = 0;
for (int i = transMeta.nrSteps() - 1; i >= 0; i--) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isSelected()) {
selectedStepsCount++;
}
}
TransPainterFlyoutExtension extension = null;
for (int i = transMeta.nrSteps() - 1; i >= 0; i--) {
StepMeta stepMeta = transMeta.getStep(i);
if (stepMeta.isSelected() && stepMeta.isDrawn() && selectedStepsCount == 1) {
extension = new TransPainterFlyoutExtension(gc, areaOwners, transMeta, stepMeta, translationX, translationY, magnification, area, offset);
break;
}
}
if (extension == null) {
// pass null to notify extension that nothing is selected
extension = new TransPainterFlyoutExtension(gc, areaOwners, transMeta, null, translationX, translationY, magnification, area, offset);
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterFlyout.id, extension);
} catch (Exception e) {
LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter step", e);
}
//
if (noInputStep != null) {
gc.setLineWidth(2);
gc.setForeground(EColor.RED);
Point n = noInputStep.getLocation();
gc.drawLine(n.x - 5, n.y - 5, n.x + iconsize + 10, n.y + iconsize + 10);
gc.drawLine(n.x - 5, n.y + iconsize + 5, n.x + iconsize + 5, n.y - 5);
}
if (drop_candidate != null) {
gc.setLineStyle(ELineStyle.SOLID);
gc.setForeground(EColor.BLACK);
Point screen = real2screen(drop_candidate.x, drop_candidate.y);
gc.drawRectangle(screen.x, screen.y, iconsize, iconsize);
}
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterEnd.id, this);
} catch (KettleException e) {
LogChannel.GENERAL.logError("Error in TransPainterEnd extension point", e);
}
if (!shadow) {
drawRect(selrect);
}
}
use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.
the class TransDelegate method elementToDataNode.
public DataNode elementToDataNode(final RepositoryElementInterface element) throws KettleException {
TransMeta transMeta = (TransMeta) element;
DataNode rootNode = new DataNode(NODE_TRANS);
if (transMeta.getPrivateDatabases() != null) {
// save all private transformations database name http://jira.pentaho.com/browse/PPP-3405
String privateDatabaseNames = StringUtils.join(transMeta.getPrivateDatabases(), TRANS_PRIVATE_DATABASE_DELIMITER);
DataNode privateDatabaseNode = rootNode.addNode(NODE_TRANS_PRIVATE_DATABASES);
privateDatabaseNode.setProperty(PROP_TRANS_PRIVATE_DATABASE_NAMES, privateDatabaseNames);
}
DataNode stepsNode = rootNode.addNode(NODE_STEPS);
// Also save all the steps in the transformation!
//
int stepNr = 0;
for (StepMeta step : transMeta.getSteps()) {
stepNr++;
// $NON-NLS-1$
DataNode stepNode = stepsNode.addNode(sanitizeNodeName(step.getName()) + "_" + stepNr + EXT_STEP);
// Store the main data
//
stepNode.setProperty(PROP_NAME, step.getName());
stepNode.setProperty(PROP_DESCRIPTION, step.getDescription());
stepNode.setProperty(PROP_STEP_TYPE, step.getStepID());
stepNode.setProperty(PROP_STEP_DISTRIBUTE, step.isDistributes());
stepNode.setProperty(PROP_STEP_ROW_DISTRIBUTION, step.getRowDistribution() == null ? null : step.getRowDistribution().getCode());
stepNode.setProperty(PROP_STEP_COPIES, step.getCopies());
stepNode.setProperty(PROP_STEP_COPIES_STRING, step.getCopiesString());
stepNode.setProperty(PROP_STEP_GUI_LOCATION_X, step.getLocation().x);
stepNode.setProperty(PROP_STEP_GUI_LOCATION_Y, step.getLocation().y);
stepNode.setProperty(PROP_STEP_GUI_DRAW, step.isDrawn());
// Also save the step group attributes map
//
AttributesMapUtil.saveAttributesMap(stepNode, step);
// Save the step metadata using the repository save method, NOT XML
// That is because we want to keep the links to databases, conditions, etc by ID, not name.
//
StepMetaInterface stepMetaInterface = step.getStepMetaInterface();
DataNode stepCustomNode = new DataNode(NODE_STEP_CUSTOM);
Repository proxy = new RepositoryProxy(stepCustomNode);
compatibleSaveRep(stepMetaInterface, proxy, null, null);
stepMetaInterface.saveRep(proxy, proxy.getMetaStore(), null, null);
stepNode.addNode(stepCustomNode);
// Save the partitioning information by reference as well...
//
StepPartitioningMeta partitioningMeta = step.getStepPartitioningMeta();
if (partitioningMeta != null && partitioningMeta.getPartitionSchema() != null && partitioningMeta.isPartitioned()) {
DataNodeRef ref = new DataNodeRef(partitioningMeta.getPartitionSchema().getObjectId().getId());
stepNode.setProperty(PROP_PARTITIONING_SCHEMA, ref);
// method of partitioning
stepNode.setProperty(PROP_PARTITIONING_METHOD, partitioningMeta.getMethodCode());
if (partitioningMeta.getPartitioner() != null) {
DataNode partitionerCustomNode = new DataNode(NODE_PARTITIONER_CUSTOM);
proxy = new RepositoryProxy(partitionerCustomNode);
partitioningMeta.getPartitioner().saveRep(proxy, null, null);
stepNode.addNode(partitionerCustomNode);
}
}
// Save the clustering information as well...
//
stepNode.setProperty(PROP_CLUSTER_SCHEMA, step.getClusterSchema() == null ? "" : // $NON-NLS-1$
step.getClusterSchema().getName());
// Save the error hop metadata
//
StepErrorMeta stepErrorMeta = step.getStepErrorMeta();
if (stepErrorMeta != null) {
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_SOURCE_STEP, stepErrorMeta.getSourceStep() != null ? stepErrorMeta.getSourceStep().getName() : // $NON-NLS-1$
"");
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_TARGET_STEP, stepErrorMeta.getTargetStep() != null ? stepErrorMeta.getTargetStep().getName() : // $NON-NLS-1$
"");
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_IS_ENABLED, stepErrorMeta.isEnabled());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_NR_VALUENAME, stepErrorMeta.getNrErrorsValuename());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_DESCRIPTIONS_VALUENAME, stepErrorMeta.getErrorDescriptionsValuename());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_FIELDS_VALUENAME, stepErrorMeta.getErrorFieldsValuename());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_CODES_VALUENAME, stepErrorMeta.getErrorCodesValuename());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_MAX_ERRORS, stepErrorMeta.getMaxErrors());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_MAX_PCT_ERRORS, stepErrorMeta.getMaxPercentErrors());
stepNode.setProperty(PROP_STEP_ERROR_HANDLING_MIN_PCT_ROWS, stepErrorMeta.getMinPercentRows());
}
}
// Save the notes
//
DataNode notesNode = rootNode.addNode(NODE_NOTES);
notesNode.setProperty(PROP_NR_NOTES, transMeta.nrNotes());
for (int i = 0; i < transMeta.nrNotes(); i++) {
NotePadMeta note = transMeta.getNote(i);
DataNode noteNode = notesNode.addNode(NOTE_PREFIX + i);
noteNode.setProperty(PROP_XML, note.getXML());
}
// Finally, save the hops
//
DataNode hopsNode = rootNode.addNode(NODE_HOPS);
hopsNode.setProperty(PROP_NR_HOPS, transMeta.nrTransHops());
for (int i = 0; i < transMeta.nrTransHops(); i++) {
TransHopMeta hop = transMeta.getTransHop(i);
DataNode hopNode = hopsNode.addNode(TRANS_HOP_PREFIX + i);
hopNode.setProperty(TRANS_HOP_FROM, hop.getFromStep().getName());
hopNode.setProperty(TRANS_HOP_TO, hop.getToStep().getName());
hopNode.setProperty(TRANS_HOP_ENABLED, hop.isEnabled());
}
// Parameters
//
String[] paramKeys = transMeta.listParameters();
DataNode paramsNode = rootNode.addNode(NODE_PARAMETERS);
paramsNode.setProperty(PROP_NR_PARAMETERS, paramKeys == null ? 0 : paramKeys.length);
for (int idx = 0; idx < paramKeys.length; idx++) {
DataNode paramNode = paramsNode.addNode(TRANS_PARAM_PREFIX + idx);
String key = paramKeys[idx];
String description = transMeta.getParameterDescription(paramKeys[idx]);
String defaultValue = transMeta.getParameterDefault(paramKeys[idx]);
// $NON-NLS-1$
paramNode.setProperty(PARAM_KEY, key != null ? key : "");
// $NON-NLS-1$
paramNode.setProperty(PARAM_DEFAULT, defaultValue != null ? defaultValue : "");
// $NON-NLS-1$
paramNode.setProperty(PARAM_DESC, description != null ? description : "");
}
// Let's not forget to save the details of the transformation itself.
// This includes logging information, parameters, etc.
//
saveTransformationDetails(rootNode, transMeta);
return rootNode;
}
Aggregations