Package at.riemers.zero.base.model

Examples of at.riemers.zero.base.model.User


    public ModelAndView filter(@ModelAttribute("RoleFilterForm") Form form, BindingResult result, SessionStatus status, HttpSession session, HttpServletRequest request) throws Exception {

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

        User user = getUser();

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

            FormWidget filter = (FormWidget) getWidgetManager(session).getWidget("ROLELIST_FILTER");
            filter.setValuesFromForm(form);
            HtmlTableWidget roleWidget = (HtmlTableWidget) getWidgetManager(session).getWidget("ROLELIST");
            RoleTableModel model = (RoleTableModel) roleWidget.getModel();
View Full Code Here


            HttpServletRequest request) throws Exception {
        log.debug("permissionList");

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

        User user = getUser();

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

            view.addWidget(new PopupWidget("user_permissionlist_select", "base.user.select_permission", PopupWidget.TYPE_SAVE));

            JSONArray jmodules = new JSONArray();
            view.getJson().element("modules", jmodules);
View Full Code Here

            @RequestParam("action") String action,
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);

        component.fireActionPerformed(action, nodeId, view, session, request);
View Full Code Here

            @RequestParam("nodeId") String nodeId,                       
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);
      
        component.fireSelectTreeNode(nodeId, view, session, request);
View Full Code Here

            @RequestParam("name") String name,
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);
      
        TreeNode node = component.addNode(parent, name);
        if (node != null) {
View Full Code Here

            @RequestParam("nodeId") String nodeId,
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);

        TreeNode node = component.getTree().getNode(nodeId);
        if (component.deleteNode(nodeId)) {
View Full Code Here

            @RequestParam("beforeId") String beforeId,
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);
       
       
        TreeNode node = component.moveNode(nodeId, parentId, beforeId);
View Full Code Here

            @RequestParam("name") String name,           
             HttpServletRequest request) throws Exception {

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

        User user = getUser();

        TreeWidget component = (TreeWidget) getWidgetManager(session).getWidget(cid);

        if (component.renameNode(nodeId, name)) {           
            JSONObject jNode = new JSONObject();
View Full Code Here

    }

    @RequestMapping(value = "/user/userList.do", method = RequestMethod.GET)
    public ModelAndView list(HttpSession session, HttpServletRequest request) throws Exception {
        log.debug("user admin action");
        User user = getUser();

        //logFunction("user-list");       

        Collection<Role> roles = user.getRoles(UserModule.AUTH_USER);
        Set<String> userGroups = new HashSet<String>();
        for (Role role : roles) {
            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

        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);
                    }
View Full Code Here

TOP

Related Classes of at.riemers.zero.base.model.User

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.