| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.kuali.rice.kew.actionrequest.dao.impl; |
| 18 |
|
|
| 19 |
|
import org.apache.commons.lang.StringUtils; |
| 20 |
|
import org.apache.ojb.broker.query.Criteria; |
| 21 |
|
import org.apache.ojb.broker.query.QueryByCriteria; |
| 22 |
|
import org.apache.ojb.broker.query.QueryFactory; |
| 23 |
|
import org.apache.ojb.broker.query.ReportQueryByCriteria; |
| 24 |
|
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
| 25 |
|
import org.kuali.rice.kew.actionrequest.dao.ActionRequestDAO; |
| 26 |
|
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 27 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 28 |
|
import org.springmodules.orm.ojb.support.PersistenceBrokerDaoSupport; |
| 29 |
|
|
| 30 |
|
import java.sql.Timestamp; |
| 31 |
|
import java.util.*; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@link |
| 36 |
|
|
| 37 |
|
@author |
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 194 (194) |
Complexity: 34 |
Complexity Density: 0.22 |
|
| 39 |
|
public class ActionRequestDAOOjbImpl extends PersistenceBrokerDaoSupport implements ActionRequestDAO { |
| 40 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 41 |
0
|
public ActionRequestValue getActionRequestByActionRequestId(Long actionRequestId) {... |
| 42 |
0
|
Criteria crit = new Criteria(); |
| 43 |
0
|
crit.addEqualTo("actionRequestId", actionRequestId); |
| 44 |
0
|
return (ActionRequestValue) this.getPersistenceBrokerTemplate().getObjectByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 45 |
|
} |
| 46 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 47 |
0
|
public void saveActionRequest(ActionRequestValue actionRequest) {... |
| 48 |
0
|
if (actionRequest.getActionRequestId() == null) { |
| 49 |
0
|
loadDefaultValues(actionRequest); |
| 50 |
|
} |
| 51 |
0
|
if ( actionRequest.getAnnotation() != null && actionRequest.getAnnotation().length() > 2000 ) { |
| 52 |
0
|
actionRequest.setAnnotation( StringUtils.abbreviate(actionRequest.getAnnotation(), 2000) ); |
| 53 |
|
} |
| 54 |
0
|
this.getPersistenceBrokerTemplate().store(actionRequest); |
| 55 |
|
} |
| 56 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 3 |
Complexity Density: 0.23 |
|
| 57 |
0
|
public List findPendingByResponsibilityIds(Collection responsibilityIds) {... |
| 58 |
0
|
if (responsibilityIds == null || responsibilityIds.size() == 0) return Collections.emptyList(); |
| 59 |
0
|
Criteria crit = new Criteria(); |
| 60 |
0
|
Criteria statusCriteria = new Criteria(); |
| 61 |
0
|
Criteria activatedCriteria = new Criteria(); |
| 62 |
0
|
activatedCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_ACTIVATED); |
| 63 |
|
|
| 64 |
0
|
Criteria initializedCriteria = new Criteria(); |
| 65 |
0
|
initializedCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_INITIALIZED); |
| 66 |
|
|
| 67 |
0
|
statusCriteria.addOrCriteria(activatedCriteria); |
| 68 |
0
|
statusCriteria.addOrCriteria(initializedCriteria); |
| 69 |
0
|
crit.addAndCriteria(statusCriteria); |
| 70 |
0
|
crit.addIn("responsibilityId", responsibilityIds); |
| 71 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 72 |
|
} |
| 73 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 74 |
0
|
public List findPendingByActionRequestedAndDocId(String actionRequestedCd, Long routeHeaderId) {... |
| 75 |
0
|
Criteria crit = new Criteria(); |
| 76 |
0
|
crit.addEqualTo("actionRequested", actionRequestedCd); |
| 77 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 78 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 79 |
0
|
crit.addAndCriteria(getPendingCriteria()); |
| 80 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 83 |
0
|
@SuppressWarnings("unchecked")... |
| 84 |
|
public List<ActionRequestValue> findByStatusAndDocId(String statusCd, Long routeHeaderId) { |
| 85 |
0
|
Criteria crit = new Criteria(); |
| 86 |
0
|
crit.addEqualTo("status", statusCd); |
| 87 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 88 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 89 |
|
|
| 90 |
0
|
return (List<ActionRequestValue>) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 93 |
0
|
private void loadDefaultValues(ActionRequestValue actionRequest) {... |
| 94 |
0
|
checkNull(actionRequest.getActionRequested(), "action requested"); |
| 95 |
0
|
checkNull(actionRequest.getResponsibilityId(), "responsibility ID"); |
| 96 |
0
|
checkNull(actionRequest.getRouteLevel(), "route level"); |
| 97 |
0
|
checkNull(actionRequest.getDocVersion(), "doc version"); |
| 98 |
0
|
if (actionRequest.getForceAction() == null) { |
| 99 |
0
|
actionRequest.setForceAction(Boolean.FALSE); |
| 100 |
|
} |
| 101 |
0
|
if (actionRequest.getStatus() == null) { |
| 102 |
0
|
actionRequest.setStatus(KEWConstants.ACTION_REQUEST_INITIALIZED); |
| 103 |
|
} |
| 104 |
0
|
if (actionRequest.getPriority() == null) { |
| 105 |
0
|
actionRequest.setPriority(KEWConstants.ACTION_REQUEST_DEFAULT_PRIORITY); |
| 106 |
|
} |
| 107 |
0
|
if (actionRequest.getCurrentIndicator() == null) { |
| 108 |
0
|
actionRequest.setCurrentIndicator(true); |
| 109 |
|
} |
| 110 |
0
|
actionRequest.setCreateDate(new Timestamp(System.currentTimeMillis())); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 114 |
0
|
private void checkNull(Object value, String valueName) throws RuntimeException {... |
| 115 |
0
|
if (value == null) { |
| 116 |
0
|
throw new RuntimeException("Null value for " + valueName); |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 120 |
0
|
public List findPendingRootRequestsByDocIdAtRouteLevel(Long routeHeaderId, Integer routeLevel) {... |
| 121 |
0
|
Criteria crit = new Criteria(); |
| 122 |
0
|
crit.addEqualTo("routeLevel", routeLevel); |
| 123 |
0
|
crit.addNotEqualTo("status", KEWConstants.ACTION_REQUEST_DONE_STATE); |
| 124 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 125 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 126 |
0
|
crit.addIsNull("parentActionRequest"); |
| 127 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 128 |
|
} |
| 129 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 130 |
0
|
public List findPendingByDocIdAtOrBelowRouteLevel(Long routeHeaderId, Integer routeLevel) {... |
| 131 |
0
|
Criteria crit = new Criteria(); |
| 132 |
0
|
crit.addLessOrEqualThan("routeLevel", routeLevel); |
| 133 |
0
|
crit.addNotEqualTo("status", KEWConstants.ACTION_REQUEST_DONE_STATE); |
| 134 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 135 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 136 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 137 |
|
} |
| 138 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 139 |
0
|
public List findPendingRootRequestsByDocIdAtOrBelowRouteLevel(Long routeHeaderId, Integer routeLevel) {... |
| 140 |
0
|
Criteria crit = new Criteria(); |
| 141 |
0
|
crit.addLessOrEqualThan("routeLevel", routeLevel); |
| 142 |
0
|
crit.addNotEqualTo("status", KEWConstants.ACTION_REQUEST_DONE_STATE); |
| 143 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 144 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 145 |
0
|
crit.addIsNull("parentActionRequest"); |
| 146 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 147 |
|
} |
| 148 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 149 |
0
|
public void delete(Long actionRequestId) {... |
| 150 |
0
|
Criteria crit = new Criteria(); |
| 151 |
0
|
crit.addEqualTo("actionRequestId", actionRequestId); |
| 152 |
0
|
this.getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 153 |
|
} |
| 154 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
| 155 |
0
|
public List findAllPendingByDocId(Long routeHeaderId) {... |
| 156 |
0
|
Criteria initializedStatCriteria = new Criteria(); |
| 157 |
0
|
initializedStatCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_INITIALIZED); |
| 158 |
|
|
| 159 |
0
|
Criteria activatedStatCriteria = new Criteria(); |
| 160 |
0
|
activatedStatCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_ACTIVATED); |
| 161 |
|
|
| 162 |
0
|
Criteria statusCriteria = new Criteria(); |
| 163 |
0
|
statusCriteria.addOrCriteria(initializedStatCriteria); |
| 164 |
0
|
statusCriteria.addOrCriteria(activatedStatCriteria); |
| 165 |
|
|
| 166 |
0
|
Criteria crit = new Criteria(); |
| 167 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 168 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 169 |
0
|
crit.addAndCriteria(statusCriteria); |
| 170 |
|
|
| 171 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 172 |
|
} |
| 173 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 174 |
0
|
public List findAllByDocId(Long routeHeaderId) {... |
| 175 |
0
|
Criteria crit = new Criteria(); |
| 176 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 177 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 178 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 179 |
|
} |
| 180 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 181 |
0
|
public List findAllRootByDocId(Long routeHeaderId) {... |
| 182 |
0
|
Criteria crit = new Criteria(); |
| 183 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 184 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 185 |
0
|
crit.addIsNull("parentActionRequest"); |
| 186 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 187 |
|
} |
| 188 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 189 |
0
|
public List findByRouteHeaderIdIgnoreCurrentInd(Long routeHeaderId) {... |
| 190 |
0
|
Criteria crit = new Criteria(); |
| 191 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 192 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 196 |
0
|
private Criteria getPendingCriteria() {... |
| 197 |
0
|
Criteria pendingCriteria = new Criteria(); |
| 198 |
0
|
Criteria activatedCriteria = new Criteria(); |
| 199 |
0
|
activatedCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_ACTIVATED); |
| 200 |
0
|
Criteria initializedCriteria = new Criteria(); |
| 201 |
0
|
initializedCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_INITIALIZED); |
| 202 |
0
|
pendingCriteria.addOrCriteria(activatedCriteria); |
| 203 |
0
|
pendingCriteria.addOrCriteria(initializedCriteria); |
| 204 |
0
|
return pendingCriteria; |
| 205 |
|
} |
| 206 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 207 |
0
|
public void deleteByRouteHeaderId(Long routeHeaderId){... |
| 208 |
0
|
Criteria crit = new Criteria(); |
| 209 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 210 |
0
|
this.getPersistenceBrokerTemplate().deleteByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 211 |
|
} |
| 212 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 213 |
0
|
public List findPendingRootRequestsByDocumentType(Long documentTypeId) {... |
| 214 |
0
|
Criteria routeHeaderCrit = new Criteria(); |
| 215 |
0
|
routeHeaderCrit.addEqualTo("documentTypeId", documentTypeId); |
| 216 |
0
|
Criteria crit = new Criteria(); |
| 217 |
|
|
| 218 |
0
|
crit.addIn("routeHeaderId", new ReportQueryByCriteria(DocumentRouteHeaderValue.class, new String[] {"routeHeaderId"}, routeHeaderCrit)); |
| 219 |
0
|
crit.addAndCriteria(getPendingCriteria()); |
| 220 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 221 |
0
|
crit.addIsNull("parentActionRequest"); |
| 222 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 223 |
|
} |
| 224 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 225 |
0
|
public List findPendingRootRequestsByDocIdAtRouteNode(Long routeHeaderId, Long nodeInstanceId) {... |
| 226 |
0
|
Criteria crit = new Criteria(); |
| 227 |
0
|
crit.addEqualTo("routeHeaderId", routeHeaderId); |
| 228 |
0
|
crit.addAndCriteria(getPendingCriteria()); |
| 229 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 230 |
0
|
crit.addIsNull("parentActionRequest"); |
| 231 |
0
|
crit.addEqualTo("nodeInstance.routeNodeInstanceId", nodeInstanceId); |
| 232 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 233 |
|
} |
| 234 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 235 |
0
|
public List findRootRequestsByDocIdAtRouteNode(Long documentId, Long nodeInstanceId) {... |
| 236 |
0
|
Criteria crit = new Criteria(); |
| 237 |
0
|
crit.addEqualTo("routeHeaderId", documentId); |
| 238 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 239 |
0
|
crit.addIsNull("parentActionRequest"); |
| 240 |
0
|
crit.addEqualTo("nodeInstance.routeNodeInstanceId", nodeInstanceId); |
| 241 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 242 |
|
} |
| 243 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 244 |
0
|
public boolean doesDocumentHaveUserRequest(String principalId, Long documentId) {... |
| 245 |
0
|
Criteria crit = new Criteria(); |
| 246 |
0
|
crit.addEqualTo("routeHeaderId", documentId); |
| 247 |
0
|
crit.addEqualTo("recipientTypeCd", KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD); |
| 248 |
0
|
crit.addEqualTo("principalId", principalId); |
| 249 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 250 |
0
|
int count = getPersistenceBrokerTemplate().getCount(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 251 |
0
|
return count > 0; |
| 252 |
|
} |
| 253 |
|
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
| 254 |
0
|
public List<String> getRequestGroupIds(Long documentId) {... |
| 255 |
0
|
Criteria crit = new Criteria(); |
| 256 |
0
|
crit.addEqualTo("routeHeaderId", documentId); |
| 257 |
0
|
crit.addEqualTo("recipientTypeCd", KEWConstants.ACTION_REQUEST_GROUP_RECIPIENT_CD); |
| 258 |
0
|
crit.addEqualTo("currentIndicator", Boolean.TRUE); |
| 259 |
|
|
| 260 |
0
|
ReportQueryByCriteria query = QueryFactory.newReportQuery(ActionRequestValue.class, crit); |
| 261 |
0
|
query.setAttributes(new String[] { "groupId" }); |
| 262 |
|
|
| 263 |
0
|
List<String> groupIds = new ArrayList<String>(); |
| 264 |
0
|
Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(query); |
| 265 |
0
|
while (iter.hasNext()) { |
| 266 |
0
|
Object[] row = (Object[]) iter.next(); |
| 267 |
0
|
String id = (String)row[0]; |
| 268 |
0
|
groupIds.add(id); |
| 269 |
|
} |
| 270 |
0
|
return groupIds; |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
|
| 274 |
|
@see |
| 275 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 276 |
0
|
public List findActivatedByGroup(String groupId) {... |
| 277 |
0
|
Criteria statusCriteria = new Criteria(); |
| 278 |
0
|
statusCriteria.addEqualTo("status", KEWConstants.ACTION_REQUEST_ACTIVATED); |
| 279 |
0
|
Criteria crit = new Criteria(); |
| 280 |
0
|
crit.addEqualTo("groupId", groupId); |
| 281 |
0
|
crit.addEqualTo("currentIndicator", true); |
| 282 |
0
|
crit.addAndCriteria(statusCriteria); |
| 283 |
|
|
| 284 |
0
|
return (List) this.getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(ActionRequestValue.class, crit)); |
| 285 |
|
} |
| 286 |
|
} |