Customer Portal

Passing paramateres to the custom component

Comments 6

  • Avatar
    avackova
    0
    Comment actions Permalink
    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();
    .
    .
    .
    }
    }
  • Avatar
    venkata
    0
    Comment actions Permalink
    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
  • Avatar
    avackova
    0
    Comment actions Permalink
    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");
  • Avatar
    venkata
    0
    Comment actions Permalink
    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
  • Avatar
    avackova
    0
    Comment actions Permalink
    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)));
  • Avatar
    venkata
    0
    Comment actions Permalink
    THANK YOU VERY MUCH avackova I am PAASING STRING ALONE

Please sign in to leave a comment.