Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved user interface for pipeline and workflow verification #4912 #4916

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ System.Log.UnexpectedError=Unexpected error
System.Tooltip.Browse=Browse folders or files...
System.Tooltip.BrowseForDir=Browse for a directory
System.Tooltip.BrowseForFileOrDirAndAdd=Browse for a file or directory & add to the list
System.Tooltip.CollapseALl=Collapse all
System.Tooltip.ExpandAll=Expand all
System.Tooltip.GetFields=Get the fields as defined in previous transforms.
System.Tooltip.Help=Display detailed information
System.Tooltip.VariableToDir=Insert a variable in the directory
Expand Down
75 changes: 36 additions & 39 deletions engine/src/main/java/org/apache/hop/pipeline/PipelineMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.IProgressMonitor;
import org.apache.hop.core.NotePadMeta;
import org.apache.hop.core.ProgressNullMonitorListener;
import org.apache.hop.core.Result;
import org.apache.hop.core.SqlStatement;
import org.apache.hop.core.attributes.AttributesUtil;
Expand Down Expand Up @@ -2782,42 +2783,41 @@ public void checkTransforms(
IVariables variables,
IHopMetadataProvider metadataProvider) {
try {
remarks.clear(); // Start with a clean slate...
// Start with a clean slate...
remarks.clear();

Map<IValueMeta, String> values = new Hashtable<>();
String[] transformnames;
TransformMeta[] transforms;
List<TransformMeta> selectedTransforms = getSelectedTransforms();
if (!onlySelected || selectedTransforms.isEmpty()) {
transformnames = getTransformNames();
transforms = getTransformsArray();
} else {
transformnames = getSelectedTransformNames();
transforms = selectedTransforms.toArray(new TransformMeta[selectedTransforms.size()]);
if (monitor == null) {
monitor = new ProgressNullMonitorListener();
}

Map<IValueMeta, String> values = new Hashtable<>();

List<TransformMeta> transforms = (onlySelected) ? getSelectedTransforms() : getTransforms();

TransformMeta[] transformArray = transforms.toArray(new TransformMeta[0]);

ExtensionPointHandler.callExtensionPoint(
LogChannel.GENERAL,
variables,
HopExtensionPoint.BeforeCheckTransforms.id,
new CheckTransformsExtension(remarks, variables, this, transforms, metadataProvider));
new CheckTransformsExtension(remarks, variables, this, transformArray, metadataProvider));

boolean stopChecking = false;

if (monitor != null) {
monitor.beginTask(
BaseMessages.getString(PKG, "PipelineMeta.Monitor.VerifyingThisPipelineTask.Title"),
transforms.length + 2);
}
monitor.beginTask(
BaseMessages.getString(PKG, "PipelineMeta.Monitor.VerifyingThisPipelineTask.Title"),
transforms.size());

int worked = 1;
for (TransformMeta transformMeta : transforms) {

for (int i = 0; i < transforms.length && !stopChecking; i++) {
if (monitor != null) {
monitor.subTask(
BaseMessages.getString(
PKG, "PipelineMeta.Monitor.VerifyingTransformTask.Title", transformnames[i]));
if (stopChecking) {
break;
}

TransformMeta transformMeta = transforms[i];
monitor.subTask(
BaseMessages.getString(
PKG, "PipelineMeta.Monitor.VerifyingTransformTask.Title", transformMeta.getName()));

int nrinfo = findNrInfoTransforms(transformMeta);
TransformMeta[] infoTransform = null;
Expand Down Expand Up @@ -2978,21 +2978,18 @@ public void checkTransforms(
remarks.add(cr);
}

if (monitor != null) {
monitor.worked(1); // progress bar...
if (monitor.isCanceled()) {
stopChecking = true;
}
monitor.worked(worked++); // progress bar...
if (monitor.isCanceled()) {
stopChecking = true;
}
}

if (monitor != null) {
monitor.subTask(
BaseMessages.getString(
PKG,
"PipelineMeta.Monitor.CheckingForDatabaseUnfriendlyCharactersInFieldNamesTask.Title"));
}
if (values.size() > 0) {
monitor.subTask(
BaseMessages.getString(
PKG,
"PipelineMeta.Monitor.CheckingForDatabaseUnfriendlyCharactersInFieldNamesTask.Title"));

if (!values.isEmpty()) {
for (IValueMeta v : values.keySet()) {
String message = values.get(v);
CheckResult cr =
Expand All @@ -3015,14 +3012,14 @@ public void checkTransforms(
null);
remarks.add(cr);
}
if (monitor != null) {
monitor.worked(1);
}

ExtensionPointHandler.callExtensionPoint(
LogChannel.GENERAL,
variables,
HopExtensionPoint.AfterCheckTransforms.id,
new CheckTransformsExtension(remarks, variables, this, transforms, metadataProvider));
new CheckTransformsExtension(remarks, variables, this, transformArray, metadataProvider));

monitor.done();
} catch (Exception e) {
throw new RuntimeException("Error checking transforms", e);
}
Expand Down
64 changes: 33 additions & 31 deletions engine/src/main/java/org/apache/hop/workflow/WorkflowMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.IProgressMonitor;
import org.apache.hop.core.NotePadMeta;
import org.apache.hop.core.ProgressNullMonitorListener;
import org.apache.hop.core.SqlStatement;
import org.apache.hop.core.attributes.AttributesUtil;
import org.apache.hop.core.database.DatabaseMeta;
Expand Down Expand Up @@ -1720,7 +1721,7 @@ protected void setInternalEntryCurrentDirectory(IVariables variables) {
* own settings.
*
* @param remarks List of CheckResult remarks inserted into by each Action
* @param onlySelected true if you only want to check the selected workflows
* @param onlySelected true if you only want to check the selected actions
* @param monitor Progress monitor (not presently in use)
*/
public void checkActions(
Expand All @@ -1729,39 +1730,40 @@ public void checkActions(
IProgressMonitor monitor,
IVariables variables,
IHopMetadataProvider metadataProvider) {
remarks.clear(); // Empty remarks
if (monitor != null) {
monitor.beginTask(
BaseMessages.getString(PKG, "WorkflowMeta.Monitor.VerifyingThisActionTask.Title"),
workflowActions.size() + 2);
}
boolean stopChecking = false;
for (int i = 0; i < workflowActions.size() && !stopChecking; i++) {
ActionMeta copy = workflowActions.get(i); // get the action copy
if ((!onlySelected) || (onlySelected && copy.isSelected())) {
IAction action = copy.getAction();
if (action != null) {
if (monitor != null) {
monitor.subTask(
BaseMessages.getString(
PKG, "WorkflowMeta.Monitor.VerifyingAction.Title", action.getName()));
}
action.check(remarks, this, variables, metadataProvider);
if (monitor != null) {
monitor.worked(1); // progress bar...
if (monitor.isCanceled()) {
stopChecking = true;
}
}
}

// Start with a clean slate...
remarks.clear();

if (monitor == null) {
monitor = new ProgressNullMonitorListener();
}

List<ActionMeta> actions = (onlySelected) ? this.getSelectedActions() : getActions();

monitor.beginTask(
BaseMessages.getString(PKG, "WorkflowMeta.Monitor.VerifyingThisActionTask.Title"),
actions.size());

int worked = 1;
for (ActionMeta actionMeta : actions) {
if (monitor.isCanceled()) {
break;
}
if (monitor != null) {
monitor.worked(1);

IAction action = actionMeta.getAction();
if (action != null) {
monitor.subTask(
BaseMessages.getString(
PKG, "WorkflowMeta.Monitor.VerifyingAction.Title", action.getName()));

action.check(remarks, this, variables, metadataProvider);

// Progress bar...
monitor.worked(worked++);
}
}
if (monitor != null) {
monitor.done();
}

monitor.done();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/** Utility class for getting formatted strings from validator resource bundle. */
public class ValidatorMessages {

private static final String BUNDLE_NAME = "org.apache.hop.workflow.entry.messages.validator";
private static final String BUNDLE_NAME = "org.apache.hop.workflow.action.messages.validator";

public static String getString(final String key, final Object... params) {
return getStringFromBundle(BUNDLE_NAME, key, params);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#

# Messages when validators return false.
messages.failed.notBlank={0} cannot be null or blank.
messages.failed.notNull={0} cannot be null.
messages.failed.fileExists={0} must exist.
messages.failed.fileDoesNotExist={0} must not exist.
messages.failed.matches={0} does not match mask.
messages.failed.integer={0} is not an integer.
messages.failed.long={0} is not a long.
messages.failed.email={0} is not an email address.
messages.failed.unableToValidate=Unable to validate. Reason: {0}
messages.failed.missingKey=Unable to validate. Reason: Key missing from context.

# Messages when validators return true.
messages.passed={0} is OK. Value: {1}

# Property labels
#properties.serverName=Server name
#properties.username=Username
#properties.password=Password
#properties.outputDirectory=Output directory
#properties.sslPort=SSL port
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.commons.vfs2.FileSelectInfo;
import org.apache.commons.vfs2.FileSelector;
import org.apache.commons.vfs2.FileType;
import org.apache.hop.core.CheckResult;
import org.apache.hop.core.Const;
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.Result;
Expand All @@ -43,8 +44,6 @@
import org.apache.hop.resource.ResourceReference;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.ActionBase;
import org.apache.hop.workflow.action.validator.ActionValidatorUtils;
import org.apache.hop.workflow.action.validator.AndValidator;

/** This defines a 'delete folders' action. */
@Action(
Expand Down Expand Up @@ -305,16 +304,22 @@ public void check(
WorkflowMeta workflowMeta,
IVariables variables,
IHopMetadataProvider metadataProvider) {
boolean res =
ActionValidatorUtils.andValidator()
.validate(
this,
"fileItems",
remarks,
AndValidator.putValidators(ActionValidatorUtils.notNullValidator()));

if (!res) {
return;
// boolean res =
// ActionValidatorUtils.andValidator()
// .validate(
// this,
// "fileItems",
// remarks,
// AndValidator.putValidators(ActionValidatorUtils.notNullValidator()));
//
// if (!res) {
// return;
// }

if (fileItems == null || fileItems.isEmpty()) {
String message = BaseMessages.getString(PKG, "CloneRowMeta.CheckResult.NrClonesdMissing");
remarks.add(
new CheckResult(ICheckResult.TYPE_RESULT_WARNING, "Any folders to deletes", this));
}

/* TODO: If we enable action check
Expand Down
7 changes: 7 additions & 0 deletions ui/src/main/java/org/apache/hop/ui/core/gui/GuiResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public class GuiResource {
private Image imageExpandAll;
private Image imageCollapseAll;
private Image imageAdd;
private Image imageCheck;
private Image imageCopy;
private Image imageCancel;
private Image imageCut;
Expand Down Expand Up @@ -440,6 +441,7 @@ private void dispose() {

// Common images
imageLogo.dispose();
imageCheck.dispose();
imageDisabledHop.dispose();
imageDatabase.dispose();
imageData.dispose();
Expand Down Expand Up @@ -718,6 +720,7 @@ private void loadCommonImages() {
imageAddAll = loadAsResource(display, "ui/images/add_all.svg", ConstUi.SMALL_ICON_SIZE);
imageAddSingle = loadAsResource(display, "ui/images/add_single.svg", ConstUi.SMALL_ICON_SIZE);
imageCalendar = loadAsResource(display, "ui/images/calendar.svg", ConstUi.SMALL_ICON_SIZE);
imageCheck = loadAsResource(display, "ui/images/check.svg", ConstUi.SMALL_ICON_SIZE);
imageClosePanel = loadAsResource(display, "ui/images/close-panel.svg", ConstUi.SMALL_ICON_SIZE);
imageCollapseAll =
loadAsResource(display, "ui/images/collapse-all.svg", ConstUi.SMALL_ICON_SIZE);
Expand Down Expand Up @@ -2100,6 +2103,10 @@ public Image getImageClose() {
return imageClose;
}

public Image getImageCheck() {
return imageCheck;
}

/**
* Gets imageToolbarPause
*
Expand Down
Loading