/** * Copyright © 2001, 2002 The JA-SIG Collaborative. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the JA-SIG Collaborative * (http://www.jasig.org/)." * * THIS SOFTWARE IS PROVIDED BY THE JA-SIG COLLABORATIVE "AS IS" AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JA-SIG COLLABORATIVE OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ package org.jasig.portal; import java.sql.Date; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jasig.portal.utils.IPortalDocument; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Describes channel user statistics. * @author rtwigg@uccs.edu */ public class ChannelUser { private static final Log log = LogFactory.getLog(ChannelUser.class); private static long zeroSeconds = 0; private int chanId; private String userName; private Date dateAdded; private Date dateInstantiated; private int totInstantiated; private Date dateTargeted; private int totTargeted; /** * Constructs a channel user . * @param chanId the channel ID * @param userName the user name */ public ChannelUser(int chanId, String userName) { this.chanId = chanId; this.userName = userName; this.dateAdded = new Date(zeroSeconds); this.dateInstantiated = new Date(zeroSeconds); this.totInstantiated = 0; this.dateTargeted = new Date(zeroSeconds);; this.totTargeted = 0; } // Accessor methods public int getChanId() { return chanId; } public String getUserName() { return userName; } public Date getDateAdded () { return dateAdded; } public Date getDateTargeted () { return dateTargeted; } public int getTotTargeted () { return totTargeted; } public Date getDateInstantiated () { return dateInstantiated; } public int getTotInstantiated () { return totInstantiated; } // Modifier methods public void setUserName(String userName) { this.userName=userName; } public void setDateAdded (Date addDate) { this.dateAdded = addDate; } public void setDateTargeted (Date targetDate) { this.dateTargeted = targetDate; } public void incTotTargeted () { this.totTargeted++; } public void setTotTargeted (int totTargeted) { this.totTargeted = totTargeted; } public void setDateInstantiated (Date instantiateDate) { this.dateInstantiated = instantiateDate; } public void incTotInstantiated () { this.totInstantiated++; } public void setTotInstantiated (int totInstantiated) { this.totInstantiated = totInstantiated; } /** * Return an xml representation of this channel user statistics */ public Element getDocument(Document doc) { Element channelUser = doc.createElement("channelUser"); channelUser.setAttribute("chanID", chanId + ""); channelUser.setAttribute("userName", userName + ""); channelUser.setAttribute("dateAdded", dateAdded + ""); channelUser.setAttribute("dateInstantiated", dateInstantiated + ""); channelUser.setAttribute("totInstantiated", totInstantiated + ""); channelUser.setAttribute("dateTargeted", dateTargeted + ""); channelUser.setAttribute("totTargeted", totTargeted + ""); return channelUser; } }