use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleController method updateScheduleOnClass.
@RequestMapping(value = "c/update", method = RequestMethod.POST)
public String updateScheduleOnClass(@RequestParam("day") String day, @RequestParam("room") String room, @RequestParam("time") String time, @RequestParam("period") String period, @RequestParam("classId") long classId, @RequestParam("scheduleId") long scheduleId, ModelMap modelMap) {
try {
Schedule schedule = new Schedule();
schedule.setDay(day);
schedule.setTime(time);
schedule.setPeriod(period);
schedule.setRoom(room);
schedule = scheduleService.updateScheduleById(scheduleId, schedule);
Set<Schedule> scheduleList = classService.getScheduleList(classId);
modelMap.put("scheduleList", scheduleList);
} catch (ScheduleException | ClassException e) {
e.printStackTrace();
}
return "schedule";
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleController method addScheduleOnClass.
@RequestMapping(value = "c/add", method = RequestMethod.POST)
public String addScheduleOnClass(@RequestParam("day") String day, @RequestParam("room") String room, @RequestParam("time") String time, @RequestParam("period") String period, @RequestParam("classId") long classId, ModelMap modelMap) {
try {
Schedule schedule = new Schedule();
schedule.setDay(day);
schedule.setTime(time);
schedule.setPeriod(period);
schedule.setRoom(room);
schedule = scheduleService.addSchedule(schedule);
classService.addScheduleById(classId, schedule.getId());
Set<Schedule> scheduleList = classService.getScheduleList(classId);
modelMap.put("scheduleList", scheduleList);
} catch (ScheduleException | ClassException e) {
e.printStackTrace();
}
return "schedule";
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleController method addSchedule.
@RequestMapping(value = "add", method = RequestMethod.POST)
public String addSchedule(@RequestParam("day") String day, @RequestParam("room") String room, @RequestParam("time") String time, @RequestParam("period") String period, ModelMap modelMap) {
try {
System.out.println("day : " + day);
System.out.println("room : " + room);
System.out.println("time : " + time);
System.out.println("period : " + period);
Schedule schedule = new Schedule();
schedule.setDay(day);
schedule.setTime(time);
schedule.setPeriod(period);
schedule.setRoom(room);
schedule = scheduleService.addSchedule(schedule);
modelMap.put("schedule", schedule);
} catch (ScheduleException e) {
e.printStackTrace();
}
return "schedule-add";
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleServiceImpl method getScheduleListByTeacherId.
@Override
public Set<Schedule> getScheduleListByTeacherId(final long teacherId) throws ScheduleException {
final Set<Schedule> scheduleList = new HashSet<>();
try {
return new AsyncTask<String, Set<Schedule>, Set<Schedule>>() {
@Override
protected Set<Schedule> doInBackground(String... args) {
try {
String link = "".concat(domain).concat("/").concat(baseUri).concat("/").concat(payload).concat("/").concat("1").concat("?teacherId=").concat(String.valueOf(teacherId));
URL url = new URL(link);
Gson gson = new Gson();
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
JSONArray jsonArray = new JSONArray(jsonData);
for (int ctr = 0; ctr < jsonArray.length(); ctr++) {
scheduleList.add(gson.fromJson(jsonArray.get(ctr).toString(), Schedule.class));
}
return scheduleList;
} else if (httpURLConnection.getResponseCode() == 404) {
InputStream inputStream = httpURLConnection.getInputStream();
String jsonData = "";
int data;
while ((data = inputStream.read()) != -1) {
jsonData += (char) data;
}
Message message = gson.fromJson(jsonData, Message.class);
Log.i("ServiceTAG", "Service : Schedule");
Log.i("ServiceTAG", "Status : " + message.getStatus());
Log.i("ServiceTAG", "Type : " + message.getType());
Log.i("ServiceTAG", "Message : " + message.getMessage());
return scheduleList;
} else
throw new ScheduleException("Server Error");
} catch (ScheduleException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
}.execute((String) null).get();
} catch (InterruptedException e) {
e.printStackTrace();
return null;
} catch (ExecutionException e) {
e.printStackTrace();
return null;
}
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class SliderScheduleFragment method init.
public void init() {
Collections.sort(scheduleList, new Comparator<Schedule>() {
@Override
public int compare(Schedule o1, Schedule o2) {
return (o1.getTime().compareTo(o2.getTime()));
}
});
scheduleRecyclerView = (RecyclerView) customView.findViewById(R.id.shedule_recyclerview);
scheduleAdapter = new ScheduleAdapter(getContext(), scheduleList);
scheduleRecyclerView.setAdapter(scheduleAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
scheduleRecyclerView.setLayoutManager(layoutManager);
scheduleRecyclerView.setItemAnimator(new DefaultItemAnimator());
scheduleRecyclerView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.INVISIBLE);
}
Aggregations