Package org.spw.model

Examples of org.spw.model.Document


        return "success";
    }
   
    public String buttonRemove_action() {
        RowKey rk = tableRowGroup1.getRowKey();
        Document document;
        if (rk != null) {
            document = (Document)list.getObject(rk);
        } else {
            return null;
        }

        String filename = document.getDocumentLink();
        File file = new File(DocumentFileManager.
                getFilenameOnServer(filename, getServerPath()));
        file.delete();
        removeDocument(document);
       
View Full Code Here


        //* Bug if you display a document with a link
        // --> use a button (see http://blogs.sun.com/tor/entry/creating_downloadable_files)
       
        //TODO: refactor this to move all the file specific actions to a new class
        RowKey rk = tableRowGroup1.getRowKey();
        Document document;
        if (rk != null) {
            document = (Document)list.getObject(rk);
        } else {
            error("This document has been removed.");
            return null;
        }
       
        String filename = document.getDocumentLink();
        String contentType = document.getDocumentType();
        if (contentType == null)
            contentType = "application/x-download";
        File file = new File(DocumentFileManager.
                getFilenameOnServer(filename, getServerPath()));
        ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
View Full Code Here

        return null;
    }

    public String buttonDetach_action() {
        RowKey rk = tableRowGroup1.getRowKey();
        Document document;
        if (rk != null) {
            document = (Document)list.getObject(rk);
        } else {
            return null;
        }
View Full Code Here

    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null) return null;
        if (!(value instanceof Document)) {
            throw new ConverterException("Error converting Document, got a " + value.getClass().getName());
        }
        Document obj = (Document) value;
        return Long.toString(obj.getIdDocument());
    }
View Full Code Here

     * Creates a new instance of DocumentDataProvider
     */
    public DocumentDataProvider() {
        aList = new ArrayList<Document>();
        // Put in dummy data for design time
        aList.add(new Document());
       
        // Wrap the list
        setList(aList);
    }
View Full Code Here

     * Creates a new instance of DocumentDataProvider
     */
    public DocumentDataProvider() {
        aList = new ArrayList<Document>();
        // Put in dummy data for design time
        aList.add(new Document());
       
        // Wrap the list
        setList(aList);
    }
View Full Code Here

        boolean found1 = false;
        boolean found2 = false;
       
        ContactController instance = new ContactController();
        Contact contact = instance.read(testPersons.get(0).getIdContact());
        Document doc1 = new Document();
        doc1.setContact(contact);
        doc1.setDocumentType("Test1");
        doc1.setTitle(getName());
       
        Document doc2 = new Document();
        doc2.setContact(contact);
        doc2.setDocumentType("Test2");
        doc2.setTitle(getName());
       
        doc1 = instance.addDocument(doc1);
        doc2 = instance.addDocument(doc2);
        assertEquals(contact, doc1.getContact());
        assertEquals(contact, doc2.getContact());
        for(Document aDoc : doc2.getContact().getDocumentLinks()) {
            if (aDoc.getTitle().equals(getName())
            && aDoc.getDocumentType().equals("Test1")) {
                found1 = true;
            }
            if (aDoc.getTitle().equals(getName())
            && aDoc.getDocumentType().equals("Test2")) {
                found2 = true;
            }
        }
        assertTrue("The added 1rst test document is not found", found1);
        assertTrue("The added 2nd test document is not found", found2);
       
        //check if donations can be read
        DocumentController documentCtrl = new DocumentController();
        assertNotNull(documentCtrl.read(doc1.getIdDocument()));
        assertNotNull(documentCtrl.read(doc2.getIdDocument()));
       
        //check update an existing donation
        doc1.setDocumentType("Test3");
        instance.addDocument(doc1);
        assertEquals("Test3", documentCtrl.read(doc1.getIdDocument()).getDocumentType());
View Full Code Here

        boolean found2 = false;
       
        ContactController instance = new ContactController();
        DocumentController docCtrl = new DocumentController();
        Contact contact = instance.read(testPersons.get(0).getIdContact());
        Document doc1 = new Document();
        doc1.setContact(contact);
        doc1.setDocumentType("Test1");
        doc1.setTitle(getName());
       
        Document doc2 = new Document();
        doc2.setContact(contact);
        doc2.setDocumentType("Test2");
        doc2.setTitle(getName());
       
        doc1 = instance.addDocument(doc1);
        doc2 = instance.addDocument(doc2);
        assertEquals(contact, doc1.getContact());
        assertEquals(contact, doc2.getContact());

        contact = instance.removeDocument(doc1);
        contact = instance.removeDocument(doc2);
        for(Document aDoc : contact.getDocumentLinks()) {
            if (aDoc.getTitle().equals(getName())
            && aDoc.getDocumentType().equals("Test1")) {
                found1 = true;
                break;
            }
            if (aDoc.getTitle().equals(getName())
            && aDoc.getDocumentType().equals("Test2")) {
                found2 = true;
                break;
            }
        }
        assertFalse("The removed 1rst test is found", found1);
        assertFalse("The removed 2nd test is found", found2);
       
        //check if donations can be read
        assertNull(docCtrl.read(doc1.getIdDocument()));
        assertNull(docCtrl.read(doc2.getIdDocument()));
    }
View Full Code Here

    public DocumentControllerTest(String testName) {
        super(testName);
    }

    protected void setUp() throws Exception {
        Document docTest = new Document();
        docTest.setIdDocument(TEST_ID);
        docTest.setDocumentLink(getName());
        docTest.setTitle(getName());
        docTest.setDocumentType("Fax");
        ctrl.create(docTest);
    }
View Full Code Here

    public void testParse() {
        System.out.println("parse");
       
        String id = "";
       
        Document result = ctrl.parse(id);
        assertNull("Must not find a document with incorrect string rep.", result);
        id = null;
        assertNull("Must not find a document with incorrect string rep.", result);
        id = "]9999999[";
        assertNull("Must not find a document with incorrect string rep.", result);
       
        id = "anything[9999999]";
        result = ctrl.parse(id);
        assertEquals((long)TEST_ID, (long)result.getIdDocument());
    }
View Full Code Here

TOP

Related Classes of org.spw.model.Document

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.