Example usage for java.util.logging FileHandler FileHandler

List of usage examples for java.util.logging FileHandler FileHandler

Introduction

In this page you can find the example usage for java.util.logging FileHandler FileHandler.

Prototype

public FileHandler(String pattern, boolean append) throws IOException, SecurityException 

Source Link

Document

Initialize a FileHandler to write to the given filename, with optional append.

Usage

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/removedesiredcourse", method = RequestMethod.POST)
public String removedesiredcourses(Model model, @RequestParam("id") String id) {
    try {//w ww  . jav a2s. c o m
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentGenerateCourses.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        GenerationcriteriaDAO.removeDesiredCourses(currentStudent.getStudentid(), id);
        logger.info("Course sucessfully removed from generation criteria.");
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Courses> courses = CourseDAO.getCourseOfferingForSchool(currentSchool.getSchoolid());
        List<Scheduleblocks> scheduleblocks = new ArrayList<>();
        for (Courses course : courses) {
            scheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(course.getScheduleblockid()));
        }
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        Generationcriteria gencriteria = GenerationcriteriaDAO
                .getGenerationCriteria(currentStudent.getStudentid());
        String[] courseids = gencriteria.getCourseids().split(",");
        List<Courses> genCourses = new ArrayList<>();
        List<Scheduleblocks> genscheduleblocks = new ArrayList<>();
        if (!gencriteria.getCourseids().isEmpty()) {
            for (String courseid : courseids) {
                Courses genCourse = CourseDAO.getCourse(Integer.parseInt(courseid));
                genCourses.add(genCourse);
                genscheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(genCourse.getScheduleblockid()));
            }
        }
        if (gencriteria.getLunch() != null && !gencriteria.getLunch().isEmpty()) {
            String[] lunch = gencriteria.getLunch().split(",");
            model.addAttribute("lunch", lunch);
        }
        String lunchrange = currentSchool.getLunchrange();
        model.addAttribute("lunchrange", lunchrange);
        int numdays = currentSchool.getNumdays();
        String lunchdays = lunchToText(numdays);
        String[] lunchdays2 = lunchdays.split(",");
        model.addAttribute("lunchdays", lunchdays2);
        model.addAttribute("genscheduleblocks", genscheduleblocks);
        model.addAttribute("gencourses", genCourses);
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("scheduleblocks", scheduleblocks);
        model.addAttribute("courses", courses);
        logger.info("Generation criteria successfully updated.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentgeneratecourses";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/removelunch", method = RequestMethod.POST)
public String removelunch(Model model, @RequestParam("lunch") String lunchday) {
    try {//from w w w  .ja  v a 2 s .  c  o  m
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentGenerateCourses.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        GenerationcriteriaDAO.removeLunch(currentStudent.getStudentid(), lunchday);
        logger.info(lunchday + " removed from generation crtieria.");
        List<Courses> courses = CourseDAO.getCourseOfferingForSchool(currentSchool.getSchoolid());
        List<Scheduleblocks> scheduleblocks = new ArrayList<>();
        for (Courses course : courses) {
            scheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(course.getScheduleblockid()));
        }
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        Generationcriteria gencriteria = GenerationcriteriaDAO
                .getGenerationCriteria(currentStudent.getStudentid());
        String[] courseids = gencriteria.getCourseids().split(",");
        List<Courses> genCourses = new ArrayList<>();
        List<Scheduleblocks> genscheduleblocks = new ArrayList<>();
        for (String courseid : courseids) {
            Courses genCourse = CourseDAO.getCourse(Integer.parseInt(courseid));
            genCourses.add(genCourse);
            genscheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(genCourse.getScheduleblockid()));
        }
        if (gencriteria.getLunch() != null && !gencriteria.getLunch().isEmpty()) {
            String[] lunch = gencriteria.getLunch().split(",");
            model.addAttribute("lunch", lunch);
        }
        String lunchrange = currentSchool.getLunchrange();
        model.addAttribute("lunchrange", lunchrange);
        int numdays = currentSchool.getNumdays();
        String lunchdays = lunchToText(numdays);
        String[] lunchdays2 = lunchdays.split(",");
        model.addAttribute("lunchdays", lunchdays2);
        model.addAttribute("genscheduleblocks", genscheduleblocks);
        model.addAttribute("gencourses", genCourses);
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("scheduleblocks", scheduleblocks);
        model.addAttribute("courses", courses);
        logger.info("Generation criteria successfully updated.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentgeneratecourses";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/addlunch", method = RequestMethod.POST)
public String addlunch(Model model, @RequestParam("lunch") String lunchday) {
    try {//from   ww w  . j av a  2  s  . com
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentGenerateCourses.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        GenerationcriteriaDAO.addLunch(currentStudent.getStudentid(), lunchday);
        logger.info(lunchday + " successfully added to Generation Criteria.");
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Courses> courses = CourseDAO.getCourseOfferingForSchool(currentSchool.getSchoolid());
        List<Scheduleblocks> scheduleblocks = new ArrayList<>();
        for (Courses course : courses) {
            scheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(course.getScheduleblockid()));
        }
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        Generationcriteria gencriteria = GenerationcriteriaDAO
                .getGenerationCriteria(currentStudent.getStudentid());
        String[] courseids = gencriteria.getCourseids().split(",");
        List<Courses> genCourses = new ArrayList<>();
        List<Scheduleblocks> genscheduleblocks = new ArrayList<>();
        for (String courseid : courseids) {
            Courses genCourse = CourseDAO.getCourse(Integer.parseInt(courseid));
            genCourses.add(genCourse);
            genscheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(genCourse.getScheduleblockid()));
        }
        if (gencriteria.getLunch() != null && !gencriteria.getLunch().isEmpty()) {
            String[] lunch = gencriteria.getLunch().split(",");
            model.addAttribute("lunch", lunch);
        }
        String lunchrange = currentSchool.getLunchrange();
        model.addAttribute("lunchrange", lunchrange);
        int numdays = currentSchool.getNumdays();
        String lunchdays = lunchToText(numdays);
        String[] lunchdays2 = lunchdays.split(",");
        model.addAttribute("lunchdays", lunchdays2);
        model.addAttribute("genscheduleblocks", genscheduleblocks);
        model.addAttribute("gencourses", genCourses);
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("scheduleblocks", scheduleblocks);
        model.addAttribute("courses", courses);
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentgeneratecourses";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/generateschedule", method = RequestMethod.GET)
public String generateSchedule(Model model, @RequestParam("instructors") String instructors) {
    try {// w  w  w .  ja v a  2 s . co m
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentGenerateCourses.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        Generationcriteria gencriteria = GenerationcriteriaDAO
                .getGenerationCriteria(currentStudent.getStudentid());
        String[] courseids = gencriteria.getCourseids().split(",");
        List<Courses> genCourses = new ArrayList<>();
        List<Scheduleblocks> genscheduleblocks = new ArrayList<>();
        if (!gencriteria.getCourseids().isEmpty()) {
            for (String courseid : courseids) {
                Courses genCourse = CourseDAO.getCourse(Integer.parseInt(courseid));
                genCourses.add(genCourse);
                genscheduleblocks.add(ScheduleBlockDAO.getScheduleBlock(genCourse.getScheduleblockid()));
            }
        }
        List<List<Courses>> conflictCourses = new ArrayList<>();
        String lunches = gencriteria.getLunch();
        String[] lunch = lunches.split(",");
        for (int i = 0; i < lunch.length; i++) {
            if (lunch[i].equals("monday")) {
                lunch[i] = "1";
            } else if (lunch[i].equals("tuesday")) {
                lunch[i] = "2";
            } else if (lunch[i].equals("wednesday")) {
                lunch[i] = "3";
            } else if (lunch[i].equals("thursday")) {
                lunch[i] = "4";
            } else if (lunch[i].equals("friday")) {
                lunch[i] = "5";
            } else if (lunch[i].equals("saturday")) {
                lunch[i] = "6";
            } else if (lunch[i].equals("sunday")) {
                lunch[i] = "7";
            }
        }
        String lunchperiods = currentSchool.getLunchrange();
        String[] temp = lunchperiods.split("-");
        int length = Integer.parseInt(temp[1]) - Integer.parseInt(temp[0]);
        int[] lunchperiod = new int[length + 1];
        int low = Integer.parseInt(temp[0]);
        for (int i = 0; i <= length; i++) {
            lunchperiod[i] = low;
            low++;
        }
        int conlunchcount = 0;
        List<List<Courses>> conflictLunches = new ArrayList<>();
        for (int i = 0; i < genscheduleblocks.size(); i++) {
            Scheduleblocks firstBlock = genscheduleblocks.get(i);
            conflictLunch: {
                for (int period : lunchperiod) {
                    if (firstBlock.getPeriod().equals(period)) {
                        String[] gendays = firstBlock.getDays().split(",");
                        for (String days : lunch) {
                            for (String genday : gendays) {
                                if (days.equals(genday)) {
                                    List<Courses> conflictCourse = new ArrayList<>();
                                    conflictCourse.add(genCourses.get(i));
                                    Courses lunchCourse = new Courses(0, "lunch", "", "", 0);
                                    conflictCourse.add(lunchCourse);
                                    conflictLunches.add(conflictCourse);
                                    conlunchcount++;
                                    break conflictLunch;
                                }
                            }
                        }
                    }
                }
            }
            for (int i2 = i + 1; i2 < genscheduleblocks.size(); i2++) {
                Scheduleblocks secondBlock = genscheduleblocks.get(i2);
                checkConflict: {
                    if (firstBlock.getPeriod().equals(secondBlock.getPeriod())) {
                        String[] days = firstBlock.getDays().split(",");
                        String[] days2 = secondBlock.getDays().split(",");
                        for (String d : days) {
                            for (String d2 : days2) {
                                if (d.equals(d2)) {
                                    Courses genCourse = genCourses.get(i);
                                    Courses genCourse2 = genCourses.get(i2);
                                    String[] semesters = genCourse.getSemester().split(",");
                                    String[] semesters2 = genCourse2.getSemester().split(",");
                                    for (String s : semesters) {
                                        for (String s2 : semesters2) {
                                            if (s.equals(s2)) {
                                                List<Courses> conflictCourse = new ArrayList<>();
                                                conflictCourse.add(genCourse);
                                                conflictCourse.add(genCourse2);
                                                conflictCourses.add(conflictCourse);
                                                break checkConflict;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        System.out.print(conlunchcount + " " + lunchperiod.length);
        if (conlunchcount >= lunchperiod.length) {

            for (List<Courses> conlunch : conflictLunches) {
                System.out.print(conlunch);
                conflictCourses.add(conlunch);
            }
        }
        if (conflictCourses.isEmpty()) {
            String[] instructor = instructors.split(",");
            for (int i = 0; i < genCourses.size(); i++) {
                Courses course1 = genCourses.get(i);
                String courseiden = course1.getCourseidentifier();
                for (int i2 = i + 1; i2 < genCourses.size(); i2++) {
                    Courses course2 = genCourses.get(i2);
                    checkCourse: {
                        if (courseiden.equals(course2.getCourseidentifier())) {
                            if (instructors.isEmpty()) {
                                List<Students> friends = StudentDAO.getFriends(currentStudent.getStudentid());
                                int friendcourse1 = 0;
                                int friendcourse2 = 0;
                                for (Students friend : friends) {
                                    if (RegistrationDAO.isRegistered(course1, friend)) {
                                        friendcourse1++;
                                    } else if (RegistrationDAO.isRegistered(course2, friend)) {
                                        friendcourse2++;
                                    }
                                }
                                if (friendcourse1 >= friendcourse2) {
                                    genCourses.remove(i2);
                                    break checkCourse;
                                } else if (friendcourse1 < friendcourse2) {
                                    genCourses.remove(i);
                                    break checkCourse;
                                } else {
                                    genCourses.remove(i);
                                    break checkCourse;
                                }
                            } else {
                                for (String inst : instructor) {
                                    if (course1.getInstructor().equals(inst)) {
                                        genCourses.remove(i2);
                                        break checkCourse;
                                    } else if (course2.getInstructor().equals(inst)) {
                                        genCourses.remove(i);
                                        break checkCourse;
                                    } else {
                                        List<Students> friends = StudentDAO
                                                .getFriends(currentStudent.getStudentid());
                                        int friendcourse1 = 0;
                                        int friendcourse2 = 0;
                                        for (Students friend : friends) {
                                            if (RegistrationDAO.isRegistered(course1, friend)) {
                                                friendcourse1++;
                                            } else if (RegistrationDAO.isRegistered(course2, friend)) {
                                                friendcourse2++;
                                            }
                                        }
                                        if (friendcourse1 >= friendcourse2) {
                                            genCourses.remove(i2);
                                            break checkCourse;
                                        } else if (friendcourse1 < friendcourse2) {
                                            genCourses.remove(i);
                                            break checkCourse;
                                        } else {
                                            genCourses.remove(i);
                                            break checkCourse;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            List<List<Courses[]>> semesters = new ArrayList<>();
            List<Students> friends = StudentDAO.getFriends(currentStudent.getStudentid());
            for (Courses course : genCourses) {
                for (Students friend : friends) {
                    List<Courses> friendCourses = CourseDAO.getCoursesForStudent(friend.getStudentid());
                    for (Courses friendCourse : friendCourses) {
                        if (friendCourse.getCourseid() == (course.getCourseid())) {
                            if (course.getFriends() != null) {
                                course.setFriends(course.getFriends() + " " + friend.getFirstname() + " "
                                        + friend.getLastname());
                            } else {
                                course.setFriends(friend.getFirstname() + " " + friend.getLastname());
                            }
                        }
                    }
                }
            }
            for (int s = 0; s < currentSchool.getNumsemesters(); s++) {
                List<Courses[]> schedule = new ArrayList<>();
                for (int i = 0; i < currentSchool.getNumperiods(); i++) {
                    Courses[] period = new Courses[7];
                    for (Courses course : genCourses) {
                        Scheduleblocks sb = ScheduleBlockDAO.getScheduleBlock(course.getScheduleblockid());
                        if (sb.getPeriod() == i + 1) {
                            String[] days = sb.getDays().split(",");
                            String[] semester = course.getSemester().split(",");
                            for (String sem : semester) {
                                if (Integer.parseInt(sem) == s + 1) {
                                    for (String day : days) {
                                        period[Integer.parseInt(day) - 1] = course;
                                    }
                                }
                            }
                        }
                    }
                    schedule.add(period);
                }
                semesters.add(schedule);
            }
            model.addAttribute("semester", semesters);
            logger.info("Generated schedule complete.");
        } else {
            model.addAttribute("conflictCourses", conflictCourses);
            logger.info("Conflicting courses displayed.");
        }

        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        model.addAttribute("schoolyears", schoolyears);
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentviewgenerated";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/acceptfriend", method = RequestMethod.POST)
public String acceptfriend(Model model, @RequestParam(value = "id") int id) {
    try {/*from   w  ww.j a  v a  2  s. c om*/
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        FriendshipsDAO.acceptfriend(currentStudent.getStudentid(), id);
        logger.info("Approved friendship between " + currentStudent.getStudentid() + " and " + id);
        List<Students> friendrequests = StudentDAO.getFriendRequests(currentStudent.getStudentid());
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("friendrequests", friendrequests);
        logger.info("Friend requests updated to model.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentmanagefriends";
}

From source file:com.openbravo.pos.sales.JRetailPanelTicket.java

public void init(AppView app) throws BeanFactoryException {
    m_App = app;//from w  ww  . j a v a 2 s  .  c  o  m
    dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");
    dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");
    dlCustomers = (DataLogicCustomers) m_App.getBean("com.openbravo.pos.customers.DataLogicCustomers");
    dlReceipts = (DataLogicReceipts) m_App.getBean("com.openbravo.pos.sales.DataLogicReceipts");

    // borramos el boton de bascula si no hay bascula conectada
    if (!m_App.getDeviceScale().existsScale()) {
        //            m_jbtnScale.setVisible(false);
    }
    if (m_App.getProperties().getProperty("machine.ticketsbag").equals("restaurant")) {
        m_jbtnPrintBill.setVisible(true);
    } else {
        m_jbtnPrintBill.setVisible(false);
    }
    customerFocus();
    menuStatus = m_App.getProperties().getProperty("machine.menustatus");
    m_jPor.setVisible(false);
    m_ticketsbag = getJTicketsBag();
    m_oTicket.setCancelTicket(false);
    m_jPanelBag.add(m_ticketsbag.getBagComponent(), BorderLayout.LINE_START);
    add(m_ticketsbag.getNullComponent(), "null");

    m_ticketlines = new JRetailTicketLines(dlSystem.getResourceAsXML("Ticket.Line"));
    m_jPanelCentral.add(m_ticketlines, java.awt.BorderLayout.CENTER);

    m_TTP = new TicketParser(m_App.getDeviceTicket(), dlSystem);

    // The configurable buttons
    m_jbtnconfig = new JRetailPanelButtons("Ticket.Buttons", this);
    m_jButtonsExt.add(m_jbtnconfig);

    // The panel product lines
    catcontainer.add(getSouthComponent(), BorderLayout.CENTER);
    catcontainer.setVisible(true);
    m_jCalculatePromotion.setVisible(true);
    m_jCalculatePromotion.setEnabled(false);
    //m_jBtnServed.setVisible(false);
    // The model tax
    senttax = dlSales.getRetailTaxList();
    sentcharge = dlSales.getRetailServiceChargeList();
    senttaxcategories = dlSales.getTaxCategoriesList();
    sentsertax = dlSales.getRetailServiceTaxList();
    sentSBtax = dlSales.getRetailSwachBharatTaxList();
    taxcategoriesmodel = new ComboBoxValModel();

    // ponemos a cero el estado
    stateToZero();

    //creating log file for kot
    String logpath = m_App.getProperties().getProperty("machine.kotlogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh1 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }
    kotlogger.addHandler(fh1);
    SimpleFormatter formatter = new SimpleFormatter();
    fh1.setFormatter(formatter);

    //creating log file for print bill

    logpath = m_App.getProperties().getProperty("machine.printlogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh2 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }
    printlogger.addHandler(fh2);
    fh2.setFormatter(formatter);

    //creating log file for settle bill
    logpath = m_App.getProperties().getProperty("machine.settlelogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh3 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
    }
    settlelogger.addHandler(fh3);
    fh3.setFormatter(formatter);

}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/rejectfriend", method = RequestMethod.POST)
public String rejectfriend(Model model, @RequestParam(value = "id") int id) {
    try {/*from  w ww. ja  v  a2  s  . com*/
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        FriendshipsDAO.deletefriend(currentStudent.getStudentid(), id);
        logger.info("Rejected friendship between " + currentStudent.getStudentid() + " and " + id);
        List<Students> friendrequests = StudentDAO.getFriendRequests(currentStudent.getStudentid());
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("friendrequests", friendrequests);
        logger.info("Friend requests updated to model.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentmanagefriends";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/unfriend", method = RequestMethod.POST)
public String unfriend(Model model, @RequestParam(value = "id") int id) {
    try {//from  ww  w.  j  a  v  a2 s  . com
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        FriendshipsDAO.deletefriend(currentStudent.getStudentid(), id);
        logger.info("Successfully deleted friendship between " + currentStudent.getStudentid() + " and " + id);
        List<Students> friends = StudentDAO.getFriends(currentStudent.getStudentid());
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("friends", friends);
        logger.info("Friends updated to model.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentdisplayfriends";
}

From source file:BSxSB.Controllers.StudentController.java

@RequestMapping(value = "/addfriend", method = RequestMethod.POST)
public String addfriend(Model model, @RequestParam(value = "email") String email) {
    try {/*from  www . ja  v a 2  s  . c om*/
        //Initialize the file that the logger writes to.
        Handler handler = new FileHandler("%tBSxSBStudentFriends.log", true);
        handler.setFormatter(new SimpleFormatter());
        logger.addHandler(handler);
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        String name = auth.getName();
        Students currentStudent = StudentDAO.getStudent(name);
        Students friend = StudentDAO.getStudent(email);
        if (friend == null) {
            model.addAttribute("msg", "The email you have entered doesn't belong to any student");
            logger.info(email + " does not exist in database.");
        } else if (friend.getStudentid() == currentStudent.getStudentid()) {
            model.addAttribute("msg", "Can't friend yourself...");
            logger.info("This is your email.");
        } else if (friend.getSchoolid() != currentStudent.getSchoolid()) {
            model.addAttribute("msg", "Can not add a student from different school");
            logger.info("This student belongs to a different school");
        } else {
            model.addAttribute("msg", FriendshipsDAO.addfriend(friend, currentStudent));
            logger.info("Successfully created a friend request.");
        }
        List<Students> friendrequests = StudentDAO.getFriendRequests(currentStudent.getStudentid());
        Schools currentSchool = SchoolDAO.getSchool(currentStudent.getSchoolid());
        List<Schools> schoolyears = SchoolDAO.getSchoolSameName(currentSchool.getSchoolname());
        model.addAttribute("schoolyears", schoolyears);
        model.addAttribute("friendrequests", friendrequests);
        logger.info("Friend requests updated to model.");
        handler.close();
        logger.removeHandler(handler);
    } catch (IOException ex) {
        logger.log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        logger.log(Level.SEVERE, null, ex);
    }
    return "studentmanagefriends";
}

From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java

public void init(AppView app) throws BeanFactoryException {
    m_App = app;/*from ww w. j a v a 2 s  .  co  m*/
    dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem");
    dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales");
    dlCustomers = (DataLogicCustomers) m_App.getBean("com.openbravo.pos.customers.DataLogicCustomers");
    dlReceipts = (DataLogicReceipts) m_App.getBean("com.openbravo.pos.sales.DataLogicReceipts");

    // borramos el boton de bascula si no hay bascula conectada
    if (!m_App.getDeviceScale().existsScale()) {
        //            m_jbtnScale.setVisible(false);
    }
    if (m_App.getProperties().getProperty("machine.ticketsbag").equals("restaurant")) {
        m_jbtnPrintBill.setVisible(true);
    } else {
        m_jbtnPrintBill.setVisible(false);
        // jPanel1.setPreferredSize(new java.awt.Dimension(282, 47));
    }
    customerFocus();
    menuStatus = m_App.getProperties().getProperty("machine.menustatus");
    //setPrinterStatus(false);
    m_jPor.setVisible(false);
    m_ticketsbag = getJTicketsBag();
    //m_oTicket.setSplitValue("");
    m_oTicket.setCancelTicket(false);
    System.out.println("init----m_oTicket.getCancelTicket()--" + m_oTicket.getCancelTicket());
    m_jPanelBag.add(m_ticketsbag.getBagComponent(), BorderLayout.LINE_START);

    add(m_ticketsbag.getNullComponent(), "null");

    m_ticketlines = new JRetailTicketLines(dlSystem.getResourceAsXML("Ticket.Line"));
    m_jPanelCentral.add(m_ticketlines, java.awt.BorderLayout.CENTER);

    m_TTP = new TicketParser(m_App.getDeviceTicket(), dlSystem);

    // Los botones configurables...
    m_jbtnconfig = new JRetailPanelTakeAwayButtons("Ticket.Buttons", this);
    m_jButtonsExt.add(m_jbtnconfig);

    // El panel de los productos o de las lineas...        
    catcontainer.add(getSouthComponent(), BorderLayout.CENTER);
    catcontainer.setVisible(true);
    m_jCalculatePromotion.setVisible(false);
    // El modelo de impuestos
    senttax = dlSales.getRetailTaxList();
    sentcharge = dlSales.getRetailServiceChargeList();
    senttaxcategories = dlSales.getTaxCategoriesList();
    sentsertax = dlSales.getRetailServiceTaxList();
    sentsbtax = dlSales.getRetailSwachBharatTaxList();
    taxcategoriesmodel = new ComboBoxValModel();

    // ponemos a cero el estado
    stateToZero();

    //creating log file for kot
    String logpath = m_App.getProperties().getProperty("machine.kotlogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh1 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    }
    kotlogger.addHandler(fh1);
    SimpleFormatter formatter = new SimpleFormatter();
    fh1.setFormatter(formatter);

    //creating log file for print bill

    logpath = m_App.getProperties().getProperty("machine.printlogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh2 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    }
    printlogger.addHandler(fh2);
    fh2.setFormatter(formatter);

    //creating log file for settle bill
    logpath = m_App.getProperties().getProperty("machine.settlelogfile");
    logpath = logpath + getLogDate() + "-POS" + m_App.getProperties().getPosNo() + ".txt";
    try {
        fh3 = new FileHandler(logpath, true);
    } catch (IOException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(JRetailPanelTakeAway.class.getName()).log(Level.SEVERE, null, ex);
    }
    settlelogger.addHandler(fh3);
    fh3.setFormatter(formatter);

    //       m_jCash.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
    //        m_jCard.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
    //        m_jCheque.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
    //    m_jFoodCoupon.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
    //    m_jVoucher.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
    //     m_jCreditAmount.getDocument().addDocumentListener(new DocumentListener() {
    //         public void changedUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void removeUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //         public void insertUpdate(DocumentEvent e) {
    //           setTenderAmount();
    //         }
    //
    //
    //    });
}