001 /**
002 * Copyright 2005-2014 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 */
016 package org.kuali.rice.krms.impl.repository;
017
018 import java.util.List;
019 import java.util.Set;
020
021 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
022 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
023 import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
024 import org.kuali.rice.krms.api.repository.agenda.AgendaTreeDefinition;
025 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
026 import org.springframework.cache.annotation.CacheEvict;
027 import org.springframework.cache.annotation.Cacheable;
028
029 /**
030 * This is the interface for accessing KRMS repository Agenda related
031 * business objects.
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 *
035 */
036 public interface AgendaBoService {
037
038 /**
039 * This will create a {@link AgendaDefinition} exactly like the parameter passed in.
040 *
041 * @param agenda The Agenda to create
042 * @throws IllegalArgumentException if the Agenda is null
043 * @throws IllegalStateException if the Agenda already exists in the system
044 */
045 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
046 public AgendaDefinition createAgenda(AgendaDefinition agenda);
047
048 /**
049 * This will update an existing {@link AgendaDefinition}.
050 *
051 * @param agenda The Agenda to update
052 * @throws IllegalArgumentException if the Agenda is null
053 * @throws IllegalStateException if the Agenda does not exists in the system
054 */
055 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
056 public void updateAgenda(AgendaDefinition agenda);
057
058 /**
059 * Delete the {@link AgendaDefinition} with the given id.
060 *
061 * @param agendaId to delete.
062 * @throws IllegalArgumentException if the Agenda is null.
063 * @throws IllegalStateException if the Agenda does not exists in the system
064 *
065 */
066 public void deleteAgenda(String agendaId);
067
068 /**
069 * Retrieves an Agenda from the repository based on the given agenda id.
070 *
071 * @param agendaId the id of the Agenda to retrieve
072 * @return an {@link AgendaDefinition} identified by the given agendaId.
073 * A null reference is returned if an invalid or non-existent id is supplied.
074 */
075 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'agendaId=' + #p0")
076 public AgendaDefinition getAgendaByAgendaId(String agendaId);
077
078 /**
079 * Retrieves an Agenda from the repository based on the provided agenda name
080 * and context id.
081 *
082 * @param name the name of the Agenda to retrieve.
083 * @param contextId the id of the context that the agenda belongs to.
084 * @return an {@link AgendaDefinition} identified by the given name and namespace.
085 * A null reference is returned if an invalid or non-existent name and
086 * namespace combination is supplied.
087 */
088 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'name=' + #p0 + '|' + 'contextId=' + #p1")
089 public AgendaDefinition getAgendaByNameAndContextId(String name, String contextId);
090
091 /**
092 * Retrieves a set of Agendas associated with a context.
093 *
094 * @param contextId the id of the context
095 * @return a set of {@link AgendaDefinition} associated with the given context.
096 * A null reference is returned if an invalid or contextId is supplied.
097 */
098 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'contextId=' + #p0")
099 public List<AgendaDefinition> getAgendasByContextId(String contextId);
100
101 /**
102 * This will create an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} in the repository exactly like
103 * the parameter passed in.
104 *
105 * @param agendaItem The AgendaItemDefinition to create
106 * @throws IllegalArgumentException if the AgendaItemDefinition is null
107 * @throws IllegalStateException if the AgendaItemDefinition already exists in the system
108 */
109 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
110 public AgendaItemDefinition createAgendaItem(AgendaItemDefinition agendaItem);
111
112 /**
113 * This will update an existing {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition}.
114 *
115 * @param agendaItem The AgendaItemDefinition to update
116 * @throws IllegalArgumentException if the AgendaItemDefinition is null
117 * @throws IllegalStateException if the AgendaItemDefinition does not exists in the system
118 */
119 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
120 public void updateAgendaItem(AgendaItemDefinition agendaItem);
121
122 /**
123 * This will create an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} in the repository exactly like
124 * the parameter passed in. The AgendaItemDefinition will be linked to an existing
125 * AgendaItemDefinition in the relationship provided. Linking the AgendaItems effectively
126 * builds a tree of AgendaItems that may be traversed by the engine.
127 *
128 * @param agendaItem The AgendaItemDefinition to create
129 * @param parentId The id of the existing AgendaItemDefinition to be linked with the
130 * newly created AgendaItemDefinition
131 * @param position A boolean used to specify the relationship between the
132 * linked AgendaItems.
133 * <p> If the position parameter is true, the new AgendaItemDefinition is linked as the next
134 * AgendaItemDefinition to be evaluated if the parent AgendaItemDefinition evaluates to TRUE.
135 * <p> If the position parameter is false, the new AgendaItemDefinition is linked as the next
136 * AgendaItemDefinition to be evaluated if the parent AgendaItemDefinition evaluates to FALSE.
137 * <p> If the position parameter is null, the new AgendaItemDefinition is linked as the next
138 * AgendaItemDefinition to be evaluated after any true or false branches of the tree have
139 * been traversed.
140 * @throws IllegalArgumentException if the AgendaItemDefinition is null
141 * @throws IllegalStateException if the parent AgendaItemDefinition does not already exists in the system
142 */
143 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
144 public void addAgendaItem(AgendaItemDefinition agendaItem, String parentId, Boolean position);
145
146 /**
147 * Retrieves an AgendaItemDefinition from the repository based on the given agenda id.
148 *
149 * @param id the id of the AgendaItemDefinition to retrieve
150 * @return an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} identified by the given id.
151 * A null reference is returned if an invalid or non-existent id is supplied.
152 */
153 @Cacheable(value= AgendaItemDefinition.Cache.NAME, key="'id=' + #p0")
154 public AgendaItemDefinition getAgendaItemById(String id);
155
156 // TODO: caching annotations
157 public List<AgendaItemDefinition> getAgendaItemsByAgendaId(String id);
158
159 // TODO: caching annotations
160 public List<AgendaDefinition> getAgendasByType(String typeId) throws RiceIllegalArgumentException;
161
162 // TODO: caching annotations
163 public List<AgendaDefinition> getAgendasByTypeAndContext(String typeId, String contextId)
164 throws RiceIllegalArgumentException;
165
166 // TODO: caching annotations
167 public List<AgendaItemDefinition> getAgendaItemsByType(String typeId) throws RiceIllegalArgumentException;
168
169 // TODO: caching annotations
170 public List<AgendaItemDefinition> getAgendaItemsByContext(String contextId) throws RiceIllegalArgumentException;
171
172 // TODO: caching annotations
173 public List<AgendaItemDefinition> getAgendaItemsByTypeAndContext(String typeId, String contextId)
174 throws RiceIllegalArgumentException;
175
176 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
177 public void deleteAgendaItem(String id) throws RiceIllegalArgumentException;
178
179 /**
180 * Converts a mutable bo to it's immutable counterpart
181 * @param bo the mutable business object
182 * @return the immutable object
183 */
184 public AgendaDefinition to(AgendaBo bo);
185
186 /**
187 * Converts a immutable object to it's mutable bo counterpart
188 * @param im immutable object
189 * @return the mutable bo
190 */
191 public AgendaBo from(AgendaDefinition im);
192 }