Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javadoc comments #3 #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ResourcePathProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.txstate.auto_scheduler;
/**
* ResourcePathProvider.java : Public Interface
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public interface ResourcePathProvider {
String getRecords();
String getClasses();
String getClassSchedule();
}
14 changes: 14 additions & 0 deletions ScheduleAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.txstate.auto_scheduler;

import java.io.FileNotFoundException;
import java.io.IOException;
/**
* ScheduleAction.java : Public interface
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public interface ScheduleAction {
ScheduleSet execute(OperationContext context) throws FileNotFoundException, java.io.IOException;;
}
20 changes: 20 additions & 0 deletions ScheduleCancelation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.txstate.auto_scheduler;

/**
* ScheduleCancelation.java : Manages if a schedual is canceled
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class ScheduleCancelation implements ScheduleAction {
ResourcePathProvider pathProvider;

public ScheduleCancelation(ResourcePathProvider pathProvider) {
this.pathProvider = pathProvider;
}
public ScheduleSet execute(OperationContext context)
{
return null;
}
}
38 changes: 38 additions & 0 deletions ScheduleDryRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.txstate.auto_scheduler;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

/**
* ScheduleDryRunner.java : Dry runner path
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class ScheduleDryRunner implements ScheduleAction {
ResourcePathProvider pathProvider;

/**
* ScheduleDryRunner() : Dry runner assignment
* @param ResourcePathProvider pathProvider
* @return N/A
*/
public ScheduleDryRunner(ResourcePathProvider pathProvider) {
this.pathProvider = pathProvider;
}

/**
* execute() : Dry runner scheduler
* @param ResourcePathProvider pathProvider
* @return ScheduleSet
*/
public ScheduleSet execute(OperationContext context) throws FileNotFoundException, IOException
{
Scheduler scheduler = new Scheduler(true, this.pathProvider);
return scheduler.execute(context);
}
}
15 changes: 15 additions & 0 deletions ScheduleSet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.txstate.auto_scheduler;

/**
* ScheduleSet.java : ScheduleSet
* @param N/A
* @return null
* @version 1.0
* @since 5-2-2019
*/
public class ScheduleSet {

String getId() {
return null;
}
}
20 changes: 20 additions & 0 deletions ScheduleShower.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.txstate.auto_scheduler;

/**
* ScheduleShower.class : class file for ScheduleAction
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class ScheduleShower implements ScheduleAction {
ResourcePathProvider pathProvider;

public ScheduleShower(ResourcePathProvider pathProvider) {
this.pathProvider = pathProvider;
}
public ScheduleSet execute(OperationContext context)
{
return null;
}
}
118 changes: 118 additions & 0 deletions Scheduler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package org.txstate.auto_scheduler;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

/**
* Scheduler.java : Will schedual students, and print grades
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class Scheduler implements ScheduleAction {
ResourcePathProvider pathProvider;
boolean readonlyMode = false;


public Scheduler(ResourcePathProvider pathProvider) {
this.pathProvider = pathProvider;
}
/**
* Scheduler() : Constructor
* @param N/A
* @return N/A
*/
public Scheduler(boolean readonlyMode, ResourcePathProvider pathProvider) {
this.pathProvider = pathProvider;
this.readonlyMode = readonlyMode;
}

/**
* execute() : gathers student data, from various functions and files
* @param StudentInfo studentInfo, String studentId
* @exception FileNotFoundException, IOException
* @return ScheduleSet
*/
public ScheduleSet execute(OperationContext context) throws FileNotFoundException, IOException
{
String studentId = context.getStudentId();
StudentInfoRepositoryImpl studentRepo = new StudentInfoRepositoryImpl(this.pathProvider);
StudentInfo studentInfo = studentRepo.getInfo(studentId);

if(studentInfo == null) {
throw new StudentNotFoundException(studentId, String.format("Student %s Not Found", studentId));
}
return implementSchedule(studentInfo, studentId);
}

/**
* implementSchedule() : implements schedular useing functions from Scheduler.java
* @param StudentInfo studentInfo, String studentId
* @exception FileNotFoundException, IOException
* @return NUll
*/
private ScheduleSet implementSchedule(
StudentInfo studentInfo,
String studentId) throws FileNotFoundException, IOException {

StudentRecordRepositoryImpl gradeRepo = new StudentRecordRepositoryImpl(this.pathProvider);
Collection<StudentRecord> records = gradeRepo.get(studentId);
printGrades(records);

DegreePlanRespositoryImpl degreePlanRespository = new DegreePlanRespositoryImpl(this.pathProvider);
Collection<CurriculumCourse> curriculumCourses = degreePlanRespository.get(studentInfo.getMajor());

printDegreePlan("Courses For Major", curriculumCourses);

CandidateCourseService candiateCourseService = new CandidateCourseServiceImpl();
Collection<CurriculumCourse> candidateCourses = candiateCourseService.buildList(records, curriculumCourses);
printDegreePlan("Candidate Courses", candidateCourses);


return null;
}

