org.apache.lokahi.core.api.job
Class Job

java.lang.Object
  extended by org.apache.lokahi.core.common.interfaces.RestObject
      extended by org.apache.lokahi.core.common.interfaces.TMCDao
          extended by org.apache.lokahi.core.api.job.Job
All Implemented Interfaces:
Collectable, Dao, Restable, TMCMessage

public class Job
extends TMCDao
implements TMCMessage

A Job is an action that the controller needs to instruct the agent to perform

Version:
$Id: Job.java,v 1.5 2006/03/07 20:18:52 drtobes Exp $
Author:
Stephen Toback

Constructor Summary
Job()
           
Job(int id, int poolId, java.lang.String name, java.sql.Blob result, int serverId, java.util.Date startTime, java.util.Date finishTime, int parentId, int stateId, java.lang.String options, int instanceId, int functionId)
           
Job(int parentId, State state, java.lang.String options, Hardware h, Function func, JobPool jp)
           
Job(Job parent, java.lang.String options, Hardware h, Function f, JobPool jp)
           
Job(java.lang.String options, Hardware h, Function f, JobPool jp)
           
Job(java.lang.String name, int state, java.lang.String result, java.lang.String options, java.lang.String server, java.lang.String command)
           
 
Method Summary
 java.lang.StringBuilder buildShortXMLRepresentation()
          Builds a short xml representation of this object containing name, and primary key.
 java.lang.StringBuilder buildXMLRepresention()
          Builds a xml representation of this object
 boolean equals(java.lang.Object o)
           
 Job fillObject(java.sql.ResultSet r)
          Creates the Dao from the passed resultset, internally calling the appriate constructor.
 java.lang.String generateName()
           
 Job get(int id)
           
 java.util.Date getFinishTime()
           
 Function getFunction()
           
 int getFunctionId()
           
 Hardware getHardware()
           
 int getHardwareId()
           
 Instance getInstance()
           
 int getInstanceId()
           
static Job getJob(int id)
           
static Job getJob(java.lang.String name)
           
 JobPool getJobPool()
           
static java.util.Collection<Job> getJobs()
           
static java.util.Collection<Job> getJobs(Instance i, State s)
           
static java.util.Collection<Job> getJobs(int poolId)
          Returns a collection of ints that are the ids of the jobs in the job pool.
 java.lang.String getName()
          Gets the name.
 java.lang.String getOptions()
           
 Job getParent()
           
 int getParentId()
           
 int getPk()
          Gets the primary key
 int getPoolId()
           
 java.lang.String getResult()
           
 java.util.Date getStartTime()
           
 State getState()
           
 int getStateId()
           
 int hashCode()
           
 java.lang.String receiveResponse(java.lang.String key, java.lang.String JobName, java.lang.String parentJob, int jobState, java.lang.String jobResult, java.lang.String server)
           
 java.lang.String receiveResponse(java.lang.String key, java.lang.String jobName, java.lang.String jobParent, int state, java.lang.String result, java.lang.String server, java.lang.String command, java.lang.String options, java.lang.String user)
           
 boolean send()
           
 void setFinishTime(java.util.Date finishTime)
           
 void setFunction(Function function)
           
 void setFunctionId(int id)
           
 void setHardware(Hardware hardware)
           
 void setHardwareId(int containerId)
           
 void setInstanceId(int instanceId)
           
 void setJobPool(JobPool jobPool)
           
 void setName(java.lang.String name)
           
 void setOptions(java.lang.String options)
           
 void setParent(Job parent)
           
 void setParentId(int parentId)
           
 void setPk(int pk)
           
 void setPoolId(int poolId)
           
 void setResult(java.sql.Blob content)
           
 void setResult(java.lang.String result)
           
 void setStartTime(java.util.Date startTime)
           
 void setState(State state)
           
 void setStateId(int stateId)
           
static Job store(Job j)
           
 java.lang.String toString()
           
static boolean update(Job j)
          This method stores the job into the database, so the user can keep checking his 'Recent Jobs' to see if the request is processed
 
Methods inherited from class org.apache.lokahi.core.common.interfaces.RestObject
elementBuilder, elementBuilder
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Job

public Job()

Job

public Job(int parentId,
           State state,
           java.lang.String options,
           Hardware h,
           Function func,
           JobPool jp)

Job

public Job(java.lang.String options,
           Hardware h,
           Function f,
           JobPool jp)

Job

public Job(Job parent,
           java.lang.String options,
           Hardware h,
           Function f,
           JobPool jp)

Job

public Job(java.lang.String name,
           int state,
           java.lang.String result,
           java.lang.String options,
           java.lang.String server,
           java.lang.String command)
    throws java.sql.SQLException
Throws:
java.sql.SQLException

Job

