001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.service.impl;
017:
018: import java.util.ArrayList;
019: import java.util.Collection;
020: import java.util.Iterator;
021: import java.util.List;
022:
023: import org.apache.commons.lang.StringUtils;
024: import org.kuali.core.dao.MaintenanceDocumentDao;
025: import org.kuali.core.document.MaintenanceDocument;
026: import org.kuali.core.document.MaintenanceLock;
027: import org.kuali.core.service.MaintenanceDocumentService;
028: import org.springframework.transaction.annotation.Transactional;
029:
030: /**
031: * This class is the service implementation for the MaintenanceDocument structure. This is the default implementation, that is
032: * delivered with Kuali.
033: */
034: @Transactional
035: public class MaintenanceDocumentServiceImpl implements
036: MaintenanceDocumentService {
037:
038: private MaintenanceDocumentDao maintenanceDocumentDao;
039:
040: /**
041: * @see org.kuali.core.service.MaintenanceDocumentService#getLockingDocumentId(org.kuali.core.document.MaintenanceDocument)
042: */
043: public String getLockingDocumentId(MaintenanceDocument document) {
044:
045: String lockingDocId = null;
046: String documentNumber = document.getDocumentNumber();
047:
048: List<MaintenanceLock> maintenanceLocks = document
049: .getNewMaintainableObject().generateMaintenanceLocks();
050: for (MaintenanceLock maintenanceLock : maintenanceLocks) {
051: lockingDocId = maintenanceDocumentDao
052: .getLockingDocumentNumber(maintenanceLock
053: .getLockingRepresentation(), documentNumber);
054: if (StringUtils.isNotBlank(lockingDocId)) {
055: break;
056: }
057: }
058:
059: return lockingDocId;
060: }
061:
062: /**
063: * @see org.kuali.core.service.MaintenanceDocumentService#getPendingObjects(java.lang.Class)
064: */
065: public List getPendingObjects(Class businessObjectClass) {
066: List pendingObjects = new ArrayList();
067:
068: Collection pendingMaintDocs = maintenanceDocumentDao
069: .getPendingDocumentsForClass(businessObjectClass);
070: for (Iterator iter = pendingMaintDocs.iterator(); iter
071: .hasNext();) {
072: MaintenanceDocument maintDoc = (MaintenanceDocument) iter
073: .next();
074: maintDoc.populateMaintainablesFromXmlDocumentContents();
075: pendingObjects.add(maintDoc.getNewMaintainableObject()
076: .getBusinessObject());
077: }
078:
079: return pendingObjects;
080: }
081:
082: /**
083: * @see org.kuali.core.service.MaintenanceDocumentService#deleteLocks(String)
084: */
085: public void deleteLocks(String documentNumber) {
086: maintenanceDocumentDao.deleteLocks(documentNumber);
087: }
088:
089: /**
090: * @see org.kuali.core.service.MaintenanceDocumentService#saveLocks(List)
091: */
092: public void storeLocks(List<MaintenanceLock> maintenanceLocks) {
093: maintenanceDocumentDao.storeLocks(maintenanceLocks);
094: }
095:
096: /**
097: * @return Returns the maintenanceDocumentDao.
098: */
099: public MaintenanceDocumentDao getMaintenanceDocumentDao() {
100: return maintenanceDocumentDao;
101: }
102:
103: /**
104: * @param maintenanceDocumentDao The maintenanceDocumentDao to set.
105: */
106: public void setMaintenanceDocumentDao(
107: MaintenanceDocumentDao maintenanceDocumentDao) {
108: this.maintenanceDocumentDao = maintenanceDocumentDao;
109: }
110: }
|