use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleResource method getScheduleList.
@GET
public Response getScheduleList() {
try {
ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
List<Schedule> scheduleList = scheduleService.getScheduleList();
for (Schedule schedule : scheduleList) schedule.addLink(resourceLinks.self(schedule.getId()));
GenericEntity<List<Schedule>> entity = new GenericEntity<List<Schedule>>(scheduleList) {
};
return Response.status(Response.Status.OK).entity(entity).build();
} catch (ScheduleException 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.Schedule in project classify-system by anverliedoit.
the class ScheduleResource method updateScheduleById.
@PUT
@Path("{scheduleId}")
public Response updateScheduleById(@PathParam("scheduleId") long id, Schedule newSchedule) {
try {
ScheduleResourceLinks resourceLinks = new ScheduleResourceLinks(uriInfo);
Schedule schedule = scheduleService.updateScheduleById(id, newSchedule);
schedule.addLink(resourceLinks.self(id));
return Response.status(Response.Status.OK).entity(schedule).build();
} catch (ScheduleException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleDaoImpl method deleteScheduleById.
@Override
public Schedule deleteScheduleById(long id) throws ScheduleException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Schedule schedule = session.get(Schedule.class, id);
if (schedule == null)
throw new ScheduleDaoException("Schedule with id : " + id + " does not exist");
Query classQuery = session.createQuery("from Class");
for (Object classObj : classQuery.list()) {
Class _class = (Class) classObj;
_class = session.get(Class.class, _class.getId());
for (Schedule s : _class.getScheduleList()) {
if (s == null)
continue;
if (s.getId() == id) {
_class.getScheduleList().remove(s);
break;
}
}
}
session.delete(schedule);
session.getTransaction().commit();
session.close();
return schedule;
} catch (ScheduleDaoException e) {
session.close();
throw new ScheduleException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleDaoImpl method getScheduleListByTeacherId.
@Override
public Set<Schedule> getScheduleListByTeacherId(long teacherId) throws ScheduleException {
Session session = sessionFactory.openSession();
session.beginTransaction();
try {
Set<Schedule> scheduleSet = new HashSet<>();
String hql = "from Class as c join c.scheduleList as s join c.teacher as t where t.id = :teacherId";
Query query = session.createQuery(hql);
query.setParameter("teacherId", teacherId);
for (Object list : query.list()) {
Object[] row = (Object[]) list;
scheduleSet.add((Schedule) row[1]);
}
session.getTransaction().commit();
session.close();
return scheduleSet;
} catch (ClassDaoException e) {
session.close();
throw new ScheduleException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ScheduleAdapter.ScheduleViewHolder holder, int position) {
Schedule schedule = scheduleList.get(position);
holder.setView(schedule, position);
}
Aggregations