Package info.jtrac.domain

Examples of info.jtrac.domain.User


       
        super(id);
        setOutputMarkupId(true);
       
        final Space space = usr.getSpace();
        final User user = usr.getUser();
       
        final Map<Integer, String> states = new TreeMap(space.getMetadata().getStatesMap());   
        states.remove(State.NEW);
        int rowspan = states.size() + 1; // add one totals row also
        final SimpleAttributeModifier sam = new SimpleAttributeModifier("rowspan", rowspan + "");
        List<Integer> stateKeys = new ArrayList<Integer>(states.keySet());                                               
       
        add(new ListView("rows", stateKeys) {
           
            protected void populateItem(ListItem listItem) {                               
               
                if (listItem.getIndex() == 0) { // rowspan output only for first row           
                   
                    WebMarkupContainer spaceCell = new WebMarkupContainer("space");    
                    spaceCell.add(sam);
                    listItem.add(spaceCell);
                                     
                    spaceCell.add(new Label("name", space.getName()));
                    spaceCell.add(new Label("prefixCode", space.getPrefixCode()));
                   
                    WebMarkupContainer newColumn = new WebMarkupContainer("new");
                    newColumn.add(sam);  
                    listItem.add(newColumn);
                   
                    if(usr.isAbleToCreateNewItem()) {
                        newColumn.add(new Link("new") {
                            public void onClick() {
                                setCurrentSpace(space);
                                setResponsePage(ItemFormPage.class);
                            }
                        });

                    } else {
                        newColumn.add(new WebMarkupContainer("new").setVisible(false));
                    }

                    listItem.add(new Link("search") {
                        public void onClick() {
                            setCurrentSpace(space);
                            ItemSearch itemSearch = new ItemSearch(space);
                            setResponsePage(ItemSearchFormPage.class, itemSearch.getAsQueryString());
                        }
                    }.add(sam));

                    listItem.add(new IndicatingAjaxLink("link") {
                        public void onClick(AjaxRequestTarget target) {
                            DashboardRowPanel dashboardRow = new DashboardRowPanel("dashboardRow", usr, counts);
                            DashboardRowExpandedPanel.this.replaceWith(dashboardRow);
                            target.addComponent(dashboardRow);
                        }
                    }.add(sam));
                   
                } else {
                    listItem.add(new WebMarkupContainer("space").setVisible(false));
                    listItem.add(new WebMarkupContainer("new").setVisible(false));
                    listItem.add(new WebMarkupContainer("search").setVisible(false));
                    listItem.add(new WebMarkupContainer("link").setVisible(false));
                }
               
                final Integer i = (Integer) listItem.getModelObject();
                listItem.add(new Label("status", states.get(i)));
               
                if(user.getId() > 0) {               
                    listItem.add(new Link("loggedByMe") {
                        public void onClick() {
                            setCurrentSpace(space);
                            ItemSearch itemSearch = new ItemSearch(space);
                            itemSearch.setLoggedBy(user);
                            itemSearch.setStatus(i);                           
                            setResponsePage(ItemListPage.class, itemSearch.getAsQueryString());
                        }
                    }.add(new Label("loggedByMe", counts.getLoggedByMeForState(i))));

                    listItem.add(new Link("assignedToMe") {
                        public void onClick() {
                            setCurrentSpace(space);
                            ItemSearch itemSearch = new ItemSearch(space);
                            itemSearch.setAssignedTo(user);
                            itemSearch.setStatus(i);                           
                            setResponsePage(ItemListPage.class, itemSearch.getAsQueryString());
                        }
                    }.add(new Label("assignedToMe", counts.getAssignedToMeForState(i))));
                } else {
                    listItem.add(new WebMarkupContainer("loggedByMe").setVisible(false));
                    listItem.add(new WebMarkupContainer("assignedToMe").setVisible(false));                   
                }
               
                listItem.add(new Link("total") {
                    public void onClick() {
                        setCurrentSpace(space);
                        ItemSearch itemSearch = new ItemSearch(space);                       
                        itemSearch.setStatus(i);                       
                        setResponsePage(ItemListPage.class, itemSearch.getAsQueryString());
                    }
                }.add(new Label("total", counts.getTotalForState(i))));               
            }
           
        });
       
        // sub totals ==========================================================
       
        if(user.getId() > 0) {       
            add(new Link("loggedByMeTotal") {
                public void onClick() {
                    setCurrentSpace(space);
                    ItemSearch itemSearch = new ItemSearch(space);
                    itemSearch.setLoggedBy(user);                   
View Full Code Here


            history.setItemUsers(item.getItemUsers());
            final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(history);
            setModel(model);
            add(new TextArea("comment").setRequired(true).add(new ErrorHighlighter()));
            // custom fields ===================================================
            User user = getPrincipal();
            add(new CustomFieldsFormPanel("fields", model, item, user));
            // =================================================================
            final Space space = item.getSpace();
            final List<UserSpaceRole> userSpaceRoles = getJtrac().findUserRolesForSpace(space.getId());           
            // assigned to =====================================================
View Full Code Here

       
        @Override
        protected void onSubmit() {
            final FileUpload fileUpload = fileUploadField.getFileUpload();
            History history = (History) getModelObject();
            User user = JtracSession.get().getUser();
            history.setLoggedBy(user);
            getJtrac().storeHistoryForItem(itemId, history, fileUpload);
            setResponsePage(ItemViewPage.class, new PageParameters("0=" + history.getRefId()));
        }
View Full Code Here

public class HeaderPanel extends BasePanel {   
   
    public HeaderPanel() {
        super("header");
       
        final User user = getPrincipal();
        final Space space = getCurrentSpace();
        final List<Space> spaces = new ArrayList(user.getSpaces());
       
        add(new Link("dashboard") {
            public void onClick() {
                setCurrentSpace(null);
                setResponsePage(DashboardPage.class);
            }           
        });
       
        if (space == null) {
            add(new WebMarkupContainer("spaceName").setVisible(false));
            add(new WebMarkupContainer("new").setVisible(false));
            add(new Link("search") {
                public void onClick() {                   
                    // if only one space don't use generic search screen
                    if(spaces.size() == 1) {
                        Space current = spaces.get(0);
                        setCurrentSpace(current);                       
                    } else {
                        setCurrentSpace(null); // may have come here with back button!                       
                    }
                    setResponsePage(ItemSearchFormPage.class);
               
                @Override
                public boolean isVisible() {
                    return spaces.size() > 0;
                }
            });           
        } else {
            add(new Label("spaceName", space.getName()));  
            add(new Label("prefixCode", space.getPrefixCode()));
            if (user.getPermittedTransitions(space, State.NEW).size() > 0) {           
                add(new Link("new") {
                    public void onClick() {
                        setResponsePage(ItemFormPage.class);
                    }           
                });
            } else {
                add(new WebMarkupContainer("new").setVisible(false));      
            }
           
            add(new Link("search") {
                public void onClick() {
                    setResponsePage(ItemSearchFormPage.class);
                }           
            });           
        }
       
        if(user.getId() == 0) {
            add(new WebMarkupContainer("options").setVisible(false));
            add(new WebMarkupContainer("logout").setVisible(false));
            add(new Link("login") {
                public void onClick() {
                    setResponsePage(LoginPage.class);
                }           
            });
            add(new WebMarkupContainer("user").setVisible(false));
        } else {
            add(new Link("options") {
                public void onClick() {
                    JtracSession.get().setCurrentSpace(null);
                    setResponsePage(OptionsPage.class);
                }           
            });
            add(new Link("logout") {
                public void onClick() {                                       
                    Cookie cookie = new Cookie("jtrac", "");                   
                    String path = ((WebRequest) getRequest()).getHttpServletRequest().getContextPath();
                    cookie.setPath(path);                   
                    ((WebResponse) getResponse()).clearCookie(cookie);                   
                    getSession().invalidate();
                    logger.debug("invalidated session and cleared cookie");
                    // is acegi - cas being used ?
                    String logoutUrl = JtracApplication.get().getCasLogoutUrl();
                    if(logoutUrl != null) {
                        logger.debug("cas authentication being used, clearing security context and redirecting to cas logout page");
                        SecurityContextHolder.clearContext();                       
                        // have to use stateless page reference because session is killed
                        setResponsePage(CasLogoutPage.class);
                    } else {
                        setResponsePage(LogoutPage.class, new PageParameters("locale=" + user.getLocale()));
                    }
                }           
            });
            add(new WebMarkupContainer("login").setVisible(false));
            add(new Label("user", user.getName()));
        }            
       
    }
View Full Code Here

    public void setPrevious(WebPage previous) {
        this.previous = previous;
    }   
   
    public UserFormPage() { 
        User user = new User();
        user.setLocale(getJtrac().getDefaultLocale());
        add(new UserForm("form", user));
    }   
View Full Code Here

            getHibernateTemplate().find("from Item item where item.id = 1");
            logger.info("database schema exists, normal startup");
        } catch (Exception e) {
            logger.warn("expected database schema does not exist, will create. Error is: " + e.getMessage());
            schemaHelper.createSchema();
            User admin = new User();
            admin.setLoginName("admin");
            admin.setName("Admin");
            admin.setEmail("admin");
            admin.setPassword("21232f297a57a5a743894a0e4a801fc3");
            admin.addSpaceWithRole(null, Role.ROLE_ADMIN);
            logger.info("inserting default admin user into database");
            storeUser(admin);
            logger.info("schema creation complete");
        }
        List<SpaceSequence> ssList = getHibernateTemplate().loadAll(SpaceSequence.class);
View Full Code Here

        Map<Field.Name, Field> fields = m2.getFields();
        assertTrue(fields.size() == 2);
    }
   
    public void testUserInsertAndLoad() {
        User user = new User();
        user.setLoginName("test");
        user.setEmail("test@jtrac.com");
        jtrac.storeUser(user);
        User user1 = jtrac.loadUser("test");
        assertTrue(user1.getEmail().equals("test@jtrac.com"));
        User user2 = dao.findUsersByEmail("test@jtrac.com").get(0);
        assertTrue(user2.getLoginName().equals("test"));
    }
View Full Code Here

        Metadata metadata = getMetadata();
       
        space.setMetadata(metadata);
        jtrac.storeSpace(space);
       
        User user = new User();
        user.setLoginName("test");
       
        user.addSpaceWithRole(space, "ROLE_TEST");
        jtrac.storeUser(user);
       
        User u1 = jtrac.loadUser("test");
       
        GrantedAuthority[] gas = u1.getAuthorities();
        assertEquals(1, gas.length);       
        assertEquals("ROLE_TEST:TEST", gas[0].getAuthority());
       
        List<UserSpaceRole> userSpaceRoles = jtrac.findUserRolesForSpace(space.getId());
        assertEquals(1, userSpaceRoles.size());
View Full Code Here

        String value = jtrac.loadConfig("testParam");
        assertEquals("testValue", value);
    }
   
    public void testStoreAndLoadUserWithAdminRole() {
        User user = new User();
        user.setLoginName("test");
        user.addSpaceWithRole(null, "ROLE_ADMIN");
        jtrac.storeUser(user);
       
        UserDetails ud = jtrac.loadUserByUsername("test");
       
        Set<String> set = new HashSet<String>();
View Full Code Here

    }
   
    public void testItemInsertAndCounts() {
        Space s = getSpace();
        jtrac.storeSpace(s);
        User u = new User();
        u.setLoginName("test");
        u.addSpaceWithRole(s, "DEFAULT");
        jtrac.storeUser(u);
        Item i = new Item();
        i.setSpace(s);
        i.setAssignedTo(u);
        i.setLoggedBy(u);
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.