/**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static Contact toModel(ContactSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    Contact model = new ContactImpl();

    model.setContactId(soapModel.getContactId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setClassNameId(soapModel.getClassNameId());
    model.setClassPK(soapModel.getClassPK());
    model.setAccountId(soapModel.getAccountId());
    model.setParentContactId(soapModel.getParentContactId());
    model.setEmailAddress(soapModel.getEmailAddress());
    model.setFirstName(soapModel.getFirstName());
    model.setMiddleName(soapModel.getMiddleName());
    model.setLastName(soapModel.getLastName());
    model.setPrefixId(soapModel.getPrefixId());
    model.setSuffixId(soapModel.getSuffixId());
    model.setMale(soapModel.getMale());
    model.setBirthday(soapModel.getBirthday());
    model.setSmsSn(soapModel.getSmsSn());
    model.setAimSn(soapModel.getAimSn());
    model.setFacebookSn(soapModel.getFacebookSn());
    model.setIcqSn(soapModel.getIcqSn());
    model.setJabberSn(soapModel.getJabberSn());
    model.setMsnSn(soapModel.getMsnSn());
    model.setMySpaceSn(soapModel.getMySpaceSn());
    model.setSkypeSn(soapModel.getSkypeSn());
    model.setTwitterSn(soapModel.getTwitterSn());
    model.setYmSn(soapModel.getYmSn());
    model.setEmployeeStatusId(soapModel.getEmployeeStatusId());
    model.setEmployeeNumber(soapModel.getEmployeeNumber());
    model.setJobTitle(soapModel.getJobTitle());
    model.setJobClass(soapModel.getJobClass());
    model.setHoursOfOperation(soapModel.getHoursOfOperation());

    return model;
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Contact newContact = _persistence.create(pk);

    newContact.setMvccVersion(RandomTestUtil.nextLong());

    newContact.setCompanyId(RandomTestUtil.nextLong());

    newContact.setUserId(RandomTestUtil.nextLong());

    newContact.setUserName(RandomTestUtil.randomString());

    newContact.setCreateDate(RandomTestUtil.nextDate());

    newContact.setModifiedDate(RandomTestUtil.nextDate());

    newContact.setClassNameId(RandomTestUtil.nextLong());

    newContact.setClassPK(RandomTestUtil.nextLong());

    newContact.setAccountId(RandomTestUtil.nextLong());

    newContact.setParentContactId(RandomTestUtil.nextLong());

    newContact.setEmailAddress(RandomTestUtil.randomString());

    newContact.setFirstName(RandomTestUtil.randomString());

    newContact.setMiddleName(RandomTestUtil.randomString());

    newContact.setLastName(RandomTestUtil.randomString());

    newContact.setPrefixId(RandomTestUtil.nextLong());

    newContact.setSuffixId(RandomTestUtil.nextLong());

    newContact.setMale(RandomTestUtil.randomBoolean());

    newContact.setBirthday(RandomTestUtil.nextDate());

    newContact.setSmsSn(RandomTestUtil.randomString());

    newContact.setFacebookSn(RandomTestUtil.randomString());

    newContact.setJabberSn(RandomTestUtil.randomString());

    newContact.setSkypeSn(RandomTestUtil.randomString());

    newContact.setTwitterSn(RandomTestUtil.randomString());

    newContact.setEmployeeStatusId(RandomTestUtil.randomString());

    newContact.setEmployeeNumber(RandomTestUtil.randomString());

    newContact.setJobTitle(RandomTestUtil.randomString());

    newContact.setJobClass(RandomTestUtil.randomString());

    newContact.setHoursOfOperation(RandomTestUtil.randomString());

    _contacts.add(_persistence.update(newContact));

    Contact existingContact = _persistence.findByPrimaryKey(newContact.getPrimaryKey());

    Assert.assertEquals(existingContact.getMvccVersion(), newContact.getMvccVersion());
    Assert.assertEquals(existingContact.getContactId(), newContact.getContactId());
    Assert.assertEquals(existingContact.getCompanyId(), newContact.getCompanyId());
    Assert.assertEquals(existingContact.getUserId(), newContact.getUserId());
    Assert.assertEquals(existingContact.getUserName(), newContact.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getCreateDate()),
        Time.getShortTimestamp(newContact.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getModifiedDate()),
        Time.getShortTimestamp(newContact.getModifiedDate()));
    Assert.assertEquals(existingContact.getClassNameId(), newContact.getClassNameId());
    Assert.assertEquals(existingContact.getClassPK(), newContact.getClassPK());
    Assert.assertEquals(existingContact.getAccountId(), newContact.getAccountId());
    Assert.assertEquals(existingContact.getParentContactId(), newContact.getParentContactId());
    Assert.assertEquals(existingContact.getEmailAddress(), newContact.getEmailAddress());
    Assert.assertEquals(existingContact.getFirstName(), newContact.getFirstName());
    Assert.assertEquals(existingContact.getMiddleName(), newContact.getMiddleName());
    Assert.assertEquals(existingContact.getLastName(), newContact.getLastName());
    Assert.assertEquals(existingContact.getPrefixId(), newContact.getPrefixId());
    Assert.assertEquals(existingContact.getSuffixId(), newContact.getSuffixId());
    Assert.assertEquals(existingContact.getMale(), newContact.getMale());
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getBirthday()),
        Time.getShortTimestamp(newContact.getBirthday()));
    Assert.assertEquals(existingContact.getSmsSn(), newContact.getSmsSn());
    Assert.assertEquals(existingContact.getFacebookSn(), newContact.getFacebookSn());
    Assert.assertEquals(existingContact.getJabberSn(), newContact.getJabberSn());
    Assert.assertEquals(existingContact.getSkypeSn(), newContact.getSkypeSn());
    Assert.assertEquals(existingContact.getTwitterSn(), newContact.getTwitterSn());
    Assert.assertEquals(existingContact.getEmployeeStatusId(), newContact.getEmployeeStatusId());
    Assert.assertEquals(existingContact.getEmployeeNumber(), newContact.getEmployeeNumber());
    Assert.assertEquals(existingContact.getJobTitle(), newContact.getJobTitle());
    Assert.assertEquals(existingContact.getJobClass(), newContact.getJobClass());
    Assert.assertEquals(existingContact.getHoursOfOperation(), newContact.getHoursOfOperation());
  }
  protected Contact addContact() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Contact contact = _persistence.create(pk);

    contact.setMvccVersion(RandomTestUtil.nextLong());

    contact.setCompanyId(RandomTestUtil.nextLong());

    contact.setUserId(RandomTestUtil.nextLong());

    contact.setUserName(RandomTestUtil.randomString());

    contact.setCreateDate(RandomTestUtil.nextDate());

    contact.setModifiedDate(RandomTestUtil.nextDate());

    contact.setClassNameId(RandomTestUtil.nextLong());

    contact.setClassPK(RandomTestUtil.nextLong());

    contact.setAccountId(RandomTestUtil.nextLong());

    contact.setParentContactId(RandomTestUtil.nextLong());

    contact.setEmailAddress(RandomTestUtil.randomString());

    contact.setFirstName(RandomTestUtil.randomString());

    contact.setMiddleName(RandomTestUtil.randomString());

    contact.setLastName(RandomTestUtil.randomString());

    contact.setPrefixId(RandomTestUtil.nextLong());

    contact.setSuffixId(RandomTestUtil.nextLong());

    contact.setMale(RandomTestUtil.randomBoolean());

    contact.setBirthday(RandomTestUtil.nextDate());

    contact.setSmsSn(RandomTestUtil.randomString());

    contact.setFacebookSn(RandomTestUtil.randomString());

    contact.setJabberSn(RandomTestUtil.randomString());

    contact.setSkypeSn(RandomTestUtil.randomString());

    contact.setTwitterSn(RandomTestUtil.randomString());

    contact.setEmployeeStatusId(RandomTestUtil.randomString());

    contact.setEmployeeNumber(RandomTestUtil.randomString());

    contact.setJobTitle(RandomTestUtil.randomString());

    contact.setJobClass(RandomTestUtil.randomString());

    contact.setHoursOfOperation(RandomTestUtil.randomString());

    _contacts.add(_persistence.update(contact));

    return contact;
  }
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public Contact addContact(
      long userId,
      String className,
      long classPK,
      String emailAddress,
      String firstName,
      String middleName,
      String lastName,
      int prefixId,
      int suffixId,
      boolean male,
      int birthdayMonth,
      int birthdayDay,
      int birthdayYear,
      String smsSn,
      String aimSn,
      String facebookSn,
      String icqSn,
      String jabberSn,
      String msnSn,
      String mySpaceSn,
      String skypeSn,
      String twitterSn,
      String ymSn,
      String jobTitle)
      throws PortalException, SystemException {

    User user = userPersistence.findByPrimaryKey(userId);
    Date birthday =
        PortalUtil.getDate(
            birthdayMonth, birthdayDay, birthdayYear, ContactBirthdayException.class);
    Date now = new Date();

    validate(className, classPK);

    long contactId = counterLocalService.increment();

    Contact contact = contactPersistence.create(contactId);

    contact.setCompanyId(user.getCompanyId());
    contact.setUserId(user.getUserId());
    contact.setUserName(user.getFullName());
    contact.setCreateDate(now);
    contact.setModifiedDate(now);
    contact.setClassName(className);
    contact.setClassPK(classPK);
    contact.setEmailAddress(emailAddress);
    contact.setFirstName(firstName);
    contact.setMiddleName(middleName);
    contact.setLastName(lastName);
    contact.setPrefixId(prefixId);
    contact.setSuffixId(suffixId);
    contact.setMale(male);
    contact.setBirthday(birthday);
    contact.setSmsSn(smsSn);
    contact.setAimSn(aimSn);
    contact.setFacebookSn(facebookSn);
    contact.setIcqSn(icqSn);
    contact.setJabberSn(jabberSn);
    contact.setMsnSn(msnSn);
    contact.setMySpaceSn(mySpaceSn);
    contact.setSkypeSn(skypeSn);
    contact.setTwitterSn(twitterSn);
    contact.setYmSn(ymSn);
    contact.setJobTitle(jobTitle);

    contactPersistence.update(contact);

    return contact;
  }