-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6718e1
commit d4625ae
Showing
5 changed files
with
167 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import java.util.ArrayList; | ||
|
||
|
||
public interface SchedulerPull { | ||
|
||
public ArrayList<String> PullMajors(); | ||
|
||
public ArrayList<String> PullConcentrations(String MajorCode); | ||
|
||
public ArrayList<Schedule> PullSchedule(Term termName, SessionInfo userSession); | ||
|
||
public void filterConflicts(SessionInfo userSession); | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.StringTokenizer; | ||
|
||
|
||
public class mysqlDBExecute { | ||
|
||
public static ArrayList<String> PullMajors(){ | ||
ArrayList<String> majors = new ArrayList<String>(); | ||
|
||
ArrayList<ArrayList<String>> records = mysqlStatement.startConnection("Select distinct `Subject`", "schedule", ""); | ||
|
||
for( ArrayList<String> currentMajor : records){ | ||
majors.add(currentMajor.toString()); | ||
} | ||
|
||
return majors; | ||
} | ||
|
||
public static ArrayList<String> PullConcentrations(String MajorCode){ | ||
ArrayList<String> concentrations = new ArrayList<String>(); | ||
String table="track"; | ||
String fields="track_name"; | ||
|
||
ArrayList<ArrayList<String>> records = mysqlStatement.startConnection("Select `track_name`", "track", ""); | ||
|
||
for( ArrayList<String> thisTrack : records){ | ||
concentrations.add(thisTrack.toString()); | ||
} | ||
|
||
return concentrations; | ||
} | ||
|
||
public static ArrayList<Schedule> PullSchedule(Term termName, SessionInfo userSession){ | ||
|
||
ArrayList<Schedule> scheduleCollection = new ArrayList<Schedule>(); | ||
|
||
// based off termName | ||
|
||
String constraints = "where `Term` = \"" + termName + "\""; | ||
|
||
ArrayList<ArrayList<String>> records = mysqlStatement.startConnection("SELECT *", "schedule", constraints); | ||
|
||
for( ArrayList<String> thisSchedule : records){ | ||
|
||
Schedule thisCourse = new Schedule(); | ||
|
||
thisCourse.CRN = Integer.parseInt(thisSchedule.get(0)); | ||
thisCourse.Subject = thisSchedule.get(1); | ||
thisCourse.Course_no = Integer.parseInt(thisSchedule.get(2)); | ||
thisCourse.Term = thisSchedule.get(3); | ||
thisCourse.Section = Integer.parseInt(thisSchedule.get(4)); | ||
thisCourse.Instruction_type = thisSchedule.get(5); | ||
thisCourse.Instructor = thisSchedule.get(6); | ||
thisCourse.Location = thisSchedule.get(7); | ||
thisCourse.Weekday = thisSchedule.get(8); | ||
thisCourse.Start_time = thisSchedule.get(9); | ||
thisCourse.End_time =thisSchedule.get(10); | ||
//thisCourse.CourseName = 11 | ||
|
||
|
||
// Special treatment for the time slot information | ||
String timeSlots = thisSchedule.get(12); | ||
StringTokenizer stArr = new StringTokenizer(timeSlots, ", "); | ||
ArrayList<Integer> timeIndices = new ArrayList<Integer>(); | ||
while(stArr.hasMoreTokens()){ | ||
timeIndices.add(Integer.parseInt(stArr.nextToken())); | ||
} | ||
thisCourse.Times = timeIndices; | ||
|
||
|
||
//List<String> timeIndexes = Arrays.asList(slotsTaken); | ||
//thisCourse.Times = | ||
|
||
scheduleCollection.add(thisCourse); | ||
|
||
} | ||
|
||
|
||
|
||
return scheduleCollection; | ||
|
||
} | ||
|
||
public void filterConflicts(SessionInfo userSession){ | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
import java.sql.*; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.StringTokenizer; | ||
|
||
/** | ||
* Author: Kevin Huang | ||
* Date: 3/17/13 , 6:23 PM | ||
* Copyright Reserved 2013 | ||
*/ | ||
public class mysqlStatement { | ||
protected static ArrayList<ArrayList<String >> startConnection(String queryStatement,String DBTable, String queryContraints) | ||
{ | ||
Connection conn = null; | ||
|
||
|
||
dbcredential database = new dbcredential(); | ||
|
||
|
||
String url = database.getOst(); | ||
String dbName = database.getDbname(); | ||
String driver = database.getDbdriver(); | ||
String userName = database.getDbname(); | ||
String password = database.getDbpass(); | ||
|
||
ArrayList<ArrayList<String >> recordSet = new ArrayList<ArrayList<String >>(); | ||
|
||
try { | ||
Class.forName(driver).newInstance(); | ||
conn = DriverManager.getConnection(url+dbName,userName,password); | ||
|
||
Statement statementSQL = conn.createStatement(); | ||
statementSQL.execute(queryStatement + " FROM " + DBTable + " " + queryContraints); | ||
ResultSet rs = statementSQL.getResultSet(); | ||
|
||
while (rs.next()) { | ||
Integer i ; | ||
ArrayList<String> oneRow = new ArrayList<String>(); | ||
for( i = 1 ; i <= rs.getMetaData().getColumnCount(); i++){ | ||
oneRow.add(rs.getString(i)); | ||
} | ||
recordSet.add(oneRow); | ||
|
||
} | ||
|
||
conn.close(); | ||
return recordSet; | ||
} catch (Exception e) { | ||
System.out.println("Connection failed, check your statement!"); | ||
return null; | ||
} | ||
} | ||
|
||
} |