ResAssignmentpublic 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.Vector | assignmentsFor(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 int | getResourceId() return rid;
| public int | getTaskId() return tid;
| public java.util.Date | getTimeStamp() return timestamp;
| public boolean | updateFromDbase() return false;
| public boolean | updateToDbase() return false;
|
|