Search in sources :

Example 26 with Schedule

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";
}
Also used : Schedule(com.remswork.project.alice.model.Schedule) ClassException(com.remswork.project.alice.exception.ClassException) ScheduleException(com.remswork.project.alice.exception.ScheduleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 27 with 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";
}
Also used : Schedule(com.remswork.project.alice.model.Schedule) ClassException(com.remswork.project.alice.exception.ClassException) ScheduleException(com.remswork.project.alice.exception.ScheduleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 28 with 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";
}
Also used : Schedule(com.remswork.project.alice.model.Schedule) ScheduleException(com.remswork.project.alice.exception.ScheduleException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 29 with Schedule

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;
    }
}
Also used : Message(com.remswork.project.alice.model.support.Message) InputStream(java.io.InputStream) AsyncTask(android.os.AsyncTask) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson) JSONException(org.json.JSONException) IOException(java.io.IOException) ScheduleException(com.remswork.project.alice.exception.ScheduleException) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) Schedule(com.remswork.project.alice.model.Schedule) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Example 30 with Schedule

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);
}
Also used : ScheduleAdapter(com.lieverandiver.thesisproject.adapter.ScheduleAdapter) Schedule(com.remswork.project.alice.model.Schedule) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

Schedule (com.remswork.project.alice.model.Schedule)36 ScheduleException (com.remswork.project.alice.exception.ScheduleException)22 Message (com.remswork.project.alice.model.support.Message)22 ClassException (com.remswork.project.alice.exception.ClassException)13 Client (javax.ws.rs.client.Client)10 WebTarget (javax.ws.rs.client.WebTarget)10 Response (javax.ws.rs.core.Response)10 ScheduleServiceException (com.remswork.project.alice.web.service.exception.ScheduleServiceException)6 ScheduleResourceLinks (com.remswork.project.alice.resource.links.ScheduleResourceLinks)5 ArrayList (java.util.ArrayList)5 ClientBuilder (javax.ws.rs.client.ClientBuilder)5 Builder (javax.ws.rs.client.Invocation.Builder)5 Session (org.hibernate.Session)5 ScheduleDaoException (com.remswork.project.alice.dao.exception.ScheduleDaoException)4 ClassScheduleListResourceLinks (com.remswork.project.alice.resource.links.ClassScheduleListResourceLinks)4 ClassServiceException (com.remswork.project.alice.web.service.exception.ClassServiceException)4 Set (java.util.Set)4 AsyncTask (android.os.AsyncTask)3 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3