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 String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null) return null;
        if (!(value instanceof Contact)) {
            throw new ConverterException("Error converting Contact, got a " + value.getClass().getName());
        }
        Contact obj = (Contact) value;
        return Long.toString(obj.getIdContact());
    }
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

    private void addCommunication() {
        String[] selected = getSessionBean1().getChoices();
        CommunicationController comCtl = new CommunicationController();
        ContactController contactCtl = new ContactController();
        Contact contact = getContact();
        Communication communication = getCommunication();
       
        //Create communication (needed for new object)
        communication = comCtl.update(communication);
       
        //Insert the participants after converting the array to List
        java.util.List<Contact> participants = new ArrayList<Contact>();
        participants.add(contact);
        if (selected != null) {
            for (int i= 0; i < selected.length; i++) {
                Contact aParticipant = contactCtl.parse("["+selected[i]+"]");
                if (aParticipant != null && !aParticipant.equals(contact)) {
                    participants.add(aParticipant);
                }
            }
        }
        communication = comCtl.updateParticipants(communication, participants);
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)list.getObject(rk);
            if (getSessionBean1().getEmailChoices().add(contact)) added++;
        }
        info(added + " added to the email selection.");
       
        return null;
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)list.getObject(rk);
            if (getSessionBean1().getMailChoices().add(contact)) added++;
        }
        info(added + " added to the mail selection.");
       
        return null;
View Full Code Here

       
        return "success";
    }

    private void persistDonation() {
        Contact contact = getContact();
        Donation donation = getDonation();
        donation.setDonor(contact);
        donation = new ContactController().addDonation(donation);
       
        setDonation(donation);
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.