Package at.riemers.zero.base.controller

Examples of at.riemers.zero.base.controller.ZeroView


        return list(session, request);
    }

    @RequestMapping(value = "/user/getMessage.do", method = RequestMethod.GET)
    public ModelAndView getMessage(HttpSession session, HttpServletRequest request) throws Exception {
        ZeroView view = new ZeroView(getMessages(), request.getLocale());
        String text = texts.get(session.getId());
        log.debug(session.getId());
        if (text != null) {
            texts.remove(session.getId());
            view.setMessage(text, Message.MSG_INFO);
        }
        return new ModelAndView(view, null);
    }
View Full Code Here


            HttpSession session,
            HttpServletRequest request,
            @RequestParam("cid") String cid,
            @RequestParam("query") String query) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());

        AutoCompleteComponent component = components.get(cid);
        if (component != null) {
            component.query(view, query);
        }
View Full Code Here

            HttpSession session,
            HttpServletRequest request,
            @RequestParam("cid") String cid,
            @RequestParam("id") String id) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());

        AutoCompleteComponent component = components.get(cid);
        if (component != null) {
            component.select(view, id);
        }
View Full Code Here

            String userGroupKey = role.getPermission(UserModule.AUTH_USER).getValue();
            userGroups.add(userGroupKey);
        }


        ZeroView view = new ZeroView(getMessages(), request.getLocale());

        view.addWidget(new JavascriptWidget("hidePopup('v2js_user_warning')"));

        view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "user_userlist"));

        FormWidget filter = (FormWidget) getWidgetManager(session).getWidget("USERLIST_FILTER");
        if (filter == null) {
            filter = new FormWidget("USERLIST_FILTER", getLocale(request));
            filter.setColumnCount(3);
            filter.setShowLabelAtTop(true);
            filter.addField(new StringField("username", "base.user.table.username", ""));
            ComboBoxField groupField = new ComboBoxField("userGroup", "base.user.label.usergroupkey", "");

            groupField.addOption("", "*");
            for (UserGroup userGroup : getUserGroups()) {
                groupField.addOption(userGroup.getId(), userGroup.getGroupKey());
            }

            filter.addField(groupField);

            ComboBoxField deletedField = new ComboBoxField("deleted", "base.user.label.deleted", "");

            deletedField.addOption("", "NOT DELETED");
            deletedField.addOption("D", "DELETED");
            deletedField.addOption("A", "ALL");


            filter.addField(deletedField);

            filter.setForm("UserFilterForm");
            getWidgetManager(session).register(filter);
        }
        view.addWidget(filter);

        List<ZeroUser> userList = null;

        if (userGroups.contains("*")) {
            userList = userDao.findAll();
        } else {
            userList = new ArrayList<ZeroUser>();
            for (String userGroup : userGroups) {
                userList.addAll(userDao.findByGroup(userGroup));
            }
        }

        HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");
        if (userListComponent == null) {
            DefaultTableModelColumn usernameColumn = new DefaultTableModelColumn("base.user.table.username", "username");
            usernameColumn.setStyleClass("emphasize");
            usernameColumn.setRenderer(new TableColumnRenderer() {

                public String getTemplate() {
                    return "v2js_widgets_username";
                }

                public Object getData(Object obj) {
                    JSONObject jLink = new JSONObject();
                    jLink.element("username", ((ZeroUser) obj).getUsername());
                    jLink.element("deleted", ((ZeroUser) obj).isDeleted());
                    return jLink;

                }
            });

            /* usernameColumn.addClickListener(new TableClickListener() {
           
            public void fireClicked(TableClickEvent event) {
            log.debug("fireClicked: " + event.getWidget().getModel().getData(event.getColumn(), event.getRow()));
            }
            });*/
            UserTableModel model = new UserTableModel(userList, getMessages(), request.getLocale());

            if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
                model.setSelectable(true);
                DefaultTableModelColumn editColumn = new DefaultTableModelColumn("", "");
                editColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return "v2js_widgets_tablelink";
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            JSONObject jLink = new JSONObject();
                            jLink.element("url", "user/userEdit.do?selected=" + ((ZeroUser) obj).getId());
                            jLink.element("text", "Edit");
                            return jLink;
                        }
                        return "";
                    }
                });
                model.addColumn(editColumn);

            }

            if (user.checkAuthorisation(UserModule.AUTH_LOGIN_AS)) {
                model.setSelectable(true);
                DefaultTableModelColumn loginColumn = new DefaultTableModelColumn("", "");
                loginColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return null;
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            return new HtmlSnippet("<a href=\"user/loginAsUser.do?selected=" + ((ZeroUser) obj).getId() + "\">Login</a>");
                        }
                        return "";
                    }
                });
                model.addColumn(loginColumn);

            }

            model.addColumn(usernameColumn);
            model.addColumn(new DefaultTableModelColumn("base.user.table.firstname", "person.firstname"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.lastname", "person.lastname"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.email", "person.email"));
            model.addColumn(new DefaultTableModelColumn("base.user.table.phone", "person.phone"));
            model.addColumn(new DefaultTableModelColumn("base.user.label.usergroupkey", "userGroup.groupKey"));
            model.addColumn(new DefaultTableModelColumn("base.user.label.locked", "locked"));

            if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
                DefaultTableModelColumn sendPwdColumn = new DefaultTableModelColumn("", "");
                sendPwdColumn.setRenderer(new TableColumnRenderer() {

                    public String getTemplate() {
                        return "v2js_widgets_tablelink";
                    }

                    public Object getData(Object obj) {
                        if (obj instanceof User) {
                            JSONObject jLink = new JSONObject();
                            jLink.element("url", "user/userSendPwd.do?selected=" + ((ZeroUser) obj).getId());
                            jLink.element("text", "Send Password");
                            return jLink;
                        }
                        return "";
                    }
                });
                model.addColumn(sendPwdColumn);

            }

            model.setSort(1);
            userListComponent = new HtmlTableWidget("USERLIST", model, request.getLocale());
            userListComponent.setRowsPerPage(20);

            getWidgetManager(session).register(userListComponent);
        } else {
            ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).setCollection(userList);
        }

        view.addWidget(userListComponent);

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
            view.getJson().element("edit", true);
        }

        return new ModelAndView(view, null);
    }
