/**
   * @param searchCriteria
   * @param fieldsForLookup
   */
  protected void buildReportForSearchCriteia(
      List<ContractsGrantsReportSearchCriteriaDataHolder> searchCriteria, Map fieldsForLookup) {
    DataDictionaryService dataDictionaryService =
        SpringContext.getBean(DataDictionaryService.class);
    for (Object field : fieldsForLookup.keySet()) {

      String fieldString = (ObjectUtils.isNull(field)) ? "" : field.toString();
      String valueString =
          (ObjectUtils.isNull(fieldsForLookup.get(field)))
              ? ""
              : fieldsForLookup.get(field).toString();

      if (!fieldString.equals("")
          && !valueString.equals("")
          && !CGConstants.ReportsConstants.reportSearchCriteriaExceptionList.contains(
              fieldString)) {
        ContractsGrantsReportSearchCriteriaDataHolder criteriaData =
            new ContractsGrantsReportSearchCriteriaDataHolder();
        String label = dataDictionaryService.getAttributeLabel(Award.class, fieldString);
        criteriaData.setSearchFieldLabel(label);
        criteriaData.setSearchFieldValue(valueString);
        searchCriteria.add(criteriaData);
      }
    }
  }
  /**
   * @see
   *     org.kuali.kfs.module.endow.document.service.CurrentTaxLotService#getCurrentTaxLotBalanceTotalHoldingUnits(org.kuali.kfs.module.endow.businessobject.FeeMethod)
   */
  public BigDecimal getCurrentTaxLotBalanceTotalHoldingUnits(FeeMethod feeMethod) {
    BigDecimal totalHoldingUnits = BigDecimal.ZERO;

    Collection securityClassCodes = new ArrayList();
    Collection securityIds = new ArrayList();
    String feeMethodCodeForClassCodes = feeMethod.getCode();
    if (StringUtils.isNotBlank(feeMethodCodeForClassCodes)) {

      if (dataDictionaryService.getAttributeForceUppercase(
          FeeClassCode.class, EndowPropertyConstants.FEE_METHOD_CODE)) {
        feeMethodCodeForClassCodes = feeMethodCodeForClassCodes.toUpperCase();
      }
    }
    securityClassCodes = currentTaxLotBalanceDao.getSecurityClassCodes(feeMethodCodeForClassCodes);

    String feeMethodCodeForSecurityIds = feeMethod.getCode();
    if (StringUtils.isNotBlank(feeMethodCodeForSecurityIds)) {

      if (dataDictionaryService.getAttributeForceUppercase(
          FeeSecurity.class, EndowPropertyConstants.FEE_METHOD_CODE)) {
        feeMethodCodeForSecurityIds = feeMethodCodeForSecurityIds.toUpperCase();
      }
    }
    securityIds = currentTaxLotBalanceDao.getSecurityIds(feeMethod.getCode());

    Collection<CurrentTaxLotBalance> currentTaxLotBalanceRecords =
        currentTaxLotBalanceDao.getCurrentTaxLotBalances(
            feeMethod, securityClassCodes, securityIds);
    for (CurrentTaxLotBalance currentTaxLotBalance : currentTaxLotBalanceRecords) {
      totalHoldingUnits = totalHoldingUnits.add(currentTaxLotBalance.getUnits());
    }

    return totalHoldingUnits;
  }
