コード例 #1
0
  /** Create the mock services and insert them into the protocol auth service. */
  @Before
  public void setUp() throws Exception {
    fundingSponsorSourceType = new FundingSourceType();
    fundingSponsorSourceType.setFundingSourceTypeCode(FundingSourceType.SPONSOR);
    fundingSponsorSourceType.setFundingSourceTypeFlag(true);
    fundingSponsorSourceType.setDescription("Sponsor");
    fundingUnitSourceType = new FundingSourceType();
    fundingUnitSourceType.setFundingSourceTypeCode(FundingSourceType.UNIT);
    fundingUnitSourceType.setFundingSourceTypeFlag(true);
    fundingUnitSourceType.setDescription("Unit");
    fundingOtherSourceType = new FundingSourceType();
    fundingOtherSourceType.setFundingSourceTypeCode(FundingSourceType.OTHER);
    fundingOtherSourceType.setFundingSourceTypeFlag(true);
    fundingOtherSourceType.setDescription("Other");
    fundingDevProposalSourceType = new FundingSourceType();
    fundingDevProposalSourceType.setFundingSourceTypeCode(FundingSourceType.PROPOSAL_DEVELOPMENT);
    fundingDevProposalSourceType.setFundingSourceTypeFlag(true);
    fundingDevProposalSourceType.setDescription("Proposal Development");
    fundingInstProposalSourceType = new FundingSourceType();
    fundingInstProposalSourceType.setFundingSourceTypeCode(
        FundingSourceType.INSTITUTIONAL_PROPOSAL);
    fundingInstProposalSourceType.setFundingSourceTypeFlag(true);
    fundingInstProposalSourceType.setDescription("Institutional Proposal");
    fundingAwardSourceType = new FundingSourceType();
    fundingAwardSourceType.setFundingSourceTypeCode(FundingSourceType.AWARD);
    fundingAwardSourceType.setFundingSourceTypeFlag(true);
    fundingAwardSourceType.setDescription("Award");

    // sponsorGood = new Sponsor();
    // sponsorGood.setSponsorName(sponsorNameAirForce);
    // sponsorGood.setSponsorCode(SPONSOR_NUMBER_AIR_FORCE);
    sponsorGood =
        KcServiceLocator.getService(SponsorService.class).getSponsor(SPONSOR_NUMBER_AIR_FORCE);
    sponsorNameAirForce = sponsorGood.getSponsorName();

    devProposalGood = new DevelopmentProposal();
    devProposalGood.setTitle(DEV_PROPOSAL_TITLE_GOOD);
    devProposalGood.setSponsorCode(sponsorGood.getSponsorCode());

    instProposalGood = new InstitutionalProposal();
    instProposalGood.setTitle(INST_PROPOSAL_TITLE_GOOD);
    instProposalGood.setSponsorCode(sponsorGood.getSponsorCode());

    awardGood = new Award();
    awardGood.setTitle(AWARD_TITLE_GOOD);
    awardGood.setSponsorCode(sponsorGood.getSponsorCode());
  }
  protected void populateRequiredFields(
      Protocol protocol, ProposalDevelopmentDocument proposalDocument) throws Exception {
    DevelopmentProposal developmentProposal = proposalDocument.getDevelopmentProposal();

    developmentProposal.setTitle(protocol.getTitle());
    developmentProposal.setOwnedByUnit(protocol.getLeadUnit().getUnit());
    developmentProposal.setOwnedByUnitNumber(protocol.getLeadUnitNumber());
    developmentProposal.setRequestedStartDateInitial(new Date(System.currentTimeMillis()));

    ParameterService parameterService = KcServiceLocator.getService(ParameterService.class);
    String projectEndDateParameter =
        parameterService.getParameterValueAsString(
            ProtocolDocument.class,
            ProtocolProposalDevelopmentDocumentService.PROJECT_END_DATE_NUMBER_OF_YEARS);
    int numberOfYears = Integer.parseInt(projectEndDateParameter);
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.YEAR, numberOfYears);
    calendar.add(Calendar.DATE, -1);
    Date projectEndDate = new Date(calendar.getTimeInMillis());
    developmentProposal.setRequestedEndDateInitial(projectEndDate);

    String activityTypeCode =
        ProposalDevelopmentUtils.getProposalDevelopmentDocumentParameter(
            ProposalDevelopmentUtils.ACTIVITY_TYPE_CODE_RESEARCH_PARM);
    String proposalTypeCode =
        ProposalDevelopmentUtils.getProposalDevelopmentDocumentParameter(
            ProposalDevelopmentUtils.PROPOSAL_TYPE_CODE_NEW_PARM);

    developmentProposal.setActivityTypeCode(activityTypeCode);
    developmentProposal.setProposalTypeCode(proposalTypeCode);

    // find sponsor from funding source
    List<ProtocolFundingSourceBase> protocolFundingSources = protocol.getProtocolFundingSources();
    ProtocolFundingSource sponsorProtocolFundingSource = null;
    for (ProtocolFundingSourceBase protocolFundingSource : protocolFundingSources) {
      if (protocolFundingSource.isSponsorFunding()) {
        sponsorProtocolFundingSource = (ProtocolFundingSource) protocolFundingSource;
        break;
      }
    }
    if (sponsorProtocolFundingSource != null) {
      developmentProposal.setSponsorCode(sponsorProtocolFundingSource.getFundingSourceNumber());
    }
  }