FileDocCategorySizeDatePackage
TimeConstraint.javaAPI DocExample2236Tue Jan 20 21:58:00 GMT 1998dcj.examples.dbase

TimeConstraint

public class TimeConstraint extends DatabaseItem
Source code from "Java Distributed Computing", by Jim Farley. Class: TimeConstraint Example: 7-5 Description: Data pertaining to a temporal constraint between two tasks.

Fields Summary
int
ctype
int
task1
int
task2
Constructors Summary
public TimeConstraint(int type, int tid1, int tid2, boolean insert)

    ctype = type;
    task1 = tid1;
    task2 = tid2;

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

    Vector constraints = new Vector();

    try {
      Statement s = DatabaseItem.dbConn.createStatement();
      ResultSet r = s.executeQuery("SELECT task1, task2, type FROM "
                                   + "time_constraint where task1 = "
                                   + tid + " or task2 = " + tid);
      while (r.next()) {
        int tid1 = r.getInt("task1");
        int tid2 = r.getInt("task2");
        int type = r.getInt("type");
        TimeConstraint c = new TimeConstraint(type, tid1, tid2,
                                              false);
        constraints.addElement(c);
      }
    }
    catch (Exception e) {}

    return constraints;
  
public intgetTask1Id()

 return task1; 
public intgetTask2Id()

 return task2; 
public intgetType()

 return ctype; 
public booleanupdateFromDbase()

 return false; 
public booleanupdateToDbase()

 return false;