001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.rice.krad.service.impl; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.rice.krad.bo.BusinessObject; 020 import org.kuali.rice.krad.dao.SequenceAccessorDao; 021 import org.kuali.rice.krad.service.SequenceAccessorService; 022 import org.springframework.transaction.annotation.Transactional; 023 024 @Transactional 025 public class SequenceAccessorServiceImpl implements SequenceAccessorService { 026 private SequenceAccessorDao sequenceAccessorDao; 027 028 public Long getNextAvailableSequenceNumber(String sequenceName, 029 Class<? extends BusinessObject> clazz) { 030 if (StringUtils.isBlank(sequenceName)) { 031 throw new RuntimeException("Sequence name cannot be blank."); 032 } 033 return sequenceAccessorDao.getNextAvailableSequenceNumber(sequenceName, clazz); 034 } 035 036 /** 037 * @see org.kuali.rice.krad.service.SequenceAccessorService#getNextAvailableSequenceNumber(java.lang.String) 038 */ 039 public Long getNextAvailableSequenceNumber(String sequenceName) { 040 if (StringUtils.isBlank(sequenceName)) { 041 throw new RuntimeException("Sequence name cannot be blank."); 042 } 043 return sequenceAccessorDao.getNextAvailableSequenceNumber(sequenceName); 044 } 045 046 public void setSequenceAccessorDao(SequenceAccessorDao sequenceAccessorDao) { 047 this.sequenceAccessorDao = sequenceAccessorDao; 048 } 049 }