Package net.sourceforge.stripes.examples.bugzooky.biz

Examples of net.sourceforge.stripes.examples.bugzooky.biz.PersonManager


    /** The URL the user was trying to access (null if the login page was accessed directly). */
    public void setTargetUrl(String targetUrl) { this.targetUrl = targetUrl; }
   
    public Resolution login() {
        PersonManager pm = new PersonManager();
        Person person = pm.getPerson(this.username);

        if (person == null) {
            ValidationError error = new LocalizableError("usernameDoesNotExist");
            getContext().getValidationErrors().add("username", error);
            return getContext().getSourcePageResolution();
View Full Code Here


     * @return a fully populated bug
     */
    protected Bug populateBug(Bug bug) {
        BugManager bm = new BugManager();
        ComponentManager cm = new ComponentManager();
        PersonManager pm = new PersonManager();
        Bug newBug;

        if (bug.getId() == null) {
            newBug = new Bug();
            newBug.setOpenDate(new Date());
        }
        else {
            newBug = bm.getBug((bug.getId()));
        }

        // Populate the fields from the bug on the form
        newBug.setLongDescription( bug.getLongDescription() );
        newBug.setPriority( bug.getPriority());
        newBug.setShortDescription( bug.getShortDescription() );
        newBug.setDueDate( bug.getDueDate() );
        newBug.setPercentComplete( bug.getPercentComplete() );

        // If it's a new bug, status isn't mandatory, so default it
        if (bug.getStatus() == null) {
            newBug.setStatus(Status.New);
        }
        else {
            newBug.setStatus( bug.getStatus() );
        }

        // Link in the full component and person based on their IDs
        newBug.setComponent( cm.getComponent(bug.getComponent().getId()) );
        newBug.setOwner( pm.getPerson(bug.getOwner().getId()) );
        return newBug;
    }
View Full Code Here

     * Validates that the two passwords entered match each other, and that the
     * username entered is not already taken in the system.
     */
    @ValidationMethod
    public void validate(ValidationErrors errors) {
        if ( new PersonManager().getPerson(this.user.getUsername()) != null ) {
            errors.add("user.username", new LocalizableError("usernameTaken"));
        }
    }
View Full Code Here

    /**
     * Registers a new user, logs them in, and redirects them to the bug list page.
     */
    @DefaultHandler
    public Resolution register() {
        PersonManager pm = new PersonManager();
        pm.saveOrUpdate(this.user);
        getContext().setUser(this.user);
        getContext().getMessages().add(
                new LocalizableMessage(getClass().getName() + ".successMessage",
                                       this.user.getFirstName(),
                                       this.user.getUsername()));
View Full Code Here

    public List<Person> getPeople() { return people; }
    public void setPeople(List<Person> people) { this.people = people; }

    @HandlesEvent("Save") @DefaultHandler
    public Resolution saveChanges() {
        PersonManager pm = new PersonManager();

        // Apply any changes to existing people (and create new ones)
        for (Person person : people) {
            Person realPerson;
            if (person.getId() == null) {
                realPerson = new Person();
            }
            else {
                realPerson = pm.getPerson(person.getId());
            }

            realPerson.setEmail(person.getEmail());
            realPerson.setFirstName(person.getFirstName());
            realPerson.setLastName(person.getLastName());
            realPerson.setUsername(person.getUsername());

            if (person.getPassword() != null) {
                realPerson.setPassword(person.getPassword());
            }
           
            pm.saveOrUpdate(realPerson);
        }

        // Then, if the user checked anyone off to be deleted, delete them
        if (deleteIds != null) {
            for (int id : deleteIds) {
                pm.deletePerson(id);
            }
        }

        return new RedirectResolution("/bugzooky/AdministerBugzooky.jsp");
    }
View Full Code Here

    public Resolution view() {
        return new ForwardResolution("/bugzooky/Login.jsp");
    }

    public Resolution login() {
        PersonManager pm = new PersonManager();
        Person person = pm.getPerson(this.username);

        if (person == null) {
            ValidationError error = new LocalizableError("usernameDoesNotExist");
            getContext().getValidationErrors().add("username", error);
            return getContext().getSourcePageResolution();
View Full Code Here

     * Validates that the two passwords entered match each other, and that the
     * username entered is not already taken in the system.
     */
    @ValidationMethod
    public void validate(ValidationErrors errors) {
        if ( new PersonManager().getPerson(this.user.getUsername()) != null ) {
            errors.add("user.username", new LocalizableError("usernameTaken"));
        }
    }
View Full Code Here

    /**
     * Registers a new user, logs them in, and redirects them to the bug list page.
     */
    public Resolution register() {
        PersonManager pm = new PersonManager();
        pm.saveOrUpdate(this.user);
        getContext().setUser(this.user);
        getContext().getMessages().add(
                new LocalizableMessage(getClass().getName() + ".successMessage",
                                       this.user.getFirstName(),
                                       this.user.getUsername()));
View Full Code Here

     * If no list of people is set and we're not handling the "save" event then populate the list of
     * people and return it.
     */
    public List<Person> getPeople() {
        if (people == null && !"Save".equals(getContext().getEventName())) {
            people = new PersonManager().getAllPeople();
        }

        return people;
    }
View Full Code Here

        return new ForwardResolution("/bugzooky/AdministerBugzooky.jsp");
    }

    @HandlesEvent("Save")
    public Resolution saveChanges() {
        PersonManager pm = new PersonManager();

        // Save any changes to existing people (and create new ones)
        for (Person person : people) {
            pm.saveOrUpdate(person);
        }

        // Then, if the user checked anyone off to be deleted, delete them
        if (deleteIds != null) {
            for (int id : deleteIds) {
                pm.deletePerson(id);
            }
        }

        return new RedirectResolution(getClass());
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.examples.bugzooky.biz.PersonManager

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.