Example #1
0
 private boolean contactSelected() {
   for (Contact con : contacts) {
     if (con.getContactId() == editContactId) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 void onActionFromEditContact(long personNumber) throws RemoteException {
   for (Contact con : contacts) {
     if (con.getPersonNumber() == personNumber) {
       contactEdited = con.clone();
       editContactId = contactEdited.getContactId();
       break;
     }
   }
 }
Example #3
0
  Object onSuccessFromContactForm() throws RemoteException {
    if (isNewContact) {
      Contact newContact = contactEdited.clone();
      // Can only have one legal contact
      if (newContact.isLegalContact()) {
        for (Contact con : contacts) {
          con.setLegalContact(false);
        }
      }
      contacts.add(newContact);
    } else if (isApplyingContact) {
      Contact newContact = contactEdited.clone();
      for (int i = 0; i < contacts.size(); i++) {
        if (contacts.get(i).getContactId() == editContactId) {
          contacts.set(i, newContact);
        } else {
          // Can only have one legal contact
          if (newContact.isLegalContact()) {
            contacts.get(i).setLegalContact(false);
          }
        }
      }

    } else if (isDeleteContact) {
      Contact contactToRemove = null;
      for (Contact con : contacts) {
        if (con.getContactId() == editContactId) {
          contactToRemove = con;
          break;
        }
      }
      if (contactToRemove != null) {
        contacts.remove(contactToRemove);
      }
    } else if (isApplyingCustomer) {
      // do nothing
    }
    clearContactForm();
    return null;
  }
Example #4
0
 /**
  * Check the contact form
  *
  * @throws ValidationException
  * @throws RemoteException
  */
 void onValidateFromContactForm() throws ValidationException, RemoteException {
   // personNumber can not be duplicated.
   if (isNewContact) {
     for (Contact con : contacts) {
       if (con.getPersonNumber() == contactEdited.getPersonNumber()) {
         throw new ValidationException(messages.get("person-number-already-exist-message"));
       }
     }
   }
   if (isApplyingContact || isDeleteContact) {
     // personNumber can be 0 in Sylvestrix
     if (contacts == null || contacts.size() == 0 || !contactSelected()) {
       throw new ValidationException(messages.get("select-row-message"));
     }
     if (isApplyingContact) {
       for (Contact con : contacts) {
         if (con.getContactId() != editContactId
             && con.getPersonNumber() == contactEdited.getPersonNumber()) {
           throw new ValidationException(messages.get("person-number-already-exist-message"));
         }
         // personal number can not be changed.
         if (con.getContactId() == editContactId
             && con.getPersonNumber() != contactEdited.getPersonNumber()) {
           throw new ValidationException(
               messages.get("person-number-can-not-be-changed-on-web-message"));
         }
       }
     }
     if (isDeleteContact) {
       boolean canContactBeDeleted =
           service.canContactBeDeleted(customer.getNumber(), contactEdited.getPersonNumber());
       if (!canContactBeDeleted) {
         throw new ValidationException(messages.get("contact-can-not-be-deleted-message"));
       }
     }
   }
 }
Example #5
0
 public String getCssRowClass() { // for marking the selected contact
   if (contact.getContactId() == editContactId) {
     return "selected";
   }
   return null;
 }