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.term;
017
018import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
019import org.kuali.rice.krms.api.KrmsConstants;
020import org.springframework.cache.annotation.Cacheable;
021
022import javax.jws.WebMethod;
023import javax.jws.WebParam;
024import javax.jws.WebResult;
025import javax.jws.WebService;
026import javax.jws.soap.SOAPBinding;
027import javax.xml.bind.annotation.XmlElement;
028import javax.xml.bind.annotation.XmlElementWrapper;
029import java.util.List;
030import org.springframework.cache.annotation.CacheEvict;
031
032/**
033 * The TermRepositoryService provides the basic access to terms and term resolvers in the repository needed
034 * for executing rules.
035 *
036 * @author Kuali Rice Team (rice.collab@kuali.org)
037 *
038 */
039@WebService(name = "termRepositoryService", targetNamespace = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0)
040@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
041public interface TermRepositoryService {
042
043
044    /**
045     * Retrieves all {@link TermResolverDefinition}s for the given namespace.
046     *
047     * @since 2.1.1
048     * @param namespace the namespace for which to get all term resolvers.
049     * @return the List of {@link TermResolverDefinition}s for the given namespace. May be empty, but never null.
050     *
051     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the namespace is null or blank.
052     */
053    @WebMethod(operationName = "findTermResolversByNamespace")
054    @XmlElementWrapper(name = "termResolvers", required = true)
055    @XmlElement(name = "termResolver", required = false)
056    @WebResult(name = "termResolvers")
057    @Cacheable(value = TermResolverDefinition.Cache.NAME, key = "'namespace=' + #p0")
058    List<TermResolverDefinition> findTermResolversByNamespace(@WebParam(name = "namespace") String namespace) throws RiceIllegalArgumentException;
059
060    /**
061     * Retrieves the {@link TermDefinition} with the given termId.
062     *
063     * @since 2.1.1
064     * @param termId the identifier of the term to retrieve.
065     * @return the {@link TermDefinition} with the given termId.  May be null if there is no term with the given termId
066     * in the repository.
067     *
068     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the termId is null or blank.
069     */
070    @WebMethod(operationName = "getTerm")
071    @WebResult(name = "term")
072    @Cacheable(value= TermDefinition.Cache.NAME, key="'id=' + #p0")
073    TermDefinition getTerm(@WebParam(name = "termId") String termId) throws RiceIllegalArgumentException;;
074
075    /**
076     * Retrieves the {@link TermSpecificationDefinition} with the given TermSpecificationId.
077     *
078     * @since 2.2.1
079     * @param id the identifier of the term specification to retrieve.
080     * @return the {@link TermSpecificationDefinition} with the given id.  May be null if there is no term specification 
081     * with the given id in the repository.
082     *
083     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the id is null or blank.
084     */
085    @WebMethod(operationName = "getTermSpecificationById")
086    @WebResult(name = "termSpecification")
087    @Cacheable(value = TermSpecificationDefinition.Cache.NAME, key = "'id=' + #p0")
088    TermSpecificationDefinition getTermSpecificationById(@WebParam(name = "id") String id)
089            throws RiceIllegalArgumentException;
090
091    /**
092     * Creates a {@link TermSpecificationDefinition}
093     *
094     * @since 2.2.1
095     * @param termSpec the term specification to be created
096     * @return the {@link TermSpecificationDefinition} after it has been created
097     * in the repository.
098     *
099     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException
100     * termSpec is null or invalid
101     */
102    @WebMethod(operationName = "createTermSpecification")
103    @WebResult(name = "termSpecification")
104    @CacheEvict(value = {TermSpecificationDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
105    TermSpecificationDefinition createTermSpecification(@WebParam(name = "termSpec") TermSpecificationDefinition termSpec)
106            throws RiceIllegalArgumentException;
107
108    /**
109     * Updates a {@link TermSpecificationDefinition}
110     *
111     * @since 2.2.1
112     * @param termSpec the term specification to be updated
113     *
114     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException
115     * termSpec is null or invalid
116     */
117    @WebMethod(operationName = "updateTermSpecification")
118    @CacheEvict(value = {TermSpecificationDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
119    void updateTermSpecification(@WebParam(name = "termSpec") TermSpecificationDefinition termSpec)
120            throws RiceIllegalArgumentException;
121
122    /**
123     * Deletes a {@link TermSpecificationDefinition}
124     *
125     * @since 2.2.1
126     * @param id the id of the term specification to be deleted
127     *
128     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException
129     * id is null or invalid
130     */
131    @WebMethod(operationName = "deleteTermSpecification")
132    @CacheEvict(value = {TermSpecificationDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
133    void deleteTermSpecification(@WebParam(name = "id") String id)
134            throws RiceIllegalArgumentException;
135
136
137    /**
138     * Create a {@link TermDefinition}
139     *
140     * @since 2.2.1
141     * @param termDef to be created
142     * @return the {@link TermDefinition} term definition after it has been
143     * created in the repository.
144     *
145     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
146     * the termDef is null or blank.
147     */
148    @WebMethod(operationName = "createTerm")
149    @WebResult(name = "term")
150    @CacheEvict(value = {TermDefinition.Cache.NAME}, allEntries = true)
151    TermDefinition createTerm(@WebParam(name = "termDef") TermDefinition termDef)
152            throws RiceIllegalArgumentException;
153
154    /**
155     * Update a {@link TermDefinition}
156     *
157     * @since 2.2.1
158     * @param termDef to be updated
159     *
160     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
161     * the termDef is null or blank.
162     */
163    @WebMethod(operationName = "updateTerm")
164    @WebResult(name = "term")
165    @CacheEvict(value = {TermDefinition.Cache.NAME}, allEntries = true)
166    void updateTerm(@WebParam(name = "termDef") TermDefinition termDef)
167            throws RiceIllegalArgumentException;
168
169
170    /**
171     * Delete a {@link TermDefinition}
172     *
173     * @since 2.2.1
174     * @param id of the termDefinition to be deleted
175     *
176     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
177     * the id is null or blank.
178     */
179    @WebMethod(operationName = "deleteTerm")
180    @WebResult(name = "term")
181    @CacheEvict(value = {TermDefinition.Cache.NAME}, allEntries = true)
182    void deleteTerm(@WebParam(name = "id") String id)
183            throws RiceIllegalArgumentException;
184
185
186    /**
187     * Retrieves the {@link TermResolverDefinition} with the given id.
188     *
189     * @since 2.2.1
190     * @param id the identifier of the term to retrieve.
191     * @return the {@link TermResolverDefinition} with the given id. May be null
192     * if there is no term with the given id in the repository.
193     *
194     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
195     * the id is null or blank.
196     */
197    @WebMethod(operationName = "getTermResolverById")
198    @WebResult(name = "termResolver")
199    @Cacheable(value = TermResolverDefinition.Cache.NAME, key = "'id=' + #p0")
200    TermResolverDefinition getTermResolverById(@WebParam(name = "id") String id)
201            throws RiceIllegalArgumentException;
202
203    /**
204     * Get the {@link TermResolverDefinition}s for any term resolvers in the
205     * specified namespace that have the given term specification as their
206     * output.
207     *
208     * @param id the id for the term specification
209     * @param namespace the namespace to search
210     * @return the List of term resolvers found. If none are found, an empty
211     * list will be returned.
212     */
213    @WebMethod(operationName = "findTermResolversByOutputId")
214    @XmlElementWrapper(name = "termResolvers", required = true)
215    @XmlElement(name = "termResolver", required = false)
216    @WebResult(name = "termResolvers")
217    @Cacheable(value = TermResolverDefinition.Cache.NAME, key = "'id=' + #p0 + '|' + 'namespace=' + #p1")
218    List<TermResolverDefinition> findTermResolversByOutputId(@WebParam(name = "id") String id,
219            @WebParam(name = "namespace") String namespace)
220            throws RiceIllegalArgumentException;
221
222    /**
223     * Creates the {@link TermResolverDefinition}.
224     *
225     * @since 2.1.1
226     * @param termResolver to be created
227     * @return the {@link TermResolver} after it has been created in the
228     * repository.
229     *
230     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
231     * the termResolver is null or blank.
232     */
233    @WebMethod(operationName = "createTermResolver")
234    @WebResult(name = "termResolver")
235    @CacheEvict(value = {TermResolverDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
236    TermResolverDefinition createTermResolver(@WebParam(name = "termResolver") TermResolverDefinition termResolver)
237            throws RiceIllegalArgumentException;
238
239
240    /**
241     * Updates the {@link TermResolverDefinition}.
242     *
243     * @since 2.1.1
244     * @param termResolver to be created
245     * @return the {@link TermResolverDefinition} after it has been created in the
246     * repository.
247     *
248     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
249     * the termResolver is null or blank.
250     */
251    @WebMethod(operationName = "updateTermResolver")
252    @CacheEvict(value = {TermResolverDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
253    void updateTermResolver(@WebParam(name = "termResolver") TermResolverDefinition termResolver)
254            throws RiceIllegalArgumentException;
255
256
257    /**
258     * deletes the {@link TermResolverDefinition} with the given id
259     *
260     * @since 2.1.1
261     * @param id of the term resolver to be deleted
262     *
263     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if
264     * the termResolver is null or blank.
265     */
266    @WebMethod(operationName = "deleteTermResolver")
267    @CacheEvict(value = {TermResolverDefinition.Cache.NAME, TermDefinition.Cache.NAME}, allEntries = true)
268    void deleteTermResolver(@WebParam(name = "id") String id)
269            throws RiceIllegalArgumentException;
270
271
272    /**
273     * Retrieves the {@link TermResolverDefinition} for the given name and namespace
274     *
275     * @param name the name for which to get term resolver
276     * @param namespace the namespace for which to get term resolver
277     * @return the {@link TermResolverDefinition} for the given name and namespace, null if none exist.
278     *
279     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the name or namespace is null or blank.
280     */
281    @WebMethod(operationName = "getTermResolverByNameAndNamespace")
282    @WebResult(name = "termResolver")
283    // TODO: set the cache right
284    //    @Cacheable(value = TermResolverDefinition.Cache.NAME, key = "'namespace=' + #p0")
285    TermResolverDefinition getTermResolverByNameAndNamespace(@WebParam(name = "name") String name,
286            @WebParam(name = "namespace") String namespace) throws RiceIllegalArgumentException;
287
288
289    /**
290     * Retrieves the {@link TermSpecificationDefinition} for the given name and namespace
291     *
292     * @param name the name for which to get term specification
293     * @param namespace the namespace for which to get term resolver
294     * @return the {@link TermSpecificationDefinition} for the given name and namespace, null if none exist.
295     *
296     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the name or namespace is null or blank.
297     */
298    @WebMethod(operationName = "getTermSpecificationByNameAndNamespace")
299    @WebResult(name = "termSpecification")
300    // TODO: set the cache right
301    //    @Cacheable(value = TermSpecificationDefinition.Cache.NAME, key = "'namespace=' + #p0")
302    TermSpecificationDefinition getTermSpecificationByNameAndNamespace(@WebParam(name = "name") String name,
303            @WebParam(name = "namespace") String namespace) throws RiceIllegalArgumentException;
304
305
306    /**
307     * Retrieves all the {@link TermSpecificationDefinition}s that are valid for the context with the given contextId.
308     *
309     * @since 2.1.4
310     * @param contextId the identifier for the context whose valid {@link TermSpecificationDefinition}s are to be retrieved. 
311     * @return all the {@link TermSpecificationDefinition}s that are valid for the context with the given contextId. May be empty but never null
312     *
313     * @throws org.kuali.rice.core.api.exception.RiceIllegalArgumentException if the contextId is null or blank.
314     */
315    @WebMethod(operationName = "findAllTermSpecificationsByContextId")
316    @XmlElementWrapper(name = "termSpecifications", required = true)
317    @XmlElement(name = "termSpecification", required = false)
318    @WebResult(name = "termSpecifications")
319    @Cacheable(value= TermSpecificationDefinition.Cache.NAME, key="'id=' + #p0")
320    List<TermSpecificationDefinition> findAllTermSpecificationsByContextId(@WebParam(name = "contextId") String contextId) throws RiceIllegalArgumentException;;
321
322}