gt:                 if (moduleService != null) {
context: /*
   * The Kuali Financial System, a comprehensive financial management system for higher education.
   *
   * Copyright 2005-2017 Kuali, Inc.
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as
   * published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
  package org.kuali.kfs.module.external.kc.businessobject;
  
  import org.apache.commons.lang.StringUtils;
  import org.kuali.kfs.coa.businessobject.Account;
  import org.kuali.kfs.coa.businessobject.AccountType;
  import org.kuali.kfs.coa.businessobject.BudgetRecordingLevel;
  import org.kuali.kfs.coa.businessobject.Chart;
  import org.kuali.kfs.coa.businessobject.Organization;
  import org.kuali.kfs.coa.businessobject.SubFundGroup;
  import org.kuali.kfs.coa.businessobject.SufficientFundsCode;
  import org.kuali.kfs.integration.cg.ContractsAndGrantsUnit;
  import org.kuali.kfs.krad.bo.PersistableBusinessObject;
  import org.kuali.kfs.krad.bo.PersistableBusinessObjectBase;
  import org.kuali.kfs.krad.service.KualiModuleService;
  import org.kuali.kfs.krad.service.ModuleService;
  import org.kuali.kfs.sys.KFSConstants;
  import org.kuali.kfs.sys.context.SpringContext;
  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
  import org.kuali.rice.kim.api.identity.Person;
  import org.kuali.rice.location.api.LocationConstants;
  import org.kuali.rice.location.framework.campus.CampusEbo;
  import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
  import org.kuali.rice.location.framework.state.StateEbo;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  
  public class AccountAutoCreateDefaults extends PersistableBusinessObjectBase implements MutableInactivatable {
      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountAutoCreateDefaults.class);
  
      protected Integer accountDefaultId;
      protected String kcUnit;
      //protected KCUnit kcUnit;
      protected String kcUnitName;
      protected Chart chartOfAccounts;
      protected String chartOfAccountsCode;
      protected Organization organization;
      protected String organizationCode;
      protected String accountZipCode;
      protected String accountCityName;
      protected String accountStateCode;
      protected String accountStreetAddress;
      private String accountCountryCode = KFSConstants.COUNTRY_CODE_UNITED_STATES;
      protected AccountType accountType;
      protected String accountTypeCode;
      protected String accountPhysicalCampusCode;
      protected SubFundGroup subFundGroup;
      protected String subFundGroupCode;
      protected boolean accountsFringesBnftIndicator;
      protected Chart fringeBenefitsChartOfAccount;
      protected String reportsToChartOfAccountsCode;
      protected String reportsToAccountNumber;
      protected String accountFiscalOfficerSystemIdentifier;
      protected String accountsSupervisorySystemsIdentifier;
      protected String accountManagerSystemIdentifier;
      protected Account reportsToAccount;
      protected Chart continuationChartOfAccount;
      protected String continuationFinChrtOfAcctCd;
      protected Account continuationAccount;
      protected String continuationAccountNumber;
      protected Account incomeStreamAccount;
      protected Chart incomeStreamChartOfAccounts;
      protected String incomeStreamFinancialCoaCode;
      protected String incomeStreamAccountNumber;
      protected String budgetRecordingLevelCode;
      protected BudgetRecordingLevel budgetRecordingLevel;
      protected SufficientFundsCode sufficientFundsCode;
      protected String accountSufficientFundsCode;
      protected boolean pendingAcctSufficientFundsIndicator;
      protected boolean extrnlFinEncumSufficntFndIndicator;
      protected boolean intrnlFinEncumSufficntFndIndicator;
      protected boolean finPreencumSufficientFundIndicator;
      protected boolean financialObjectivePrsctrlIndicator;
      protected Integer contractsAndGrantsAccountResponsibilityId;
      protected String accountDescriptionCampusCode;
      protected String accountDescriptionBuildingCode;
      protected boolean active;
  
      private CampusEbo accountPhysicalCampus;
      protected StateEbo accountState;
      private PostalCodeEbo postalZipCode;
  
      protected Person accountFiscalOfficerUser;
      protected Person accountSupervisoryUser;
      protected Person accountManagerUser;
      protected ContractsAndGrantsUnit unitDTO;
      protected List<IndirectCostRecoveryAutoDefAccount> indirectCostRecoveryAutoDefAccounts;
  
      /**
       * Default no-arg constructor.
       */
      public AccountAutoCreateDefaults() {
          active = true; // assume active until otherwise set
          indirectCostRecoveryAutoDefAccounts = new ArrayList<IndirectCostRecoveryAutoDefAccount>();
      }
  
      /**
       * Gets the kcUnit attribute.
       *
       * @return Returns the kcUnit.
       */
      public String getKcUnit() {
          return kcUnit;
      }
  
      /**
       * Sets the kcUnit attribute value.
       *
       * @param kcUnit The kcUnit to set.
       */
      public void setKcUnit(String kcUnit) {
          this.kcUnit = kcUnit;
      }
  
      /**
       * Gets the kcUnitName attribute.
       *
       * @return Returns the kcUnitName.
       */
      public String getKcUnitName() {
          return kcUnitName;
      }
  
      /**
       * Sets the kcUnitName attribute value.
       *
       * @param kcUnitName The kcUnitName to set.
       */
      public void setKcUnitName(String kcUnitName) {
          this.kcUnitName = kcUnitName;
      }
  
      /**
       * Gets the chartOfAccounts attribute.
       *
       * @return Returns the chartOfAccounts.
       */
      public Chart getChartOfAccounts() {
          return chartOfAccounts;
      }
  
      /**
       * Sets the chartOfAccounts attribute value.
       *
       * @param chartOfAccounts The chartOfAccounts to set.
       */
      public void setChartOfAccounts(Chart chartOfAccounts) {
          this.chartOfAccounts = chartOfAccounts;
      }
  
      /**
       * Gets the chartOfAccountsCode attribute.
       *
       * @return Returns the chartOfAccountsCode.
       */
      public String getChartOfAccountsCode() {
          return chartOfAccountsCode;
      }
  
      /**
       * Sets the chartOfAccountsCode attribute value.
       *
       * @param chartOfAccountsCode The chartOfAccountsCode to set.
       */
      public void setChartOfAccountsCode(String chartOfAccountsCode) {
          this.chartOfAccountsCode = chartOfAccountsCode;
      }
  
      /**
       * Gets the organization attribute.
       *
       * @return Returns the organization.
       */
      public Organization getOrganization() {
          return organization;
      }
  
      /**
       * Sets the organization attribute value.
       *
       * @param organization The organization to set.
       */
      public void setOrganization(Organization organization) {
          this.organization = organization;
      }
  
      /**
       * Gets the organizationCode attribute.
       *
       * @return Returns the organizationCode.
       */
      public String getOrganizationCode() {
          return organizationCode;
      }
  
      /**
       * Sets the organizationCode attribute value.
       *
       * @param organizationCode The organizationCode to set.
       */
      public void setOrganizationCode(String organizationCode) {
          this.organizationCode = organizationCode;
      }
  
      /**
       * Gets the accountZipCode attribute.
       *
       * @return Returns the accountZipCode.
       */
      public String getAccountZipCode() {
          return accountZipCode;
      }
  
      /**
       * Sets the accountZipCode attribute value.
       *
       * @param accountZipCode The accountZipCode to set.
       */
      public void setAccountZipCode(String accountZipCode) {
          this.accountZipCode = accountZipCode;
      }
  
      /**
       * Gets the postalZipCode attribute.
       *
       * @return Returns the postalZipCode.
       */
      public PostalCodeEbo getPostalZipCode() {
          if (StringUtils.isBlank(accountZipCode) || StringUtils.isBlank(accountCountryCode)) {
              postalZipCode = null;
          } else {
              if (postalZipCode == null || !StringUtils.equals(postalZipCode.getCode(), accountZipCode)
                  || !StringUtils.equals(postalZipCode.getCountryCode(), accountCountryCode)) {
                  ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
                  if (moduleService != null) {
                      Map<String, Object> keys = new HashMap<String, Object>(2);
                      keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, accountCountryCode);
                      keys.put(LocationConstants.PrimaryKeyConstants.CODE, accountZipCode);
                      postalZipCode = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
                  } else {
                      throw new RuntimeException("CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
                  }
              }
          }
          return postalZipCode;
      }
  
      /**
       * Sets the postalZipCode attribute value.
       *
       * @param postalZipCode The postalZipCode to set.
       */
      public void setPostalZipCode(PostalCodeEbo postalZipCode) {
          this.postalZipCode = postalZipCode;
      }
  
  
      /**
       * Gets the accountCityName attribute.
       *
       * @return Returns the accountCityName.
       */
      public String getAccountCityName() {
          return accountCityName;
      }
  
      /**
       * Sets the accountCityName attribute value.
       *
       * @param accountCityName The accountCityName to set.
       */
      public void setAccountCityName(String accountCityName) {
          this.accountCityName = accountCityName;
      }
  
      /**
       * Gets the accountStateCode attribute.
       *
       * @return Returns the accountStateCode.
       */
      public String getAccountStateCode() {
          return accountStateCode;
      }
  
      /**
       * Sets the accountStateCode attribute value.
       *
       * @param accountStateCode The accountStateCode to set.
       */
      public void setAccountStateCode(String accountStateCode) {
          this.accountStateCode = accountStateCode;
      }
  
      /**
       * Gets the accountState attribute.
       *
       * @return Returns the accountState.
       */
      public StateEbo getAccountState() {
          if (StringUtils.isBlank(accountStateCode) || StringUtils.isBlank(accountCountryCode)) {
              accountState = null;
          } else {
              if (accountState == null || !StringUtils.equals(accountState.getCode(), accountStateCode) || !StringUtils.equals(accountState.getCountryCode(), accountCountryCode)) {
                  ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
                  if (moduleService != null) {
                      Map<String, Object> keys = new HashMap<String, Object>(2);
                      keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, accountCountryCode);
                      keys.put(LocationConstants.PrimaryKeyConstants.CODE, accountStateCode);
                      accountState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
                  } else {
                      throw new RuntimeException("CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
                  }
              }
          }
          return accountState;
      }
  
  
      /**
       * Gets the accountStreetAddress attribute.
       *
       * @return Returns the accountStreetAddress.
       */
      public String getAccountStreetAddress() {
          return accountStreetAddress;
      }
  
      /**
       * Sets the accountStreetAddress attribute value.
       *
       * @param accountStreetAddress The accountStreetAddress to set.
       */
      public void setAccountStreetAddress(String accountStreetAddress) {
          this.accountStreetAddress = accountStreetAddress;
      }
  
      /**
       * Gets the accountType attribute.
       *
       * @return Returns the accountType.
       */
      public AccountType getAccountType() {
          return accountType;
      }
  
      /**
       * Sets the accountType attribute value.
       *
       * @param accountType The accountType to set.
       */
      public void setAccountType(AccountType accountType) {
          this.accountType = accountType;
      }
  
      /**
       * Gets the accountTypeCode attribute.
       *
       * @return Returns the accountTypeCode.
       */
      public String getAccountTypeCode() {
          return accountTypeCode;
      }
  
      /**
       * Sets the accountTypeCode attribute value.
       *
       * @param accountTypeCode The accountTypeCode to set.
       */
      public void setAccountTypeCode(String accountTypeCode) {
          this.accountTypeCode = accountTypeCode;
      }
  
      /**
       * Gets the accountPhysicalCampusCode attribute.
       *
       * @return Returns the accountPhysicalCampusCode.
       */
      public String getAccountPhysicalCampusCode() {
          return accountPhysicalCampusCode;
      }
  
      /**
       * Sets the accountPhysicalCampusCode attribute value.
       *
       * @param accountPhysicalCampusCode The accountPhysicalCampusCode to set.
       */
      public void setAccountPhysicalCampusCode(String accountPhysicalCampusCode) {
          this.accountPhysicalCampusCode = accountPhysicalCampusCode;
      }
  
      /**
       * Gets the accountPhysicalCampus attribute.
       *
       * @return Returns the accountPhysicalCampus.
       */
      public CampusEbo getAccountPhysicalCampus() {
          if (StringUtils.isBlank(accountPhysicalCampusCode)) {
              accountPhysicalCampus = null;
          } else {
              if (accountPhysicalCampus == null || !StringUtils.equals(accountPhysicalCampus.getCode(), accountPhysicalCampusCode)) {
                  ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
  