/**
   * Method to get the Party information for all participants and get the logical Id for claim
   * import.
   *
   * @param claimImportCompositeDTO
   * @param lstParticipants
   */
  private void retrieveParty(
      ClaimImportCompositeDTO claimImportCompositeDTO, List<DataTransferObject> lstParticipants) {
    for (DataTransferObject participant : lstParticipants) {
      Long partyId = null;
      if (participant instanceof CALClaimParticipationDTO) {
        partyId = ((CALClaimParticipationDTO) participant).getPartyId();
      } else if (participant instanceof CaseParticipationDTO) {
        partyId = ((CaseParticipationDTO) participant).getPartyId();
      } else if (participant instanceof CALClaimParticipationContactDTO) {
        partyId = ((CALClaimParticipationContactDTO) participant).getPartyId();
      } else if (participant instanceof ClaimPolicyParticipationDTO) {
        partyId = ((ClaimPolicyParticipationDTO) participant).getPartyId();
      } else if (participant instanceof CALClaimParticipationProvDTO) {
        partyId = ((CALClaimParticipationProvDTO) participant).getPartyId();
      }

      // If participant is unknown then party id will be null
      if (partyId == null) {
        continue;
      }

      Long partyIndex = null;
      if (partyList.contains(partyId)) {
        partyIndex = new Long(partyList.indexOf(partyId) + 1);
        participant.setObjectId(partyIndex.toString());
      } else {
        PartyDTO partyDTO = getClientPartyService().retrievePartyDetails(partyId);
        if (partyDTO != null) {
          partyList.add(partyId);
          partyDTO.setPreferences(null);
          partyDTO.setPartyPreference(null);
          partyIndex = new Long(partyList.indexOf(partyId) + 1);
          partyDTO.setRecordId(partyIndex);
          participant.setObjectId(partyIndex.toString());
          partyDTO.setAuthorizations(null);
          if (partyDTO instanceof PersonDTO) {
            claimImportCompositeDTO.getPersons().add((ClientPersonDTO) partyDTO);
          } else {
            claimImportCompositeDTO.getOrganizations().add((ClientOrganizationDTO) partyDTO);
          }
        }
      }

      if (participant instanceof CALClaimParticipationDTO) {
        ((CALClaimParticipationDTO) participant).setPartyId(null);
      } else if (participant instanceof CaseParticipationDTO) {
        ((CaseParticipationDTO) participant).setPartyId(null);
      } else if (participant instanceof CALClaimParticipationContactDTO) {
        ((CALClaimParticipationContactDTO) participant).setPartyId(null);
      } else if (participant instanceof ClaimPolicyParticipationDTO) {
        ((ClaimPolicyParticipationDTO) participant).setPartyId(null);
      } else if (participant instanceof CALClaimParticipationProvDTO) {
        ((CALClaimParticipationProvDTO) participant).setPartyId(null);
      }
    }
  }
  /**
   * Method to get the Party Information for Participants and return the Logical Id for Claim
   * Import.
   *
   * @param claimImportCompositeDTO
   * @param partyId
   * @return Logical Id for Claim Import
   */
  private Long retrieveParty(ClaimImportCompositeDTO claimImportCompositeDTO, Long partyId) {
    Long partyIndex = null;
    if (partyList.contains(partyId)) {
      return new Long(partyList.indexOf(partyId) + 1);
    } else {
      PartyDTO partyDTO = getClientPartyService().retrievePartyDetails(partyId);
      if (partyDTO != null) {
        partyList.add(partyId);
        partyDTO.setPreferences(null);
        partyDTO.setPartyPreference(null);
        partyIndex = new Long(partyList.indexOf(partyId) + 1);
        partyDTO.setRecordId(partyIndex);

        if (partyDTO instanceof PersonDTO) {
          claimImportCompositeDTO.getPersons().add((ClientPersonDTO) partyDTO);
        } else {
          claimImportCompositeDTO.getOrganizations().add((ClientOrganizationDTO) partyDTO);
        }
      }
      return partyIndex;
    }
  }