1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.coa.service.impl;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.kuali.ole.coa.businessobject.Account;
22 import org.kuali.ole.coa.businessobject.ObjectCode;
23 import org.kuali.ole.coa.businessobject.SubAccount;
24 import org.kuali.ole.coa.businessobject.SubObjectCode;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.OLEPropertyConstants;
27 import org.kuali.rice.krad.bo.BusinessObject;
28 import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
29 import org.kuali.rice.krad.service.PersistenceService;
30 import org.kuali.rice.krad.service.impl.InactivationBlockingDetectionServiceImpl;
31
32 public class IndirectCostRecoveryRateDetailInactivationBlockingDetectionServiceImpl extends InactivationBlockingDetectionServiceImpl {
33 protected PersistenceService persistenceService;
34
35 @Override
36 protected Map<String, String> buildInactivationBlockerQueryMap(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
37 Class<? extends BusinessObject> boClass = blockedBo.getClass();
38 if (!(Account.class.isAssignableFrom(boClass) || SubAccount.class.isAssignableFrom(boClass) || ObjectCode.class.isAssignableFrom(boClass) || SubObjectCode.class.isAssignableFrom(boClass))) {
39 throw new IllegalArgumentException("BO must be either an Account, SubAccount, ObjectCode, or SubObjectCode (was: " + boClass + ")");
40 }
41
42
43 Map<String, Object> fieldValues = persistenceService.getPrimaryKeyFieldValues(blockedBo);
44 if (Account.class.isAssignableFrom(boClass)) {
45 fieldValues.put(OLEPropertyConstants.ACCOUNT_ACTIVE_INDICATOR, OLEConstants.ParameterValues.NO);
46 }
47 else {
48 fieldValues.put(OLEPropertyConstants.ACTIVE, OLEConstants.ParameterValues.YES);
49 }
50 return convertFieldValuesToStrings(fieldValues);
51 }
52
53
54
55
56
57
58 protected Map<String, String> convertFieldValuesToStrings(Map<String, Object> fieldValues) {
59 Map<String, String> newFieldValues = new HashMap<String, String>();
60 for (String key : fieldValues.keySet()) {
61 final Object value = fieldValues.get(key);
62 if (value != null) {
63 newFieldValues.put(key, value.toString());
64 }
65 }
66 return newFieldValues;
67 }
68
69 public void setPersistenceService(PersistenceService persistenceService) {
70 this.persistenceService = persistenceService;
71 }
72 }