use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class StudentController method getStudentAndView.
@RequestMapping(value = "view", method = RequestMethod.GET)
public String getStudentAndView(@RequestParam("id") long id, ModelMap modelMap) {
try {
Student student = studentService.getStudentById(id);
modelMap.put("student", student);
return "student-view";
} catch (StudentException e) {
e.printStackTrace();
return "error";
}
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class StudentController method updateStudentById.
@RequestMapping(value = "update", method = RequestMethod.POST)
public String updateStudentById(@RequestParam("id") long id, @RequestParam("studentNumber") long studentNumber, @RequestParam("firstName") String firstName, @RequestParam("middleName") String middleName, @RequestParam("lastName") String lastName, @RequestParam("gender") String gender, @RequestParam("age") int age, @RequestParam("sectionId") long sectionId, ModelMap modelMap) {
try {
Student newStudent = new Student(studentNumber, firstName, lastName, middleName, gender, age, "");
try {
studentService.updateStudentById(id, newStudent, sectionId);
} catch (StudentException e) {
try {
e.printStackTrace();
sectionId = 0;
studentService.updateStudentById(id, newStudent, sectionId);
} catch (StudentException e2) {
e2.printStackTrace();
}
}
List<Student> studentList = studentService.getStudentList();
List<Section> sectionList = sectionService.getSectionList();
modelMap.put("studentList", studentList);
modelMap.put("sectionList", sectionList);
return "student";
} catch (StudentException | SectionException e) {
e.printStackTrace();
return "error";
}
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ClassServiceImpl method addStudentById.
@Override
public Student addStudentById(long classId, long studentId) throws ClassException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(classId);
uri.append("/");
uri.append("student");
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.queryParam("studentId", studentId).request(MediaType.APPLICATION_JSON);
Response response = builder.post(Entity.xml(new Student()));
if (response.getStatus() == 200) {
return (Student) response.readEntity(Student.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new ClassServiceException(message.getMessage());
} else
throw new ClassServiceException("The request might invalid or server is down");
} catch (ClassServiceException e) {
throw new ClassException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class ClassServiceImpl method getStudentList.
@Override
public Set<Student> getStudentList(long classId) throws ClassException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(classId);
uri.append("/");
uri.append("student");
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Response response = target.request().get();
if (response.getStatus() == 200) {
return (Set<Student>) response.readEntity(new GenericType<Set<Student>>() {
});
} else if (response.getStatus() == 404) {
Message message = (Message) response.readEntity(Message.class);
throw new ClassServiceException(message.getMessage());
} else
throw new ClassServiceException("The request might invalid or server is down");
} catch (ClassServiceException e) {
throw new ClassException(e.getMessage());
}
}
use of com.remswork.project.alice.model.Student in project classify-system by anverliedoit.
the class StudentServiceImpl method getStudentById.
@Override
public Student getStudentById(long id) throws StudentException {
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 (Student) response.readEntity(Student.class);
} else if (response.getStatus() == 404) {
Message message = (Message) response.readEntity(Message.class);
throw new StudentServiceException(message.getMessage());
} else
throw new StudentServiceException("The request might invalid or server is down");
} catch (StudentServiceException e) {
throw new StudentException(e.getMessage());
}
}
Aggregations