Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Custom Org List for TreeModel

DanielOrcl.irOct 25 2015 — edited Nov 19 2015

hi every body

i'm beginner in Oracle Adf

I create Tree Model from my organizations (Fields: orgId,OrgName,ParentId) by This Code:

public List\<OrganizationTree> getAllEmployees() {

    OrganizationsList rootOrg = ServiceLocator.getGroupService().getOrganizationsListFindParentAllByOrgId().get(0); // Return Organization's Of Logined User

    OrganizationTree manager = new OrganizationTree(rootOrg.getOrgName().toString(), rootOrg.getOrgId().toString());// Create Level One

    OrganizationTree manager1;// Level Two

    OrganizationTree manager2;// Level Three

    OrganizationTree manager3;// Level Four

    String RootParentId = "";

    try

        {

                RootParentId = rootOrg.getParentId().toString();

        }

        catch(Exception e)

        {

            System.out.println("ParentId Is Null");

        }

    BigDecimal RootOrgId;

    RootOrgId = getBigDecimal(rootOrg.getOrgId());// Get Root Org Id

    String parentId = "";

    System.out.println("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*");

    /\* ----------------- LEVEL TWO ------------------ \*/

    if (RootParentId == "") {

        BigDecimal orgId1;

        sub1 = ServiceLocator.getGroupService().findOrganizationByParentId(RootOrgId);// Get Sub Org Of Root

        for (int i = 0; i \< sub1.size(); i++) {

            orgId1 = getBigDecimal(sub1.get(i).getOrgId());

            parentId = sub1.get(i).getParentId().toString();

            if (RootOrgId.toString().equals(parentId)) {// Check Parents match

                manager1 =

                    new OrganizationTree(sub1.get(i).getOrgName().toString(), sub1.get(i).getOrgId().toString());

                manager.addDirect(manager1);

                /\* ----------------- LEVEL THREE ------------------ \*/

                sub2 = ServiceLocator.getGroupService().findOrganizationByParentId(orgId1);

                String parentId2 = "";

                for (int j = 0; j \< sub2.size(); j++) {

                BigDecimal OrgId2 = getBigDecimal(sub2.get(j).getOrgId());

                    parentId2 = sub2.get(j).getParentId().toString();

                    if (orgId1.toString().equals(parentId2)) {

                        manager2 =

                            new OrganizationTree(sub2.get(j).getOrgName().toString(),

                                                 sub2.get(j).getOrgId().toString());

                        manager1.addDirect(manager2);

                        sub3 = ServiceLocator.getGroupService().findOrganizationByParentId(OrgId2);

                        /\* ----------------- LEVEL FOUR ------------------ \*/

                        String parentId3 = "";

                        String OrgId3 = sub2.get(j).getOrgId().toString();

                        for (int k = 0; k \< sub3.size(); k++) {

                            parentId3 = sub3.get(k).getParentId().toString();

                            if (OrgId3.equals(parentId3)) {

                                manager3 =

                                    new OrganizationTree(sub3.get(k).getOrgName().toString(),

                                                         sub3.get(k).getOrgId().toString());

                                manager2.addDirect(manager3);

                            }

                        }

                    }

                }

            }

        }

    }

    allEmployees.add(manager);

    employeeTree = new ChildPropertyTreeModel(allEmployees, "Orgs");

    return allEmployees;

}

/*****************************************************/

After Running This Code every Thing Is Ok but When I Refresh page, My Tree Structure Is Changed

look At pic to findOut

Untitled.png

Can any body help me??

tnx

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 17 2015
Added on Oct 25 2015
2 comments
534 views