001/**
002 * Copyright 2005-2016 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.krms.api.repository.type;
017
018import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
019import org.kuali.rice.core.api.exception.RiceIllegalStateException;
020import java.util.List;
021
022public interface KrmsTypeBoService {
023
024    /**
025     * This will create a {@link KrmsTypeDefinition} exactly like the parameter passed in.
026     *
027     * @param krmsType - KrmsType
028     * @throws IllegalArgumentException if the krmsType is
029     * +
030     * @throws IllegalStateException if the KrmsType already exists in the system
031     */
032    KrmsTypeDefinition createKrmsType(KrmsTypeDefinition krmsType)
033        throws RiceIllegalArgumentException, RiceIllegalStateException;
034
035    /**
036     * This will update an existing {@link KrmsTypeDefinition}
037     *
038     * @param krmsType - KrmsType
039     * @throws IllegalArgumentException if the krmsType is null
040     * @throws IllegalStateException if the KrmsType does not exist in the system
041     */
042    KrmsTypeDefinition updateKrmsType(KrmsTypeDefinition krmsType)
043        throws RiceIllegalArgumentException, RiceIllegalStateException;
044
045    /**
046     * Lookup a krms type based on the given id.
047     *
048     * @param id the given KRMS type id
049     * @return a KRMS KrmsType object with the given id.  A null reference is returned if an invalid or
050     *         non-existant id is supplied.
051     */
052    KrmsTypeDefinition getTypeById(String id)
053        throws RiceIllegalArgumentException;
054
055    /**
056     * Get a krms type object based on name and namespace
057     *
058     * @param namespaceCode the given type namespace
059     * @param name the given type name
060     * 
061     * @return A krms type object with the given namespace and name if one with that name and namespace
062     *         exists.  Otherwise, null is returned.
063     *
064     * @throws IllegalArgumentException if the given namespaceCode or name is a null or blank value
065     * @throws IllegalStateException if multiple krms types exist with the same name and namespace
066     */
067    KrmsTypeDefinition getTypeByName( String namespaceCode, String name)
068        throws RiceIllegalArgumentException, RiceIllegalStateException;
069
070   /**
071     * Returns all KRMS types that for a given namespace.
072     *
073     * @return all KRMS types for a namespace
074     * @throws IllegalArgumentException if the given namespaceCode is a null or blank value
075     */
076    List<KrmsTypeDefinition> findAllTypesByNamespace(String namespaceCode)
077        throws RiceIllegalArgumentException;
078    
079   /**
080     * Returns all KRMS types that for a given serviceName.
081     *
082     * @return all KRMS types for a serviceName
083     * @throws IllegalArgumentException if the given serviceName is a null or blank value
084     */
085    List<KrmsTypeDefinition> findAllTypesByServiceName(String serviceName)
086        throws RiceIllegalArgumentException;
087
088    /**
089     * Returns all KRMS types
090     *
091     * @return all KRMS types
092     */
093    List<KrmsTypeDefinition> findAllTypes();
094
095    /**
096     * Returns all agenda types for the given contextId.
097     *
098     * @param contextId the id of the context
099     * @return all agenda types for the given contextId
100     * @throws IllegalArgumentException if the given contextId is a null or blank value
101     */
102    List<KrmsTypeDefinition> findAllAgendaTypesByContextId(String contextId)
103        throws RiceIllegalArgumentException;
104
105    /**
106     * Return the agenda type by agendaItemId for the given contextId.
107     *
108     * @param agendaTypeId the id of the agendaType
109     * @param contextId the id of the context
110     * @return agendaType or null if none is found
111     * @throws IllegalArgumentException if the given agendaTypeId or contextId is a null or blank value
112     */
113    KrmsTypeDefinition getAgendaTypeByAgendaTypeIdAndContextId(String agendaTypeId,String contextId)
114        throws RiceIllegalArgumentException;
115
116    /**
117     * Returns all rule types for the given contextId.
118     *
119     * @param contextId the id of the context
120     * @return all rule types for the given contextId
121     * @throws IllegalArgumentException if the given contextId is a null or blank value
122     */
123    List<KrmsTypeDefinition> findAllRuleTypesByContextId(String contextId)
124        throws RiceIllegalArgumentException;
125
126    /**
127     * Return the rule type by ruleItemId for the given contextId.
128     *
129     * @param ruleTypeId the id of the ruleType
130     * @param contextId the id of the context
131     * @return ruleType or null if none is found
132     * @throws IllegalArgumentException if the given ruleTypeId or contextId is a null or blank value
133     */
134    KrmsTypeDefinition getRuleTypeByRuleTypeIdAndContextId(String ruleTypeId, String contextId)
135        throws RiceIllegalArgumentException;
136
137    /**
138     * Returns all action types for the given contextId.
139     *
140     * @param contextId the id of the context
141     * @return all action types for the given contextId
142     * @throws IllegalArgumentException if the given contextId is a null or blank value
143     */
144    List<KrmsTypeDefinition> findAllActionTypesByContextId(String contextId)
145        throws RiceIllegalArgumentException;
146
147    /**
148     * Return the action type by actionItemId for the given contextId.
149     *
150     * @param actionTypeId the id of the actionType
151     * @param contextId the id of the context
152     * @return actionType or null if none is found
153     * @throws IllegalArgumentException if the given actionTypeId or contextId is a null or blank value
154     */
155    KrmsTypeDefinition getActionTypeByActionTypeIdAndContextId(String actionTypeId, String contextId)
156        throws RiceIllegalArgumentException;
157
158    /**
159     * Retrieves an attribute definition for the given id.
160     *
161     * @param attributeDefinitionId the id of the attribute definition to retrieve
162     *
163     * @return the attribute definition matching the given id, or null if no corresponding attribute definition could
164     * be found with the given id value
165     * @throws IllegalArgumentException if the given attributeDefinitionId is a null or blank value
166     */
167    KrmsAttributeDefinition getAttributeDefinitionById(String attributeDefinitionId)
168            throws RiceIllegalArgumentException;
169
170    /**
171     * Retrieves an attribute definition for the given namespace code and name.
172     *
173     * @param namespaceCode the namespace under which to locate the attribute definition
174     * @param name the name of the attribute definition to retrieve
175     *
176     * @return the attribute definition matching the give namespace code and name, or null if no corresponding attribute
177     * definition could be located
178     *
179     * @throws RiceIllegalArgumentException if the given namespaceCode or name is a null or blank value
180     */
181    KrmsAttributeDefinition getAttributeDefinitionByName(String namespaceCode, String name
182    ) throws RiceIllegalArgumentException;
183}