use of com.remswork.project.alice.exception.SubjectException in project classify-system by anverliedoit.
the class Teacher_Activity_Teacher_Profile method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TeacherServiceImpl teacherService = new TeacherServiceImpl();
Teacher teacher;
try {
teacher = teacherService.getTeacherById(getIntent().getExtras().getLong("teacherId"));
} catch (Exception e) {
e.printStackTrace();
teacher = new Teacher();
}
setContentView(R.layout.teacher_activity_view_teacher_profile);
txtvName = (TextView) findViewById(R.id.txtv_fullname);
txtvDept = (TextView) findViewById(R.id.txtv_dept);
buttonback = (Button) findViewById(R.id.add_backsubject);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview_view_subject);
SubjectServiceImpl subjectService = new SubjectServiceImpl();
SubjectAdapter subjectAdapter = null;
try {
subjectAdapter = new SubjectAdapter(this, subjectService.getSubjectListByTeacherId(teacher.getId()));
} catch (SubjectException e) {
e.printStackTrace();
}
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setAdapter(subjectAdapter);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
txtvName.setText(teacher.getFirstName() + " " + teacher.getMiddleName().substring(0, 1) + ". " + teacher.getLastName());
txtvDept.setText(teacher.getDepartment() != null ? teacher.getDepartment().getName() : "None");
buttonback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
finish();
}
});
}
use of com.remswork.project.alice.exception.SubjectException in project classify-system by anverliedoit.
the class Teacher_Activity_View_Subject_Datails method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.teacher_activity_view_subject_datails);
try {
subject = new SubjectServiceImpl().getSubjectById(getIntent().getExtras().getLong("subjectId"));
} catch (SubjectException e) {
e.printStackTrace();
}
textViewMidtermPercent = (TextView) findViewById(R.id.midterm_percent_sub_view);
textViewMidtermPercent = (TextView) findViewById(R.id.finals_percent_sub_view);
recyclerViewMidterm = (RecyclerView) findViewById(R.id.midterm_recycleview);
recyclerViewFinals = (RecyclerView) findViewById(R.id.finals_recycleview);
linearLayoutm = (LinearLayout) findViewById(R.id.midterm_setting);
linearLayoutf = (LinearLayout) findViewById(R.id.finals_setting);
name = (TextView) findViewById(R.id.a_class_f_view_subject_name);
code = (TextView) findViewById(R.id.a_class_f_view_subject_code);
desc = (TextView) findViewById(R.id.a_class_f_view_subject_desc);
unit = (TextView) findViewById(R.id.a_class_f_view_subject_unit);
toggleButtonM = (ToggleButton) findViewById(R.id.toggle_midview);
toggleButtonF = (ToggleButton) findViewById(R.id.toggle_finview);
recyclerViewMidterm.setVisibility(View.GONE);
recyclerViewFinals.setVisibility(View.GONE);
toggleButtonM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
recyclerViewMidterm.setVisibility(View.VISIBLE);
} else {
recyclerViewMidterm.setVisibility(View.GONE);
}
}
});
toggleButtonF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
recyclerViewFinals.setVisibility(View.VISIBLE);
} else {
recyclerViewFinals.setVisibility(View.GONE);
}
}
});
name.setText(subject.getName());
code.setText(subject.getCode());
desc.setText(subject.getDescription());
unit.setText(subject.getUnit() + "");
try {
Formula formula = new FormulaHelper(this).getFormula("1-midterm");
if (formula != null && formula.getSubject() != null) {
if (formula.getSubject().getId() == subject.getId()) {
recyclerViewMidterm.setVisibility(View.VISIBLE);
String[] key = new String[6];
key[0] = formula.getActivityPercentage() + "%";
key[1] = formula.getAssignmentPercentage() + "%";
key[2] = formula.getAttendancePercentage() + "%";
key[3] = formula.getExamPercentage() + "%";
key[4] = formula.getProjectPercentage() + "%";
key[5] = formula.getQuizPercentage() + "%";
List<String> datas = new ArrayList<>();
for (String s : key) datas.add(s);
CriteriaAdapter criteriaAdapter = new CriteriaAdapter(this, datas);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerViewMidterm.setAdapter(criteriaAdapter);
recyclerViewMidterm.setLayoutManager(layoutManager);
recyclerViewMidterm.setItemAnimator(new DefaultItemAnimator());
}
}
} catch (GradingFactorException e) {
e.printStackTrace();
}
linearLayoutm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Midterm.class);
intent.putExtra("subjectId", subject.getId());
startActivity(intent);
finish();
}
});
linearLayoutf.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Finals.class);
startActivity(intent);
finish();
}
});
}
use of com.remswork.project.alice.exception.SubjectException in project classify-system by anverliedoit.
the class SubjectController method addSubject.
@RequestMapping(value = "add", method = RequestMethod.POST)
public String addSubject(@RequestParam("name") String name, @RequestParam("code") String code, @RequestParam("description") String description, @RequestParam("unit") int unit, ModelMap modelMap) {
try {
Subject subject = new Subject(name, code, description, unit);
subjectService.addSubject(subject);
List<Subject> subjectList = subjectService.getSubjectList();
modelMap.put("subjectList", subjectList);
return "subject";
} catch (SubjectException e) {
e.printStackTrace();
return "error";
}
}
use of com.remswork.project.alice.exception.SubjectException in project classify-system by anverliedoit.
the class SubjectServiceImpl method deleteSubjectById.
@Override
public Subject deleteSubjectById(long id) throws SubjectException {
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.request();
builder.accept("application/json");
Response response = builder.delete();
if (response.getStatus() == 200) {
return (Subject) response.readEntity(Subject.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new SubjectServiceException(message.getMessage());
} else
throw new SubjectServiceException("The request might invalid or server is down");
} catch (SubjectServiceException e) {
throw new SubjectException(e.getMessage());
}
}
use of com.remswork.project.alice.exception.SubjectException in project classify-system by anverliedoit.
the class SubjectServiceImpl method getSubjectByScheduleId.
@Override
public Subject getSubjectByScheduleId(long scheduleId) throws SubjectException {
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());
Response response = target.queryParam("scheduleId", scheduleId).request().get();
if (response.getStatus() == 200) {
return (Subject) response.readEntity(Subject.class);
} else if (response.getStatus() == 404) {
Message message = (Message) response.readEntity(Message.class);
throw new SubjectServiceException(message.getMessage());
} else
throw new SubjectServiceException("The request might invalid or server is down");
} catch (SubjectServiceException e) {
throw new SubjectException(e.getMessage());
}
}
Aggregations