View Javadoc

1   /*
2    * Copyright 2007-2010 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.kim.service.impl;
17  
18  import org.kuali.rice.kew.service.KEWServiceLocator;
19  import org.kuali.rice.kim.bo.role.impl.RoleMemberAttributeDataImpl;
20  import org.kuali.rice.kim.util.KimConstants;
21  import org.kuali.rice.kns.service.BusinessObjectService;
22  import org.kuali.rice.kns.service.KNSServiceLocator;
23  import org.kuali.rice.kns.service.SequenceAccessorService;
24  import org.kuali.rice.ksb.cache.RiceCacheAdministrator;
25  
26  /**
27   * This is a description of what this class does - jjhanso don't forget to fill this in. 
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   *
31   */
32  public class ResponsibilityServiceBase {
33  	protected static final String RESPONSIBILITY_IMPL_CACHE_PREFIX = "ResponsibilityImpl-Template-";
34  	protected static final String RESPONSIBILITY_IMPL_CACHE_GROUP = "ResponsibilityImpl";
35  	protected static final String DEFAULT_RESPONSIBILITY_TYPE_SERVICE = "defaultResponsibilityTypeService";
36  	protected static final Integer DEFAULT_PRIORITY_NUMBER = Integer.valueOf(1);
37  	
38  	private SequenceAccessorService sequenceAccessorService;
39  	private RiceCacheAdministrator cacheAdministrator;
40  
41  	private BusinessObjectService businessObjectService;
42  	
43  	protected BusinessObjectService getBusinessObjectService() {
44  		if ( businessObjectService == null ) {
45  			businessObjectService = KNSServiceLocator.getBusinessObjectService();
46  		}
47  		return businessObjectService;
48  	}
49  	
50  	public void flushResponsibilityImplCache() {
51      	getCacheAdministrator().flushGroup(RESPONSIBILITY_IMPL_CACHE_GROUP);
52      }
53  	
54  	protected String getResponsibilityImplByTemplateNameCacheKey( String namespaceCode, String responsibilityTemplateName ) {
55      	return RESPONSIBILITY_IMPL_CACHE_PREFIX + namespaceCode + "-" + responsibilityTemplateName;
56      }
57  	
58  	protected String getNewAttributeDataId(){
59  		SequenceAccessorService sas = getSequenceAccessorService();		
60  		Long nextSeq = sas.getNextAvailableSequenceNumber(
61  				KimConstants.SequenceNames.KRIM_ATTR_DATA_ID_S, 
62  				RoleMemberAttributeDataImpl.class );
63  		return nextSeq.toString();
64      }
65  	
66  	protected SequenceAccessorService getSequenceAccessorService() {
67  		if ( sequenceAccessorService == null ) {
68  			sequenceAccessorService = KNSServiceLocator.getSequenceAccessorService();
69  		}
70  		return sequenceAccessorService;
71  	}
72  	
73  	protected RiceCacheAdministrator getCacheAdministrator() {
74  		if ( cacheAdministrator == null ) {
75  			cacheAdministrator = KEWServiceLocator.getCacheAdministrator();
76  		}
77  		return cacheAdministrator;
78  	}
79  	
80  	
81  }