/**
   * @org.kuali.kfs.module.endow.document.service.CurrentTaxLotService#getAllCurrentTaxLotBalance()
   */
  public Collection<CurrentTaxLotBalance> getAllCurrentTaxLotBalance() {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances = new ArrayList();

    currentTaxLotBalances = businessObjectService.findAll(CurrentTaxLotBalance.class);

    return currentTaxLotBalances;
  }
  /*
   * This method will set the values to award amount info xml object
   * attributes.
   */
  private AwardAmountInfo getAwardAmountInfo(Award award) {
    AmountInfoType amountInfoType = null;
    AwardAmountInfo awardAmountInfo = AwardAmountInfo.Factory.newInstance();
    List<AmountInfoType> amountInfoTypes = new ArrayList<AmountInfoType>();
    AwardHierarchy branchNode =
        award.getAwardHierarchyService().loadFullHierarchyFromAnyNode(award.getParentNumber());
    org.kuali.kra.award.home.AwardAmountInfo awardAmount = award.getLastAwardAmountInfo();
    BusinessObjectService businessObjectService =
        KraServiceLocator.getService(BusinessObjectService.class);
    Collection<Award> awards = businessObjectService.findAll(Award.class);
    Award parentAward = null;
    for (Award awardParent : awards) {
      if (awardParent.getAwardNumber().equals(branchNode.getAwardNumber())) {
        parentAward = awardParent;
        break;
      }
    }
    if (branchNode != null) {

      amountInfoType = setAwardAmountInfo(parentAward, parentAward.getLastAwardAmountInfo());
      amountInfoTypes = recurseTree(branchNode, amountInfoTypes);
      amountInfoTypes.add(0, amountInfoType);
      awardAmountInfo.setAmountInfoArray(amountInfoTypes.toArray(new AmountInfoType[0]));
    }
    return awardAmountInfo;
  }
  /**
   * @see
   *     org.kuali.kfs.module.endow.document.service.CurrentTaxLotService#clearAllCurrentTaxLotRecords()
   *     clears all the records from the CurrentTaxLotBalance table.
   */
  public void clearAllCurrentTaxLotRecords() {
    Collection<CurrentTaxLotBalance> currentTaxLotBalances =
        businessObjectService.findAll(CurrentTaxLotBalance.class);

    for (CurrentTaxLotBalance currentTaxLotBalance : currentTaxLotBalances) {
      businessObjectService.delete(currentTaxLotBalance);
    }
  }
  /**
   * @see org.kuali.kfs.module.endow.batch.service.AvailableCashUpdateService#clearAvailableCash()
   *     Method to clear all the records in the kemidCurrentAvailableBalance table
   */
  public void clearAllAvailableCash() {
    LOG.info("Step1: Clearing all available cash records");

    Collection<KEMIDCurrentAvailableBalance> KEMIDCurrentAvailableBalances =
        businessObjectService.findAll(KEMIDCurrentAvailableBalance.class);

    for (KEMIDCurrentAvailableBalance kemidCurrentAvailableBalance :
        KEMIDCurrentAvailableBalances) {
      businessObjectService.delete(kemidCurrentAvailableBalance);
    }
  }
  @Override
  public List<KeyValue> getKeyValues() {
    BusinessObjectService boService = KraServiceLocator.getService(BusinessObjectService.class);
    Collection<UnitAdministratorType> types =
        (Collection<UnitAdministratorType>) boService.findAll(UnitAdministratorType.class);
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    for (UnitAdministratorType aType : types) {
      if (aType
          .getDefaultGroupFlag()
          .equals(Constants.UNIT_CONTACTS_DEFAULT_GROUP_FLAG)) { // only get Unit Contacts
        keyValues.add(
            new ConcreteKeyValue(aType.getUnitAdministratorTypeCode(), aType.getDescription()));
      }
    }
    keyValues.add(
        0,
        new ConcreteKeyValue(
            PrefixValuesFinder.getPrefixKey(), PrefixValuesFinder.getDefaultPrefixValue()));

    return keyValues;
  }
  @Override
  public List<CfdaDTO> lookupCfda(List<HashMapElement> criteria) {
    HashMap<String, String> searchCriteria = new HashMap<String, String>();
    List<CFDA> cfdaNumbers = new ArrayList<CFDA>();
    // if the criteria passed is null, then return all units.
    if (ObjectUtils.isNull(criteria)) {
      cfdaNumbers = new ArrayList<CFDA>(businessObjectService.findAll(CFDA.class));
    } else {
      // Reconstruct Hashmap from object list
      for (HashMapElement element : criteria) {
        searchCriteria.put(element.getKey(), element.getValue());
      }
      cfdaNumbers =
          new ArrayList<CFDA>(businessObjectService.findMatching(CFDA.class, searchCriteria));
    }

    List<CfdaDTO> cfdaDTOs = new ArrayList<CfdaDTO>();
    for (CFDA cfda : cfdaNumbers) {
      cfdaDTOs.add(boToDTO(cfda));
    }

    return cfdaDTOs;
  }
 public void execute(String attributesToEncryptPropertyFileName, boolean checkOjbEncryptConfig) {
   PostDataLoadEncryptionService postDataLoadEncryptionService =
       KRADServiceLocatorInternal.getService(
           PostDataLoadEncryptionService.POST_DATA_LOAD_ENCRYPTION_SERVICE);
   Properties attributesToEncryptProperties = new Properties();
   try {
     attributesToEncryptProperties.load(
         new FileSystemResource(attributesToEncryptPropertyFileName).getInputStream());
   } catch (Exception e) {
     throw new IllegalArgumentException(
         "PostDataLoadEncrypter requires the full, absolute path to a properties file where the keys are the names of the BusinessObject classes that should be processed and the values are the list of attributes on each that require encryption",
         e);
   }
   for (Map.Entry<Object, Object> entry : attributesToEncryptProperties.entrySet()) {
     Class<? extends PersistableBusinessObject> businessObjectClass;
     try {
       businessObjectClass =
           (Class<? extends PersistableBusinessObject>) Class.forName((String) entry.getKey());
     } catch (Exception e) {
       throw new IllegalArgumentException(
           new StringBuffer("Unable to load Class ")
               .append((String) entry.getKey())
               .append(" specified by name in attributesToEncryptProperties file ")
               .append(attributesToEncryptProperties)
               .toString(),
           e);
     }
     final Set<String> attributeNames;
     try {
       attributeNames =
           new HashSet<String>(Arrays.asList(StringUtils.split((String) entry.getValue(), ",")));
     } catch (Exception e) {
       throw new IllegalArgumentException(
           new StringBuffer(
                   "Unable to load attributeNames Set from comma-delimited list of attribute names specified as value for property with Class name ")
               .append(entry.getKey())
               .append(" key in attributesToEncryptProperties file ")
               .append(attributesToEncryptProperties)
               .toString(),
           e);
     }
     postDataLoadEncryptionService.checkArguments(
         businessObjectClass, attributeNames, checkOjbEncryptConfig);
     postDataLoadEncryptionService.createBackupTable(businessObjectClass);
     BusinessObjectService businessObjectService = KRADServiceLocator.getBusinessObjectService();
     try {
       postDataLoadEncryptionService.prepClassDescriptor(businessObjectClass, attributeNames);
       Collection<? extends PersistableBusinessObject> objectsToEncrypt =
           businessObjectService.findAll(businessObjectClass);
       for (Object businessObject : objectsToEncrypt) {
         postDataLoadEncryptionService.encrypt(
             (PersistableBusinessObject) businessObject, attributeNames);
       }
       postDataLoadEncryptionService.restoreClassDescriptor(businessObjectClass, attributeNames);
       LOG.info(
           new StringBuffer("Encrypted ")
               .append(entry.getValue())
               .append(" attributes of Class ")
               .append(entry.getKey()));
     } catch (Exception e) {
       postDataLoadEncryptionService.restoreTableFromBackup(businessObjectClass);
       LOG.error(
           new StringBuffer("Caught exception, while encrypting ")
               .append(entry.getValue())
               .append(" attributes of Class ")
               .append(entry.getKey())
               .append(" and restored table from backup"),
           e);
     }
     postDataLoadEncryptionService.dropBackupTable(businessObjectClass);
   }
 }