1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krms.impl.repository;
17
18 import java.util.List;
19 import java.util.Set;
20
21 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
22 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
23 import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
24 import org.kuali.rice.krms.api.repository.agenda.AgendaTreeDefinition;
25 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
26 import org.springframework.cache.annotation.CacheEvict;
27 import org.springframework.cache.annotation.Cacheable;
28
29 /**
30 * This is the interface for accessing KRMS repository Agenda related
31 * business objects.
32 *
33 * @author Kuali Rice Team (rice.collab@kuali.org)
34 *
35 */
36 public interface AgendaBoService {
37
38 /**
39 * This will create a {@link AgendaDefinition} exactly like the parameter passed in.
40 *
41 * @param agenda The Agenda to create
42 * @throws IllegalArgumentException if the Agenda is null
43 * @throws IllegalStateException if the Agenda already exists in the system
44 */
45 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
46 public AgendaDefinition createAgenda(AgendaDefinition agenda);
47
48 /**
49 * This will update an existing {@link AgendaDefinition}.
50 *
51 * @param agenda The Agenda to update
52 * @throws IllegalArgumentException if the Agenda is null
53 * @throws IllegalStateException if the Agenda does not exists in the system
54 */
55 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
56 public void updateAgenda(AgendaDefinition agenda);
57
58 /**
59 * Delete the {@link AgendaDefinition} with the given id.
60 *
61 * @param agendaId to delete.
62 * @throws IllegalArgumentException if the Agenda is null.
63 * @throws IllegalStateException if the Agenda does not exists in the system
64 *
65 */
66 public void deleteAgenda(String agendaId);
67
68 /**
69 * Retrieves an Agenda from the repository based on the given agenda id.
70 *
71 * @param agendaId the id of the Agenda to retrieve
72 * @return an {@link AgendaDefinition} identified by the given agendaId.
73 * A null reference is returned if an invalid or non-existent id is supplied.
74 */
75 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'agendaId=' + #p0")
76 public AgendaDefinition getAgendaByAgendaId(String agendaId);
77
78 /**
79 * Retrieves an Agenda from the repository based on the provided agenda name
80 * and context id.
81 *
82 * @param name the name of the Agenda to retrieve.
83 * @param contextId the id of the context that the agenda belongs to.
84 * @return an {@link AgendaDefinition} identified by the given name and namespace.
85 * A null reference is returned if an invalid or non-existent name and
86 * namespace combination is supplied.
87 */
88 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'name=' + #p0 + '|' + 'contextId=' + #p1")
89 public AgendaDefinition getAgendaByNameAndContextId(String name, String contextId);
90
91 /**
92 * Retrieves a set of Agendas associated with a context.
93 *
94 * @param contextId the id of the context
95 * @return a set of {@link AgendaDefinition} associated with the given context.
96 * A null reference is returned if an invalid or contextId is supplied.
97 */
98 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'contextId=' + #p0")
99 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 }