public Job(int id,
           int poolId,
           java.lang.String name,
           java.sql.Blob result,
           int serverId,
           java.util.Date startTime,
           java.util.Date finishTime,
           int parentId,
           int stateId,
           java.lang.String options,
           int instanceId,
           int functionId)
    throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getJobPool

public JobPool getJobPool()

setJobPool

public void setJobPool(JobPool jobPool)

getState

public State getState()

setState

public void setState(State state)

getHardware

public Hardware getHardware()

setHardware

public void setHardware(Hardware hardware)

getFunction

public Function getFunction()

setFunction

public void setFunction(Function function)

getParent

public Job getParent()
              throws java.sql.SQLException
Throws:
java.sql.SQLException

setParent

public void setParent(Job parent)

getPk

public int getPk()
Description copied from interface: Collectable
Gets the primary key

Specified by:
getPk in interface Collectable
Returns:
the int primary key

setPk

public void setPk(int pk)

getPoolId

public int getPoolId()

setPoolId

public void setPoolId(int poolId)

getName

public java.lang.String getName()
Description copied from interface: Collectable
Gets the name.

Specified by:
getName in interface Collectable
Returns:
the String name.

setName

public void setName(java.lang.String name)

getResult

public java.lang.String getResult()

setResult

public void setResult(java.lang.String result)

setResult

public void setResult(java.sql.Blob content)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

getHardwareId

public int getHardwareId()

setHardwareId

public void setHardwareId(int containerId)

getStartTime

public java.util.Date getStartTime()

setStartTime

public void setStartTime(java.util.Date startTime)

getFinishTime

public java.util.Date getFinishTime()

setFinishTime

public void setFinishTime(java.util.Date finishTime)

getParentId

public int getParentId()

setParentId

public void setParentId(int parentId)

getStateId

public int getStateId()

setStateId

public void setStateId(int stateId)

getOptions

public java.lang.String getOptions()

setOptions

public void setOptions(java.lang.String options)

getInstanceId

public int getInstanceId()

setInstanceId

public void setInstanceId(int instanceId)

getFunctionId

public int getFunctionId()

setFunctionId

public void setFunctionId(int id)

getInstance

public Instance getInstance()

generateName

public java.lang.String generateName()

receiveResponse

public java.lang.String receiveResponse(java.lang.String key,
                                        java.lang.String JobName,
                                        java.lang.String parentJob,
                                        int jobState,
                                        java.lang.String jobResult,
                                        java.lang.String server)

receiveResponse

public java.lang.String receiveResponse(java.lang.String key,
                                        java.lang.String jobName,
                                        java.lang.String jobParent,
                                        int state,
                                        java.lang.String result,
                                        java.lang.String server,
                                        java.lang.String command,
                                        java.lang.String options,
                                        java.lang.String user)

store

public static Job store(Job j)
                 throws java.sql.SQLException,
                        java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

update

public static boolean update(Job j)
                      throws java.sql.SQLException,
                             java.io.IOException
This method stores the job into the database, so the user can keep checking his 'Recent Jobs' to see if the request is processed

Parameters:
j - - Job to update
Throws:
java.sql.SQLException
java.io.IOException

get

public Job get(int id)
        throws java.sql.SQLException
Specified by:
get in class TMCDao
Throws:
java.sql.SQLException

getJob

public static Job getJob(int id)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

getJobs

public static java.util.Collection<Job> getJobs()
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

getJob

public static Job getJob(java.lang.String name)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

getJobs

public static java.util.Collection<Job> getJobs(Instance i,
                                                State s)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

getJobs

public static java.util.Collection<Job> getJobs(int poolId)
                                         throws java.sql.SQLException
Returns a collection of ints that are the ids of the jobs in the job pool.

Parameters:
poolId - - pool id of the jobs to look for.
Returns:
Collection of jobs
Throws:
java.sql.SQLException

fillObject

public Job fillObject(java.sql.ResultSet r)
               throws java.sql.SQLException
Description copied from interface: Dao
Creates the Dao from the passed resultset, internally calling the appriate constructor.

Specified by:
fillObject in interface Dao
Parameters:
r - the resultset from a database call, should include the entire object
Returns:
Object populated from the resultset
Throws:
java.sql.SQLException

send

public boolean send()
Specified by:
send in interface TMCMessage

buildShortXMLRepresentation

public java.lang.StringBuilder buildShortXMLRepresentation()
Description copied from interface: Restable
Builds a short xml representation of this object containing name, and primary key.

Specified by:
buildShortXMLRepresentation in interface Restable
Returns:
the xml representation

buildXMLRepresention

public java.lang.StringBuilder buildXMLRepresention()
Description copied from interface: Restable
Builds a xml representation of this object

Specified by:
buildXMLRepresention in interface Restable
Returns:
the xml representation

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object