1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.document.validation.impl;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.kuali.ole.coa.businessobject.ObjectConsolidation;
22 import org.kuali.ole.coa.businessobject.ObjectLevel;
23 import org.kuali.ole.sys.OLEKeyConstants;
24 import org.kuali.rice.kns.document.MaintenanceDocument;
25 import org.kuali.rice.kns.maintenance.rules.MaintenanceDocumentRuleBase;
26
27
28
29
30
31 public class ObjectLevelRule extends MaintenanceDocumentRuleBase {
32
33
34
35
36
37
38
39
40 @Override
41 protected boolean processCustomSaveDocumentBusinessRules(MaintenanceDocument document) {
42 checkObjConsCode();
43 return true;
44 }
45
46
47
48
49
50
51
52
53
54 @Override
55 protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
56 boolean success = true;
57 success &= checkObjConsCode();
58 return success;
59 }
60
61
62
63
64
65
66
67
68 protected boolean checkObjConsCode() {
69 boolean success = true;
70 ObjectLevel objLevel = (ObjectLevel) super.getNewBo();
71 String chartOfAccountsCode = objLevel.getChartOfAccountsCode();
72 String finConsolidationObjectCode = objLevel.getFinancialObjectLevelCode();
73 Map primaryKeys = new HashMap();
74 primaryKeys.put("chartOfAccountsCode", chartOfAccountsCode);
75 primaryKeys.put("finConsolidationObjectCode", finConsolidationObjectCode);
76 ObjectConsolidation objCons = (ObjectConsolidation) getBoService().findByPrimaryKey(ObjectConsolidation.class, primaryKeys);
77 if (objCons != null) {
78 success = false;
79 putFieldError("financialObjectLevelCode", OLEKeyConstants.ERROR_DOCUMENT_OBJLEVELMAINT_ALREADY_EXISTS_AS_OBJCONS);
80 }
81 return success;
82 }
83 }