Skip to content
Merged
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 @@ -27,6 +27,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.hop.core.Const;
Expand All @@ -51,10 +52,42 @@
import org.w3c.dom.Node;

public class XmlMetadataUtil {

private static final String FQN_TRANSFORM_FACTORY =
"org.apache.hop.pipeline.transform.ITransformMeta$TransformFactory";
private static final String FQN_ACTION_FACTORY =
"org.apache.hop.workflow.action.IAction$ActionFactory";

private XmlMetadataUtil() {
// Hides the public constructor
}

/**
* {@link MissingResourceException} from transform/action factories: substitute {@code Missing} /
* {@code MissingAction} via reflection (no core → engine compile dependency).
*/
private static Object newMissingPluginPlaceholder(
HopMetadataObject metadataObject, Node node, String pluginId) {
String factoryName = metadataObject.objectFactory().getName();
String name = node != null ? XmlHandler.getTagValue(node, "name") : null;
try {
if (FQN_TRANSFORM_FACTORY.equals(factoryName)) {
Class<?> c = Class.forName("org.apache.hop.pipeline.transforms.missing.Missing");
return c.getDeclaredConstructor(String.class, String.class)
.newInstance(Const.NVL(name, ""), pluginId);
}
if (FQN_ACTION_FACTORY.equals(factoryName)) {
Class<?> c = Class.forName("org.apache.hop.workflow.actions.missing.MissingAction");
String actionName = (name == null || name.isEmpty()) ? null : name;
return c.getDeclaredConstructor(String.class, String.class)
.newInstance(actionName, pluginId);
}
} catch (Exception ignored) {
return null;
}
return null;
}

/**
* This method looks at the fields in the class of the provided parentObject. It then sees which
* fields have annotation HopMetadataProperty and proceeds to serialize the values of those fields
Expand Down Expand Up @@ -816,6 +849,17 @@ private static <T> T createNewObject(Object parentObject, Node node, Class<? ext
IHopMetadataObjectFactory factory =
metadataObject.objectFactory().getConstructor().newInstance();
object = (T) factory.createObject(objectId, parentObject);
} catch (MissingResourceException e) {
Object placeholder = newMissingPluginPlaceholder(metadataObject, node, objectId);
if (placeholder == null) {
throw new HopXmlException(
"Unable to create a new instance of class "
+ clazz.getName()
+ " while de-serializing XML: "
+ e.getMessage(),
e);
}
object = (T) placeholder;
} catch (HopMissingPluginsException e) {
throw new HopXmlException(
"The plugin for class "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,26 @@

package org.apache.hop.pipeline.transforms.missing;

import org.apache.hop.core.exception.HopException;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.pipeline.Pipeline;
import org.apache.hop.pipeline.PipelineMeta;
import org.apache.hop.pipeline.transform.BaseTransform;
import org.apache.hop.pipeline.transform.TransformMeta;
import org.apache.hop.pipeline.transforms.dummy.Dummy;
import org.apache.hop.pipeline.transforms.dummy.DummyData;
import org.apache.hop.pipeline.transforms.dummy.DummyMeta;

public class MissingTransform extends Dummy {
/**
* Runtime stand-in for a transform whose plugin is not installed. {@link Missing} declares {@code
* BaseTransformMeta<MissingTransform, MissingData>}, so {@link
* org.apache.hop.pipeline.transform.BaseTransformMeta#createTransform} must find a constructor
* {@code (TransformMeta, Missing, MissingData, int, PipelineMeta, Pipeline)}.
*/
public class MissingTransform extends BaseTransform<Missing, MissingData> {
private static final Class<?> PKG = MissingTransform.class;

public MissingTransform(
TransformMeta transformMeta,
DummyMeta meta,
DummyData data,
Missing meta,
MissingData data,
int copyNr,
PipelineMeta pipelineMeta,
Pipeline pipeline) {
Expand All @@ -45,4 +50,15 @@ public boolean init() {
}
return false;
}

@Override
public boolean processRow() throws HopException {
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
putRow(getInputRowMeta(), r);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.hop.pipeline.transform.TransformMeta;
import org.apache.hop.pipeline.transform.TransformPartitioningMeta;
import org.apache.hop.pipeline.transform.stream.IStream;
import org.apache.hop.pipeline.transforms.missing.Missing;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.dialog.ErrorDialog;
import org.apache.hop.ui.core.dialog.MessageBox;
Expand All @@ -61,6 +62,7 @@
import org.apache.hop.ui.hopgui.partition.processor.IMethodProcessor;
import org.apache.hop.ui.hopgui.partition.processor.MethodProcessorFactory;
import org.apache.hop.ui.pipeline.transform.TransformErrorMetaDialog;
import org.apache.hop.ui.pipeline.transforms.missing.MissingPipelineDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;

Expand All @@ -82,6 +84,15 @@ public ITransformDialog getTransformDialog(
ITransformMeta transformMeta, PipelineMeta pipelineMeta, String transformName)
throws HopException {

if (transformMeta instanceof Missing) {
return new MissingPipelineDialog(
hopGui.getShell(),
pipelineGraph.getVariables(),
transformMeta,
pipelineMeta,
transformName);
}

PluginRegistry registry = PluginRegistry.getInstance();
IPlugin plugin = registry.getPlugin(TransformPluginType.class, transformMeta);
if (plugin == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public IActionDialog getActionDialog(IAction action, WorkflowMeta workflowMeta)
Object[] arguments =
new Object[] {hopGui.getShell(), action, workflowMeta, workflowGraph.getVariables()};

if (MissingAction.ID.equals(action.getPluginId())) {
if (action instanceof MissingAction) {
return new MissingActionDialog(
hopGui.getActiveShell(), action, workflowMeta, workflowGraph.getVariables());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
Expand Down Expand Up @@ -569,7 +568,6 @@ protected void createTree(Composite parent) {
tree.addListener(SWT.Selection, event -> updateSelection());
tree.addListener(SWT.DefaultSelection, this::openFile);
PropsUi.setLook(tree);
logFileExplorerFont("tree", tree.getFont());

FormData treeFormData = new FormData();
treeFormData.left = new FormAttachment(0, 0);
Expand Down Expand Up @@ -641,24 +639,6 @@ protected void createTree(Composite parent) {
GuiRegistry.getInstance().executeCallbackMethods(GUI_CONTEXT_MENU_CREATED_CALLBACK_ID);
}

private void logFileExplorerFont(String widget, Font font) {
if (font == null || font.isDisposed()) {
return;
}
FontData[] fda = font.getFontData();
if (fda != null && fda.length > 0) {
hopGui
.getLog()
.logBasic(
"File explorer "
+ widget
+ " font: family="
+ fda[0].getName()
+ ", size="
+ fda[0].getHeight());
}
}

/**
* Creates the Drag & Drop DragSource for items being dragged from the tree.
*
Expand Down
Loading
Loading