1 /*
2 * Copyright 2005-2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.kns.service.impl;
17
18 import java.util.List;
19
20 import org.apache.commons.lang.StringUtils;
21 import org.kuali.rice.kns.dao.MaintenanceDocumentDao;
22 import org.kuali.rice.kns.document.MaintenanceDocument;
23 import org.kuali.rice.kns.document.MaintenanceLock;
24 import org.kuali.rice.kns.maintenance.Maintainable;
25 import org.kuali.rice.kns.service.MaintenanceDocumentService;
26 import org.springframework.transaction.annotation.Transactional;
27
28 /**
29 * This class is the service implementation for the MaintenanceDocument structure. This is the default implementation, that is
30 * delivered with Kuali.
31 */
32 @Transactional
33 public class MaintenanceDocumentServiceImpl implements MaintenanceDocumentService {
34
35 private MaintenanceDocumentDao maintenanceDocumentDao;
36
37 /**
38 * @see org.kuali.rice.kns.service.MaintenanceDocumentService#getLockingDocumentId(org.kuali.rice.kns.document.MaintenanceDocument)
39 */
40 public String getLockingDocumentId(MaintenanceDocument document) {
41 return getLockingDocumentId(document.getNewMaintainableObject(), document.getDocumentNumber());
42 }
43
44 /**
45 * @see org.kuali.rice.kns.service.MaintenanceDocumentService#getLockingDocumentId(org.kuali.rice.kns.maintenance.Maintainable, java.lang.String)
46 */
47 public String getLockingDocumentId(Maintainable maintainable, String documentNumber) {
48 String lockingDocId = null;
49 List<MaintenanceLock> maintenanceLocks = maintainable.generateMaintenanceLocks();
50 for (MaintenanceLock maintenanceLock : maintenanceLocks) {
51 lockingDocId = maintenanceDocumentDao.getLockingDocumentNumber(maintenanceLock.getLockingRepresentation(),documentNumber);
52 if (StringUtils.isNotBlank(lockingDocId)) {
53 break;
54 }
55 }
56 return lockingDocId;
57 }
58
59 // /**
60 // * @see org.kuali.rice.kns.service.MaintenanceDocumentService#getPendingObjects(java.lang.Class)
61 // */
62 // public List getPendingObjects(Class businessObjectClass) {
63 // List pendingObjects = new ArrayList();
64 //
65 // Collection pendingMaintDocs = maintenanceDocumentDao.getPendingDocumentsForClass(businessObjectClass);
66 // for (Iterator iter = pendingMaintDocs.iterator(); iter.hasNext();) {
67 // MaintenanceDocument maintDoc = (MaintenanceDocument) iter.next();
68 // maintDoc.populateMaintainablesFromXmlDocumentContents();
69 // pendingObjects.add(maintDoc.getNewMaintainableObject().getBusinessObject());
70 // }
71 //
72 // return pendingObjects;
73 // }
74
75 /**
76 * @see org.kuali.rice.kns.service.MaintenanceDocumentService#deleteLocks(String)
77 */
78 public void deleteLocks(String documentNumber) {
79 maintenanceDocumentDao.deleteLocks(documentNumber);
80 }
81
82 /**
83 * @see org.kuali.rice.kns.service.MaintenanceDocumentService#saveLocks(List)
84 */
85 public void storeLocks(List<MaintenanceLock> maintenanceLocks) {
86 maintenanceDocumentDao.storeLocks(maintenanceLocks);
87 }
88
89 /**
90 * @return Returns the maintenanceDocumentDao.
91 */
92 public MaintenanceDocumentDao getMaintenanceDocumentDao() {
93 return maintenanceDocumentDao;
94 }
95
96 /**
97 * @param maintenanceDocumentDao The maintenanceDocumentDao to set.
98 */
99 public void setMaintenanceDocumentDao(MaintenanceDocumentDao maintenanceDocumentDao) {
100 this.maintenanceDocumentDao = maintenanceDocumentDao;
101 }
102 }