/**
* printGrades() :Prints grades to display
* @param Iterable<StudentRecord> records
* @return N/A
*/
private void printGrades(Iterable<StudentRecord> records) {
System.out.println("******Grades******");
if(records != null ) {
for(StudentRecord record: records) {
String studentId = record.getStudentId();
String courseNumber = record.getCourseCode();
CourseGrade courseGrde = record.getGrade();
System.out.format("StudnetId %s, coureNumber:%s, CourseGrade:%s\n",studentId, courseNumber, courseGrde);
}
}
System.out.println("******************");
}

/**
* printDegreePlan() : prints degree plan to display
* @param String tagName, Iterable<CurriculumCourse> majorCourses
* @return N/A
*/
private void printDegreePlan(String tagName, Iterable<CurriculumCourse> majorCourses) {
System.out.println("******"+ tagName + "******");
if(majorCourses != null ) {
for(CurriculumCourse course: majorCourses) {
String courseNumber = course.getCourseNumber();
String courseName = course.getCourseName();
String preReq = course.getPreRequisite();

System.out.format("courseNumber %s, courseName:%s, preReq:%s\n",
courseNumber,
courseName,
preReq);
}
}
System.out.println("******************");
}
}
14 changes: 14 additions & 0 deletions StudentCourseGradeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.txstate.auto_scheduler;

import java.io.FileNotFoundException;
import java.io.IOException;
/**
* StudentCourseGradeService.java : Public Interface
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public interface StudentCourseGradeService {
boolean hasCourse(String studentId,String courseCode) throws FileNotFoundException, IOException;
}
54 changes: 54 additions & 0 deletions StudentCourseGradeServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.txstate.auto_scheduler;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collection;
import java.util.Dictionary;
import java.util.Hashtable;
/**
* StudentCourseGradeService.java : Checks the history of students courses
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class StudentCourseGradeServiceImpl implements StudentCourseGradeService {
StudentRecordRepository recordRepository;

public StudentCourseGradeServiceImpl(StudentRecordRepository recordRepository) {
this.recordRepository = recordRepository;
}
/**
* hasCourse() : Checks is course had been schedualed or taken
* @param String studentId,String courseCode
* @return boolean
* @exception FileNotFoundException, IOException
*/
public boolean hasCourse(String studentId,String courseCode) throws FileNotFoundException, IOException {
Dictionary<String, StudentRecord> map = getMap(studentId);
StudentRecord studentRecord = map.get(courseCode);
if (studentRecord !=null && studentRecord.getGrade().ordinal() > CourseGrade.D.ordinal()) {
return true;
}
return false;
}
/**
* getMap() : Add grades to student records
* @param String studentId
* @return Dictionary<String, StudentRecord> map
* @exception FileNotFoundException, IOException
*/
Dictionary<String, StudentRecord> getMap(String studentId) throws FileNotFoundException, IOException {
Collection<StudentRecord> records = recordRepository.get(studentId);
Dictionary<String, StudentRecord> map = new Hashtable<String, StudentRecord>();
if(records != null) {
for(StudentRecord record : records) {
if(record != null)
//TODO; loop through and only add the highest grade achieved.
map.put(record.getCourseCode(), record);
}
}
return map;
}

}
60 changes: 60 additions & 0 deletions StudentInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.txstate.auto_scheduler;

import java.util.Date;

/**
* StudentInfo.class : Class file for StudentInfo
* @param N/A
* @return N/A
* @version 1.0
* @since 5-2-2019
*/
public class StudentInfo {

private String firstName;
private String lastName;
private Date dateOfBirth;
private String studentId;
private int year;
private String major;

public String getNameFirst() {
return this.firstName;
}
public String getLastName() {
return this.lastName;
}
public Date getDateOfBirth() {
return this.dateOfBirth;
}
public String getStudentId() {
return this.studentId;
}

public int getYear() {
return this.year;
}

public String getMajor() {
return this.major;
}

public void setNameFirst(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public void setYear(int year) {
this.year = year;
}
public void setMajor(String major) {
this.major = major;
}
}