Package com.agiletec.plugins.jpaddressbook.aps.system.services.addressbook.model

Examples of com.agiletec.plugins.jpaddressbook.aps.system.services.addressbook.model.Contact


  protected void saveProfile(IUserProfile userProfile) {
    try {
      if (userProfile != null) {
        this.getAddressBookDAO().deleteContact(userProfile.getId());
        if (!userProfile.isPublicProfile()) return;
        Contact contact = new Contact(userProfile);
        contact.setOwner(userProfile.getUsername());
        contact.setPublicContact(userProfile.isPublicProfile());
        contact.setId(userProfile.getId());
        this.getAddressBookDAO().addContact(contact);
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "saveProfile");
    }
View Full Code Here


    return contactsKeys.contains(contactKey);
  }
 
  @Override
  public IContact getContact(String contactKey) throws ApsSystemException {
    Contact contact = null;
    try {
      ContactRecord contactVo = (ContactRecord) this.getAddressBookDAO().loadEntityRecord(contactKey);
      if (contactVo != null) {
        IUserProfile profile = (IUserProfile) this.createEntityFromXml(contactVo.getTypeCode(), contactVo.getXml());
        contact = new Contact(profile);
        contact.setId(contactVo.getId());
        contact.setOwner(contactVo.getOwner());
        contact.setPublicContact(contactVo.isPublicContact());
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "getContact");
      throw new ApsSystemException("Errore recupero getContact", t);
    }
View Full Code Here

  public void testAddGetContact() throws Throwable {
    try {
      Date birthdate1 = this._helper.setBirthdate(1981, 10, 25);
      IUserProfile profile1 = this._helper.createUserProfile(null,
          "name1 surname1", "indirizzoemail1@inesistente.itt", birthdate1, "it");
      Contact contact1 = this._helper.createContact(null, "editorCoach", true, profile1);
      // Aggiunta contatto1
      this._addressBookManager.addContact(contact1);
      IContact added1 = this._addressBookManager.getContact(contact1.getId());
      this.compareContacts(contact1, added1);
      assertNotNull(added1.getId());
      assertNotNull(added1.getContactInfo().getId());
     
      Date birthdate2 = this._helper.setBirthdate(1982, 10, 25);
      IUserProfile profile2 = this._helper.createUserProfile("pippo",
          "name2 surname2", "indirizzoemail2@inesistente.itt", birthdate2, "it");
      Contact contact2 = this._helper.createContact("pippo", "editorCoach", true, profile2);
      // Aggiunta contatto2
      this._addressBookManager.addContact(contact2);
      IContact added2 = this._addressBookManager.getContact(contact2.getId());
      this.compareContacts(contact2, added2);
      assertEquals("pippo", added2.getId());
      assertEquals("pippo", added2.getContactInfo().getId());
      assertEquals("pippo", profile2.getId());
    } catch (Throwable t) {
View Full Code Here

  public void testUpdateDeleteContact() throws Throwable {
    try {
      Date birthdate = this._helper.setBirthdate(1982, 10, 25);
      IUserProfile profile = this._helper.createUserProfile(null,
          "name surname", "indirizzoemail@inesistente.itt", birthdate, "it");
      Contact contact = this._helper.createContact(null, "editorCoach", true, profile);
      // Aggiunta contatto
      this._addressBookManager.addContact(contact);
      IContact added = this._addressBookManager.getContact(contact.getId());
      this.compareContacts(contact, added);
     
      // Modifica contatto
      Date newBirthdate = this._helper.setBirthdate(1985, 12, 02);
      IUserProfile modifiedProfile = this._helper.createUserProfile(contact.getId(),
          "nameMOD surnameMOD", "indirizzoemailMOD@inesistente.itt", newBirthdate, "en");
      Contact modifiedContact = this._helper.createContact(contact.getId(), contact.getOwner(), false, modifiedProfile);
      this._addressBookManager.updateContact(contact.getOwner(), modifiedContact);
      IContact updated = this._addressBookManager.getContact(contact.getId());
      this.compareContacts(modifiedContact, updated);
     
      // Rimozione contatto
      this._addressBookManager.deleteContact(contact.getOwner(), contact.getId());
      IContact removed = this._addressBookManager.getContact(modifiedContact.getId());
      assertNull(removed);
    } catch (Throwable t) {
      throw t;
    } finally {
      this._helper.cleanAddressBook();
View Full Code Here

 
  public void testAddUpdateDeleteContact() throws Throwable {
    Date birthdate = this._helper.setBirthdate(1982, 10, 25);
    IUserProfile profile = this._helper.createUserProfile("mainEditor",
        "name surname", "indirizzoemail@inesistente.itt", birthdate, "it");
    Contact contact = this._helper.createContact("1", "editorCoach", true, profile);
    try {
      // Aggiunta contatto
      this._addressBookDAO.addContact(contact);
      ContactRecord record = (ContactRecord) this._addressBookDAO.loadEntityRecord(contact.getId());
      this.compareContacts(contact, record);
     
      // Modifica contatto
      Date newBirthdate = this._helper.setBirthdate(1964, 07, 01);
      IUserProfile modifiedProfile = this._helper.createUserProfile("supervisorCoach",
          "nameMOD surnameMOD", "indirizzoemailMOD@inesistente.itt", newBirthdate, "en");
      Contact modifiedContact = this._helper.createContact(contact.getId(), "pageManagerCoach", false, modifiedProfile);
      this._addressBookDAO.updateContact(modifiedContact);
      record = (ContactRecord) this._addressBookDAO.loadEntityRecord(contact.getId());
      modifiedContact.setOwner(contact.getOwner()); // FIXME ? Non modifica il proprietario del contatto
      this.compareContacts(modifiedContact, record);
     
      // Rimozione contatto
      this._addressBookDAO.deleteContact(contact.getId());
      record = (ContactRecord) this._addressBookDAO.loadEntityRecord(modifiedContact.getId());
      assertNull(record);
    } catch (Throwable t) {
      throw t;
    } finally {
      this._helper.cleanAddressBook();
View Full Code Here

  @Override
  public String createNew() {
    try {
      IUserProfile defaultProfile = this.getUserProfileManager().getDefaultProfileType();
      defaultProfile.disableAttributes(JpaddressbookSystemConstants.ATTRIBUTE_DISABLING_CODE_ON_MANAGE_CONTACT);
      Contact contact = new Contact(defaultProfile);
      contact.setOwner(this.getCurrentUser().getUsername());
      this.getRequest().getSession().setAttribute(SESSION_PARAM_NAME_CURRENT_CONTACT, contact);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "createNew");
      return FAILURE;
    }
View Full Code Here

  }
 
  public void addContact(String id, String owner,
      boolean publicContact, String fullname, String email, Date birthdate, String lang) {
    IUserProfile profile = this.createUserProfile(id, fullname, email, birthdate, lang);
    Contact contact = this.createContact(id, owner, publicContact, profile);
    this._addressBookDAO.addContact(contact);
  }
View Full Code Here

    Contact contact = this.createContact(id, owner, publicContact, profile);
    this._addressBookDAO.addContact(contact);
  }
 
  public Contact createContact(String id, String owner, boolean publicContact, IUserProfile profile) {
    Contact contact = new Contact(profile);
    contact.setId(id);
    contact.setOwner(owner);
    contact.setPublicContact(publicContact);
    return contact;
  }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpaddressbook.aps.system.services.addressbook.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.