01: /**
02: * $Id: PSFTTimeEntryUtils.java,v 1.3 2005/10/19 12:38:58 pg133018 Exp $
03: * Copyright 2004 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.psftportlet.timeentryportlet;
14:
15: import com.sun.portal.psftportlet.common.IWAYResponseParser;
16:
17: import com.sun.portal.iwayutil.connection.IWAYRequest;
18:
19: import com.sun.portal.log.common.PortalLogger;
20:
21: import java.util.ResourceBundle;
22: import java.util.Vector;
23: import java.util.logging.Logger;
24:
25: import org.jdom.Element;
26:
27: /**
28: * This class has the utility methods used by PeopleSoft Time Entry portlet.
29: *
30: * @author Pradeep Gond
31: */
32:
33: public class PSFTTimeEntryUtils {
34: private static Logger logger = PortalLogger
35: .getLogger(PSFTTimeEntryUtils.class);
36: private ResourceBundle rb;
37: private String datesTableName;
38: private String dateName;
39: private String timeReportedName;
40:
41: public PSFTTimeEntryUtils(ResourceBundle rb) {
42: this .rb = rb;
43: datesTableName = rb
44: .getString(PSFTTimeEntryConstants.DATES_TABLE_NAME);
45: dateName = rb.getString(PSFTTimeEntryConstants.DATE_NAME);
46: timeReportedName = rb
47: .getString(PSFTTimeEntryConstants.TIME_REPORTED_NAME);
48: }
49:
50: public IWAYRequest getBrowseRequest(String userID) {
51: String iwayRequest = rb
52: .getString(PSFTTimeEntryConstants.TIME_ENTRY_BROWSE);
53: iwayRequest = iwayRequest.replaceAll(
54: PSFTTimeEntryConstants.USER_ID_TAG, userID);
55: logger.info("iWayRequest =>" + iwayRequest);
56:
57: return new IWAYRequest(iwayRequest);
58: }
59:
60: public void parseData(IWAYResponseParser parser,
61: PSFTTimeEntryObject result) {
62: if (!parser.isValid()) {
63: result.setErrorMessage(parser.getErrorMessage());
64: } else {
65: // set name
66: result.setEmployeeName(parser
67: .getValue(PSFTTimeEntryConstants.NAME));
68: // set dates and timeReported
69: Vector elements = parser.getElements(datesTableName);
70: Vector dates = new Vector();
71: Vector timeReported = new Vector();
72:
73: for (int i = 0; i < elements.size(); i++) {
74: Element e = (Element) elements.get(i);
75: dates.add(e.getChild(dateName).getTextTrim());
76: timeReported.add(e.getChild(timeReportedName)
77: .getTextTrim());
78: }
79:
80: result.setDates(dates);
81: result.setTimeReported(timeReported);
82: }
83: }
84: }
|