Loading in tree structure from arraylist

Hi,
I have a ArrayList contains xml file path like
ArrayList al={"/folder1/sub1/sub11/1.xml",
"/folder1/sub1/2.xml,
"/folder1/test1/3.xml",
"/folder2/sub2/4.xml",
"/folder2/sub2/sub3/5.xml"}
Note: 1.This arraylist objects are dynamically loaded.
2.The objects in array list are not file system directory path like (e.g., C:/folder1/sub1/.....). Its string added in arraylist.
using this arraylist i want to load it in jsp tree structure, like
folder1
|___sub1
| |_sub11
| | |__1.xml
| |_2.xml
|___test1
|_3.xml
folder2
|
|_sub2
|___4.xml
|___sub3
|___5.xml
Can any one help me with logic or predefined function in java to iterate each string array object and split parent and sub child folder and load it in tree.
Edited by: manjunath_2284 on Aug 11, 2009 6:04 AM

Create a Node class that has a name and Map<String, Node> as children.
Iterate over the list, split each entry on "/", and place the parts that you get into the Node structure.

Similar Messages

  • How to populate Tree structure from BAPI while tree grows or shrinks

    Hi All
    Currently I am populating the tree structure from BAPI based on the HLevel (Hierarchy  Level) parameter, but when ever insertion and deletion happens in the tree at any level in the UI and at the same time i am updating these tree node values with HLevel value(example : 1 is first level , 2 is second level, 3 is third level etc)  updating successfully& correctly  into the BAPI, no issues.
    Once it is updated into the BAPI, next time when i refreshed the UI then i am not populating the tree structure correctly from BAPI with updated new nodes based on the HLevel. when tree struture grows or shrinks in the BAPI after updating into BAPI from UI then i am not populating the tree sturcture correctly based on the HLevel value from the BAPI.
    Please let me know any sample code how to populate tree structure correctly when tree structure grows or shrinks based on the HLevel value ( Hierarchy Level , for example : 1 is level , 2 is 2nd level , 3 is third level nodes etc)
    anybody helps in this regard with sample code on the populating tree tructure then it would be great help to me.
    Thanks in advance
    Regards
    Kalki Reddy
    Edited by: KalkiReddy on Nov 29, 2009 3:48 PM

    Bapi output node:
    Value     | Text     | HLevel
    01     | A     | 1               
    0101     | AA       | 2
    010101     | AAA     | 3
    01010B     | AAB     | 3
    0102     | AB     | 2
    02     | B     | 1
    0201     | BA        | 2
    This code is used to build the tree in wdDoInit method
         IE_T_CatalogueNode catalogueNode = wdContext.nodeE_T_Catalogue();
         int size = catalogueNode.size();
         ICatalogoElement level1elem = null;
         for (int i = 0; i < size; i ++)
              IE_T_CatalogueElement catalogueElem = catalogueNode.getE_T_CatalogueElementAt(i);
              if (catalogueElem.getLevel().equals("1"))
                   // 1 Livello
                   level1elem = wdContext.createCatalogoElement();
                   level1elem.setKATALOGART_CODE(catalogueElem.getKatalogart());
                   level1elem.setCODEGRUPPE_CODE(catalogueElem.getCodegruppe());
                   level1elem.setCODE(catalogueElem.getCode());
                   level1elem.setCODE_DESCR(catalogueElem.getKatalogart_Descr());
                   level1elem.setDESCR(catalogueElem.getKatalogart_Descr());
                   wdContext.nodeCatalogo().addElement(level1elem);
                   for (int j = i + 1; j < size; j ++)
                        IE_T_CatalogueElement catalogueElem2level =
                                                 catalogueNode.getE_T_CatalogueElementAt( j );
                        String level2 = catalogueElem2level.getLevel();
                        if (level2.equals("2"))
                             ICatalogoElement level2elem = level1elem.nodeChild().createCatalogoElement();
                             level2elem.setKATALOGART_CODE(catalogueElem2level.getKatalogart());
                             level2elem.setCODEGRUPPE_CODE(catalogueElem2level.getCodegruppe());
                             level2elem.setCODE(catalogueElem2level.getCode());
                             level2elem.setCODE_DESCR(catalogueElem2level.getCodegruppe_Descr());
                             level2elem.setDESCR(catalogueElem2level.getCodegruppe_Descr());
                             level1elem.nodeChild().addElement(level2elem);
                             for (int k = j + 1; k < size; k ++)
                                  IE_T_CatalogueElement catalogueElem3level =
                                                           catalogueNode.getE_T_CatalogueElementAt( k );
                                  String level3 = catalogueElem3level.getLevel();
                                  if (level3.equals("3"))
                                       ICatalogoElement level3elem = level2elem.nodeChild().createCatalogoElement();
                                       level3elem.setKATALOGART_CODE(catalogueElem3level.getKatalogart());
                                       level3elem.setCODEGRUPPE_CODE(catalogueElem3level.getCodegruppe());
                                       level3elem.setCODE(catalogueElem3level.getCode());
                                       level3elem.setCODE_DESCR(catalogueElem3level.getCode_Descr());
                                       level3elem.setDESCR(catalogueElem3level.getCode_Descr());
                                       level2elem.nodeChild().addElement(level3elem);
    Damiano

  • Generate Tree Structure from DB - XSQL??

    We have a table that contains a tree structure using Parent/Child fields. We use "Connect By" to extract this in normal applications to show in a tree control.
    We now want this in XML format output by our web server, where a client side app running in the browser can load this.
    I have looked at XSQL utility but it looks to only generate a simple flat structure.
    Anyone have an idea of how to automatically create a tree structure straight from the DB?
    Thanks
    Rob

    You downloaded the wrong XML Parser!
    XSQL requires Java Parser. Well, there's a copy included with the XSQL package so you actually don't need to do another download.
    You really don't need XSQL if you just want a XML file from DB, you just needed a XML SQL Utility. Download that and run the samples.

  • How to Show floders and documents as a tree structure from path only

    sir,
    I am doing system side project using Java..
    so i want to know how to show folders and documents as tree structure format..
    plz give your idea regarding this?

    See for example Tree taglib in Coldtags suite:
    http://www.servletsuite.com/jsp.htm

  • Rendering Tree Structure from nested Iterators

    I am attempting to create a master-detail tree structure using nested iterators using JDeveloper 11.1.1.6.0. I have my data control set up and the master - child relation is set up using a view link.
    The intent is to be able to have a form that results in the following basic design:
    ------------------|
    parent 1 details
    -child 1 details and operations
    -child 2 details and operations
    ------------------|
    parent 2 details
    -child 3 details and operations
    ------------------|
    Thus far when I've tried nested iterators using the data control, I instead get the following:
    ------------------|
    parent 1 details
    -child 1 details and operations
    -child 2 details and operations
    -child 3 details and operations
    ------------------|
    parent 2 details
    ------------------|
    -child 1 details and operations
    -child 2 details and operations
    -child 3 details and operations
    ------------------|
    I've attempted to get this to work by using two completely seperate binding iterators, each tied to a different af:iterator in the following structure:
    <af:iterator id="i1" value="#{bindings.parent.collectionModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
      <af:panelBox text="#{row.bindings.detail.inputValue}">
        <af:iterator id="i2" value="#{bindings.child.collectionModel}" var="row2" rows="#{bindings.childIterator.rangeSize}">
          <af:outputText value="#{row2.bindings.detail.inputValue}"/>
        </af:iterator>
      </af:panelBox>
    </af:iterator>However, this renders the above situation. I have not been ablue to figure out how to have the second iterator's values be dependant on the current row of the first iterator. I can get the organizational structure to work using an af:tree element and my data control. However, I cannot modify the look of the af:tree elements to match what is required by the customer, nor do I beleive that I could create the required functionality using it. Does anyone have any suggestions on how to get this to work?
    Thank you
    Edited by: user13468716 on May 15, 2012 6:23 AM

    You can't use collectionModel for both the iterators. You will either need to create a treeBinding with a tree level rule and refer the first one as +#{bindings.<TreeBindingName>.treeModel}+ name it as row
    and refer to the next iterator as #{row.<TreeLevelRuleName>}.
    This will atleast create the stamping of the rows properly.Something like this -
    <af:iterator id="i1" value="#{bindings.parent.treeModel} var="row" rows="#{bindings.parentIterator.rangeSize}">
      <af:panelBox text="#{row.bindings.detail.inputValue}">
        <af:iterator id="i2" value="#{row.child}" var="row2" rows="#{bindings.childIterator.rangeSize}">
          <af:outputText value="#{row2.bindings.detail.inputValue}"/>
        </af:iterator>
      </af:panelBox>
    </af:iterator>where +parent+ is a treeBinding having +child+ as a tree level rule
    Edited by: Sudipto Desmukh on May 15, 2012 6:57 PM

  • How to get tree structure from file list?

    I have got following rows from my select query presenting a folder structure:
    PATH
    /KING/JONES/SCOTT
    /KING/JONES/SCOTT/ADAMS
    /KING/JONES/FORD
    /KING/JONES/FORD/SMITH
    /KING/BLAKE
    /KING/BLAKE/ALLEN
    /KING/BLAKE/WARD
    /KING/BLAKE/MARTIN
    /KING/BLAKE/TURNER
    /KING/BLAKE/JAMES
    /KING/CLARK
    /KING/CLARK/MILLER
    /PALO/TEMP
    On base of this data I need to build tree in my application by effecient way.
    Therefore i would like to achieve data (SELECT with two columns) as bellow:
    FOLDER        PARENTFOLDER
    KING     NULL
    JONES   KING
    SCOTT  KING/JONES
    ADAMS  KING/JONES/SCOTT
    FORD     KING/JONES
    SMITH    KING/JONES/FORD
    BLAKE    KING
    ALLEN    KING/BLAKE
    WARD    KING/BLAKE
    MARTIN  KING/BLAKE
    TURNER  KING/BLAKE
    JAMES    KING/BLAKE
    CLARK     KING
    MILLER    KING/CLARK
    PALO      NULL
    TEMP      PALOIs this possible to do it on SQL level(not PL SQL)?
    Thanks

    Perhaps something like this?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select '/KING/JONES/SCOTT' as path from dual union all
      2             select '/KING/JONES/SCOTT/ADAMS' from dual union all
      3             select '/KING/JONES/FORD' from dual union all
      4             select '/KING/JONES/FORD/SMITH' from dual union all
      5             select '/KING/BLAKE' from dual union all
      6             select '/KING/BLAKE/ALLEN' from dual union all
      7             select '/KING/BLAKE/WARD' from dual union all
      8             select '/KING/BLAKE/MARTIN' from dual union all
      9             select '/KING/BLAKE/TURNER' from dual union all
    10             select '/KING/BLAKE/JAMES' from dual union all
    11             select '/KING/CLARK' from dual union all
    12             select '/KING/CLARK/MILLER' from dual union all
    13             select '/PALO/TEMP' from dual
    14            )
    15  --
    16  -- END OF TEST DATA
    17  --
    18  select distinct substr(path,instr(path,'/',1,rn)+1,decode(instr(path,'/',1,rn+1),0,length(path)+1,instr(path,'/',1,rn+1))-instr(path,'/',1,rn)-1) as folder, substr(path,2,instr(path,'/',1,rn)-2) as parent
    19  from t
    20       cross join (select rownum rn from dual connect by rownum <= (select max(length(regexp_replace(path,'[^/]'))) from t)) x
    21* where instr(path,'/',1,rn) > 0
    SQL> /
    FOLDER                  PARENT
    BLAKE                   KING
    SCOTT                   KING/JONES
    JAMES                   KING/BLAKE
    MARTIN                  KING/BLAKE
    SMITH                   KING/JONES/FORD
    KING
    WARD                    KING/BLAKE
    ADAMS                   KING/JONES/SCOTT
    FORD                    KING/JONES
    TURNER                  KING/BLAKE
    MILLER                  KING/CLARK
    PALO
    TEMP                    PALO
    JONES                   KING
    CLARK                   KING
    ALLEN                   KING/BLAKE
    16 rows selected.
    SQL>

  • Tree movement from Peoplesoft to Hyperion

    Hi all,
    I'm new to DRM and presently working on implementing a project where DRM would be used to manage the Hierarchies and Peoplesoft would be the main application which would send tree structures to DRM on an adhoc basis. My Question is,
    1. What are are ways to move tree structures from P.S into DRM ?
    One thing is to take exports from P.S ,then manipulate it to a DRM readable format and then import it into DRM (and then Blend with the existing tree). But what are the other options available here?
    2. Also, how to set up Hyperion DRM initially with the P.S tree structures?
    Regards,
    Suvi

    Have you seen this one: http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/hyperion_hps.chm
    Cheers,
    Mehmet

  • Save tree structure to text file and load textfile to another tree control

    I'm able to save the structure and data to a text file, thanks to the "save tree structure to textfile" info found on this msg board, but can't seem to load the complete tree structure data from the text file into another tree. I've only been able to load parent data but can't get the hierarchy of the tree with the indents and child data to work.
    Thanks

    Thanks Tanya,
    However, I'm still stumped on how to copy (from text file) to other columns in the tree (from one tree to another).  I can only get the first column to load.
    I've attached my working VI and a textfile that I use to load into the "User list" tree.
    Rick
    Attachments:
    Text File to Tree V2.2.vi ‏58 KB
    test file save16.txt ‏1 KB

  • How to load my tree with data from SQL database????

    Hello friends
    May i know how i can load my tree with my database??
    i have 3 different tables and i need them to be the 3 main nodes of my tree
    They are
    1.fiche
    2.amis and
    3.famille
    and in each of these nodes need to load the 3 databases
    thank u in advance

    Heres my program so i loaded my vector ,
    Now how can i integrate the coding u gave me, and where ??
    Is it where i put the quetion mark?
    if so
    can you tell me how?? because i didnt understood well the codings you gave me as im nt at all familiar with this
    Thank you in advance
    public class carnetf extends javax.swing.JFrame  {
       DefaultMutableTreeNode root =null;
        public carnetf() {
           root= new DefaultMutableTreeNode("Carnet");
            DefaultMutableTreeNode tnFiche=new DefaultMutableTreeNode("Fiche");
           root.add( tnFiche);
            DefaultMutableTreeNode tnAmis=new DefaultMutableTreeNode("Amis");
            root.add( tnAmis);
            DefaultMutableTreeNode tnFamille=new DefaultMutableTreeNode("Famille");
            root.add( tnFamille);
           initComponents();
        public Vector vecfiche() {
            Vector v = new Vector();    
            Connection connection = null;
            try
                Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver());;
            catch (Exception E)
                System.out.println("Unable to load driver.");
                System.out.println(E.getMessage());
                E.printStackTrace();
                return null;
            try
                connection = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;user=sa;password=sa;DatabaseName=carnet");
            catch (Exception E)
                System.out.println("Unable to connect.");
                System.out.println(E.getMessage());
                return null;
            try
                Statement Stmt = connection.createStatement();
                if(jRadioButton1.isSelected()==true)  
                    String Query = "SELECT * FROM fiche";
                ResultSet RS= Stmt.executeQuery( Query );
                while ( RS.next())
                 v.add( new vecfiche( RS.getString("Nom"), RS.getString("Prenom")));
                if( RS!= null) RS.close();}
                if(jRadioButton2.isSelected()==true)  
                    String Query = "SELECT * FROM amis";
                ResultSet RS= Stmt.executeQuery( Query );
                while ( RS.next())
                 v.add( new vecfiche( RS.getString("Anom"), RS.getString("Aprenom")));
                if( RS!= null) RS.close();}
                if(jRadioButton3.isSelected()==true)  
                    String Query = "SELECT * FROM famille";
                ResultSet RS= Stmt.executeQuery( Query );
                while ( RS.next())
                 v.add( new vecfiche( RS.getString("Fnom"), RS.getString("Fprenom")));
                if( RS!= null) RS.close();}
                if( Stmt!= null) Stmt.close();
            catch (Exception E)
                System.out.println("Unable to query.");
                System.out.println(E.getMessage());
                return null;
            try
                connection.close();
            } catch (Exception E)
                System.out.println("Unable to close.");
                System.out.println(E.getMessage());
                return null;
            return v;
        }

  • How do I read text from specific rows and columns in a tree structure?

    How do I read text from specific rows and columns in a tree structure? In a table you can specify the cell to read from but I have not been able to figure out how to do this with a tree structure.

    You need to set two properties to activate the correct cell and then you can read it's string property.
    The positioning properties are the "ActiveItemTag" and
    "ActiveColNum" properties. With them you select the tree item by it's tag and the active column. The string can then be read from the "Cell String" property.
    MTO

  • Loading a tree of objects from a cache in a single call using an aggregator

    Hi,
    I currently have the following problem. I am trying to load a tree of objects from coherence by recursing up an object tree from a child object.
    What is currently in place is something like this (not actual implementation).
    Child child...// initialisation of Child;
    List<Parent> parents = new LinkedList<Parent>();
    Parent parent = null;
    int parentId = child.getParentId();
    while (true) {
    parent = cache.get(parentId);
    if (parent != null) {
    parents.add(parent);
    parentId = parent.getParentId();
    } else {
    break;
    However, this results in a number of calls over the network to the coherence cache and is proving to be quite inefficient. What I would like is to be able to write something like a filter or an aggregation function which will simply take in the child, or the parent id of the child, and return a list of all the parents (with the recursion logic taking place on the coherence node). This will hopefully reduce network latency considerably.
    Does anybody know how to go about doing this within coherence?

    XML might be a better solution, but using tags should work.
    The Sun tutorial at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags5.html#68205 should be helpful to you.
    When processing a tag, determine if there is a parent tag by using getParent() or findAncestorWithClass().
    If there is no parent, instantiate your site navigation object based on the tag arguments and save a reference within the tag object. You'll probably want to also add the reference to page or session scope as an attribute for later use.
    If there is a parent, instantiate the new navigation object and then retrieve the parent navigation object from the parent tag (create a getNavigation() method in tag?). Then add the new navigation object to the array in the parent navigation object.

  • Create a Tree Node Structure from XML

    Hi
    We have a requirement where we have an XML file we want to create the Tree Node structure from the XML can anyone help out on this
    We are referring to the following blog but in that it is coming from KM content and we require the tree structure to form from a XML file
    http://wiki.sdn.sap.com/wiki/display/Snippets/SmartNavigationTreeforKM+Folders
    Can anyone help me
    Regards
    JM

    Hi,
    Could you elaborate a litle more exacly what you need to do?
    I found the link http://help.sap.com/saphelp_470/helpdata/en/86/8280db12d511d5991b00508b6b8b11/content.htm that maybe assist you.
    Please remember to evaluate the replays, this incentive the SDN to keep growing,
    regards,
    Fabio

  • How do you retrieve child tags from a parent tag in a tree structure and build an array from it?

    Is there a property node somewhere that can retrieve the tags of all the children of an "active" parent tag in a tree structure? If I click on the parent tag, I want to be able to show what child tags are under that parent tag.

    There is not a property or method that I have been able to find, however I wrote this VI that given a parent tag returns all the children.
    Evan Collier
    Attachments:
    Get_1_Lv_of_children.vi ‏59 KB

  • I would like to know where the forum tree structure is so I can see what I'm doing and not be led around to irrelevant information.

    I'm having trouble '''Finding''' the forum where I can look for the information I need. I keep ending up in '''endless menus of non-helpful information. '''
    I got a popup message, I needed to upgrade to 3.6.17. After allowing it and rebooting, I couldn't start FF anymore, just got a crash report. I tried going to the restore point I had set with no luck and I tried creating a new profile. I lost all my bookmarks (only the Cache remained). And I sat in live chat for an hour waiting for help. German live chat had one helper and English live chat was closed.
    So I gave up on help, uninstalled FF 3.6.17 and downloaded FF 3.6.15 and installed it. It loads but all bookmarks are gone. More importantly, now when I load the bookmarks, I can't '''retrieve''' them except by storing a new one. '''Only''' when I create a new bookmark can I see the folders I've created. I can't get to the organizer so I can't use the bookmarks to retrieve websites.
    I'm disturbed that I can't get to the tree-structure forum where I can get the help I need. This "lead me around" labyrinth from one question to another, without being able to look through the forum for the information I need, is not helpful.
    Thank you.
    Foxhunt

    I believe you just are able to delete them from iTunes.
    Hope it will be helpful

  • Org Chart in tree structure

    Hi Friends,
    How to Create a tree structure  for org. unit in  web dynpro ABAP
    and call the tree in F4 Help of a input box.

    Good advice there guys.
    I myself just finished such an implementation at one of my customers. It took 2 days to complete. I can't give you the solution as the customer retains the immaterial rights for the solution but I thought I would tell you the steps involved to get you on the right track.
    1. Context. Build a context node that on the top level has the orgunit, it's attributes (such as otype, objid, stext, etc) and the recursive node that points to the orgunit node. Inside the orgunit create a node for the position. Inside the node place the attributes for the position (like before) and a recursive node that points to the position node. Finally inside the position node place a node for the person and it's attributes (like before), but no recursion node this time.
    2. Layout: Place a tree element in your view. Inside the tree element insert two node types and one item type. First node is for orgunit, second one is for position. The only item is for the person. You might want to add respective icons, to get nicer UI. Add the load children action for orgunit and position. Depending on what you want to select from the tree, add a select action for either orgunit, position or person.
    3. Code #1: as Chris points out, use RH_STRUC_GET to get the organization tree. I myself used O_S_P. You might want to create a FM that returns all 3 itabs returned by RH_STRUC_GET to the WDA. Create a freely programmed value help as suggested in many threads, it's pretty straight forward. In the WDA utilizing the VH, mark one or more items in the context as freely programmed VH and connect to your implementation.
    4. Code #2: At start up, for example in the WDDOINIT method, create only the root node and call it for example "All organization units". Then create one action that is called when children nodes have to be loaded, one method for figuring out what do when a child is being requested (and what kind of child: orgunit, position or person) and finally a method for actually creating the node.
    5. Code #3: The magic comes from RH_STRUC_GET. Use the STRUC itab at runtime to find the objects at certain levels and to determine their parent(s) and children. The most important values in the STRUC itab in this case are LEVEL, OTYPE, OBJID and PUP.
    Pretty straight forward and the solution is quite nice indeed. I'm sorry if I forgot something, I wrote this without access to the system.

Maybe you are looking for