Exemple #3
0
 public List<HeaderNavigation> getBudgetHeaderNavigatorList() {
   DataDictionaryService dataDictionaryService =
       (DataDictionaryService)
           KraServiceLocator.getService(Constants.DATA_DICTIONARY_SERVICE_NAME);
   DocumentEntry docEntry =
       dataDictionaryService.getDataDictionary().getDocumentEntry(BudgetDocument.class.getName());
   return docEntry.getHeaderNavigationList();
 }
  /**
   * @org
   *     .kuali.kfs.module.endow.document.service.CurrentTaxLotService#getCurrentTaxLotBalancesForMatchingSecurityClassCode(String)
   */
  public Collection<CurrentTaxLotBalance> getCurrentTaxLotBalancesForMatchingSecurityClassCode(
      String securityClassCode) {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances = new ArrayList();

    Collection<Security> securities = new ArrayList();

    if (StringUtils.isNotBlank(securityClassCode)) {
      Map criteria = new HashMap();

      if (dataDictionaryService.getAttributeForceUppercase(
          Security.class, EndowPropertyConstants.SECURITY_CLASS_CODE)) {
        securityClassCode = securityClassCode.toUpperCase();
      }
      criteria.put(EndowPropertyConstants.SECURITY_CLASS_CODE, securityClassCode);

      securities = businessObjectService.findMatching(Security.class, criteria);

      for (Security security : securities) {
        criteria.clear();
        criteria.put(EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_SECURITY_ID, security.getId());

        currentTaxLotBalances.addAll(
            businessObjectService.findMatching(HoldingHistory.class, criteria));
      }
    }

    return currentTaxLotBalances;
  }
  /**
   * Calculates a map with the field length of all of the attributes of the class given by the
   * getBusinessObjectClass method
   */
  protected void initializeFieldLengthMap() {
    fieldLengthMap = new HashMap<String, Integer>();
    DataDictionaryService dataDictionaryService =
        SpringContext.getBean(DataDictionaryService.class);
    List<AttributeDefinition> attributes =
        dataDictionaryService
            .getDataDictionary()
            .getBusinessObjectEntry(getBusinessObjectClass().getName())
            .getAttributes();

    for (AttributeDefinition attributeDefinition : attributes) {
      Integer fieldLength;
      fieldLength =
          dataDictionaryService.getAttributeMaxLength(
              getBusinessObjectClass(), attributeDefinition.getName());
      fieldLengthMap.put(attributeDefinition.getName(), fieldLength);
    }
  }
  /**
   * @org
   *     .kuali.kfs.module.endow.document.service.CurrentTaxLotService#getCurrentTaxLotBalancesBySecurityId(String)
   */
  public Collection<CurrentTaxLotBalance> getCurrentTaxLotBalancesBySecurityId(String securityId) {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances = new ArrayList();

    if (StringUtils.isNotBlank(securityId)) {
      Map criteria = new HashMap();

      if (dataDictionaryService.getAttributeForceUppercase(
          CurrentTaxLotBalance.class, EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_SECURITY_ID)) {
        securityId = securityId.toUpperCase();
      }

      criteria.put(EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_SECURITY_ID, securityId);

      currentTaxLotBalances =
          businessObjectService.findMatching(CurrentTaxLotBalance.class, criteria);
    }

    return currentTaxLotBalances;
  }
  /**
   * Checks an account numbers exact length
   *
   * @param accountNumber
   * @param size to be returned
   * @return
   */
  protected boolean isValidAccountNumberLength(
      String accountNumber, AccountCreationStatusDTO accountCreationStatus) {

    boolean isValid = false;
    int fieldSize = -1;

    // grab account number length from DD and set size
    final org.kuali.rice.krad.datadictionary.BusinessObjectEntry entry =
        dataDictionaryService.getDataDictionary().getBusinessObjectEntry(Account.class.getName());
    AttributeDefinition attributeDefinition =
        entry.getAttributeDefinition(KFSPropertyConstants.ACCOUNT_NUMBER);

    if (ObjectUtils.isNotNull(attributeDefinition)) {
      final ValidationPattern validationPattern = attributeDefinition.getValidationPattern();

      if (ObjectUtils.isNotNull(validationPattern)
          && validationPattern instanceof AlphaNumericValidationPattern) {
        AlphaNumericValidationPattern alphaPattern =
            (AlphaNumericValidationPattern) validationPattern;
        fieldSize = alphaPattern.getExactLength();
      }
    }

    // skip if account number null
    if (ObjectUtils.isNotNull(accountNumber)) {

      // data dictionary defined size must equal length of incoming value
      if (fieldSize == accountNumber.length()) {
        isValid = true;
      }
    }

    if (isValid == false) {
      setFailStatus(
          accountCreationStatus,
          KcUtils.getErrorMessage(
              KcConstants.AccountCreationService.ERROR_KR_ALPHANUMERIC_VALIDATION_EXACT_LENGTH,
              new String[] {"account number", String.valueOf(fieldSize)}));
    }

    return isValid;
  }
  /**
   * @see
   *     org.kuali.kfs.module.endow.document.service.CurrentTaxLotService#getHoldingMarketValue(HoldingTaxLot,
   *     String)
   */
  public BigDecimal getHoldingMarketValue(HoldingTaxLot holdingTaxLot, String securityId) {
    BigDecimal holdingMarketValue = BigDecimal.ZERO;

    Security security = securityService.getByPrimaryKey(securityId);

    String classCodeType = security.getClassCode().getClassCodeType();

    if (EndowConstants.ClassCodeTypes.ALTERNATIVE_INVESTMENT.equalsIgnoreCase(classCodeType)) {
      String kemid = holdingTaxLot.getKemid();
      if (dataDictionaryService.getAttributeForceUppercase(
          TransactionArchive.class, EndowPropertyConstants.TRANSACTION_ARCHIVE_KEM_ID)) {
        kemid = kemid.toUpperCase();
      }
      BigDecimal totalCashActivity =
          transactionArchiveDao.getTransactionArchivesTotalCashActivity(kemid, securityId);
      return (security.getSecurityValueByMarket().subtract(totalCashActivity));
    }
    // calculations for BONDS
    if (EndowConstants.ClassCodeTypes.BOND.equalsIgnoreCase(classCodeType)) {
      holdingMarketValue =
          KEMCalculationRoundingHelper.multiply(
              holdingTaxLot.getUnits(),
              security.getUnitValue(),
              EndowConstants.Scale.SECURITY_MARKET_VALUE);
      holdingMarketValue =
          KEMCalculationRoundingHelper.divide(
              holdingMarketValue,
              BigDecimal.valueOf(100),
              EndowConstants.Scale.SECURITY_MARKET_VALUE);
      return holdingMarketValue;
    }

    // other cases...
    holdingMarketValue =
        KEMCalculationRoundingHelper.multiply(
            holdingTaxLot.getUnits(),
            security.getUnitValue(),
            EndowConstants.Scale.SECURITY_MARKET_VALUE);

    return holdingMarketValue;
  }
  /**
   * @org
   *     .kuali.kfs.module.endow.document.service.CurrentTaxLotService#getCurrentTaxLotBalancesBySecurityId(String)
   */
  public Collection<CurrentTaxLotBalance> getCurrentTaxLotBalancesByIncomePrincipalIndicator(
      String incomePrincipalIndicator) {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances = new ArrayList();

    if (StringUtils.isNotBlank(incomePrincipalIndicator)) {
      Map criteria = new HashMap();

      if (dataDictionaryService.getAttributeForceUppercase(
          CurrentTaxLotBalance.class,
          EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_INCOME_PRINCIPAL_INDICATOR)) {
        incomePrincipalIndicator = incomePrincipalIndicator.toUpperCase();
      }

      criteria.put(
          EndowPropertyConstants.CURRENT_TAX_LOT_BALANCE_INCOME_PRINCIPAL_INDICATOR,
          incomePrincipalIndicator);

      currentTaxLotBalances =
          businessObjectService.findMatching(CurrentTaxLotBalance.class, criteria);
    }

    return currentTaxLotBalances;
  }
  private boolean verifyProposaEditableColumnsDataType(MaintenanceDocument maintenanceDocument) {
    ProposalColumnsToAlter newEditableProposalField =
        (ProposalColumnsToAlter) maintenanceDocument.getNewMaintainableObject().getDataObject();
    KcPersistenceStructureService kraPersistenceStructureService =
        KcServiceLocator.getService(KcPersistenceStructureService.class);
    DataDictionaryService dataDictionaryService =
        (DataDictionaryService) KNSServiceLocator.getDataDictionaryService();
    Map<String, String> fieldMap =
        kraPersistenceStructureService.getDBColumnToObjectAttributeMap(ProposalOverview.class);
    DataDictionaryEntry entry =
        dataDictionaryService
            .getDataDictionary()
            .getDictionaryObjectEntry(ProposalDevelopmentDocument.class.getName());

    boolean returnFlag = true;
    String editableProposalField = "";
    Integer fieldMaxLength = -1;
    Integer inputDataLength = -1;
    String proposalFieldDataType = "";
    String inputDataType = "";
    ValidationPattern validatingPattern = null;

    if (newEditableProposalField != null
        && StringUtils.isNotEmpty(newEditableProposalField.getColumnName())) {
      editableProposalField = fieldMap.get(newEditableProposalField.getColumnName());
      if (StringUtils.isNotEmpty(editableProposalField)) {
        if (entry != null) {
          AttributeDefinition attributeDefinition =
              entry.getAttributeDefinition(editableProposalField);
          if (attributeDefinition != null && attributeDefinition.hasValidationPattern()) {
            validatingPattern = attributeDefinition.getValidationPattern();
            if (validatingPattern != null) {
              proposalFieldDataType =
                  validationClassesMap.get(validatingPattern.getClass().getName());
              inputDataType = newEditableProposalField.getDataType();
              if (!proposalFieldDataType.equalsIgnoreCase(inputDataType)) {
                // throw error
                GlobalVariables.getMessageMap()
                    .putError(
                        Constants.PROPOSAL_EDITABLECOLUMN_DATATYPE,
                        KeyConstants.PROPOSAL_EDITABLECOLUMN_DATATYPE_MISMATCH);
                returnFlag = false;
              }
            }
          }
        }

        inputDataLength = newEditableProposalField.getDataLength();
        fieldMaxLength =
            dataDictionaryService.getAttributeMaxLength(
                DevelopmentProposal.class, editableProposalField);
        if (fieldMaxLength > inputDataLength) {
          // throw error
          GlobalVariables.getMessageMap()
              .putError(
                  Constants.PROPOSAL_EDITABLECOLUMN_DATALENGTH,
                  KeyConstants.PROPOSAL_EDITABLECOLUMN_DATALENGTH_MISMATCH);
          returnFlag = false;
        }
      }
    }

    return returnFlag;
  }
  /**
   * This method sends out emails for upcoming milestones.
   *
   * @see org.kuali.kfs.module.ar.service.CGEmailService#sendEmail(java.util.List,
   *     org.kuali.kfs.module.ar.businessobject.Award)
   */
  @Override
  public void sendEmail(List<Milestone> milestones, ContractsAndGrantsBillingAward award) {
    LOG.debug("sendEmail() starting");

    MailMessage message = new MailMessage();

    message.setFromAddress(mailService.getBatchMailingList());
    message.setSubject(getEmailSubject(ArConstants.REMINDER_EMAIL_SUBJECT));
    message
        .getToAddresses()
        .add(award.getAwardPrimaryFundManager().getFundManager().getEmailAddress());
    StringBuffer body = new StringBuffer();

    String messageKey =
        kualiConfigurationService.getPropertyValueAsString(
            ArKeyConstants.MESSAGE_CG_UPCOMING_MILESTONES_EMAIL_LINE_1);
    body.append(MessageFormat.format(messageKey, new Object[] {null}));

    body.append(award.getProposalNumber() + ".\n\n");

    for (Milestone milestone : milestones) {

      String milestoneNumber =
          dataDictionaryService.getAttributeLabel(Milestone.class, "milestoneNumber");
      String milestoneDescription =
          dataDictionaryService.getAttributeLabel(Milestone.class, "milestoneDescription");
      String milestoneAmount =
          dataDictionaryService.getAttributeLabel(Milestone.class, "milestoneAmount");
      String milestoneExpectedCompletionDate =
          dataDictionaryService.getAttributeLabel(
              Milestone.class, "milestoneExpectedCompletionDate");
      String milestoneActualCompletionDate =
          dataDictionaryService.getAttributeLabel(Milestone.class, "milestoneActualCompletionDate");

      body.append(milestoneNumber + ": " + milestone.getMilestoneNumber() + " \n");
      body.append(milestoneDescription + ": " + milestone.getMilestoneDescription() + " \n");
      body.append(milestoneAmount + ": " + milestone.getMilestoneAmount() + " \n");
      body.append(
          milestoneExpectedCompletionDate
              + ": "
              + milestone.getMilestoneExpectedCompletionDate()
              + " \n");

      body.append("\n\n");
    }
    body.append("\n\n");

    messageKey =
        kualiConfigurationService.getPropertyValueAsString(
            ArKeyConstants.MESSAGE_CG_UPCOMING_MILESTONES_EMAIL_LINE_2);
    body.append(MessageFormat.format(messageKey, new Object[] {null}) + "\n\n");

    message.setMessage(body.toString());

    try {
      mailService.sendMessage(message);
    } catch (InvalidAddressException ex) {
      // TODO Auto-generated catch block
      LOG.error("InvalidAddressException ", ex);
    } catch (MessagingException ex) {
      // TODO Auto-generated catch block
      LOG.error("MessagingException ", ex);
    }
  }