Package org.spw.model

Examples of org.spw.model.Contact


        int begin = contact.lastIndexOf('[');
        if (begin < 0) return null;
        int last  = contact.lastIndexOf(']');
        if (last < 0) return null;
        String number = contact.substring(begin+1, last);
        Contact retValue = null;
        try {
            retValue = read(Long.parseLong(number));
        } catch (NumberFormatException ex) {
            //incorrect number, could not appen
            Logger.getLogger(ContactController.class.getName()).severe(contact +
View Full Code Here


     * @param donation the donation to persist. The donor must be set
     * @return the new version of the donation after persisted (the donor is
     * updated with the lastest version of the contact)
     */
    public Donation addDonation(Donation donation) {
        Contact contact = donation.getDonor();
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        // remove the donation if exist
        if (donation.getIdDonation() != null) {
            contact.getDonations().remove(donation);
        }
        // merge the donation, add it and merge the contact
        donation = em.merge(donation);
        contact.getDonations().add(donation);
        contact = em.merge(contact);
        em.getTransaction().commit();
        em.close();
        // store the donor in the donation as a return value
        donation.setDonor(contact);
View Full Code Here

     */
    public Contact removeDonation(Donation donation) {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        donation = em.find(Donation.class, donation.getIdDonation());
        Contact contact = donation.getDonor();
        // remove the donation if exist
        if (donation.getIdDonation() != null) {
            contact.getDonations().remove(donation);
        }
        em.remove(donation);
        contact = em.merge(contact);
        em.getTransaction().commit();
        em.close();
View Full Code Here

     * @param document the document to persist. The contact must be set
     * @return the new version of the document after persisted (the contact is
     * updated with the lastest version of the contact)
     */
    public Document addDocument(Document document) {
        Contact contact = document.getContact();
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        // remove the document if exist
        if (document.getIdDocument() != null) {
            contact.getDocumentLinks().remove(document);
        }
        // merge the document, add it and merge the contact
        document = em.merge(document);
        contact.getDocumentLinks().add(document);
        contact = em.merge(contact);
        em.getTransaction().commit();
        em.close();
        // store the contact in the document as a return value
        document.setContact(contact);
View Full Code Here

     */
    public Contact removeDocument(Document document) {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        document = em.find(Document.class, document.getIdDocument());
        Contact contact = document.getContact();
        // remove the donation if exist
        if (document.getIdDocument() != null) {
            contact.getDocumentLinks().remove(document);
        }
        em.remove(document);
        contact = em.merge(contact);
        em.getTransaction().commit();
        em.close();
View Full Code Here

    public String buttonEmail_action() {
        int added = 0;
        int selectedRows = getTableRowGroup1().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys();
        for(RowKey rk : selectedRowKeys){
            Contact contact = (Contact)getSessionBean1().
                    getContactDataProvider().getObject(rk);
            if (getSessionBean1().getEmailChoices().add(contact)) added++;
        }
        info (added + " added to the email selection.");
       
View Full Code Here

    public String buttonMail_action() {
        int added = 0;
        int selectedRows = getTableRowGroup1().getSelectedRowsCount();
        RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys();
        for(RowKey rk : selectedRowKeys){
            Contact contact = (Contact)getSessionBean1().
                    getContactDataProvider().getObject(rk);
            if (getSessionBean1().getMailChoices().add(contact)) added++;
        }
        info (added + " added to the mail selection.");
        return null;
View Full Code Here

        super(testName);
    }
   
    @Override
    protected void setUp() throws Exception {
        contact = new Contact();
        contact.setFirstName(this.getName());
        contact = contactCtrl.update(contact);
        donation = new Donation();
        donation.setProposalTitle(this.getName());
        donation.setDonor(contact);
View Full Code Here

        Donation result = donationCtrl.read(donation.getIdDonation());
        assertNotNull(result);
        instance.deleteDonation(result);
        result = donationCtrl.read(donation.getIdDonation());
        assertNull(result);
        Contact resultContact = contactCtrl.read(contact.getIdContact());
        assertFalse(resultContact.getDonations().contains(donation));
    }
View Full Code Here

       
        String contact = "";
        ContactController instance = new ContactController();
       
        // --- Tests incorrects cases (return null)
        Contact expResult = null;
        //test empty string
        Contact result = instance.parse(contact);
        assertEquals("Parsing empty string should give a null contact",
                expResult, result);
       
        // test null string
        contact = null;
        result = instance.parse(contact);
        assertEquals("Parsing null string should give a null contact",
                expResult, result);
       
        // test incorrect number
        contact = "[199999999]"; //this case can't occur until few thousand of years
        result = instance.parse(contact);
        assertEquals("Parsing incorrect number should give a null contact",
                expResult, result);
       
        // test incorrect format number
        contact = "[1Z1]";
        result = instance.parse(contact);
        assertEquals("Parsing invalid format number should give a null contact",
                expResult, result);
       
        // --- Test correct case
        // test correct number
        expResult = new Contact();
        expResult.setNote("Test case");
        instance.create(expResult);
        contact = "[" + expResult.getIdContact().toString() + "]";
        result = instance.parse(contact);
        assertEquals("Parsing empty string should give a null contact",
View Full Code Here

TOP

Related Classes of org.spw.model.Contact

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.