⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usertestassocbean.java

📁 老外的在线考试
💻 JAVA
字号:
/* * SchoolEJB - CyberDemia's library of EJBs for educational related services. * Copyright (C) 2003 CyberDemia Research and Services * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. *  * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA  02111-1307, USA. * * See the COPYING file located in the top-level-directory of * the archive of this library for complete text of license. */package com.cyberdemia.school;import javax.ejb.*;import java.util.Date;import com.cyberdemia.ejb.BaseEntityBean;/** * UserTestAssocBean represents a Test that is assigned to a User * and records a score for a user for a test, etc. * * @ejb.bean name="UserTestAssocBean" *           type="CMP" *           view-type="local" *           schema="UserTestAssoc" *           cmp-version="2.x" *           local-jndi-name="ejb/LocalUserTestAssoc" * * @ejb.util generate="physical" * @ejb.interface local-class="com.cyberdemia.school.LocalUserTestAssoc" local-extends="javax.ejb.EJBLocalObject" * @ejb.home local-class="com.cyberdemia.school.LocalUserTestAssocHome" local-extends="javax.ejb.EJBLocalHome" * @ejb.pk class="com.cyberdemia.school.UserTestAssocKey" extends="java.lang.Object" * @ejb.persistence table-name="UserTestAssoc" * * @ejb.finder signature="java.util.Collection findByUser(java.lang.Integer userId)" *             query="SELECT DISTINCT OBJECT(a) FROM UserTestAssoc a WHERE a.userId=?1" * * @ejb.finder signature="java.util.Collection findByNotUser(java.lang.Integer userId)" *             query="SELECT DISTINCT OBJECT(a) FROM UserTestAssoc a WHERE a.userId <> ?1" * * @ejb.finder signature="java.util.Collection findByTest(java.lang.Integer testId)" *             query="SELECT DISTINCT OBJECT(a) FROM UserTestAssoc a WHERE a.testId=?1" * * @ejb.finder signature="java.util.Collection findByUserAndTest(java.lang.Integer userId, java.lang.Integer testId)" *             query="SELECT DISTINCT OBJECT(a) FROM UserTestAssoc a WHERE a.userId=?1 AND a.testId=?2" * * @jboss.method-attributes pattern="get*" read-only="true" * @jboss.method-attributes pattern="is*" read-only="true" * @jboss.container-configuration name="CyberDemia Optimized Standalone CMP" * * @author Alexander Yap * @version $Revision: 1.6 $ at $Date: 2004/06/26 17:08:39 $ by $Author: alexycyap $ */public abstract class UserTestAssocBean extends BaseEntityBean{	/**	* Gets the User ID of this association.	*	* @ejb.persistence	* @ejb.pk-field	* @ejb.interface-method	*	* @return User ID.	*/	public abstract Integer getUserId();	/**	* Sets the User ID of this association.	*	* @ejb.interface-method	*	* @param userId User ID of this association.	*/	public abstract void setUserId(Integer userId);	/**	* Gets the Test ID that is assigned to the User.	*	* @ejb.persistence	* @ejb.pk-field	* @ejb.interface-method	*	* @return Test ID.	*/	public abstract Integer getTestId();	/**	* Sets the Test ID that is assigned to the User.	*	* @ejb.interface-method	*	* @param testId Test ID that is assigned to the User.	*/	public abstract void setTestId(Integer testId);	/**	* Gets the current score as an int.	*	* @ejb.persistence	* @ejb.interface-method	*	* @return Current score	*/	public abstract int getScore();	/**	* Sets the current score as an int.	*	* @ejb.interface-method	*	* @param val Current score	*/	public abstract void setScore(int val);		/**	 * Gets the exceeded test time flag.	 *	 * @ejb.persistence	 * @ejb.interface-method	 *	 * @return true if this test's time limit has been exceeded.	 */	public abstract boolean getExceededTestTime();	/**	 * Sets the exceeded test time flag.	 *	 * @ejb.interface-method	 *	 * @param exceeded true if this test's time limit has been exceeded.	 */	public abstract void setExceededTestTime(boolean exceeded);	/**	 * Gets the maximum score as an int.	 * This is the maximum value that score can be.	 *	 * @ejb.persistence	 * @ejb.interface-method	 *	 * @return Maximum score	 */	public abstract int getMaxScore();	/**	* Sets the maximum score as an int.	*	* @ejb.interface-method	*	* @param val Maximum score	*/	public abstract void setMaxScore(int val);	/**	 * Gets the last modified datetime in milliseconds.	 *	 * @ejb.persistence	 * @ejb.interface-method	 *	 * @return Date in milliseconds when this association was last modified/updated.	 */	public abstract long getLastModifiedMillis();		/**	 * Sets the last modified datetime in milliseconds.	 *	 * @ejb.interface-method	 *	 * @param millis Date in milliseconds when this association was last modified/updated.	 */	public abstract void setLastModifiedMillis(long millis);			/**	 * Checks whether this user has already completed this test.	 * If this returns false, it may mean that either the user has never taken this test or	 * if the test was taken but terminated before completion (e.g. a system error).	 *	 * @ejb.interface-method	 * @ejb.persistence	 *	 * @return true if this user has completed this test, otherwise false.  	 */	public abstract boolean getTestCompleted();		/**	 * Sets whether this user has already completed this test.	 *	 * @ejb.interface-method	 *	 * @param completed true if this user has completed this test, otherwise false.  	 */	public abstract void setTestCompleted(boolean completed);		/**	 * Gets the last modified datetime.	 *	 * @ejb.interface-method	 *	 * @return Date when this association was last modified/updated.	 */	public Date getLastModifiedDateTime()	{		return new Date(getLastModifiedMillis());		}	/**	 * Sets the last modified datetime.	 *	 * @ejb.interface-method	 *	 * @param dt Date when this association was last modified/updated.	 */	public void setLastModifiedDateTime(Date dt)	{		setLastModifiedMillis(dt.getTime());		}	/**	* Adds value and the maximum value to score.	*	* @ejb.interface-method	*	* @param val Value to add.	* @param maxVal The maximum value that val can be.	* @return New score.	*/	public int addScore(int val, int maxVal)	{		int newVal = getScore() + Math.min(val,maxVal);		int newMaxVal = getMaxScore() + maxVal;		setScore( newVal );		setMaxScore(newMaxVal);		setLastModifiedDateTime( new Date());		return newVal;	}	/**	 * Mark that the user has exceeded the time limit for this test.	 * Once marked as true, it cannot be unmarked.	 *	 * @ejb.interface-method	 *	 */	public void exceededTestTime()	{		setExceededTestTime(true);	}		/**	 * Checks if the user has exceeded the time limit for this test.	 *	 * @ejb.interface-method	 *	 * @return true if this test's time limit has been exceeded.	 */	public boolean isExceededTestTime()	{		return getExceededTestTime();	}	/**	 * Checks whether this user has already completed this test.	 * If this returns false, it may mean that either the user has never taken this test or	 * if the test was taken but terminated before completion (e.g. a system error).	 *	 * @ejb.interface-method	 *	 * @return true if this user has completed this test, otherwise false.  	 */	public boolean isTestCompleted()	{		return getTestCompleted();	}		//-----------------------------	// Create methods.	//-----------------------------	/**	* Creates a UserTestAssoc.	*	* @ejb.create-method view-type="local"	*/	public UserTestAssocKey ejbCreate( Integer testId, Integer userId) throws CreateException	{		setUserId(userId);		setTestId(testId);		setScore(0);		setMaxScore(0);		setLastModifiedDateTime( new Date());		setExceededTestTime(false);		setTestCompleted(false);		return null;	}	public void ejbPostCreate( Integer testId, Integer userId )	{        // Nothing here	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -