1 /**
2 * Copyright 2005-2015 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, AgendaItemDefinition.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, AgendaItemDefinition.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 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
67 public void deleteAgenda(String agendaId);
68
69 /**
70 * Retrieves an Agenda from the repository based on the given agenda id.
71 *
72 * @param agendaId the id of the Agenda to retrieve
73 * @return an {@link AgendaDefinition} identified by the given agendaId.
74 * A null reference is returned if an invalid or non-existent id is supplied.
75 */
76 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'agendaId=' + #p0")
77 public AgendaDefinition getAgendaByAgendaId(String agendaId);
78
79 /**
80 * Retrieves an Agenda from the repository based on the provided agenda name
81 * and context id.
82 *
83 * @param name the name of the Agenda to retrieve.
84 * @param contextId the id of the context that the agenda belongs to.
85 * @return an {@link AgendaDefinition} identified by the given name and namespace.
86 * A null reference is returned if an invalid or non-existent name and
87 * namespace combination is supplied.
88 */
89 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'name=' + #p0 + '|' + 'contextId=' + #p1")
90 public AgendaDefinition getAgendaByNameAndContextId(String name, String contextId);
91
92 /**
93 * Retrieves a set of Agendas associated with a context.
94 *
95 * @param contextId the id of the context
96 * @return a set of {@link AgendaDefinition} associated with the given context.
97 * A null reference is returned if an invalid or contextId is supplied.
98 */
99 @Cacheable(value= AgendaDefinition.Cache.NAME, key="'contextId=' + #p0")
100 public List<AgendaDefinition> getAgendasByContextId(String contextId);
101
102 /**
103 * This will create an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} in the repository exactly like
104 * the parameter passed in.
105 *
106 * @param agendaItem The AgendaItemDefinition to create
107 * @throws IllegalArgumentException if the AgendaItemDefinition is null
108 * @throws IllegalStateException if the AgendaItemDefinition already exists in the system
109 */
110 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
111 public AgendaItemDefinition createAgendaItem(AgendaItemDefinition agendaItem);
112
113 /**
114 * This will update an existing {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition}.
115 *
116 * @param agendaItem The AgendaItemDefinition to update
117 * @throws IllegalArgumentException if the AgendaItemDefinition is null
118 * @throws IllegalStateException if the AgendaItemDefinition does not exists in the system
119 */
120 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
121 public void updateAgendaItem(AgendaItemDefinition agendaItem);
122
123 /**
124 * This will create an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} in the repository exactly like
125 * the parameter passed in. The AgendaItemDefinition will be linked to an existing
126 * AgendaItemDefinition in the relationship provided. Linking the AgendaItems effectively
127 * builds a tree of AgendaItems that may be traversed by the engine.
128 *
129 * @param agendaItem The AgendaItemDefinition to create
130 * @param parentId The id of the existing AgendaItemDefinition to be linked with the
131 * newly created AgendaItemDefinition
132 * @param position A boolean used to specify the relationship between the
133 * linked AgendaItems.
134 * <p> If the position parameter is true, the new AgendaItemDefinition is linked as the next
135 * AgendaItemDefinition to be evaluated if the parent AgendaItemDefinition evaluates to TRUE.
136 * <p> If the position parameter is false, the new AgendaItemDefinition is linked as the next
137 * AgendaItemDefinition to be evaluated if the parent AgendaItemDefinition evaluates to FALSE.
138 * <p> If the position parameter is null, the new AgendaItemDefinition is linked as the next
139 * AgendaItemDefinition to be evaluated after any true or false branches of the tree have
140 * been traversed.
141 * @throws IllegalArgumentException if the AgendaItemDefinition is null
142 * @throws IllegalStateException if the parent AgendaItemDefinition does not already exists in the system
143 */
144 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
145 public void addAgendaItem(AgendaItemDefinition agendaItem, String parentId, Boolean position);
146
147 /**
148 * Retrieves an AgendaItemDefinition from the repository based on the given agenda id.
149 *
150 * @param id the id of the AgendaItemDefinition to retrieve
151 * @return an {@link org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition} identified by the given id.
152 * A null reference is returned if an invalid or non-existent id is supplied.
153 */
154 @Cacheable(value= AgendaItemDefinition.Cache.NAME, key="'id=' + #p0")
155 public AgendaItemDefinition getAgendaItemById(String id);
156
157 // TODO: caching annotations
158 public List<AgendaItemDefinition> getAgendaItemsByAgendaId(String id);
159
160 // TODO: caching annotations
161 public List<AgendaDefinition> getAgendasByType(String typeId) throws RiceIllegalArgumentException;
162
163 // TODO: caching annotations
164 public List<AgendaDefinition> getAgendasByTypeAndContext(String typeId, String contextId)
165 throws RiceIllegalArgumentException;
166
167 // TODO: caching annotations
168 public List<AgendaItemDefinition> getAgendaItemsByType(String typeId) throws RiceIllegalArgumentException;
169
170 // TODO: caching annotations
171 public List<AgendaItemDefinition> getAgendaItemsByContext(String contextId) throws RiceIllegalArgumentException;
172
173 // TODO: caching annotations
174 public List<AgendaItemDefinition> getAgendaItemsByTypeAndContext(String typeId, String contextId)
175 throws RiceIllegalArgumentException;
176
177 @CacheEvict(value={AgendaTreeDefinition.Cache.NAME, AgendaDefinition.Cache.NAME, AgendaItemDefinition.Cache.NAME, ContextDefinition.Cache.NAME}, allEntries = true)
178 public void deleteAgendaItem(String id) throws RiceIllegalArgumentException;
179
180 /**
181 * Converts a mutable bo to it's immutable counterpart
182 * @param bo the mutable business object
183 * @return the immutable object
184 */
185 public AgendaDefinition to(AgendaBo bo);
186
187 /**
188 * Converts a immutable object to it's mutable bo counterpart
189 * @param im immutable object
190 * @return the mutable bo
191 */
192 public AgendaBo from(AgendaDefinition im);
193 }