コード例 #1
0
  /**
   * 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;
  }
コード例 #2
0
  @Override
  protected void doVerify() throws Exception {
    List<User> users = UserLocalServiceUtil.getNoContacts();

    if (_log.isDebugEnabled()) {
      _log.debug("Processing " + users.size() + " users with no contacts");
    }

    Date now = new Date();

    for (User user : users) {
      if (_log.isDebugEnabled()) {
        _log.debug("Creating contact for user " + user.getUserId());
      }

      long contactId = CounterLocalServiceUtil.increment();

      Contact contact = ContactLocalServiceUtil.createContact(contactId);

      Company company = CompanyLocalServiceUtil.getCompanyById(user.getCompanyId());

      contact.setCompanyId(user.getCompanyId());
      contact.setUserId(user.getUserId());
      contact.setUserName(StringPool.BLANK);
      contact.setCreateDate(now);
      contact.setModifiedDate(now);
      contact.setAccountId(company.getAccountId());
      contact.setParentContactId(ContactConstants.DEFAULT_PARENT_CONTACT_ID);
      contact.setFirstName(user.getFirstName());
      contact.setMiddleName(user.getMiddleName());
      contact.setLastName(user.getLastName());
      contact.setPrefixId(0);
      contact.setSuffixId(0);
      contact.setJobTitle(user.getJobTitle());

      ContactLocalServiceUtil.updateContact(contact);

      user.setContactId(contactId);

      UserLocalServiceUtil.updateUser(user);
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Contacts verified for users");
    }

    users = UserLocalServiceUtil.getNoGroups();

    if (_log.isDebugEnabled()) {
      _log.debug("Processing " + users.size() + " users with no groups");
    }

    for (User user : users) {
      if (_log.isDebugEnabled()) {
        _log.debug("Creating group for user " + user.getUserId());
      }

      GroupLocalServiceUtil.addGroup(
          user.getUserId(),
          User.class.getName(),
          user.getUserId(),
          null,
          null,
          0,
          StringPool.SLASH + user.getScreenName(),
          false,
          true,
          null);
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Groups verified for users");
    }
  }
コード例 #3
0
  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;
  }
コード例 #4
0
  @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());
  }