use of com.remswork.project.alice.model.Term in project classify-system by anverliedoit.
the class TermResource method getTermById.
@GET
@Path("{termId}")
public Response getTermById(@PathParam("termId") long id) {
try {
TermResourceLinks resourceLinks = new TermResourceLinks(uriInfo);
Term term = termService.getTermById(id);
term.addLink(resourceLinks.self(id));
return Response.status(Response.Status.OK).entity(term).build();
} catch (GradingFactorException e) {
e.printStackTrace();
Message message = new Message(404, "Not Found", e.getMessage());
return Response.status(Response.Status.NOT_FOUND).entity(message).build();
}
}
use of com.remswork.project.alice.model.Term in project classify-system by anverliedoit.
the class FormulaDaoImpl method updateFormulaById.
@Override
public Formula updateFormulaById(long id, Formula newFormula, long subjectId, long teacherId, long termId) throws GradingFactorException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Formula formula = session.get(Formula.class, id);
Subject subject = session.get(Subject.class, subjectId);
Teacher teacher = session.get(Teacher.class, teacherId);
Term term = session.get(Term.class, termId);
if (newFormula == null)
newFormula = new Formula();
if (formula == null)
throw new GradingFactorDaoException("Formula with id : " + id + " does not exist");
if (subject == null && subjectId != 0)
throw new GradingFactorDaoException("Factor's subject with id : " + subjectId + " does not exist");
if (teacher == null && teacherId != 0)
throw new GradingFactorDaoException("Factor's teacher with id : " + teacherId + " does not exist");
if (term == null && termId != 0)
throw new GradingFactorDaoException("Factor's term with id : " + termId + " does not exist");
formula.setActivityPercentage(newFormula.getActivityPercentage());
formula.setAssignmentPercentage(newFormula.getAssignmentPercentage());
formula.setAttendancePercentage(newFormula.getAttendancePercentage());
formula.setExamPercentage(newFormula.getExamPercentage());
formula.setProjectPercentage(newFormula.getProjectPercentage());
formula.setQuizPercentage(newFormula.getQuizPercentage());
formula.setRecitationPercentage(newFormula.getRecitationPercentage());
if (subjectId > 0) {
if (subjectId == (formula.getSubject() != null ? formula.getSubject().getId() : 0))
throw new GradingFactorException("Formula's subject with id : " + subjectId + " already exist");
formula.setSubject(subject);
}
if (teacherId > 0) {
if (teacherId == (formula.getTeacher() != null ? formula.getTeacher().getId() : 0))
throw new GradingFactorException("Formula's teacher with id : " + teacherId + " already exist");
formula.setTeacher(teacher);
}
if (termId > 0) {
if (termId == (formula.getTerm() != null ? formula.getTerm().getId() : 0))
throw new GradingFactorException("Formula's term with id : " + termId + " already exist");
formula.setTerm(term);
}
session.getTransaction().commit();
session.close();
return formula;
} catch (GradingFactorDaoException e) {
session.close();
throw new GradingFactorException(e.getMessage());
}
}
Aggregations