use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class TeacherController method getTeacherAndView.
@RequestMapping(value = "view", method = RequestMethod.GET)
public String getTeacherAndView(@RequestParam("id") long id, ModelMap modelMap) {
try {
Teacher teacher = teacherService.getTeacherById(id);
List<com.remswork.project.alice.model.Class> classList = classService.getClassListByTeacherId(id);
List<Subject> subjectList = subjectService.getSubjectListByTeacherId(id);
List<Subject> allSubject = subjectService.getSubjectList();
List<Section> sectionList = sectionService.getSectionList();
modelMap.put("teacher", teacher);
modelMap.put("cclassList", classList);
modelMap.put("subjectList", subjectList);
modelMap.put("allSubject", allSubject);
modelMap.put("sectionList", sectionList);
return "teacher-view";
} catch (TeacherException | ClassException | SubjectException | SectionException e) {
e.printStackTrace();
return "error";
}
}
use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class SectionServiceImpl method updateSectionById.
@Override
public Section updateSectionById(long id, Section newSection, long departmentId) throws SectionException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(id);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.queryParam("departmentId", departmentId).request();
builder.accept("application/json");
Response response = builder.put(Entity.json(newSection));
if (response.getStatus() == 200) {
return (Section) response.readEntity(Section.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new SectionServiceException(message.getMessage());
} else
throw new SectionServiceException("The request might invalid or server is down");
} catch (SectionServiceException e) {
throw new SectionException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class SectionServiceImpl method addSection.
@Override
public Section addSection(Section Section, long departmentId) throws SectionException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.queryParam("departmentId", departmentId).request();
builder.accept("application/json");
Response response = builder.post(Entity.json(Section));
if (response.getStatus() == 201) {
return (Section) response.readEntity(Section.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new SectionServiceException(message.getMessage());
} else
throw new SectionServiceException("The request might invalid or server is down");
} catch (SectionServiceException e) {
throw new SectionException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class SectionServiceImpl method getSectionById.
@Override
public Section getSectionById(long id) throws SectionException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(id);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Response response = target.request().get();
if (response.getStatus() == 200) {
return (Section) response.readEntity(Section.class);
} else if (response.getStatus() == 404) {
Message message = (Message) response.readEntity(Message.class);
throw new SectionServiceException(message.getMessage());
} else
throw new SectionServiceException("The request might invalid or server is down");
} catch (SectionServiceException e) {
throw new SectionException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Section in project classify-system by anverliedoit.
the class StudentResource method addStudent.
@POST
public Response addStudent(Student student) {
try {
StudentResourceLinks resourceLinks = new StudentResourceLinks(uriInfo);
SectionResourceLinks sectionResourceLinks = new SectionResourceLinks(uriInfo);
DepartmentResourceLinks departmentResourceLinks = new DepartmentResourceLinks(uriInfo);
student = studentService.addStudent(student, sectionId);
student.addLink(resourceLinks.self(student.getId()));
if (student.getSection() != null) {
Section section = student.getSection();
section.addLink(sectionResourceLinks.self(section.getId()));
if (section.getDepartment() != null)
section.getDepartment().addLink(departmentResourceLinks.self(section.getDepartment().getId()));
}
return Response.status(Response.Status.CREATED).entity(student).build();
} catch (StudentException e) {
e.printStackTrace();
Message message = new Message(400, "Bad Request", e.getMessage());
return Response.status(Response.Status.BAD_REQUEST).entity(message).build();
}
}
Aggregations