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

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


    public List<Component> getComponents() { return components; }
    public void setComponents(List<Component> components) { this.components = components; }

    @DefaultHandler
    public Resolution save() {
        ComponentManager cm = new ComponentManager();

        // Apply any changes to existing people (and create new ones)
        for (Component component : components) {
            Component realComponent;
            if (component.getId() == null) {
                realComponent = new Component();
            }
            else {
                realComponent = cm.getComponent(component.getId());
            }

            realComponent.setName(component.getName());
            cm.saveOrUpdate(realComponent);
        }

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

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


     * @param bug a bug from which to create a fully populated bug
     * @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

     * If no list of components is set and we're not handling the "save" event then populate the
     * list of components and return it.
     */
    public List<Component> getComponents() {
        if (components == null && !"save".equals(getContext().getEventName())) {
            components = new ComponentManager().getAllComponents();
        }

        return components;
    }
View Full Code Here

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

    public Resolution save() {
        ComponentManager cm = new ComponentManager();

        // Save any changes to existing components (and create new ones)
        for (Component component : components) {
            cm.saveOrUpdate(component);
        }

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

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

            Collection<ValidationError> errors) {
        Component component = null;

        try {
            int id = Integer.valueOf(input);
            ComponentManager componentManager = new ComponentManager();
            component = componentManager.getComponent(id);
        }
        catch (NumberFormatException e) {
            errors.add(new SimpleError("The number {0} is not a valid Component ID", input));
        }
View Full Code Here

TOP

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

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.