/* ======================================================================
The Bodington System Software License, Version 1.0
  
Copyright (c) 2001 The University of Leeds.  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.  The end-user documentation included with the redistribution, if any,
must include the following acknowledgement:  "This product includes
software developed by the University of Leeds
(http://www.bodington.org/)."  Alternately, this acknowledgement may
appear in the software itself, if and wherever such third-party
acknowledgements normally appear.

4.  The names "Bodington", "Nathan Bodington", "Bodington System",
"Bodington Open Source Project", and "The University of Leeds" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
d.gardner@leeds.ac.uk.

5.  The name "Bodington" may not appear in the name of products derived
from this software without prior written permission of the University of
Leeds.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  TITLE,  THE IMPLIED WARRANTIES 
OF QUALITY  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO 
EVENT SHALL THE UNIVERSITY OF LEEDS 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.
=========================================================

This software was originally created by the University of Leeds and may contain voluntary 
contributions from others.  For more information on the Bodington Open Source Project, please 
see http://bodington.org/

====================================================================== */

package org.bodington.assessment;

import java.util.Enumeration;

import org.bodington.sqldatabase.*;
import org.bodington.database.*;
import org.bodington.server.BuildingServerException;
import org.bodington.text.BigString;


public class TextQResponse extends org.bodington.sqldatabase.SqlPersistentObject
	{
	private PrimaryKey textq_response_id;
	private PrimaryKey textq_result_id;
	private PrimaryKey text_question_id;
	private PrimaryKey response_big_string_id;
	private PrimaryKey feedback_big_string_id;
	private Integer mark;
	
	
	public static TextQResponse findTextQResponse( PrimaryKey key )
	    throws BuildingServerException
	    {
	    return (TextQResponse)findPersistentObject( key, "org.bodington.server.assessment.TextQResponse" );
	    }
	
	public static TextQResponse findTextQResponse( String where )
	    throws BuildingServerException
	    {
	    return (TextQResponse)findPersistentObject( where, "org.bodington.assessment.TextQResponse" );
	    }
	
	public static Enumeration findTextQResponses( String where )
	    throws BuildingServerException
	    {
	    return findPersistentObjects( where, "org.bodington.assessment.TextQResponse" );
	    }
	
	public static Enumeration findTextQResponses( String where, String order )
	    throws BuildingServerException
	    {
	    return findPersistentObjects( where, order, "org.bodington.assessment.TextQResponse" );
	    }
	

	
    public PrimaryKey getPrimaryKey()
    	{
        return getTextQResponseId();
    	}

    public void setPrimaryKey(PrimaryKey key)
    	{
    	setTextQResponseId( key );
    	}

	
	public PrimaryKey getTextQResponseId()
		{
		return textq_response_id;
		}
		
	public void setTextQResponseId( PrimaryKey id )
		{
		textq_response_id = id;
		}


	public PrimaryKey getTextQResultId()
		{
		return textq_result_id;
		}
		
	public void setTextQResultId( PrimaryKey id )
		{
		textq_result_id = id;
		}


	public PrimaryKey getTextQuestionId()
		{
		return text_question_id;
		}
		
	public void setTextQuestionId( PrimaryKey id )
		{
		text_question_id = id;
		}


	public PrimaryKey getResponseBigStringId()
		{
		return response_big_string_id;
		}
		
	public void setResponseBigStringId( PrimaryKey s )
		{
		response_big_string_id = s;
		setUnsaved();
		}
		
	public String getResponse()
		throws BuildingServerException
		{
		if ( response_big_string_id == null )
			return null;
		BigString bstr = BigString.findBigString( response_big_string_id );
		if ( bstr == null )
			return null;
		return bstr.getString();
		}
		
	public void setResponse( String s )
		throws BuildingServerException
		{
		BigString bstr=null;
		if ( response_big_string_id != null )
			bstr = BigString.findBigString( response_big_string_id );
		if ( bstr == null )
			{
			bstr = new BigString();
			bstr.setString( s );
			bstr.save();
			response_big_string_id = bstr.getBigStringId();
			setUnsaved();
			return;
			}

		bstr.setString( s );
		bstr.save();
		}
	
		

	public PrimaryKey getFeedbackBigStringId()
		{
		return feedback_big_string_id;
		}
		
	public void setFeedbackBigStringId( PrimaryKey s )
		{
		feedback_big_string_id = s;
		setUnsaved();
		}

	public String getFeedback()
		throws BuildingServerException
		{
		if ( feedback_big_string_id == null )
			return null;
		BigString bstr = BigString.findBigString( feedback_big_string_id );
		if ( bstr == null )
			return null;
		return bstr.getString();
		}
		
	public void setFeedback( String s )
		throws BuildingServerException
		{
		BigString bstr=null;
		if ( feedback_big_string_id != null )
			bstr = BigString.findBigString( feedback_big_string_id );
		if ( bstr == null )
			{
			bstr = new BigString();
			bstr.setString( s );
			bstr.save();
			feedback_big_string_id = bstr.getBigStringId();
			setUnsaved();
			return;
			}

		bstr.setString( s );
		bstr.save();
		}
	
		
		
	public Integer getMark()
		{
		return mark;
		}
		
	public void setMark( Integer i )
		{
		mark = i;
		setUnsaved();
		}
		
	}
