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 java.util.List;
019
020import org.kuali.rice.krms.api.repository.action.ActionDefinition;
021import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
022import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
023import org.springframework.cache.annotation.CacheEvict;
024import org.springframework.cache.annotation.Cacheable;
025
026/**
027 * This is the interface for accessing KRMS repository Action related
028 * business objects. 
029 * 
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 *
032 */
033public interface ActionBoService {
034
035    /**
036     * This will create a {@link ActionDefinition} exactly like the parameter passed in.
037     *
038     * @param action  The Action to create
039     * @throws IllegalArgumentException if the action is null
040     * @throws IllegalStateException if the action already exists in the system
041     */
042    @CacheEvict(value={ActionDefinition.Cache.NAME, RuleDefinition.Cache.NAME}, allEntries = true)
043        public ActionDefinition createAction(ActionDefinition action);
044        
045    /**
046     * This will update an existing {@link ActionDefinition}.
047     *
048     * @param action  The Action to update
049     * @throws IllegalArgumentException if the Action is null
050     * @throws IllegalStateException if the Action does not exists in the system
051     */
052    @CacheEvict(value={ActionDefinition.Cache.NAME, RuleDefinition.Cache.NAME}, allEntries = true)
053        public void updateAction(ActionDefinition action);
054        
055    /**
056     * Retrieves an Action from the repository based on the given action id.
057     *
058     * @param actionId the id of the Action to retrieve
059     * @return an {@link ActionDefinition} identified by the given actionId.  
060     * A null reference is returned if an invalid or non-existent id is supplied.
061     * @throws IllegalArgumentException if the actionId is null or blank.
062     */
063    @Cacheable(value= ActionDefinition.Cache.NAME, key="'actionId=' + #p0")
064        public ActionDefinition getActionByActionId(String actionId);
065        
066    /**
067     * Retrieves an Action from the repository based on the provided action name
068     * and namespace.
069     *
070     * @param name the name of the Action to retrieve.
071     * @param namespace the namespace that the action is under.
072     * @return an {@link ActionDefinition} identified by the given name and namespace.  
073     * A null reference is returned if an invalid or non-existent name and
074     * namespace combination is supplied.
075     * @throws IllegalArgumentException if the either the name or the namespace
076     * is null or blank.
077     */
078    @Cacheable(value= ActionDefinition.Cache.NAME, key="'name=' + #p0 + '|' + 'namespace=' + #p1")
079        public ActionDefinition getActionByNameAndNamespace(String name, String namespace);
080
081    /**
082     * Retrieves an ordered List of Actions associated with a
083     * {@link org.kuali.rice.krms.api.repository.rule.RuleDefinition}.
084     * The order of the list is determined by the sequenceNumber property
085     * of the Actions.
086     *
087     * @param ruleId the id of the rule
088     * @return a list of {@link ActionDefinition} associated with the given rule.  
089     * A null reference is returned if an invalid or ruleId is supplied.
090     * @throws IllegalArgumentException if the ruleId is null or blank.
091     */
092    @Cacheable(value= ActionDefinition.Cache.NAME, key="'ruleId=' + #p0")
093        public List<ActionDefinition> getActionsByRuleId(String ruleId);
094
095    /**
096     * Retrieves an specific Action associated with a Rule.
097     *
098     * @param ruleId the id of the rule
099     * @param sequenceNumber an Integer that represents the sequence number of the action.
100     * @return an {@link ActionDefinition} identified associated with the 
101     * Rule and identified by the given sequenceNumber
102     * A null reference is returned if an invalid or non-existent name and
103     * namespace combination is supplied.
104     * @throws IllegalArgumentException if the ruleId is null or blank. Or 
105     * if the sequenceNumber is null.
106     */
107    @Cacheable(value= ActionDefinition.Cache.NAME, key="'ruleId=' + #p0 + '|' + 'sequenceNumber=' + #p1")
108        public ActionDefinition getActionByRuleIdAndSequenceNumber(String ruleId, Integer sequenceNumber);
109        
110//      public ActionAttribute createActionAttribute(ActionAttribute actionAttribute);
111//      public void updateActionAttribute(ActionAttribute actionAttribute);
112        
113}