Exemplo n.º 1
0
  public static TableModel generateTable() {
    cis406.Database db = new cis406.Database("users");
    TableModel table = null;
    Vector<String> fields = new Vector<String>();

    // Prepare the database query to be used to populate the table
    db.innerJoin("status");
    db.innerJoin("clearance");
    // Populating a map of my fields so that I can choose which columns to
    // display and what labels to display them as.
    fields.add("user_name");
    fields.add("first_name");
    fields.add("last_name");
    fields.add("failed_logon_attempts");
    // Use table.fieldname when querying multiple tables joined together
    fields.add("status.description AS user_status");
    fields.add("clearance.description AS user_type");
    try {
      // Generate the table from the query
      table = new TableModel(db.select(fields));
      table.parseData();
    } catch (Exception e) {
      System.out.println("Failed to load the internship table");
      System.out.println(e.getMessage());
    }
    return table;
  }
  public static TableModel generateStudentTable() {
    Database db = new Database("student");
    TableModel table = null;
    Vector<String> fields = new Vector<String>();

    // Prepare the database query to be used to populate the table
    db.innerJoin("major");
    db.innerJoin("minor");
    // Populating a map of my fields so that I can choose which columns to
    // display and what labels to display them as. Use null to not alias.
    fields.add("last_name AS LastName");
    fields.add("first_name as FirstName");
    fields.add("student_id AS StudentID");
    fields.add("last_update AS updated");
    // Use table.fieldname when querying multiple tables joined together
    fields.add("major.major_name AS major");
    fields.add("minor.minor_name AS minor");
    db.setOrderBy("last_name ASC");
    fields.add("graduated AS Graduated");
    try {
      // Generate the table from the query
      table = new TableModel(db.select(fields));
      table.parseData();
    } catch (Exception e) {
      System.out.println("Failed to load the student table");
      System.out.println(e.getMessage());
    }
    return table;
  }
  public static TableModel generateInternshipTable() {
    Database db = new Database("internship");
    TableModel table = null;
    Vector<String> fields = new Vector<String>();

    // Prepare the database query to be used to populate the table
    db.innerJoin("company");
    db.innerJoin("career_path");
    // Populating a map of my fields so that I can choose which columns to
    // display and what labels to display them as.
    fields.add("title");
    fields.add("post_date AS posted");
    fields.add("expiration AS expires");
    fields.add("quantity AS positions");
    // Use table.fieldname when querying multiple tables joined together
    fields.add("career_path.name AS career_path");
    fields.add("company.name AS company");
    try {
      // Generate the table from the query
      table = new TableModel(db.select(fields));
      table.parseData();
    } catch (Exception e) {
      System.out.println("Failed to load the internship table");
      System.out.println(e.getMessage());
    }
    return table;
  }
 public Boolean assignInternship() {
   java.sql.Date sqlAssignDate;
   java.sql.Date sqlSecuredDate;
   Database db = new Database("student_internship");
   db.addField("course_credit", forCredit);
   db.addField("student_id", assignedStudent.getId());
   db.addField("internship_id", assignedInternship.getId());
   db.addField("date_secured", dateSecured);
   db.addField("date_assigned", assignDate);
   try {
     if (id == 0) {
       db.insert();
     } else {
       db.update(id);
     }
     return true;
   } catch (Exception e) {
     System.out.println("Failed to save the student-internship assignment");
     System.out.println(e.getMessage());
     return false;
   }
 }