use of org.apache.hop.pipeline.transforms.injector.InjectorMeta in project hop by apache.
the class KafkaConsumerInputDialog method createSubPipelineMeta.
protected PipelineMeta createSubPipelineMeta() {
InjectorMeta injectorMeta = new InjectorMeta();
String[] fieldNames = getFieldNames();
int[] fieldTypes = getFieldTypes();
for (int i = 0; i < fieldNames.length; i++) {
InjectorField field = new InjectorField(fieldNames[i], ValueMetaFactory.getValueMetaName(fieldTypes[i]), "", "");
injectorMeta.getInjectorFields().add(field);
}
TransformMeta recsFromStream = new TransformMeta("RecordsFromStream", "Get messages from Kafka", injectorMeta);
recsFromStream.setLocation(new Point(100, 100));
PipelineMeta pipelineMeta = new PipelineMeta();
pipelineMeta.addTransform(recsFromStream);
pipelineMeta.setFilename("");
return pipelineMeta;
}
use of org.apache.hop.pipeline.transforms.injector.InjectorMeta in project hop by apache.
the class XsltTest method runTestWithParams.
public void runTestWithParams(String xmlFieldname, String resultFieldname, boolean xslInField, boolean xslFileInField, String xslFileField, String xslFilename, String xslFactory) throws Exception {
HopEnvironment.init();
//
// Create a new pipeline...
//
PipelineMeta pipelineMeta = new PipelineMeta();
pipelineMeta.setName("xslt");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector transform...
//
String injectorTransformName = "injector transform";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(TransformPluginType.class, im);
TransformMeta injectorTransform = new TransformMeta(injectorPid, injectorTransformName, im);
pipelineMeta.addTransform(injectorTransform);
//
// Create a XSLT transform
//
String xsltName = "xslt transform";
XsltMeta xm = new XsltMeta();
String xsltPid = registry.getPluginId(TransformPluginType.class, xm);
TransformMeta xsltTransform = new TransformMeta(xsltPid, xsltName, xm);
pipelineMeta.addTransform(xsltTransform);
TextFileInputField[] fields = new TextFileInputField[3];
for (int idx = 0; idx < fields.length; idx++) {
fields[idx] = new TextFileInputField();
}
fields[0].setName("XML");
fields[0].setType(IValueMeta.TYPE_STRING);
fields[0].setFormat("");
fields[0].setLength(-1);
fields[0].setPrecision(-1);
fields[0].setCurrencySymbol("");
fields[0].setDecimalSymbol("");
fields[0].setGroupSymbol("");
fields[0].setTrimType(IValueMeta.TRIM_TYPE_NONE);
fields[1].setName("XSL");
fields[1].setType(IValueMeta.TYPE_STRING);
fields[1].setFormat("");
fields[1].setLength(-1);
fields[1].setPrecision(-1);
fields[1].setCurrencySymbol("");
fields[1].setDecimalSymbol("");
fields[1].setGroupSymbol("");
fields[1].setTrimType(IValueMeta.TRIM_TYPE_NONE);
fields[2].setName("filename");
fields[2].setType(IValueMeta.TYPE_STRING);
fields[2].setFormat("");
fields[2].setLength(-1);
fields[2].setPrecision(-1);
fields[2].setCurrencySymbol("");
fields[2].setDecimalSymbol("");
fields[2].setGroupSymbol("");
fields[2].setTrimType(IValueMeta.TRIM_TYPE_NONE);
xm.setFieldname(xmlFieldname);
xm.setResultfieldname(resultFieldname);
xm.setXSLField(xslInField);
xm.setXSLFileField(xslFileField);
xm.setXSLFieldIsAFile(xslFileInField);
xm.setXslFilename(xslFilename);
xm.setXSLFactory(xslFactory);
PipelineHopMeta hi = new PipelineHopMeta(injectorTransform, xsltTransform);
pipelineMeta.addPipelineHop(hi);
//
// Create a dummy transform 1
//
String dummyTransformName1 = "dummy transform 1";
DummyMeta dm1 = new DummyMeta();
String dummyPid1 = registry.getPluginId(TransformPluginType.class, dm1);
TransformMeta dummyTransform1 = new TransformMeta(dummyPid1, dummyTransformName1, dm1);
pipelineMeta.addTransform(dummyTransform1);
PipelineHopMeta hi1 = new PipelineHopMeta(xsltTransform, dummyTransform1);
pipelineMeta.addPipelineHop(hi1);
// Now execute the pipeline...
Pipeline pipeline = new LocalPipelineEngine(pipelineMeta);
pipeline.prepareExecution();
ITransform si = pipeline.getTransform(dummyTransformName1, 0);
RowTransformCollector dummyRc1 = new RowTransformCollector();
si.addRowListener(dummyRc1);
RowProducer rp = pipeline.addRowProducer(injectorTransformName, 0);
pipeline.startThreads();
// add rows
List<RowMetaAndData> inputList = createData(xslFilename);
Iterator<RowMetaAndData> it = inputList.iterator();
while (it.hasNext()) {
RowMetaAndData rm = it.next();
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
pipeline.waitUntilFinished();
// Compare the results
List<RowMetaAndData> resultRows = dummyRc1.getRowsWritten();
List<RowMetaAndData> goldenImageRows = createResultData1();
checkRows(goldenImageRows, resultRows, 2);
}
use of org.apache.hop.pipeline.transforms.injector.InjectorMeta in project hop by apache.
the class GetXMLDataTest method testInit.
public void testInit() throws Exception {
HopEnvironment.init();
//
// Create a new pipeline...
//
PipelineMeta pipelineMeta = new PipelineMeta();
pipelineMeta.setName("getxmldata1");
PluginRegistry registry = PluginRegistry.getInstance();
//
// create an injector transform...
//
String injectorTransformName = "injector transform";
InjectorMeta im = new InjectorMeta();
// Set the information of the injector.
String injectorPid = registry.getPluginId(TransformPluginType.class, im);
TransformMeta injectorTransform = new TransformMeta(injectorPid, injectorTransformName, im);
pipelineMeta.addTransform(injectorTransform);
//
// Create a Get XML Data transform
//
String getXMLDataName = "get xml data transform";
GetXmlDataMeta gxdm = new GetXmlDataMeta();
String getXMLDataPid = registry.getPluginId(TransformPluginType.class, gxdm);
TransformMeta getXMLDataTransform = new TransformMeta(getXMLDataPid, getXMLDataName, gxdm);
pipelineMeta.addTransform(getXMLDataTransform);
GetXmlDataField[] fields = new GetXmlDataField[5];
for (int idx = 0; idx < fields.length; idx++) {
fields[idx] = new GetXmlDataField();
}
fields[0].setName("objectid");
fields[0].setXPath("${xml_path}");
fields[0].setElementType(GetXmlDataField.ELEMENT_TYPE_NODE);
fields[0].setType(IValueMeta.TYPE_STRING);
fields[0].setFormat("");
fields[0].setLength(-1);
fields[0].setPrecision(-1);
fields[0].setCurrencySymbol("");
fields[0].setDecimalSymbol("");
fields[0].setGroupSymbol("");
fields[0].setTrimType(GetXmlDataField.TYPE_TRIM_NONE);
gxdm.setEncoding("UTF-8");
gxdm.setIsAFile(false);
gxdm.setInFields(true);
gxdm.setLoopXPath("Level1/Level2/Props");
gxdm.setXMLField("field1");
gxdm.setInputFields(fields);
PipelineHopMeta hi = new PipelineHopMeta(injectorTransform, getXMLDataTransform);
pipelineMeta.addPipelineHop(hi);
//
// Create a dummy transform 1
//
String dummyTransformName1 = "dummy transform 1";
DummyMeta dm1 = new DummyMeta();
String dummyPid1 = registry.getPluginId(TransformPluginType.class, dm1);
TransformMeta dummyTransform1 = new TransformMeta(dummyPid1, dummyTransformName1, dm1);
pipelineMeta.addTransform(dummyTransform1);
PipelineHopMeta hi1 = new PipelineHopMeta(getXMLDataTransform, dummyTransform1);
pipelineMeta.addPipelineHop(hi1);
// Now execute the pipeline...
Pipeline pipeline = new LocalPipelineEngine(pipelineMeta);
pipeline.prepareExecution();
ITransform si = pipeline.getTransform(dummyTransformName1, 0);
RowTransformCollector dummyRc1 = new RowTransformCollector();
si.addRowListener(dummyRc1);
RowProducer rp = pipeline.addRowProducer(injectorTransformName, 0);
pipeline.startThreads();
// add rows
List<RowMetaAndData> inputList = createData();
Iterator<RowMetaAndData> it = inputList.iterator();
while (it.hasNext()) {
RowMetaAndData rm = it.next();
rp.putRow(rm.getRowMeta(), rm.getData());
}
rp.finished();
pipeline.waitUntilFinished();
// Compare the results
List<RowMetaAndData> resultRows = dummyRc1.getRowsWritten();
List<RowMetaAndData> goldenImageRows = createResultData1();
GetXmlDataData getXMLDataData = new GetXmlDataData();
GetXmlData getXmlData = new GetXmlData(dummyTransform1, gxdm, getXMLDataData, 0, pipelineMeta, pipeline);
getXmlData.setVariable("xml_path", "data/owner");
getXmlData.init();
assertEquals("${xml_path}", gxdm.getInputFields()[0].getXPath());
assertEquals("data/owner", gxdm.getInputFields()[0].getResolvedXPath());
}
use of org.apache.hop.pipeline.transforms.injector.InjectorMeta in project hop by apache.
the class TestUtilities method createInjectorTransform.
/**
* Create an injector transform.
*
* @param name
* @param pluginRegistry
* @return TransformMeta
*/
public static synchronized TransformMeta createInjectorTransform(String name, PluginRegistry pluginRegistry) {
// create an injector transform...
InjectorMeta injectorMeta = new InjectorMeta();
// Set the information of the injector
String injectorPid = pluginRegistry.getPluginId(TransformPluginType.class, injectorMeta);
TransformMeta injectorTransform = new TransformMeta(injectorPid, name, injectorMeta);
return injectorTransform;
}
use of org.apache.hop.pipeline.transforms.injector.InjectorMeta in project hop by apache.
the class PipelineTestFactory method getInjectorTransformMeta.
static TransformMeta getInjectorTransformMeta() {
InjectorMeta zeroMeta = new InjectorMeta();
TransformMeta zero = new TransformMeta(registry.getPluginId(TransformPluginType.class, zeroMeta), INJECTOR_TRANSFORMNAME, zeroMeta);
zero.setLocation(50, 50);
// zero.setDraw( true );
return zero;
}
Aggregations