/**
  * This method typecasts the given {@link XmlObject} to the required generator type and returns
  * back the document of that generator type.
  *
  * @param xmlObject which needs to be converted to the document type of the required generator
  * @return {@link XmlObject} document of the required generator type
  * @see org.kuali.kra.s2s.generator.S2SFormGenerator#getFormObject(XmlObject)
  */
 public XmlObject getFormObject(XmlObject xmlObject) {
   LobbyingActivitiesDisclosureDocument lobbyingDisclosureDocument =
       LobbyingActivitiesDisclosureDocument.Factory.newInstance();
   LobbyingActivitiesDisclosure lobbyingActivitiesDisclosure =
       (LobbyingActivitiesDisclosure) xmlObject;
   lobbyingDisclosureDocument.setLobbyingActivitiesDisclosure(lobbyingActivitiesDisclosure);
   return lobbyingDisclosureDocument;
 }
  /**
   * This method returns LobbyingActivitiesDisclosureDocument object based on proposal development
   * document which contains the LobbyingActivitiesDisclosureDocument informations
   * FederalActionType,FederalActionStatus,ReportType,ReportEntity,FederalAgencyDepartment,
   * FederalProgramName,LobbyingRegistrant,IndividualsPerformingServices,SignatureBlock and
   * LobbyingActivitiesDisclosure for a particular proposal
   *
   * @return lobbyingADDocument {@link XmlObject} of type LobbyingActivitiesDisclosureDocument.
   */
  private LobbyingActivitiesDisclosureDocument getLobbyingActivitiesDisclosure() {

    LobbyingActivitiesDisclosureDocument lobbyingADDocument =
        LobbyingActivitiesDisclosureDocument.Factory.newInstance();
    LobbyingActivitiesDisclosure lobbyingDisclosure =
        LobbyingActivitiesDisclosure.Factory.newInstance();
    lobbyingDisclosure.setFormVersion(S2SConstants.FORMVERSION_1_0);
    lobbyingDisclosure.setFederalActionType(FederalActionType.GRANT);
    lobbyingDisclosure.setFederalActionStatus(FederalActionStatus.BID_OFFER);
    lobbyingDisclosure.setReportType(ReportDataType.INITIAL_FILING);
    lobbyingDisclosure.setReportEntity(getReportEntity());
    lobbyingDisclosure.setFederalAgencyDepartment("");
    Sponsor sponsor = pdDoc.getDevelopmentProposal().getSponsor();
    if (sponsor != null) {
      if (sponsor.getSponsorName() != null) {
        if (sponsor.getSponsorName().length() > SPONSOR_NAME_MAX_LENGTH) {
          lobbyingDisclosure.setFederalAgencyDepartment(
              sponsor.getSponsorName().substring(0, SPONSOR_NAME_MAX_LENGTH));
        } else {
          lobbyingDisclosure.setFederalAgencyDepartment(sponsor.getSponsorName());
        }
      }
    } else {
      String primeSponsorCode = pdDoc.getDevelopmentProposal().getPrimeSponsorCode();

      if (primeSponsorCode != null) {
        BusinessObjectService businessObjectService =
            KraServiceLocator.getService(BusinessObjectService.class);
        Map<String, String> sponsorMap = new HashMap<String, String>();
        sponsorMap.put(KEY_SPONSOR_CODE, primeSponsorCode);
        Sponsor primeSponsor =
            (Sponsor) businessObjectService.findByPrimaryKey(Sponsor.class, sponsorMap);
        if (primeSponsor.getSponsorName() != null) {
          if (primeSponsor.getSponsorName().length() > SPONSOR_NAME_MAX_LENGTH) {
            lobbyingDisclosure.setFederalAgencyDepartment(
                primeSponsor.getSponsorName().substring(0, SPONSOR_NAME_MAX_LENGTH));
          } else {
            lobbyingDisclosure.setFederalAgencyDepartment(primeSponsor.getSponsorName());
          }
        }
      }
    }
    lobbyingDisclosure.setFederalProgramName(getFedProgramName());
    lobbyingDisclosure.setLobbyingRegistrant(getLobbyingRegistrant());
    lobbyingDisclosure.setIndividualsPerformingServices(getIndividualsPerformingServices());
    lobbyingDisclosure.setSignatureBlock(getSignatureBlock());
    lobbyingADDocument.setLobbyingActivitiesDisclosure(lobbyingDisclosure);
    return lobbyingADDocument;
  }