View Full Code Here

    }

    @RequestMapping(value = "/user/deleteUser.do", method = RequestMethod.POST)
    public ModelAndView delete(@ModelAttribute("selected") Selected selected, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());
        log.debug("delete User");

        logFunction("user-delete");

        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                log.debug(row);
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.delete_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
View Full Code Here

    }

    @RequestMapping(value = "/user/undeleteUser.do", method = RequestMethod.POST)
    public ModelAndView undelete(@ModelAttribute("selected") Selected selected, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());

        logFunction("user-undelete");
        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.delete_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
View Full Code Here

    }

    @RequestMapping(value = "/user/filter.do", method = RequestMethod.POST)
    public ModelAndView filter(@ModelAttribute("UserFilterForm") Form form, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());
        log.debug("filter User");

        logFunction("user-filter");
        User user = getUser();
View Full Code Here

    }

    @RequestMapping(value = "/user/lockUser.do", method = RequestMethod.POST)
    public ModelAndView lock(@ModelAttribute("selected") Selected selected, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());

        logFunction("user-lock");
        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.edit_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
View Full Code Here

    }

    @RequestMapping(value = "/user/unlockUser.do", method = RequestMethod.POST)
    public ModelAndView unlock(@ModelAttribute("selected") Selected selected, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());
        logFunction("user-unlock");

        User user = getUser();

        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            HtmlTableWidget userListComponent = (HtmlTableWidget) getWidgetManager(session).getWidget("USERLIST");

            for (String selectedRow : selected.getSelected().keySet()) {
                int row = Integer.parseInt(selectedRow);
                row = row + userListComponent.getPage() * userListComponent.getRowsPerPage();
                ZeroUser selectedUser = ((DefaultTableModel<ZeroUser>) userListComponent.getModel()).get(row);
                if (selectedUser != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.edit_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                } else {
                    log.debug("username not found");
                }
View Full Code Here

    @RequestMapping(value = "/user/userEdit.do", method = RequestMethod.GET)
    public ModelAndView edit(HttpSession session,
            @RequestParam(value = "selected", required = false) String selected,
            HttpServletRequest request) throws Exception {

        ZeroView view = new ZeroView(getMessages(), request.getLocale());


        User user = getUser();
        if (user.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {

            session.setAttribute(SESSION_USER_TRANSACTION, new UserTransaction());

            ZeroUser selectedUser = null;
            if (selected == null || selected.equals("")) {
                log.debug("create user");
                selectedUser = new ZeroUser("", "zero");
                selectedUser.setId("");
            } else {
                selectedUser = userDao.findById(selected);
                if (selectedUser == null) {
                    log.debug("selected user == null");
                }
                if (selectedUser.getUserGroup() == null) {
                    log.debug("selected user.getUserGroup == null");
                }
                if (user == null) {
                    log.debug("user == null");
                }

                if (selectedUser.getUserGroup() != null) {
                    if (!user.checkAuthorisation(
                            new Permission(UserModule.AUTH_USER, selectedUser.getUserGroup().getGroupKey()),
                            new Permission(UserModule.AUTH_USER_EDIT, "", false))) {
                        view.setMessage(new Message("zero.message.user.edit_no_permission", Message.MSG_ERROR, selectedUser.getUsername()));
                        return new ModelAndView(view, null);
                    }
                }


            }
            session.setAttribute(SESSION_USER_SELECTEDUSER, selectedUser);

            updateUserParameters(selectedUser);


            view.addWidget(new SimpleWidget(ZeroView.DIV_CONTENT, "user_userEdit"));

            view.getJson().element("user", UserJSONizer.createUserWithRoles((ZeroUser) selectedUser, getModuleManager()));
            view.getJson().element("parameters", UserJSONizer.createParameters(getModuleManager(), (ZeroUser) selectedUser));
            JSONArray jUserGroups = new JSONArray();
            view.getJson().element("userGroups", jUserGroups);

            Collection<Role> roles = user.getRoles(UserModule.AUTH_USER);
            Set<UserGroup> userGroups = new HashSet<UserGroup>();
            for (Role role : roles) {
                if (role.checkAuthorisation(UserModule.AUTH_USER_EDIT)) {
View Full Code Here

TOP

Related Classes of at.riemers.zero.base.controller.ZeroView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.