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

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


    @DefaultHandler
    public Resolution save() {
        BugManager bm = new BugManager();

        for (Bug bug : bugs) {
            Bug newBug = populateBug(bug);
            bm.saveOrUpdate(newBug);
        }

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


    public void setAttachmentIndex(Integer attachmentIndex) { this.attachmentIndex = attachmentIndex; }

    @DefaultHandler
    public Resolution getAttachment() {
        BugManager bm = new BugManager();
        Bug bug = bm.getBug(this.bugId);
        Attachment attachment = bug.getAttachments().get(this.attachmentIndex);

        // Uses a StreamingResolution to send the file contents back to the user.
        // Note the use of the chained .setFilename() method, which causes the
        // browser to [prompt to] save the "file" instead of displaying it in browser
        return new StreamingResolution
View Full Code Here

     */
    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

    /** Saves (or updates) a bug, and then returns the user to the bug list. */
    @DefaultHandler
    public Resolution save() throws IOException {
        BugManager bm = new BugManager();

        Bug newBug = populateBug(this.bug);
        if (this.newAttachment != null) {
            Attachment attachment = new Attachment();
            attachment.setName(this.newAttachment.getFileName());
            attachment.setSize(this.newAttachment.getSize());
            attachment.setContentType(this.newAttachment.getContentType());

            byte[] data = new byte[(int) this.newAttachment.getSize()];
            InputStream in = this.newAttachment.getInputStream();
            in.read(data);
            attachment.setData(data);
            newBug.addAttachment(attachment);
        }

        bm.saveOrUpdate(newBug);

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

    /** Saves (or updates) a bug, and then returns the user to the bug list. */
    public Resolution save() throws IOException {
        BugManager bm = new BugManager();

        Bug bug = getBug();
        if (this.newAttachment != null) {
            Attachment attachment = new Attachment();
            attachment.setName(this.newAttachment.getFileName());
            attachment.setSize(this.newAttachment.getSize());
            attachment.setContentType(this.newAttachment.getContentType());

            byte[] data = new byte[(int) this.newAttachment.getSize()];
            InputStream in = this.newAttachment.getInputStream();
            in.read(data);
            attachment.setData(data);
            bug.addAttachment(attachment);
        }

        // Set the open date for new bugs
        if (bug.getOpenDate() == null)
            bug.setOpenDate(new Date());

        bm.saveOrUpdate(bug);

        return new RedirectResolution(BugListActionBean.class);
    }
View Full Code Here

     * @param errors The validation errors for this request. If the input string cannot be parsed,
     *            then we will add a new {@link ValidationError} to this collection and return null.
     */
    public Bug convert(String input, Class<? extends Bug> targetType,
            Collection<ValidationError> errors) {
        Bug bug = null;

        try {
            int id = Integer.valueOf(input);
            BugManager bugManager = new BugManager();
            bug = bugManager.getBug(id);
View Full Code Here

TOP

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

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.