2 Replies Latest reply: Jan 8, 2013 11:51 AM by Vijay Nimmakuri RSS

    How to get child node( which is defined as Component in Model Structure).

    Vijay Nimmakuri
      Hi All,

      Can you please let me know how to get the child node which is defined as a Component in my model structure. I could able to get the top node of the Model structure, but facing difficulty in getting the Component node. This CX i am launching it from front end.

      I tried with the below, but no luck.

      IRuntimeNode compo = rootNode.getChildByID(modelId);
      and also with
      IRuntimeNode compo = rootNode.getChildByPersistentID(15420);


      public void displayAttributes(IRuntimeNode irn)
      {
      try
      {
           Configuration config = irn.getConfiguration();
      rootNode = config.getRootComponent(); etc...

      Example :

      CNX1000 (Model Root node - BOM Nodes)
      +OptionClass1
      (options)
      +OptionClass2
      (options)
      SLSCNX1000 (Node which is defined as component)
      +Sales Option class1
      (options)
      +Sales Option class2
      (options)

      I want to get 'SLSCNX1000' node and loop through. I could able to get CNX1000 the BOM root node.

      Thanks in advance,

      Edited by: Vijay Nimmakuri on Jan 5, 2013 1:54 AM
        • 1. Re: How to get child node( which is defined as Component in Model Structure).
          Eogan
          Vijay --

          It is generally not advisable to get children by IDs. Doing so requires determination of information that is not known without querying the CZ schema, and that is rarely necessary, as you typically at least know the name of the node to which you're trying to navigate. You can use the following to get the Component:

          IRuntimeNode compo = rootNode.getChildByName("SLSCNX1000");

          I don't know exactly what you mean by "loop through"; I assume you intend to iterate through that Component's "Sales Options", which I take to be Option Features. To get a List of all of the Component's Option Features, you'd use:

          compo.getChildrenByType(IRuntimeNode.OPTION_FEATURE)

          Hope this helps.

          Eogan
          • 2. Re: How to get child node( which is defined as Component in Model Structure).
            Vijay Nimmakuri
            Hello Eogan,

            Thanks it helped me i implemented it this way.

            IRuntimeNode compo = irn.getChildByName(componentname);
            List czItemNode =compo.getChildrenByType(IRuntimeNode.OPTION_FEATURE);

            ListIterator Oclist = czItemNode.listIterator();
            while (Oclist.hasNext())
                 {
                 IRuntimeNode nodeTemp = (IRuntimeNode) Oclist.next();
                 
            // Added for gettings tokens
            String country = getModelOptions(irn);
            InformationalMessage iMsg3 = new InformationalMessage((new StringBuilder("getCountrySelected---->")).append(country).toString(), irn);
            StringTokenizer st = new StringTokenizer(country, ".");
                 
                 while (st.hasMoreElements())
                 {
                      config.addInformationalMessage(iMsg14);
                 czItemNode2.setState(IState.TRUE);
                 }
                 }

            Thanks a Lot :)

            -Vijay