Exemplo n.º 1
0
  @Override
  public void populateProposalPerson(ProposalPerson person, ProposalDevelopmentDocument document) {
    /* populate certification questions for new person */
    person = getYnqService().getPersonYNQ(person, document);

    if (person.isInvestigator()) {
      if (!document.getDevelopmentProposal().getInvestigators().contains(person)) {
        document.getDevelopmentProposal().getInvestigators().add(person);
      }
      populateCreditTypes(person);
    }

    person.setRoleChanged(false);

    try {
      if (person.getPersonId() != null && person.getPerson().getExtendedAttributes() != null) {
        KcPerson origPerson = person.getPerson();
        for (PersonDegree degree : origPerson.getExtendedAttributes().getPersonDegrees()) {
          ProposalPersonDegree newDegree = new ProposalPersonDegree();
          newDegree.setDegree(degree.getDegree());
          newDegree.setDegreeCode(degree.getDegreeCode());
          newDegree.setFieldOfStudy(degree.getFieldOfStudy());
          newDegree.setGraduationYear(degree.getGraduationYear());
          newDegree.setSchool(degree.getSchool());
          newDegree.setSchoolId(degree.getSchoolId());
          newDegree.setSchoolIdCode(degree.getSchoolIdCode());
          newDegree.setDegreeSequenceNumber(
              document.getDocumentNextValue(Constants.PROPOSAL_PERSON_DEGREE_SEQUENCE_NUMBER));
          person.addDegree(newDegree);
        }
        if (origPerson.getExtendedAttributes().getAttachments() != null) {
          for (PersonBiosketch attachment : origPerson.getExtendedAttributes().getAttachments()) {
            ProposalPersonBiography bio = new ProposalPersonBiography();
            bio.setProposalPersonNumber(person.getProposalPersonNumber());
            bio.setDocumentTypeCode(getDefaultPersonAttachmentDocType());
            bio.setDescription(attachment.getDescription());
            bio.setName(attachment.getFileName());
            bio.setType(attachment.getContentType());

            ProposalPersonBiographyAttachment personnelAttachment =
                new ProposalPersonBiographyAttachment();
            personnelAttachment.setName(attachment.getFileName());
            personnelAttachment.setProposalNumber(
                document.getDevelopmentProposal().getProposalNumber());
            personnelAttachment.setProposalPersonNumber(person.getProposalPersonNumber());
            personnelAttachment.setData(attachment.getAttachmentContent());
            personnelAttachment.setType(attachment.getContentType());
            bio.setPersonnelAttachment(personnelAttachment);

            document.getDevelopmentProposal().addProposalPersonBiography(bio);
          }
        }
      }
    } catch (IllegalArgumentException e) {
      // catching the possibility that person.getPerson can not
      // find a EntityContract for this person id.
    }
  }
Exemplo n.º 2
0
  public void addProposalPerson(
      ProposalPerson proposalPerson, ProposalDevelopmentDocument document) {
    getPersonEditableService().populateContactFields(proposalPerson);
    document.getDevelopmentProposal().addProposalPerson(proposalPerson);

    LOG.info(
        "Added Proposal Person with proposalNumber = "
            + document.getDevelopmentProposal().getProposalNumber()
            + " and proposalPersonNumber = "
            + proposalPerson.getProposalPersonNumber());
    // handle lead unit for investigators respective to coi or pi
    if (proposalPerson.isPrincipalInvestigator()) {
      assignLeadUnit(proposalPerson, document.getDevelopmentProposal().getOwnedByUnitNumber());
    } else {
      // Lead Unit information needs to be removed in case the person used to be a PI
      ProposalPersonUnit unit =
          proposalPerson.getUnit(document.getDevelopmentProposal().getOwnedByUnitNumber());
      if (unit != null) {
        unit.setLeadUnit(false);
      }
    }
    if (proposalPerson.getHomeUnit() != null) {
      proposalPerson.refreshReferenceObject("homeUnitRef");
      String divisionName =
          getProposalPersonService().getProposalPersonDivisionName(proposalPerson);
      proposalPerson.setDivision(divisionName);
    } else {
      proposalPerson.setDivision(ROLODEX_PERSON);
    }
    if (proposalPerson.getProposalPersonRoleId().equals(PRINCIPAL_INVESTIGATOR_ROLE)
        || proposalPerson.getProposalPersonRoleId().equals(CO_INVESTIGATOR_ROLE)) {
      if (isNotBlank(proposalPerson.getHomeUnit())
          && isValidHomeUnit(proposalPerson, proposalPerson.getHomeUnit())) {
        addUnitToPerson(
            proposalPerson, createProposalPersonUnit(proposalPerson.getHomeUnit(), proposalPerson));
      }
    }

    populateProposalPerson(proposalPerson, document);
  }
