View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.coa.document.validation.impl;
17  
18  import org.kuali.ole.coa.businessobject.AccountDelegateModel;
19  import org.kuali.ole.coa.businessobject.AccountDelegateModelDetail;
20  import org.kuali.rice.kns.document.MaintenanceDocument;
21  
22  /**
23   * 
24   * This class...
25   */
26  public class OrganizationRoutingModelPreRules extends MaintenancePreRulesBase {
27      public OrganizationRoutingModelPreRules() {
28      }
29  
30      /**
31       * This performs pre rules checks 
32       * <ul>
33       * <li>{@link OrganizationRoutingModelPreRules#copyKeyAttributesToModelDetail(OrganizationRoutingModelName)}</li>
34       * </ul>
35       * @see org.kuali.ole.coa.document.validation.impl.MaintenancePreRulesBase#doCustomPreRules(org.kuali.rice.kns.document.MaintenanceDocument)
36       */
37      @Override
38      protected boolean doCustomPreRules(MaintenanceDocument maintDoc) {
39          AccountDelegateModel model = (AccountDelegateModel) maintDoc.getNewMaintainableObject().getBusinessObject();
40          copyKeyAttributesToModelDetail(model);
41          return true;
42      }
43  
44      /**
45       * 
46       * This copies the chart of accounts, object code, and organization model name from the parent {@link OrganizationRoutingModelName} to the 
47       * {@link OrganizationRoutingModel} objects  
48       * @param model
49       */
50      protected void copyKeyAttributesToModelDetail(AccountDelegateModel model) {
51          for (AccountDelegateModelDetail modelDelegate : model.getAccountDelegateModelDetails()) {
52              modelDelegate.setChartOfAccountsCode(model.getChartOfAccountsCode());
53              modelDelegate.setOrganizationCode(model.getOrganizationCode());
54              modelDelegate.setAccountDelegateModelName(model.getAccountDelegateModelName());
55          }
56      }
57  
58  }