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.ArrayList;
19 import java.util.Collection;
20 import java.util.Iterator;
21 import java.util.Map;
22
23 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
24 import org.kuali.rice.krad.bo.BusinessObject;
25 import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
26 import org.kuali.rice.krad.service.impl.InactivationBlockingDetectionServiceImpl;
27
28
29
30
31
32
33
34
35 public class OffsetDefinitionInactivationBlockingDetectionServiceImpl extends InactivationBlockingDetectionServiceImpl {
36 protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OffsetDefinitionInactivationBlockingDetectionServiceImpl.class);
37
38
39
40
41 public Collection<BusinessObject> listAllBlockerRecords(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
42 Collection<BusinessObject> blockingRecords = new ArrayList<BusinessObject>();
43
44 Map<String, String> queryMap = buildInactivationBlockerQueryMap(blockedBo, inactivationBlockingMetadata);
45 if (LOG.isDebugEnabled()) {
46 LOG.debug("Checking for blocker records for object: " + blockedBo);
47 LOG.debug(" With Metadata: " + inactivationBlockingMetadata);
48 LOG.debug(" Resulting Query Map: " + queryMap);
49 }
50
51 if (queryMap != null) {
52 Collection<? extends BusinessObject> potentialBlockingRecords = businessObjectService.findMatching(
53 inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass(), queryMap);
54 for (Iterator<? extends BusinessObject> iterator = potentialBlockingRecords.iterator(); iterator.hasNext();) {
55 MutableInactivatable businessObject = (MutableInactivatable) iterator.next();
56 blockingRecords.add((BusinessObject) businessObject);
57 }
58 }
59
60 return blockingRecords;
61 }
62
63
64
65
66
67 public boolean hasABlockingRecord(BusinessObject blockedBo, InactivationBlockingMetadata inactivationBlockingMetadata) {
68 boolean hasBlockingRecord = false;
69
70 Map<String, String> queryMap = buildInactivationBlockerQueryMap(blockedBo, inactivationBlockingMetadata);
71 if (queryMap != null) {
72 Collection<? extends BusinessObject> potentialBlockingRecords = businessObjectService.findMatching(
73 inactivationBlockingMetadata.getBlockingReferenceBusinessObjectClass(), queryMap);
74 return !potentialBlockingRecords.isEmpty();
75 }
76
77
78 return hasBlockingRecord;
79 }
80 }