View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
5    * compliance with the License. You may obtain a copy of the License at
6    * 
7    * http://www.opensource.org/licenses/ecl2.php
8    * 
9    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
10   * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11   * language governing permissions and limitations under the License.
12   */
13  package org.kuali.rice.kns.service.impl;
14  
15  import org.apache.commons.lang.StringUtils;
16  import org.kuali.rice.kns.bo.BusinessObject;
17  import org.kuali.rice.kns.dao.SequenceAccessorDao;
18  import org.kuali.rice.kns.service.SequenceAccessorService;
19  import org.springframework.transaction.annotation.Transactional;
20  
21  @Transactional
22  public class SequenceAccessorServiceImpl implements SequenceAccessorService {
23      private SequenceAccessorDao sequenceAccessorDao;
24  
25  	public Long getNextAvailableSequenceNumber(String sequenceName, 
26  			Class<? extends BusinessObject> clazz) {
27      	if (StringUtils.isBlank(sequenceName)) {
28      		throw new RuntimeException("Sequence name cannot be blank.");
29      	}
30      	return sequenceAccessorDao.getNextAvailableSequenceNumber(sequenceName, clazz);		
31  	}
32  	
33      /**
34       * @see org.kuali.rice.kns.service.SequenceAccessorService#getNextAvailableSequenceNumber(java.lang.String)
35       */
36      public Long getNextAvailableSequenceNumber(String sequenceName) {
37      	if (StringUtils.isBlank(sequenceName)) {
38      		throw new RuntimeException("Sequence name cannot be blank.");
39      	}
40      	return sequenceAccessorDao.getNextAvailableSequenceNumber(sequenceName);
41      }
42  
43      public void setSequenceAccessorDao(SequenceAccessorDao sequenceAccessorDao) {
44      	this.sequenceAccessorDao = sequenceAccessorDao;
45      }
46  }