001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package com.sourcetap.sfa.ui;
018:
019: import org.ofbiz.entity.*;
020:
021: import java.util.*;
022:
023: /**
024: * DOCUMENT ME!
025: *
026: */
027: public class ContactTreeNode extends BasicTreeNode {
028: public ContactTreeNode() {
029: super ();
030: }
031:
032: public ContactTreeNode(Object userObject) {
033: super (userObject);
034: }
035:
036: /**
037: * DOCUMENT ME!
038: *
039: * @param delegator
040: * @param accountId
041: *
042: * @return
043: *
044: * @throws GenericEntityException
045: * @throws ClassNotFoundException
046: * @throws LinkageError
047: * @throws ExceptionInInitializerError
048: * @throws InstantiationException
049: * @throws IllegalAccessException
050: */
051: public static BasicTreeNode createTree(GenericDelegator delegator,
052: String accountId) throws GenericEntityException,
053: ClassNotFoundException, LinkageError,
054: ExceptionInInitializerError, InstantiationException,
055: IllegalAccessException {
056: ArrayList orderBy = new ArrayList();
057: orderBy.add("reportsTo");
058:
059: HashMap acctMap = new HashMap();
060: acctMap.put("accountId", accountId);
061:
062: List rows = delegator.findByLike("Contact", acctMap, orderBy);
063: GenericValue[] genericValue = (GenericValue[]) rows
064: .toArray(new GenericValue[0]);
065:
066: return createTree(genericValue, "contactId", "reportsTo",
067: "com.sourcetap.sfa.ui.ContactTreeNode");
068: }
069:
070: /**
071: * DOCUMENT ME!
072: *
073: * @return
074: */
075: public String getDisplayText() {
076: Object o = getUserObject();
077:
078: String name = "";
079: String title = "";
080:
081: if (o instanceof String) {
082: name = (String) o;
083:
084: if (name.equals("PLACEHOLDER")) {
085: name = "";
086: }
087: } else if (o instanceof GenericValue) {
088: GenericValue gv = (GenericValue) o;
089: name = (String) gv.get("firstName") + " "
090: + gv.get("lastName");
091: title = (String) gv.get("title");
092: }
093:
094: String html = "<font color=#003399><b><center>" + name
095: + "</center></b>\n";
096: html += ("<br><center>" + title + "\n");
097:
098: // html += "<br><div align=right><a href=\"viewdeptinfo.php?deptid=$deptid1\"><img src=\"./info.gif\" alt=\"View Department Information\" width=\"17\" height=\"17\" border=0></a></div>\n";
099: return html;
100: }
101: }
|