001/** 002 * Copyright 2005-2018 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 */ 016package org.kuali.rice.kns.kim.responsibility; 017 018import org.kuali.rice.core.api.exception.RiceIllegalArgumentException; 019import org.kuali.rice.kim.api.responsibility.Responsibility; 020import org.kuali.rice.kim.framework.responsibility.ResponsibilityTypeService; 021import org.kuali.rice.kns.kim.type.DataDictionaryTypeServiceBase; 022 023import java.util.ArrayList; 024import java.util.Collections; 025import java.util.List; 026import java.util.Map; 027 028/** 029 * @deprecated A krad integrated type service base class will be provided in the future. 030 */ 031@Deprecated 032public class KimResponsibilityTypeServiceBase extends DataDictionaryTypeServiceBase 033 implements ResponsibilityTypeService { 034 035 @Override 036 public final List<Responsibility> getMatchingResponsibilities( Map<String, String> requestedDetails, List<Responsibility> responsibilitiesList ) { 037 if (requestedDetails == null) { 038 throw new RiceIllegalArgumentException("requestedDetails is null"); 039 } 040 041 if (responsibilitiesList == null) { 042 throw new RiceIllegalArgumentException("responsibilitiesList is null"); 043 } 044 045 requestedDetails = translateInputAttributes(requestedDetails); 046 validateRequiredAttributesAgainstReceived(requestedDetails); 047 return Collections.unmodifiableList(performResponsibilityMatches(requestedDetails, responsibilitiesList)); 048 } 049 050 /** 051 * Internal method for matching Responsibilities. Override this method to customize the matching behavior. 052 * 053 * This base implementation uses the {@link #performMatch(Map, Map)} method 054 * to perform an exact match on the Responsibility details and return all that are equal. 055 */ 056 protected List<Responsibility> performResponsibilityMatches(Map<String, String> requestedDetails, List<Responsibility> responsibilitiesList) { 057 List<Responsibility> matchingResponsibilities = new ArrayList<Responsibility>(); 058 for (Responsibility responsibility : responsibilitiesList) { 059 if ( performMatch(requestedDetails, responsibility.getAttributes())) { 060 matchingResponsibilities.add( responsibility ); 061 } 062 } 063 return matchingResponsibilities; 064 } 065}