Package info.jtrac.domain

Examples of info.jtrac.domain.User


        if(usrs.size() == 0) {
            return notFullyAllocated;
        }
        Set<UserSpaceRole> allocated = new HashSet(usrs);
        Set<Space> processed = new HashSet<Space>(usrs.size());
        User user = usrs.get(0).getUser();
        boolean isSuperUser = user.isSuperUser();                        
        for(UserSpaceRole usr : usrs) {
            Space space = usr.getSpace();
            if(space == null || processed.contains(space)) {
                continue;
            }
View Full Code Here


                             */
                            List<Space> spaces = getJtrac().findSpacesWhereGuestAllowed();
                            if (spaces.size() > 0) {
                                logger.debug(spaces.size() +
                                        " public space(s) available, initializing guest user");
                                User guestUser = new User();
                                guestUser.setLoginName("guest");
                                guestUser.setName("Guest");
                                for (Space space : spaces) {
                                    guestUser.addSpaceWithRole(space, Role.ROLE_GUEST);
                                }
                               
                                JtracSession.get().setUser(guestUser);
                                // and proceed
                                return true;
View Full Code Here

                continue;
            }
            String loginName = value.substring(0, index);
            String encodedPassword = value.substring(index + 1);
            logger.debug("valid cookie, attempting authentication");
            User user = (User) getJtrac().loadUserByUsername(loginName);
            if (encodedPassword.equals(user.getPassword())) {
                JtracSession.get().setUser(user);
                logger.debug("remember me login success");
                return true;
            }
        } // end for
