KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > businessUtility > Tree


1 /*
2  *************************************************************************
3  * The contents of this file are subject to the Openbravo Public License
4  * Version 1.0 (the "License"), being the Mozilla Public License
5  * Version 1.1 with a permitted attribution clause; you may not use this
6  * file except in compliance with the License. You may obtain a copy of
7  * the License at http://www.openbravo.com/legal/license.html
8  * Software distributed under the License is distributed on an "AS IS"
9  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
10  * License for the specific language governing rights and limitations
11  * under the License.
12  * The Original Code is Openbravo ERP.
13  * The Initial Developer of the Original Code is Openbravo SL
14  * All portions are Copyright (C) 2001-2006 Openbravo SL
15  * All Rights Reserved.
16  * Contributor(s): ______________________________________.
17  ************************************************************************
18 */

19 package org.openbravo.erpCommon.businessUtility;
20
21 import org.openbravo.database.ConnectionProvider;
22 import java.io.*;
23 import javax.servlet.*;
24 import org.apache.log4j.Logger ;
25
26
27 public class Tree {
28   static Logger log4jTree = Logger.getLogger(Tree.class);
29
30   public static String JavaDoc getMembers (ConnectionProvider conn, String JavaDoc treeId, String JavaDoc parentNodeId) throws IOException,ServletException {
31     log4jTree.debug("Tree.getMembers");
32     TreeData[] data = TreeData.select(conn, treeId, parentNodeId);
33
34     boolean bolFirstLine = true;
35     String JavaDoc strText = "";
36     for (int i = 0; i < data.length; i++) {
37       if (bolFirstLine){
38         bolFirstLine = false;
39         strText = data[i].id;
40       }
41       else{
42         strText = data[i].id + "," + strText ;
43       }
44     }
45     return strText;
46   }
47
48     public static String JavaDoc getTreeOrgs (ConnectionProvider conn, String JavaDoc client) throws IOException,ServletException {
49     log4jTree.debug("Tree.getTreeOrg");
50     TreeData[] data = TreeData.getTreeOrgs(conn, client);
51
52     boolean bolFirstLine = true;
53     String JavaDoc strText = "";
54     for (int i = 0; i < data.length; i++) {
55       if (bolFirstLine){
56         bolFirstLine = false;
57         strText = data[i].id;
58       }
59       else{
60         strText = data[i].id + "," + strText ;
61       }
62     }
63     return strText;
64   }
65
66     public static String JavaDoc getTreeAccounts (ConnectionProvider conn, String JavaDoc client) throws IOException,ServletException {
67     log4jTree.debug("Tree.getTreeOrg");
68     TreeData[] data = TreeData.getTreeAccounts(conn, client);
69
70     boolean bolFirstLine = true;
71     String JavaDoc strText = "";
72     for (int i = 0; i < data.length; i++) {
73       if (bolFirstLine){
74         bolFirstLine = false;
75         strText = data[i].id;
76       }
77       else{
78         strText = data[i].id + "," + strText ;
79       }
80     }
81     return strText;
82   }
83 }
84
Popular Tags