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