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 org.kuali.rice.krms.api.KrmsConstants;
021import org.springframework.cache.annotation.CacheEvict;
022import org.springframework.cache.annotation.Cacheable;
023
024import javax.jws.WebMethod;
025import javax.jws.WebParam;
026import javax.jws.WebResult;
027import javax.jws.WebService;
028import javax.jws.soap.SOAPBinding;
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlElementWrapper;
031import java.util.List;
032
033
034@WebService(name = "KRMSTypeService", targetNamespace = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0)
035@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
036public interface KrmsTypeRepositoryService {
037
038    /**
039     * This will create a {@link KrmsTypeDefinition} exactly like the parameter passed in.
040     *
041     * @param krmsType - KrmsType
042     * @throws IllegalArgumentException if the krmsType is
043     * +
044     * @throws IllegalStateException if the KrmsType already exists in the system
045     */
046    @WebMethod(operationName="createKrmsType")
047    @WebResult(name = "krmsType")
048    @CacheEvict(value={KrmsTypeDefinition.Cache.NAME}, allEntries = true)
049    KrmsTypeDefinition createKrmsType(@WebParam(name = "krmsType") KrmsTypeDefinition krmsType)
050        throws RiceIllegalArgumentException, RiceIllegalStateException;
051
052    /**
053     * This will update an existing {@link KrmsTypeDefinition}
054     *
055     * @param krmsType - KrmsType
056     * @throws IllegalArgumentException if the krmsType is null
057     * @throws IllegalStateException if the KrmsType does not exist in the system
058     */
059    @WebMethod(operationName="updateKrmsType")
060    @WebResult(name = "krmsType")
061    @CacheEvict(value={KrmsTypeDefinition.Cache.NAME}, allEntries = true)
062    KrmsTypeDefinition updateKrmsType(@WebParam(name = "krmsType") KrmsTypeDefinition krmsType)
063        throws RiceIllegalArgumentException, RiceIllegalStateException;
064
065    /**
066     * Lookup a krms type based on the given id.
067     *
068     * @param id the given KRMS type id
069     * @return a KRMS KrmsType object with the given id.  A null reference is returned if an invalid or
070     *         non-existant id is supplied.
071     */
072    @WebMethod(operationName = "getTypeById")
073    @WebResult(name = "type")
074    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'id=' + #p0")
075    KrmsTypeDefinition getTypeById(@WebParam(name = "id") String id)
076        throws RiceIllegalArgumentException;
077
078    /**
079     * Get a krms type object based on name and namespace
080     *
081     * @param namespaceCode the given type namespace
082     * @param name the given type name
083     * 
084     * @return A krms type object with the given namespace and name if one with that name and namespace
085     *         exists.  Otherwise, null is returned.
086     *
087     * @throws IllegalArgumentException if the given namespaceCode or name is a null or blank value
088     * @throws IllegalStateException if multiple krms types exist with the same name and namespace
089     */
090    @WebMethod(operationName = "getTypeByName")
091    @WebResult(name = "type")
092    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'namespaceCode=' + #p0 + '|' + 'name=' + #p1")
093    KrmsTypeDefinition getTypeByName(
094            @WebParam(name = "namespaceCode") String namespaceCode,
095            @WebParam(name = "name") String name)
096        throws RiceIllegalArgumentException, RiceIllegalStateException;
097
098   /**
099     * Returns all KRMS types that for a given namespace.
100     *
101     * @return all KRMS types for a namespace
102     * @throws IllegalArgumentException if the given namespaceCode is a null or blank value
103     */
104    @WebMethod(operationName = "findAllTypesByNamespace")
105    @XmlElementWrapper(name = "namespaceTypes", required = true)
106    @XmlElement(name = "namespaceType", required = false)
107    @WebResult(name = "namespaceTypes")
108    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'allByNamespaceCode=' + #p0")
109    List<KrmsTypeDefinition> findAllTypesByNamespace(
110                @WebParam(name = "namespaceCode") String namespaceCode)
111        throws RiceIllegalArgumentException;
112
113    /**
114     * Returns all KRMS types
115     *
116     * @return all KRMS types
117     */
118    @WebMethod(operationName = "findAllTypes")
119    @XmlElementWrapper(name = "types", required = true)
120    @XmlElement(name = "type", required = false)
121    @WebResult(name = "types")
122    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'all'")
123    List<KrmsTypeDefinition> findAllTypes();
124
125    /**
126     * Returns all agenda types for the given contextId.
127     *
128     * @param contextId the id of the context
129     * @return all agenda types for the given contextId
130     * @throws IllegalArgumentException if the given contextId is a null or blank value
131     */
132    @WebMethod(operationName = "findAllAgendaTypesByContextId")
133    @XmlElementWrapper(name = "agendaTypes", required = true)
134    @XmlElement(name = "agendaType", required = false)
135    @WebResult(name = "agendaTypes")
136    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'{AgendaType}contextId=' + #p0")
137    List<KrmsTypeDefinition> findAllAgendaTypesByContextId(
138            @WebParam(name="contextId") String contextId)
139        throws RiceIllegalArgumentException;
140
141    /**
142     * Return the agenda type by agendaItemId for the given contextId.
143     *
144     * @param agendaTypeId the id of the agendaType
145     * @param contextId the id of the context
146     * @return agendaType or null if none is found
147     * @throws IllegalArgumentException if the given agendaTypeId or contextId is a null or blank value
148     */
149    @WebMethod(operationName = "getAgendaTypeByAgendaTypeIdAndContextId")
150    @WebResult(name = "type")
151    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'agendaTypeId=' + #p0 + '|' + 'contextId=' + #p1")
152    KrmsTypeDefinition getAgendaTypeByAgendaTypeIdAndContextId(
153            @WebParam(name="agendaTypeId") String agendaTypeId,
154            @WebParam(name="contextId") String contextId)
155        throws RiceIllegalArgumentException;
156
157    /**
158     * Returns all rule types for the given contextId.
159     *
160     * @param contextId the id of the context
161     * @return all rule types for the given contextId
162     * @throws IllegalArgumentException if the given contextId is a null or blank value
163     */
164    @WebMethod(operationName = "findAllRuleTypesByContextId")
165    @XmlElementWrapper(name = "ruleTypes", required = true)
166    @XmlElement(name = "ruleType", required = false)
167    @WebResult(name = "ruleTypes")
168    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'{RuleType}contextId=' + #p0")
169    List<KrmsTypeDefinition> findAllRuleTypesByContextId(
170            @WebParam(name="contextId") String contextId)
171        throws RiceIllegalArgumentException;
172
173    /**
174     * Return the rule type by ruleItemId for the given contextId.
175     *
176     * @param ruleTypeId the id of the ruleType
177     * @param contextId the id of the context
178     * @return ruleType or null if none is found
179     * @throws IllegalArgumentException if the given ruleTypeId or contextId is a null or blank value
180     */
181    @WebMethod(operationName = "getRuleTypeByRuleTypeIdAndContextId")
182    @WebResult(name = "ruleType")
183    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'ruleTypeId=' + #p0 + '|' + 'contextId=' + #p1")
184    KrmsTypeDefinition getRuleTypeByRuleTypeIdAndContextId(
185            @WebParam(name="ruleTypeId") String ruleTypeId,
186            @WebParam(name="contextId") String contextId)
187        throws RiceIllegalArgumentException;
188
189    /**
190     * Returns all action types for the given contextId.
191     *
192     * @param contextId the id of the context
193     * @return all action types for the given contextId
194     * @throws IllegalArgumentException if the given contextId is a null or blank value
195     */
196    @WebMethod(operationName = "findAllActionTypesByContextId")
197    @XmlElementWrapper(name = "actionTypes", required = true)
198    @XmlElement(name = "actionType", required = false)
199    @WebResult(name = "actionTypes")
200    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'{ActionType}contextId=' + #p0")
201    List<KrmsTypeDefinition> findAllActionTypesByContextId(
202            @WebParam(name="contextId") String contextId)
203        throws RiceIllegalArgumentException;
204
205    /**
206     * Return the action type by actionItemId for the given contextId.
207     *
208     * @param actionTypeId the id of the actionType
209     * @param contextId the id of the context
210     * @return actionType or null if none is found
211     * @throws IllegalArgumentException if the given actionTypeId or contextId is a null or blank value
212     */
213    @WebMethod(operationName = "getActionTypeByActionTypeIdAndContextId")
214    @WebResult(name = "actionType")
215    @Cacheable(value= KrmsTypeDefinition.Cache.NAME, key="'actionTypeId=' + #p0 + '|' + 'contextId=' + #p1")
216    KrmsTypeDefinition getActionTypeByActionTypeIdAndContextId(
217            @WebParam(name="actionTypeId") String actionTypeId,
218            @WebParam(name="contextId") String contextId)
219        throws RiceIllegalArgumentException;
220
221    /**
222     * Retrieves an attribute definition for the given id.
223     *
224     * @param attributeDefinitionId the id of the attribute definition to retrieve
225     *
226     * @return the attribute definition matching the given id, or null if no corresponding attribute definition could
227     * be found with the given id value
228     * @throws IllegalArgumentException if the given attributeDefinitionId is a null or blank value
229     */
230    @WebMethod(operationName = "getAttributeDefinitionById")
231    @WebResult(name = "attribute")
232    @Cacheable(value= KrmsAttributeDefinition.Cache.NAME, key="'attributeDefinitionId=' + #p0")
233    KrmsAttributeDefinition getAttributeDefinitionById(@WebParam(name = "attributeDefinitionId") String attributeDefinitionId)
234            throws RiceIllegalArgumentException;
235
236    /**
237     * Retrieves an attribute definition for the given namespace code and name.
238     *
239     * @param namespaceCode the namespace under which to locate the attribute definition
240     * @param name the name of the attribute definition to retrieve
241     *
242     * @return the attribute definition matching the give namespace code and name, or null if no corresponding attribute
243     * definition could be located
244     *
245     * @throws RiceIllegalArgumentException if the given namespaceCode or name is a null or blank value
246     */
247    @WebMethod(operationName = "getAttributeDefinitionByName")
248    @WebResult(name = "attribute")
249    @Cacheable(value= KrmsAttributeDefinition.Cache.NAME, key="'namespaceCode=' + #p0 + '|' + 'name=' + #p1")
250    KrmsAttributeDefinition getAttributeDefinitionByName(
251            @WebParam(name = "namespaceCode") String namespaceCode,
252            @WebParam(name = "name") String name
253    ) throws RiceIllegalArgumentException;
254}