FileDocCategorySizeDatePackage
ResAssignment.javaAPI DocExample2039Tue Jan 20 21:59:04 GMT 1998dcj.examples.dbase

ResAssignment

public class ResAssignment extends DatabaseItem
Source code from "Java Distributed Computing", by Jim Farley. Class: ResAssignment Example: 7-6 Description: Data pertaining to an assignment of a task to a resource.

Fields Summary
int
rid
int
tid
Date
timestamp
Constructors Summary
ResAssignment(int res, int task, Date time, boolean insert)

    rid = res;
    tid = task;
    timestamp = time;

    if (insert) {
      // Create a new record in the database.
      try {
        Statement s = DatabaseItem.dbConn.createStatement();
        int numr = s.executeUpdate("INSERT INTO res_assignment "
                     + " (resource, task, time) VALUES ("
                     + rid + ", " + tid + ", " + time + ")");
        if (numr != 1)
          valid = false;
        else
          valid = true;
      }
      catch (SQLException e) {
        valid = false;
      }
    }
  
Methods Summary
public static java.util.VectorassignmentsFor(int rid)

    Vector ras = new Vector();

    try {
      Statement s = DatabaseItem.dbConn.createStatement();
      ResultSet r = s.executeQuery("SELECT task, time FROM "
                                   + "res_assignment where resource = "
                                   + rid);
      while (r.next()) {
        int tid = r.getInt("task");
        Date time = r.getDate("time");
        ResAssignment ra = new ResAssignment(rid, tid, time,
                                             false);
        ras.addElement(ra);
      }
    }
    catch (Exception e) {}

    return ras;
  
public intgetResourceId()

 return rid; 
public intgetTaskId()

 return tid; 
public java.util.DategetTimeStamp()

 return timestamp; 
public booleanupdateFromDbase()

 return false; 
public booleanupdateToDbase()

 return false;