I have requirement like, i have to take the Value objects as input and i have to wirte those value objects to XLS.
For that i have devloped a custom Component
And i have created the grf file based on the custom component. i calling the graph file through java like this
it is execeuting fine.
But right now my requirement is like. While calling the graph it self i need to pass some input parameters. i.e what ever the method i am calling in execute() (new PMIFacade().processDealExtract() ) requires some input parameter. i .e the new method will looks like new PMIFacade().processDealExtract(int a, string b). i nned to pass those inputs while calling the grah.
can anyone help on this.
Thanks in advance
Venkat
              For that i have devloped a custom Component
public Result execute() throws Exception {
		InputPortDirect inPort = (InputPortDirect) getInputPort(READ_FROM_PORT);;
		List<DealDetailsVO> dealDetailsVOList = new PMIFacade().processDealExtract();
		Iterator<DealDetailsVO> iterator = dealDetailsVOList.iterator();
		
		while (iterator.hasNext() && runIt) {
				DealDetailsVO dealDetailsVO = (DealDetailsVO) iterator.next();
				outRecord.getField("ACCOUNTID").setValue(dealDetailsVO.getAccountId());
				outRecord.getField("DEALID").setValue(dealDetailsVO.getDealId());
				outRecord.getField("DEALNAME").setValue(dealDetailsVO.getDealName());
				outRecord.getField("BUSINESSSEGMENT").setValue(dealDetailsVO.getBusinessSegment());
				outRecord.getField("BUSINESSSUBSEGMENT").setValue(dealDetailsVO.getBusinessSubSegment());
				outRecord.getField("ORIGINATINGLOCATION").setValue(dealDetailsVO.getOriginatingLocation());
				outRecord.getField("BOOKINGLOCATION").setValue(dealDetailsVO.getBookingLocation());
				outRecord.getField("DATEFIRSTINPIPELINE").setValue(dealDetailsVO.getDateFirstInPipeline());
				outRecord.getField("CLOSEDDATE").setValue(dealDetailsVO.getClosedDate());
				outRecord.getField("LOSTDATE").setValue(dealDetailsVO.getLostDate());
				outRecord.getField("SALESSTAGE").setValue(dealDetailsVO.getSalesStage());
				outRecord.getField("UPDATEDTOTALANNUALREVENUE").setValue(dealDetailsVO.getUpdatedTotalAnnualRevenue());
				outRecord.getField("PRODUCTTYPE").setValue(dealDetailsVO.getProductType());
				outRecord.getField("SUBPRODUCTTYPE").setValue(dealDetailsVO.getSubProductType());
				outRecord.getField("ACCOUNTNAME").setValue(dealDetailsVO.getAccountName());
				outRecord.getField("ACCTGROUPID").setValue(dealDetailsVO.getAcctGroupId());
				outRecord.getField("ACCTLEID").setValue(dealDetailsVO.getAcctLEId());
				outRecord.getField("ACCTSUBPROFILEID").setValue(dealDetailsVO.getAcctSubProfileId());
				outRecord.getField("CREATEDDATE").setValue(dealDetailsVO.getCreatedDate());
				getOutputPort(0).writeRecord(outRecord);
		
			SynchronizeUtils.cloverYield();
		}
		
        return runIt ? Result.FINISHED_OK : Result.ABORTED;
	}
And i have created the grf file based on the custom component. i calling the graph file through java like this
                        EngineInitializer.initEngine("C:\\cloverETL.rel-3-0-0\\cloverETL\\plugins", null, null);
			String graphPath = "c:\\cloverETL.rel-3-0-0\\cloverETL\\bin\\graph\\tets.grf";
			InputStream is = new BufferedInputStream(new FileInputStream(graphPath));
			TransformationGraph graph = null;
			// engine customizationnm
			GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
			// graph loading
			graph = TransformationGraphXMLReaderWriter.loadGraph(is,runtimeContext);
			// engine initialization
			EngineInitializer.initGraph(graph, runtimeContext);
			// graph running
			IThreadManager threadManager = new SimpleThreadManager();
			WatchDog watchDog = new WatchDog(graph, runtimeContext);
			threadManager.executeWatchDog(watchDog);
it is execeuting fine.
But right now my requirement is like. While calling the graph it self i need to pass some input parameters. i.e what ever the method i am calling in execute() (new PMIFacade().processDealExtract() ) requires some input parameter. i .e the new method will looks like new PMIFacade().processDealExtract(int a, string b). i nned to pass those inputs while calling the grah.
can anyone help on this.
Thanks in advance
Venkat
- 
                
What about adding the attributes to your component? Something like that: 
public class MyComponent extends Node
public static String XML_A_PARAMETER_ATTRIBUTE = "aParameter";
public static String XML_B_PARAMETER_ATTRIBUTE = "bParameter";
int a;
String b;
.
.
public static Node fromXML(TransformationGraph graph, Element xmlElement) throws XMLConfigurationException {
ComponentXMLAttributes xattribs = new ComponentXMLAttributes(xmlElement, graph);
MyComponent component;
.
.
.
int aAttribute = xattribs.getInteger(XML_A_PARAMETER_ATTRIBUTE);
String bAttribute = xattribs.getString(XML_B_PARAMETER_ATTRIBUTE);
component.setAAttribute(aAttribute);
component.setBAttribute(bAttribute);
.
.
.
}
public Result execute() throws Exception {
InputPortDirect inPort = (InputPortDirect) getInputPort(READ_FROM_PORT);;
List<DealDetailsVO> dealDetailsVOList = new PMIFacade().processDealExtract(a,b);
Iterator<DealDetailsVO> iterator = dealDetailsVOList.iterator();
.
.
.
}
} - 
                
Thank you very much for your reply. 
I haven't tried yet. I will try this and i will update you. I have one more doubt. To call the grf file using the follwing code.
EngineInitializer.initEngine("C:\\cloverETL.rel-3-0-0\\cloverETL\\plugins", null, null);
String graphPath = "c:\\cloverETL.rel-3-0-0\\cloverETL\\bin\\graph\\scbcdh.grf";
InputStream is = new BufferedInputStream(new FileInputStream(graphPath));
TransformationGraph graph = null;
// engine customizationnm
GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
// graph loading
graph = TransformationGraphXMLReaderWriter.loadGraph(is,runtimeContext);
// engine initialization
EngineInitializer.initGraph(graph, runtimeContext);
// graph running
IThreadManager threadManager = new SimpleThreadManager();
WatchDog watchDog = new WatchDog(graph, runtimeContext);
threadManager.executeWatchDog(watchDog);
here where i need to pass those parameters.
Thanks
Venkat - 
                
Hello Venkat, 
define these attributes by parameters in your graph, eg:
<Node aParameter="${a}" bParameter="${b}" id="MY_COMPONENT0" type="MY_COMPONENT"/>
and paste the values to the GraphRuntimeContext object:
runtimeContext.addAdditionalProperty("a", "1");
runtimeContext.addAdditionalProperty("b", "b"); - 
                
Hi avackova, 
Thank you very much. It is working fine.
I have another question like is it possible to pass the List of object's as input. If it is how can we do that.
Thank you
Venkat - 
                
Hello Venkat, 
List object can't be passed to the graph. You need to split the string, eg.:
component.setListAttribute(Arrays.asList(xattribs.getString(XML_LIST_ATTRIBUTE).split(Defaults.Component.KEY_FIELDS_DELIMITER_REGEX))); - 
                
THANK YOU VERY MUCH avackova I am PAASING STRING ALONE  
Please sign in to leave a comment.
Comments 6