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.impl.repository;
017
018import org.kuali.rice.krms.api.repository.action.ActionDefinition;
019import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
020import org.kuali.rice.krms.api.repository.proposition.PropositionDefinition;
021import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
022import org.springframework.cache.annotation.CacheEvict;
023import org.springframework.cache.annotation.Cacheable;
024
025/**
026 * This is the interface for accessing KRMS repository Rule related bos 
027 * 
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 *
030 */
031public interface RuleBoService {
032    /**
033     * This will create a {@link RuleDefinition} exactly like the parameter passed in.
034     *
035     * @param rule  The Rule to create
036     * @throws IllegalArgumentException if the rule is null
037     * @throws IllegalStateException if the rule already exists in the system
038     */
039    @CacheEvict(value={RuleDefinition.Cache.NAME, PropositionDefinition.Cache.NAME, ActionDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME}, allEntries = true)
040        public RuleDefinition createRule(RuleDefinition rule);
041
042    /**
043     * This will update an existing {@link RuleDefinition}.
044     *
045     * @param rule  The Rule to update
046     * @throws IllegalArgumentException if the Rule is null
047     * @throws IllegalStateException if the Rule does not exists in the system
048     */
049    @CacheEvict(value={RuleDefinition.Cache.NAME, PropositionDefinition.Cache.NAME, ActionDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME}, allEntries = true)
050        public void updateRule(RuleDefinition rule);
051
052    /**
053     * Delete the {@link RuleDefinition} with the given id.
054     *
055     * @param ruleId to delete.
056     * @throws IllegalArgumentException if the Rule is null.
057     * @throws IllegalStateException if the Rule does not exists in the system
058     *
059     */
060    public void deleteRule(String ruleId);
061
062    /**
063     * Retrieves an Rule from the repository based on the given rule id.
064     *
065     * @param ruleId the id of the Rule to retrieve
066     * @return an {@link RuleDefinition} identified by the given actionId.
067     * A null reference is returned if an invalid or non-existent id is supplied.
068     * @throws IllegalArgumentException if the ruleId is null or blank.
069     */
070    @Cacheable(value= RuleDefinition.Cache.NAME, key="'ruleId=' + #p0")
071        public RuleDefinition getRuleByRuleId(String ruleId);
072
073    /**
074     * Retrieves an Rule from the repository based on the provided rule name
075     * and namespace.
076     *
077     * @param name the name of the Rule to retrieve.
078     * @param namespace the namespace that the rule is under.
079     * @return an {@link RuleDefinition} identified by the given name and namespace.
080     * A null reference is returned if an invalid or non-existent name and
081     * namespace combination is supplied.
082     * @throws IllegalArgumentException if the either the name or the namespace
083     * is null or blank.
084     */
085    @Cacheable(value= RuleDefinition.Cache.NAME, key="'name=' + #p0 + '|' + 'namespace=' + #p1")
086        public RuleDefinition getRuleByNameAndNamespace(String name, String namespace);
087        
088//      public void createRuleAttribute(RuleAttribute ruleAttribute);
089//      public void updateRuleAttribute(RuleAttribute ruleAttribute);
090//      
091//      public RuleAttribute getRuleAttributeById(String attrId);
092
093//      public void setBusinessObjectService(final BusinessObjectService businessObjectService);
094//      public List<RuleDefinition> convertListOfBosToImmutables(final Collection<RuleBo> ruleBos);
095}