コード例 #1
0
  @SuppressWarnings("unchecked")
  private List<ValidCeJobCode> getApplicableCostElements(
      Budget budget, BudgetPersonnelDetails newBudgetPersonnelDetails, boolean save) {
    List<ValidCeJobCode> validCostElements = null;

    if (save) {
      String jobCodeValidationEnabledInd =
          this.paramService.getParameterValueAsString(
              Budget.class, Constants.BUDGET_JOBCODE_VALIDATION_ENABLED);

      Map<String, Object> fieldValues = new HashMap<String, Object>();
      BudgetPerson budgetPerson = null;

      if (StringUtils.isNotEmpty(jobCodeValidationEnabledInd)
          && jobCodeValidationEnabledInd.equals("Y")) {

        List<BudgetPerson> budgetPersons = budget.getBudgetPersons();
        for (BudgetPerson tmpBudgetPerson : budgetPersons) {
          if (tmpBudgetPerson.getPersonSequenceNumber().intValue()
              == newBudgetPersonnelDetails.getPersonSequenceNumber().intValue()) {
            budgetPerson = tmpBudgetPerson;
            break;
          }
        }
        if (budgetPerson != null && StringUtils.isNotEmpty(budgetPerson.getJobCode())) {
          fieldValues.put("jobCode", budgetPerson.getJobCode().toUpperCase());
          validCostElements =
              (List<ValidCeJobCode>) this.boService.findMatching(ValidCeJobCode.class, fieldValues);
        }
      }

    } else {
      validCostElements =
          budgetPersonService.getApplicableCostElements(
              budget, newBudgetPersonnelDetails.getPersonSequenceNumber().toString());
    }

    return validCostElements;
  }
コード例 #2
0
 protected boolean isBudgetPersonExistsInPersonnelDetails(
     List<BudgetLineItem> budgetLineItems, BudgetPerson budgetPerson) {
   for (BudgetLineItem budgetLineItem : budgetLineItems) {
     for (BudgetPersonnelDetails budgetPersonnelDetails :
         budgetLineItem.getBudgetPersonnelDetailsList()) {
       if (budgetPersonnelDetails
           .getPersonSequenceNumber()
           .equals(budgetPerson.getPersonSequenceNumber())) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #3
0
  /**
   * Gets a Collection of sequence numbers from every lines items personnel details
   *
   * @param budgetLineItems the lines items
   * @return Collection of sequence numbers
   */
  private Collection<Integer> getBudgetPersonSequencesFromPersonnelDetails(
      final Collection<BudgetLineItem> budgetLineItems) {
    assert budgetLineItems != null : "the budgetLineItems is null";

    final Collection<Integer> budgetPersonSequences = new ArrayList<Integer>();

    for (final BudgetLineItem budgetLineItem : budgetLineItems) {
      for (final BudgetPersonnelDetails budgetPersonnelDetails :
          budgetLineItem.getBudgetPersonnelDetailsList()) {
        budgetPersonSequences.add(budgetPersonnelDetails.getPersonSequenceNumber());
      }
    }
    return budgetPersonSequences;
  }
コード例 #4
0
 /*
  * Check if this budget person has any budgetdetail set.  This is called before checking whether
  * this person can be deleted.  If retrieve from DB, then it might not be correct because
  * the deleted detail may have not been persisted before delete person is called.
  */
 private boolean isPersonDetailsFound(Budget budget, BudgetPerson budgetPerson) {
   for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
     for (BudgetLineItem lineItem : budgetPeriod.getBudgetLineItems()) {
       for (BudgetPersonnelDetails budgetPersonnelDetail :
           lineItem.getBudgetPersonnelDetailsList()) {
         if (budgetPersonnelDetail
             .getPersonSequenceNumber()
             .equals(budgetPerson.getPersonSequenceNumber())) {
           return true;
         }
       }
     }
   }
   return false;
 }
コード例 #5
0
  /**
   * Updates personnel details job code from a person's job code.
   *
   * @param budgetLineItems the lines items
   * @param person the person
   */
  private void updateJobCodeOnDetailsFromPerson(
      final Collection<BudgetLineItem> budgetLineItems, final BudgetPerson person) {
    assert budgetLineItems != null : "the budgetLineItems is null";
    assert person != null : "the person is null";

    if (person.getJobCode() == null) {
      return;
    }

    for (final BudgetLineItem budgetLineItem : budgetLineItems) {
      for (final BudgetPersonnelDetails budgetPersonnelDetails :
          budgetLineItem.getBudgetPersonnelDetailsList()) {
        if (person
            .getPersonSequenceNumber()
            .equals(budgetPersonnelDetails.getPersonSequenceNumber())) {
          budgetPersonnelDetails.setJobCode(person.getJobCode());
        }
      }
    }
  }
コード例 #6
0
  @KcEventMethod
  public boolean addPersonnelCheck(AddPersonnelBudgetEvent event) {
    boolean result = true;
    Budget budget = event.getBudget();
    BudgetPeriod budgetPeriod = event.getBudgetPeriod();
    BudgetLineItem newBudgetLineItem = event.getBudgetLineItem();
    BudgetPersonnelDetails budgetPersonDetails = event.getBudgetPersonnelDetails();
    String errorKey = event.getErrorKey();

    GlobalVariables.getMessageMap().addToErrorPath(errorKey);
    if (dictionaryValidationService.validate(newBudgetLineItem).getNumberOfErrors() > 0) {
      result = false;
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(errorKey);

    if (budgetPeriod == null) {
      GlobalVariables.getMessageMap()
          .putError("viewBudgetPeriod", KeyConstants.ERROR_BUDGET_PERIOD_NOT_SELECTED);
      result = false;
    }
    if (newBudgetLineItem.getCostElement() == null
        || StringUtils.equalsIgnoreCase(newBudgetLineItem.getCostElement(), "")) {
      GlobalVariables.getMessageMap()
          .putError(errorKey, KeyConstants.ERROR_COST_ELEMENT_NOT_SELECTED);
      result = false;
    }
    if (budgetPersonDetails.getPersonSequenceNumber() == null) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.personSequenceNumber",
              KeyConstants.ERROR_BUDGET_PERSONNEL_NOT_SELECTED);
      result = false;
    }
    if (!processCheckJobCodeObjectCodeCombo(budget, budgetPersonDetails, false)) {
      GlobalVariables.getMessageMap()
          .putError(errorKey, KeyConstants.ERROR_JOBCODE_COST_ELEMENT_COMBO_INVALID);
      result = false;
    }
    return result;
  }