01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.chart.maintenance;
17:
18: import java.util.List;
19:
20: import org.kuali.core.bo.PersistableBusinessObject;
21: import org.kuali.core.maintenance.KualiMaintainableImpl;
22: import org.kuali.core.service.BusinessObjectService;
23: import org.kuali.core.service.DateTimeService;
24: import org.kuali.kfs.context.SpringContext;
25: import org.kuali.module.chart.bo.Account;
26:
27: /**
28: * This class overrides the saveBusinessObject() method which is called during post process from the KualiPostProcessor so that it
29: * can automatically deactivate the Sub-Accounts related to the account It also overrides the processAfterCopy so that it sets
30: * specific fields that shouldn't be copied to default values {@link KualiPostProcessor}
31: */
32: public class KualiAccountMaintainableImpl extends KualiMaintainableImpl {
33: /**
34: * Automatically deactivates {@link SubAccount}s after saving the {@link Account}
35: *
36: * @see org.kuali.core.maintenance.Maintainable#saveBusinessObject()
37: */
38: @Override
39: public void saveBusinessObject() {
40: // make sure we save account first
41: super .saveBusinessObject();
42: BusinessObjectService boService = SpringContext
43: .getBean(BusinessObjectService.class);
44: Account acct = (Account) businessObject;
45:
46: // deactivate any indicated BOs
47: List<PersistableBusinessObject> bosToDeactivate = acct
48: .generateDeactivationsToPersist();
49: if (bosToDeactivate != null) {
50: if (!bosToDeactivate.isEmpty()) {
51: boService.save(bosToDeactivate);
52: }
53: }
54: }
55:
56: /**
57: * After a copy is done set specific fields on {@link Account} to default values
58: *
59: * @see org.kuali.core.maintenance.KualiMaintainableImpl#processAfterCopy()
60: */
61: @Override
62: public void processAfterCopy() {
63: Account account = (Account) this .getBusinessObject();
64: account.setAccountCreateDate(null); // account's pre-rules will fill this field in
65: account.setAccountEffectiveDate(SpringContext.getBean(
66: DateTimeService.class).getCurrentTimestamp());
67: account.setAccountClosedIndicator(false);
68: super.processAfterCopy();
69: }
70:
71: }
|