/**
   * Update Traveler information (name, id, network id) after looking up the Profile
   *
   * @param refreshCaller
   * @param fieldValues
   * @param document
   */
  protected void updateFieldsFromProfileRefresh(
      String refreshCaller, Map fieldValues, MaintenanceDocument document) {

    if (StringUtils.isNotEmpty(refreshCaller)
        && refreshCaller.equals(TemConstants.TEM_PROFILE_LOOKUPABLE)) {

      AgencyStagingDataMaintainable newMaintainable =
          (AgencyStagingDataMaintainable) document.getNewMaintainableObject();
      AgencyStagingData agencyData = (AgencyStagingData) newMaintainable.getBusinessObject();

      TemProfile profile = agencyData.getProfile();
      if (ObjectUtils.isNotNull(profile)) {
        if (StringUtils.isNotEmpty(profile.getEmployeeId())) {
          agencyData.setTravelerId(profile.getEmployeeId());
        } else if (StringUtils.isNotEmpty(profile.getCustomerNumber())) {
          agencyData.setTravelerId(profile.getCustomerNumber());
        } else {
          agencyData.setTravelerId("");
        }

        agencyData.setTravelerName(profile.getFirstName() + " " + profile.getLastName());

        if (ObjectUtils.isNotNull(profile.getPrincipal())) {
          agencyData.setTravelerNetworkId(profile.getPrincipal().getPrincipalName());
        } else {
          agencyData.setTravelerNetworkId("");
        }
      }
    }
  }
  /**
   * @see
   *     org.kuali.rice.kns.maintenance.KualiMaintainableImpl#processAfterCopy(org.kuali.rice.kns.document.MaintenanceDocument,
   *     java.util.Map)
   */
  @Override
  public void processAfterCopy(MaintenanceDocument document, Map<String, String[]> parameters) {
    super.processAfterCopy(document, parameters);
    AgencyStagingData agencyData = (AgencyStagingData) getBusinessObject();
    agencyData.setManualCreated(true);
    agencyData.setCreationTimestamp(getDateTimeService().getCurrentTimestamp());

    AgencyStagingDataMaintainable oldMaintainable =
        (AgencyStagingDataMaintainable) document.getOldMaintainableObject();
    // this is not new, so it must be for copy - we will set the Copied From Id
    agencyData.setCopiedFromId(((AgencyStagingData) oldMaintainable.getBusinessObject()).getId());

    // set TripAccountingInformation primary key and foreign key to null so the maintainance
    // document can handle setting the appropriate key values
    if (!agencyData.getTripAccountingInformation().isEmpty()) {
      for (TripAccountingInformation account : agencyData.getTripAccountingInformation()) {
        account.setId(null);
        account.setAgencyStagingDataId(null);
      }
    }
  }