1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.dao.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.ojb.broker.query.Criteria;
20 import org.apache.ojb.broker.query.QueryFactory;
21 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
22 import org.kuali.rice.krad.dao.MaintenanceDocumentDao;
23 import org.kuali.rice.krad.maintenance.MaintenanceLock;
24 import org.kuali.rice.krad.util.KRADPropertyConstants;
25
26
27
28
29 public class MaintenanceDocumentDaoOjb extends PlatformAwareDaoBaseOjb implements MaintenanceDocumentDao {
30
31
32
33
34
35
36 public String getLockingDocumentNumber(String lockingRepresentation, String documentNumber) {
37
38 String lockingDocNumber = "";
39
40
41 Criteria criteria = new Criteria();
42 criteria.addEqualTo("lockingRepresentation", lockingRepresentation);
43
44
45
46 if (StringUtils.isNotBlank(documentNumber)) {
47 criteria.addNotEqualTo(KRADPropertyConstants.DOCUMENT_NUMBER, documentNumber);
48 }
49
50
51 MaintenanceLock maintenanceLock = (MaintenanceLock) getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(MaintenanceLock.class, criteria));
52
53
54
55 if (maintenanceLock != null) {
56 lockingDocNumber = maintenanceLock.getDocumentNumber();
57 }
58 return lockingDocNumber;
59 }
60
61 }