View Full Code Here

            final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt");
           
            add(new ListView("usrs", new ArrayList(userRolesMap.keySet())) {
                protected void populateItem(ListItem listItem) {
                    long userId = (Long) listItem.getModelObject();
                    final User user = userRolesMap.get(userId).get(0).getUser();
                    if(selectedUserId == userId) {
                        listItem.add(new SimpleAttributeModifier("class", "selected"));
                    } else if(listItem.getIndex() % 2 == 1) {
                        listItem.add(sam);
                    }                    
                    listItem.add(new Link("loginName") {
                        public void onClick() {                           
                            if(previous instanceof UserAllocatePage) { // prevent recursive stack buildup
                                previous = null;
                            }                              
                            setResponsePage(new UserAllocatePage(user.getId(), SpaceAllocatePage.this, spaceId));
                        }
                    }.add(new Label("loginName", new PropertyModel(user, "loginName"))));
                    listItem.add(new Label("name", new PropertyModel(user, "name")));
                    List<UserSpaceRole> usrs = userRolesMap.get(userId);
                    listItem.add(new RoleDeAllocatePanel("roleDeAllocatePanel", usrs));
                }
            });
           
            add(new Link("createNewUser") {
                @Override
                public void onClick() {
                    UserFormPage page = new UserFormPage();
                    page.setPrevious(SpaceAllocatePage.this);
                    setResponsePage(page);
                }
            });
           
            List<User> users = getJtrac().findUsersNotFullyAllocatedToSpace(spaceId);                     
           
            DropDownChoice userChoice = new DropDownChoice("user", users, new IChoiceRenderer() {
                public Object getDisplayValue(Object o) {
                    User u = (User) o;
                    return u.getName() + " (" + u.getLoginName() + ")";
                }
                public String getIdValue(Object o, int i) {
                    return ((User) o).getId() + "";
                }
            });
            userChoice.setNullValid(true);

            add(userChoice);
                       
            userChoice.add(new AjaxFormComponentUpdatingBehavior("onChange") {
                protected void onUpdate(AjaxRequestTarget target) {
                    User u = (User) getFormComponent().getConvertedInput();
                    if (u == null) {             
                        roleAllocatePanel.setChoices(new ArrayList<String>());
                        allocateButton.setEnabled(false);
                    } else {
                        User temp = getJtrac().loadUser(u.getId());
                        // populate choice, enable button etc
                        initRoleChoice(temp);
                    }
                    target.addComponent(roleAllocatePanel);
                    target.addComponent(allocateButton);
                }
            });            
           
            roleAllocatePanel = new RoleAllocatePanel("roleAllocatePanel");                   
            roleAllocatePanel.setOutputMarkupId(true);                                 
            add(roleAllocatePanel);
           
            allocateButton = new Button("allocate") {
                @Override
                public void onSubmit() {   
                    List<String> roleKeys = roleAllocatePanel.getSelected();
                    if(user == null || roleKeys.size() == 0) {
                        return;
                    }
                    // avoid lazy init problem
                    User temp = getJtrac().loadUser(user.getId());
                    for(String roleKey : roleKeys) {
                        getJtrac().storeUserSpaceRole(temp, space, roleKey);
                    }                                        
                    JtracSession.get().refreshPrincipalIfSameAs(temp);
                    setResponsePage(new SpaceAllocatePage(spaceId, previous, user.getId()));
View Full Code Here

                        (password!=null ? "is set" : "is null") + ".");
                error(getLocalizer().getString("login.error", null));
                return;
            }
           
            User user = JtracApplication.get().authenticate(loginName, password);
            if (user == null) {
                /*
                 * ================================
                 * Login failed!
                 * ================================
 
View Full Code Here

     
    public OptionsPage() {                 
       
        setVersioned(false);                     
       
        final User user = getPrincipal();
       
        add(new Link("profile") {
            public void onClick() {
                UserFormPage page = new UserFormPage(user);
                page.setPrevious(OptionsPage.this);
                setResponsePage(page);
            }           
        });
       
        boolean isSuperUser = user.isSuperUser();
        boolean isSpaceAdmin = user.getSpacesWhereRoleIsAdmin().size() > 0;
       
        add(new Link("users") {
            public void onClick() {
                setResponsePage(new UserListPage());
            }           
View Full Code Here

       
    private Component getFilterUiFragment(ColumnHeading ch) {
        if(ch.getFilterCriteria().getExpression() == null) {
            return new WebMarkupContainer("fragParent");
        }       
        User user = JtracSession.get().getUser();
        // the space could be null also
        Space space = JtracSession.get().getCurrentSpace();
        Jtrac jtrac = JtracApplication.get().getJtrac();
        return ch.getFilterUiFragment(this, user, space, jtrac);
    }
View Full Code Here

       
        final SimpleAttributeModifier sam = new SimpleAttributeModifier("class", "alt");
       
        ListView listView = new ListView("users", userListModel) {
            protected void populateItem(ListItem listItem) {               
                final User user = (User) listItem.getModelObject();               
                if (selectedUserId == user.getId()) {
                    listItem.add(new SimpleAttributeModifier("class", "selected"));
                } else if(listItem.getIndex() % 2 == 1) {
                    listItem.add(sam);
                }                                
                listItem.add(new Label("name", new PropertyModel(user, "name")));
                listItem.add(new Label("loginName", new PropertyModel(user, "loginName")));                                              
                listItem.add(new Label("email", new PropertyModel(user, "email")));
                listItem.add(new Label("locale", new PropertyModel(user, "locale")));
                listItem.add(new WebMarkupContainer("locked").setVisible(user.isLocked()));
                listItem.add(new Link("edit") {
                    public void onClick() {
                        UserFormPage page = new UserFormPage(user);
                        page.setPrevious(UserListPage.this);
                        setResponsePage(page);
                    }                   
                });                
                listItem.add(new Link("allocate") {
                    public void onClick() {
                        setResponsePage(new UserAllocatePage(user.getId(), UserListPage.this));
                    }                   
                });
            }           
        };
       
View Full Code Here

       
        add(link);
       
        boolean isRelate = itemSearch != null && itemSearch.getRelatingItemRefId() != null;
       
        User user = getPrincipal();
       
        if(!user.isAllocatedToSpace(item.getSpace().getId())) {
            logger.debug("user is not allocated to space");
            throw new RestartResponseAtInterceptPageException(ErrorPage.class);
        }               
       
        // Edit: Only if there is no history (related item) of the Item
        boolean nohistory = true;
        if (item.getHistory() != null) {
            List<History> history = new ArrayList<History>(item.getHistory());
            if (history.size() > 1) {
              nohistory = false;
           
        }
       
        // Edit: Also the owner of the item should change it.
        final Map<String, String> configMap = getJtrac().loadAllConfig();
        String shouldEdit = configMap.get("jtrac.edit.item");       
        add(new Link("edit") {
            public void onClick() {
                setResponsePage(new ItemFormPage(item.getId()));
            }
        }.setVisible((item.getLoggedBy().getLoginName().equals(user.getLoginName()) &&
                 ("true".equals(shouldEdit)) &&
                 (nohistory)) ||
                 user.isSuperUser() ||
                 user.isAdminForSpace(item.getSpace().getId())));                       
        add(new ItemViewPanel("itemViewPanel", item, isRelate || user.getId() == 0));
       
        if(user.isGuestForSpace(item.getSpace()) || isRelate) {       
            add(new WebMarkupContainer("itemViewFormPanel").setVisible(false));
        } else {           
            add(new ItemViewFormPanel("itemViewFormPanel", item, itemSearch));
        }       
    }
View Full Code Here

*/
public class DashboardPage extends BasePage {
   
    public DashboardPage() {               
       
        final User user = getPrincipal();
        setCurrentSpace(null);
        List<UserSpaceRole> spaceRoles = new ArrayList(user.getSpaceRoles());       
       
        WebMarkupContainer table = new WebMarkupContainer("table");
        WebMarkupContainer message = new WebMarkupContainer("message");
       
        add(table);
        add(message);
       
        if(spaceRoles.size() > 0) {       
            final CountsHolder countsHolder = getJtrac().loadCountsForUser(user);               

            WebMarkupContainer hideLogged = new WebMarkupContainer("hideLogged");
            WebMarkupContainer hideAssigned = new WebMarkupContainer("hideAssigned");
            if(user.getId() == 0) {
                hideLogged.setVisible(false);
                hideAssigned.setVisible(false);
            }
            table.add(hideLogged);
            table.add(hideAssigned);

            table.add(new ListView("dashboardRows", spaceRoles) {
                protected void populateItem(final ListItem listItem) {
                    UserSpaceRole usr = (UserSpaceRole) listItem.getModelObject();
                    Counts counts = countsHolder.getCounts().get(usr.getSpace().getId());
                    if (counts == null) {
                        counts = new Counts(false); // this can happen if fresh space
                    }
                    DashboardRowPanel dashboardRow = new DashboardRowPanel("dashboardRow", usr, counts);                   
                    listItem.add(dashboardRow);
                }
            });

            // TODO panelize totals row and reduce redundant code
            WebMarkupContainer total = new WebMarkupContainer("total");

            if(spaceRoles.size() > 1) {

                total.add(new Link("search") {
                    public void onClick() {                       
                        setResponsePage(ItemSearchFormPage.class);
                    }
                });

                if(user.getId() > 0) {           
                    total.add(new Link("loggedByMe") {
                        public void onClick() {                           
                            ItemSearch itemSearch = new ItemSearch(user);
                            itemSearch.setLoggedBy(user);                           
                            setResponsePage(ItemListPage.class, itemSearch.getAsQueryString());
View Full Code Here

TOP

Related Classes of info.jtrac.domain.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.