Package org.nxplanner.domain

Examples of org.nxplanner.domain.Note


        Logger.getLogger(EditNoteAction.class).debug("Populating...");

        super.populateObject(request, object, form);

        NoteEditorForm noteForm = (NoteEditorForm)form;
        Note note = (Note)object;

        FormFile formFile = noteForm.getFormFile();
        if (formFile != null) {
            String filename = formFile.getFileName();
            if (StringUtils.isNotEmpty(filename)) {
                String contentType = formFile.getContentType();
                InputStream input = formFile.getInputStream();
                int fileSize = formFile.getFileSize();
                int projectId = request.getParameter("projectId") != null ?
                        Integer.parseInt(request.getParameter("projectId")) : 0;
                Directory directory = fileSystem.getDirectory("/attachments/project/"+projectId);
                File file = fileSystem.createFile(directory, filename, contentType, fileSize, input);
                note.setFile(file);

                Logger.getLogger(EditNoteAction.class).debug("Saving note: filename="
                        + filename + ", fileSize=" + fileSize + ", contentType=" + contentType);

            }
View Full Code Here


        Logger.getLogger(EditNoteAction.class).debug("Populating...");

        super.populateObject(request, object, form);

        NoteEditorForm noteForm = (NoteEditorForm)form;
        Note note = (Note)object;

        FormFile formFile = noteForm.getFormFile();
        if (formFile != null) {
            String filename = formFile.getFileName();
            if (StringUtils.isNotEmpty(filename)) {
                String contentType = formFile.getContentType();
                InputStream input = formFile.getInputStream();
                int fileSize = formFile.getFileSize();
                int projectId = request.getParameter("projectId") != null ?
                        Integer.parseInt(request.getParameter("projectId")) : 0;
                Directory directory = fileSystem.getDirectory("/attachments/project/"+projectId);
                File file = fileSystem.createFile(directory, filename, contentType, fileSize, input);
                note.setFile(file);

                Logger.getLogger(EditNoteAction.class).debug("Saving note: filename="
                        + filename + ", fileSize=" + fileSize + ", contentType=" + contentType);

            }
View Full Code Here

    }

    protected void setUp() throws Exception {
        super.setUp();
        action = new DownloadAttachmentAction();
        testNote = new Note();
        fileContent = "XXXXXX";
        file = fileContent.getBytes();
        contentType = "text/plain";
        fileSize = 6;
        filename = "testFile.txt";
View Full Code Here

        notes.add(testNote);
        mockSession.findReturn = notes;
        String expectedQuery = "from object in class org.nxplanner.domain.Note"
                + " where id=" + testId;

        Note actualNote = action.locateNote(mockSession, testId);

        assertEquals("Session did not receive the correct query.", expectedQuery, mockSession.findQuery);
        assertEquals("Did not receive the correct note.", testNote, actualNote);
    }
View Full Code Here

    }

    protected void setUp() throws Exception {
        super.setUp();
        action = new DownloadAttachmentAction();
        testNote = new Note();
        fileContent = "XXXXXX";
        file = fileContent.getBytes();
        contentType = "text/plain";
        fileSize = 6;
        filename = "testFile.txt";
View Full Code Here

        notes.add(testNote);
        mockSession.findReturn = notes;
        String expectedQuery = "from object in class org.nxplanner.domain.Note"
                + " where id=" + testId;

        Note actualNote = action.locateNote(mockSession, testId);

        assertEquals("Session did not receive the correct query.", expectedQuery, mockSession.findQuery);
        assertEquals("Did not receive the correct note.", testNote, actualNote);
    }
View Full Code Here

    private FileSystem mockFileSystem;

    protected void setUp() throws Exception {
        super.setUp();
        support = new XPlannerTestSupport();
        testNote = new Note();
        noteForm = new NoteEditorForm();
        fileContent = "XXXXXX";
        blob = new MockBlob();
        blob.getBinaryStreamReturn = new ByteArrayInputStream(fileContent.getBytes());
        testFormFile = new InputStreamFormFile(new ByteArrayInputStream(fileContent.getBytes()));
View Full Code Here

        action = new EditNoteAction();
        action.setFileSystem(mockFileSystem);
    }

    public void testPopulate() throws Exception {
        Note actualNote = new Note();
        actualNote.setSubmissionTime(testNote.getSubmissionTime());
        noteForm.setFormFile(testFormFile);
        MockControl mockDirectoryControl = createLocalClassControl(Directory.class);
        Directory mockDirectory = (Directory)mockDirectoryControl.getMock();
        mockFileSystemControl.expectAndReturn(mockFileSystem.getDirectory("/attachments/project/0"),
                mockDirectory);
View Full Code Here

        ResultSet rs = null;
        try {
            rs = statement.executeQuery("select id,filename,content_type,file_size,file " +
                    "from note where file is not null");
            while (rs.next()) {
                Note note = (Note)session.load(Note.class, new Integer(rs.getInt("id")));
                Integer projectId = (Integer)noteToProjectMap.get(new Integer(note.getId()));
                if (projectId == null) {
                    projectId = new Integer(0);
                }
                int filesize = rs.getInt("file_size");
                final FileSystem fileSystem = new FileSystemImpl();
                Directory directory = fileSystem.getDirectory("/attachments/project/"+projectId);
                File file = fileSystem.createFile(directory, rs.getString("filename"), rs.getString("content_type"),
                        filesize, rs.getBlob("file").getBinaryStream());
                note.setFile(file);
            }
            session.flush();
            session.connection().commit();
        } catch (SQLException e) {
            throw e;
View Full Code Here

public class DownloadAttachmentAction extends AbstractAction {
    private static Logger logger = Logger.getLogger(DownloadAttachmentAction.class);
    private static final int BUFFER_SIZE = 4000;

    protected Note locateNote(Session session, int id) {
        Note result = null;

        try {
            try {
                Class objectClass = Note.class;
                String query = "from object in class " + objectClass.getName();
View Full Code Here

TOP

Related Classes of org.nxplanner.domain.Note

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.