Package org.spw.model

Examples of org.spw.model.Communication


        com3.setTopic(getName());
        comCtrl.create(com3);
    }
   
    protected void tearDown() throws Exception {
        Communication com;
        comCtrl.delete(comCtrl.read(TEST_ID_COMPLETED));
        comCtrl.delete(comCtrl.read(TEST_ID_NO_ACTION));
        comCtrl.delete(comCtrl.read(TEST_ID_NOT_COMPLETED));
       
        Person person;
View Full Code Here


            person.setLastName(getName() + " #" + i);
            person = pCtrl.update(person);
            participants.add(person);
        }
       
        Communication com = new Communication();
        com.setIdCommunication(TEST_ID_COMPLETED);
        com.setActionToBeConducted(getName());
        com.setDateCommunication(new Date());
        com.setDateOfCompletion(new Date());
        com.setMedia("test");
        com.setTopic(getName());
        com = comCtrl.update(com);
        com = comCtrl.updateParticipants(com, participants);
        assertEquals(10, com.getParticipants().size());
        Person person;
        for(int i=0; i < 10; i++) {
            person = pCtrl.read(TEST_ID_CONTACT1 + i);
            assertTrue(person.getParticipate().contains(com));
        }
       
        //try to remove one participant and check if the relation is updated for both side
        participants = new ArrayList(com.getParticipants());
        person = pCtrl.read(TEST_ID_CONTACT1);
        assertTrue(participants.remove(person));
       
        com = comCtrl.updateParticipants(com, participants);
        // check the removed participant doesn't contain the communication
        person = pCtrl.read(person.getIdContact());
        assertFalse(person.getParticipate().contains(com));
        //check new list size
        assertEquals(9, com.getParticipants().size());
    }
View Full Code Here

    }
   
    public String buttonCompleted_action() {
        RowKey rk = tableRowGroup1.getRowKey();
        if (rk != null) {
            Communication communication = (Communication)getSessionBean1().
                    getCommunicationDataProvider().getObject(rk);
            communication.setDateOfCompletion(new Date());
            new CommunicationController().update(communication);
        }
        // Refresh
        actionsNotCompletedList.refreshListActionsNotCompleted();
       
View Full Code Here

    }
   
    public String buttonEditCommunication_action() {
        RowKey rk = tableRowGroup1.getRowKey();
        if (rk != null) {
            Communication communication = (Communication) actionsNotCompletedList.getObject(rk);
            if (! communication.getParticipants().isEmpty()) {
                Contact contact = communication.getParticipants().get(0);
                if (contact instanceof Partnership) {
                    getSessionBean1().setPartnership((Partnership) contact);
                    return "infoPartnership";
                } else if (contact instanceof Person) {
                    getSessionBean1().setPerson((Person) contact);
View Full Code Here

        }
    }
   
    private void historize(Contact contact) {
        CommunicationController comCtl = new CommunicationController();
        Communication com = new Communication();
        com.setDateCommunication(new Date());
        com.setMedia("Email");
        com.setTopic(this.getSubject());
        List<Contact> participants = new ArrayList<Contact>(1);
        participants.add(contact);
        com.setParticipants(participants);
        comCtl.create(com);
    }
View Full Code Here

     * @param key The unique ID of the object
     * @return a communication if found, null otherwise
     */
    public Communication read(Long key) {
        EntityManager em = emf.createEntityManager();
        Communication retValue = null;
        try {
            retValue = em.find(Communication.class, key);
        } catch (Exception e) {
            Logger.getLogger(CommunicationController.class.getName()).log(Level.SEVERE, "Error reading " + key, e);
            if (em.getTransaction().isActive())
View Full Code Here

     * Update an existing communication. If it's a new Communication, create it.
     * @param object The communication to update
     * @return the new object communication after the persistence operation
     */
    public Communication update(Communication object) {
        Communication result = null;
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            result = em.merge(object);
            em.getTransaction().commit();
View Full Code Here

     */
    public void delete(Communication object) {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            Communication entity = em.find(Communication.class, object.getIdCommunication());
            // remove communication from contact removed from the list
            for(Contact contact : entity.getParticipants()) {
                contact.getParticipate().remove(entity);
                em.merge(contact);
            }
           
            em.remove(entity);
View Full Code Here

     * @return the new communication object after being persisted
     */
    public Communication updateParticipants(Communication communication,
            List<Contact> newParticipants) {
        // First persist the communication with all the contacts
        Communication result = null;
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        try {
            // remove communication from contact removed from the list
            for(Contact contact : communication.getParticipants()) {
View Full Code Here

        contactCtrl = new ContactController();
        testContact = new Contact();
        testContact.setFirstName(getName());
        contactCtrl.create(testContact);
        //Action completed with a participant
        completedWithContact = new Communication();
        completedWithContact.setActionToBeConducted("Test already done");
        completedWithContact.setDateOfCompletion(new Date());
        completedWithContact.setTopic(getName());
        List participants = new ArrayList();
        participants.add(testContact);
        completedWithContact.setParticipants(participants);
        comCtrl.create(completedWithContact);
        testContact.getParticipate().add(completedWithContact);
        contactCtrl.update(testContact);
        //No action to complete
        noAction = new Communication();
        noAction.setTopic(getName());
        comCtrl.create(noAction);
        //Action to complete
        withActionToComplete = new Communication();
        withActionToComplete.setActionToBeConducted("Test to be done");
        withActionToComplete.setTopic(getName());
        comCtrl.create(withActionToComplete);
    }
View Full Code Here

TOP

Related Classes of org.spw.model.Communication

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.