Exemplo n.º 3
0
  /**
   * Everytime something changes that will effect credit split values, this gets called to generate
   * a graph of the new data.
   *
   * @param document
   * @return Map
   */
  public Map calculateCreditSplitTotals(ProposalDevelopmentDocument document) {
    Map<String, Map<String, ScaleTwoDecimal>> retval =
        new HashMap<String, Map<String, ScaleTwoDecimal>>();

    // Initialize investigator credit types if there aren't any
    if (document.getDevelopmentProposal().getInvestigatorCreditTypes() == null
        || document.getDevelopmentProposal().getInvestigatorCreditTypes().size() == 0) {
      document.getDevelopmentProposal().setInvestigatorCreditTypes(getInvestigatorCreditTypes());
    }

    Collection<InvestigatorCreditType> creditTypes =
        document.getDevelopmentProposal().getInvestigatorCreditTypes();

    for (ProposalPerson investigator : document.getDevelopmentProposal().getInvestigators()) {
      Map<String, ScaleTwoDecimal> creditTypeTotals =
          retval.get(investigator.getProposalPersonNumber().toString());
      Map<String, ScaleTwoDecimal> investigatorCreditTypeTotals =
          retval.get(PROPOSAL_PERSON_INVESTIGATOR);

      if (creditTypeTotals == null) {
        creditTypeTotals = new HashMap<String, ScaleTwoDecimal>();
        retval.put(investigator.getProposalPersonNumber().toString(), creditTypeTotals);
      }
      if (investigatorCreditTypeTotals == null) {
        investigatorCreditTypeTotals = new HashMap<String, ScaleTwoDecimal>();
        retval.put(PROPOSAL_PERSON_INVESTIGATOR, investigatorCreditTypeTotals);
      }

      // Initialize everything to zero
      for (InvestigatorCreditType creditType : creditTypes) {
        ScaleTwoDecimal totalCredit = creditTypeTotals.get(creditType.getCode());

        if (totalCredit == null) {
          totalCredit = new ScaleTwoDecimal(0);
          creditTypeTotals.put(creditType.getCode(), totalCredit);
        }
        ScaleTwoDecimal investigatorTotalCredit =
            investigatorCreditTypeTotals.get(creditType.getCode());

        if (investigatorTotalCredit == null) {
          investigatorTotalCredit = new ScaleTwoDecimal(0);
          investigatorCreditTypeTotals.put(creditType.getCode(), investigatorTotalCredit);
        }
        // set investigator credit total
        for (CreditSplit creditSplit : investigator.getCreditSplits()) {
          if (creditSplit.getInvCreditTypeCode().equals(creditType.getCode())) {
            investigatorCreditTypeTotals.put(
                creditType.getCode(), investigatorTotalCredit.add(creditSplit.getCredit()));
          }
        }
      }

      for (ProposalPersonUnit unit : investigator.getUnits()) {
        for (CreditSplit creditSplit : unit.getCreditSplits()) {
          ScaleTwoDecimal totalCredit = creditTypeTotals.get(creditSplit.getInvCreditTypeCode());

          if (totalCredit == null) {
            totalCredit = new ScaleTwoDecimal(0);
            creditTypeTotals.put(creditSplit.getInvCreditTypeCode(), totalCredit);
          }
          creditTypeTotals.put(
              creditSplit.getInvCreditTypeCode(), totalCredit.add(creditSplit.getCredit()));
        }
      }
    }

    return retval;
  }