/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

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

package org.bodington.server;


import org.bodington.database.*;
import org.bodington.text.*;

import java.util.Enumeration;

public class JobResult extends org.bodington.sqldatabase.SqlPersistentObject
    {
    public static final int RESULT_INCOMPLETE     = 0;
    public static final int RESULT_OK		  = 1;
    public static final int RESULT_ERROR       	  = 2;
        
    PrimaryKey job_result_id;
    PrimaryKey job_id;
    PrimaryKey big_string_id;
    int result_code;
    java.sql.Timestamp execution_time;
        
    public static JobResult findJobResult( PrimaryKey key )
	throws BuildingServerException
	{
	return (JobResult)findPersistentObject( key, "org.bodington.server.JobResult" );
	}

    public static JobResult findJobResult( String where )
	throws BuildingServerException
	{
	return (JobResult)findPersistentObject( where, "org.bodington.server.JobResult" );
	}

    public static Enumeration findJobResults( String where )
	throws BuildingServerException
	{
	return findPersistentObjects( where, "org.bodington.server.JobResult" );
	}

    public static Enumeration findJobResults( String where, String order )
	throws BuildingServerException
	{
	return findPersistentObjects( where, order, "org.bodington.server.JobResult" );
	}

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

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

    public PrimaryKey getJobResultId()
        {
        return job_result_id;
        }
         
    public void setJobResultId( PrimaryKey key )
        {
        job_result_id = key;
        }
        
    
    public PrimaryKey getJobId()
        {
        return job_id;
        }
         
    public void setJobId( PrimaryKey key )
        {
        job_id = key;
        }
        
    
    public PrimaryKey getBigStringId()
        {
        return big_string_id;
        }
         
    public void setBigStringId( PrimaryKey key )
        {
        big_string_id = key;
        setUnsaved();
        }
        
    public BigString getBigString()
	throws BuildingServerException
	{
	if ( big_string_id == null ) return null;
	return BigString.findBigString( big_string_id );
	}

    public String getString()
	throws BuildingServerException
	{
	BigString bstr = getBigString();
	if ( bstr == null )
	    return null;
	return bstr.getString();
	}
	
    public int getResultCode()
        {
        return result_code;
        }
         
    public void setResultCode( int n )
        {
        result_code = n;
        setUnsaved();
        }
        
        
    public java.sql.Timestamp getExecutionTime()
	{
	return execution_time;
	}
    public void setExecutionTime( java.sql.Timestamp t )
	{
	execution_time = t;
	setUnsaved();
	}

    }
    
