use of com.remswork.project.alice.dao.exception.GradingFactorDaoException in project classify-system by anverliedoit.
the class ProjectDaoImpl method getProjectResultById.
@Override
public ProjectResult getProjectResultById(long id) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
ProjectResult result = session.get(ProjectResult.class, id);
if (result == null)
throw new GradingFactorDaoException("ProjectResult with id : " + id + " does not exist");
session.getTransaction().commit();
session.close();
return result;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
use of com.remswork.project.alice.dao.exception.GradingFactorDaoException in project classify-system by anverliedoit.
the class ProjectDaoImpl method deleteProjectResultByProjectAndStudentId.
@Override
public ProjectResult deleteProjectResultByProjectAndStudentId(long projectId, long studentId) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Project project = session.get(Project.class, projectId);
Student student = session.get(Student.class, studentId);
String hql = "from ProjectResult as R where R.project.id = :projectId and R.student.id = :studentId";
Query query = session.createQuery(hql);
query.setParameter("projectId", projectId);
query.setParameter("studentId", studentId);
if (project == null)
throw new GradingFactorDaoException("Project's project with id : " + projectId + " does not exist");
if (student == null)
throw new GradingFactorDaoException("Project's student with id : " + studentId + " does not exist");
if (projectId < 1)
throw new GradingFactorDaoException("Query param : projectId is required");
if (studentId < 1)
throw new GradingFactorDaoException("Query param : studentId is required");
if (query.list().size() < 1)
throw new GradingFactorDaoException("No result to delete");
ProjectResult result = (ProjectResult) query.list().get(0);
session.delete(result);
session.getTransaction().commit();
session.close();
return result;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
use of com.remswork.project.alice.dao.exception.GradingFactorDaoException in project classify-system by anverliedoit.
the class ProjectDaoImpl method getProjectById.
@Override
public Project getProjectById(long id) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Project project = session.get(Project.class, id);
if (project == null)
throw new GradingFactorDaoException("Project with id : " + id + " does not exist");
session.getTransaction().commit();
session.close();
return project;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
use of com.remswork.project.alice.dao.exception.GradingFactorDaoException in project classify-system by anverliedoit.
the class AttendanceDaoImpl method getAttendanceListByClassId.
@Override
public List<Attendance> getAttendanceListByClassId(long classId) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
List<Attendance> attendanceList = new ArrayList<>();
Query query = session.createQuery("from Attendance where _class.id = :classId");
query.setParameter("classId", classId);
for (Object objAttendance : query.list()) attendanceList.add((Attendance) objAttendance);
session.getTransaction().commit();
session.close();
return attendanceList;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
use of com.remswork.project.alice.dao.exception.GradingFactorDaoException in project classify-system by anverliedoit.
the class AttendanceDaoImpl method getAttendanceById.
@Override
public Attendance getAttendanceById(long id) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Attendance attendance = session.get(Attendance.class, id);
if (attendance == null)
throw new GradingFactorDaoException("Attendance with id : " + id + " does not exist");
session.getTransaction().commit();
session.close();
return attendance;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
Aggregations