1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.lum.lu.service.impl; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collections; |
20 | |
import java.util.Comparator; |
21 | |
import java.util.Date; |
22 | |
import java.util.HashMap; |
23 | |
import java.util.HashSet; |
24 | |
import java.util.Iterator; |
25 | |
import java.util.List; |
26 | |
import java.util.Map; |
27 | |
import java.util.Map.Entry; |
28 | |
import java.util.Set; |
29 | |
|
30 | |
import javax.jws.WebService; |
31 | |
import javax.persistence.NoResultException; |
32 | |
|
33 | |
import org.apache.log4j.Logger; |
34 | |
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
35 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
36 | |
import org.kuali.student.common.dto.CurrencyAmountInfo; |
37 | |
import org.kuali.student.common.dto.DtoConstants; |
38 | |
import org.kuali.student.common.dto.StatusInfo; |
39 | |
import org.kuali.student.common.entity.Amount; |
40 | |
import org.kuali.student.common.entity.TimeAmount; |
41 | |
import org.kuali.student.common.entity.Version; |
42 | |
import org.kuali.student.common.entity.VersionEntity; |
43 | |
import org.kuali.student.common.exceptions.AlreadyExistsException; |
44 | |
import org.kuali.student.common.exceptions.CircularRelationshipException; |
45 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
46 | |
import org.kuali.student.common.exceptions.DependentObjectsExistException; |
47 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
48 | |
import org.kuali.student.common.exceptions.IllegalVersionSequencingException; |
49 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
50 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
51 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
52 | |
import org.kuali.student.common.exceptions.PermissionDeniedException; |
53 | |
import org.kuali.student.common.exceptions.UnsupportedActionException; |
54 | |
import org.kuali.student.common.exceptions.VersionMismatchException; |
55 | |
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
56 | |
import org.kuali.student.common.search.dto.SearchParam; |
57 | |
import org.kuali.student.common.search.dto.SearchRequest; |
58 | |
import org.kuali.student.common.search.dto.SearchResult; |
59 | |
import org.kuali.student.common.search.dto.SearchResultCell; |
60 | |
import org.kuali.student.common.search.dto.SearchResultRow; |
61 | |
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
62 | |
import org.kuali.student.common.search.dto.SearchTypeInfo; |
63 | |
import org.kuali.student.common.search.service.SearchDispatcher; |
64 | |
import org.kuali.student.common.search.service.SearchManager; |
65 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
66 | |
import org.kuali.student.common.validator.Validator; |
67 | |
import org.kuali.student.common.validator.ValidatorFactory; |
68 | |
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
69 | |
import org.kuali.student.lum.lu.dao.LuDao; |
70 | |
import org.kuali.student.lum.lu.dto.AccreditationInfo; |
71 | |
import org.kuali.student.lum.lu.dto.AdminOrgInfo; |
72 | |
import org.kuali.student.lum.lu.dto.AffiliatedOrgInfo; |
73 | |
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
74 | |
import org.kuali.student.lum.lu.dto.CluFeeRecordInfo; |
75 | |
import org.kuali.student.lum.lu.dto.CluIdentifierInfo; |
76 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
77 | |
import org.kuali.student.lum.lu.dto.CluInstructorInfo; |
78 | |
import org.kuali.student.lum.lu.dto.CluLoRelationInfo; |
79 | |
import org.kuali.student.lum.lu.dto.CluLoRelationTypeInfo; |
80 | |
import org.kuali.student.lum.lu.dto.CluPublicationInfo; |
81 | |
import org.kuali.student.lum.lu.dto.CluResultInfo; |
82 | |
import org.kuali.student.lum.lu.dto.CluResultTypeInfo; |
83 | |
import org.kuali.student.lum.lu.dto.CluSetInfo; |
84 | |
import org.kuali.student.lum.lu.dto.CluSetTreeViewInfo; |
85 | |
import org.kuali.student.lum.lu.dto.CluSetTypeInfo; |
86 | |
import org.kuali.student.lum.lu.dto.DeliveryMethodTypeInfo; |
87 | |
import org.kuali.student.lum.lu.dto.FieldInfo; |
88 | |
import org.kuali.student.lum.lu.dto.InstructionalFormatTypeInfo; |
89 | |
import org.kuali.student.lum.lu.dto.LuCodeInfo; |
90 | |
import org.kuali.student.lum.lu.dto.LuCodeTypeInfo; |
91 | |
import org.kuali.student.lum.lu.dto.LuLuRelationTypeInfo; |
92 | |
import org.kuali.student.lum.lu.dto.LuPublicationTypeInfo; |
93 | |
import org.kuali.student.lum.lu.dto.LuTypeInfo; |
94 | |
import org.kuali.student.lum.lu.dto.LuiInfo; |
95 | |
import org.kuali.student.lum.lu.dto.LuiLuiRelationInfo; |
96 | |
import org.kuali.student.lum.lu.dto.MembershipQueryInfo; |
97 | |
import org.kuali.student.lum.lu.dto.ResultOptionInfo; |
98 | |
import org.kuali.student.lum.lu.dto.ResultUsageTypeInfo; |
99 | |
import org.kuali.student.lum.lu.entity.Clu; |
100 | |
import org.kuali.student.lum.lu.entity.CluAccounting; |
101 | |
import org.kuali.student.lum.lu.entity.CluAccountingAttribute; |
102 | |
import org.kuali.student.lum.lu.entity.CluAccreditation; |
103 | |
import org.kuali.student.lum.lu.entity.CluAccreditationAttribute; |
104 | |
import org.kuali.student.lum.lu.entity.CluAdminOrg; |
105 | |
import org.kuali.student.lum.lu.entity.CluAdminOrgAttribute; |
106 | |
import org.kuali.student.lum.lu.entity.CluAtpTypeKey; |
107 | |
import org.kuali.student.lum.lu.entity.CluAttribute; |
108 | |
import org.kuali.student.lum.lu.entity.CluCampusLocation; |
109 | |
import org.kuali.student.lum.lu.entity.CluCluRelation; |
110 | |
import org.kuali.student.lum.lu.entity.CluCluRelationAttribute; |
111 | |
import org.kuali.student.lum.lu.entity.CluFee; |
112 | |
import org.kuali.student.lum.lu.entity.CluIdentifier; |
113 | |
import org.kuali.student.lum.lu.entity.CluInstructor; |
114 | |
import org.kuali.student.lum.lu.entity.CluInstructorAttribute; |
115 | |
import org.kuali.student.lum.lu.entity.CluLoRelation; |
116 | |
import org.kuali.student.lum.lu.entity.CluLoRelationAttribute; |
117 | |
import org.kuali.student.lum.lu.entity.CluLoRelationType; |
118 | |
import org.kuali.student.lum.lu.entity.CluPublication; |
119 | |
import org.kuali.student.lum.lu.entity.CluPublicationAttribute; |
120 | |
import org.kuali.student.lum.lu.entity.CluPublicationType; |
121 | |
import org.kuali.student.lum.lu.entity.CluPublicationVariant; |
122 | |
import org.kuali.student.lum.lu.entity.CluResult; |
123 | |
import org.kuali.student.lum.lu.entity.CluResultType; |
124 | |
import org.kuali.student.lum.lu.entity.CluSet; |
125 | |
import org.kuali.student.lum.lu.entity.CluSetAttribute; |
126 | |
import org.kuali.student.lum.lu.entity.CluSetJoinVersionIndClu; |
127 | |
import org.kuali.student.lum.lu.entity.CluSetType; |
128 | |
import org.kuali.student.lum.lu.entity.DeliveryMethodType; |
129 | |
import org.kuali.student.lum.lu.entity.InstructionalFormatType; |
130 | |
import org.kuali.student.lum.lu.entity.LuCode; |
131 | |
import org.kuali.student.lum.lu.entity.LuCodeAttribute; |
132 | |
import org.kuali.student.lum.lu.entity.LuCodeType; |
133 | |
import org.kuali.student.lum.lu.entity.LuLuRelationType; |
134 | |
import org.kuali.student.lum.lu.entity.LuPublicationType; |
135 | |
import org.kuali.student.lum.lu.entity.LuRichText; |
136 | |
import org.kuali.student.lum.lu.entity.LuType; |
137 | |
import org.kuali.student.lum.lu.entity.Lui; |
138 | |
import org.kuali.student.lum.lu.entity.LuiAttribute; |
139 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelation; |
140 | |
import org.kuali.student.lum.lu.entity.LuiLuiRelationAttribute; |
141 | |
import org.kuali.student.lum.lu.entity.MembershipQuery; |
142 | |
import org.kuali.student.lum.lu.entity.ResultOption; |
143 | |
import org.kuali.student.lum.lu.entity.ResultUsageType; |
144 | |
import org.kuali.student.lum.lu.service.LuService; |
145 | |
import org.kuali.student.lum.lu.service.LuServiceConstants; |
146 | |
import org.springframework.beans.BeanUtils; |
147 | |
import org.springframework.transaction.annotation.Transactional; |
148 | |
|
149 | |
@WebService(endpointInterface = "org.kuali.student.lum.lu.service.LuService", serviceName = "LuService", portName = "LuService", targetNamespace = "http://student.kuali.org/wsdl/lu") |
150 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
151 | 8 | public class LuServiceImpl implements LuService { |
152 | |
|
153 | |
private static final String SEARCH_KEY_DEPENDENCY_ANALYSIS = "lu.search.dependencyAnalysis"; |
154 | |
private static final String SEARCH_KEY_BROWSE_PROGRAM = "lu.search.browseProgram"; |
155 | |
private static final String SEARCH_KEY_BROWSE_VARIATIONS = "lu.search.browseVariations"; |
156 | |
private static final String SEARCH_KEY_LRC_RESULT_COMPONENT = "lrc.search.resultComponent"; |
157 | |
private static final String SEARCH_KEY_PROPOSALS_BY_COURSE_CODE = "lu.search.proposalsByCourseCode"; |
158 | |
private static final String SEARCH_KEY_BROWSE_VERSIONS = "lu.search.clu.versions"; |
159 | |
private static final String SEARCH_KEY_LU_RESULT_COMPONENTS = "lu.search.resultComponents"; |
160 | |
|
161 | 8 | final Logger logger = Logger.getLogger(LuServiceImpl.class); |
162 | |
|
163 | |
private LuDao luDao; |
164 | |
private SearchManager searchManager; |
165 | |
private SearchDispatcher searchDispatcher; |
166 | |
private DictionaryService dictionaryServiceDelegate; |
167 | |
private ValidatorFactory validatorFactory; |
168 | |
|
169 | |
public void setSearchManager(SearchManager searchManager) { |
170 | 4 | this.searchManager = searchManager; |
171 | 4 | } |
172 | |
|
173 | |
public void setDictionaryServiceDelegate( |
174 | |
DictionaryService dictionaryServiceDelegate) { |
175 | 3 | this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
176 | 3 | } |
177 | |
|
178 | |
public DictionaryService getDictionaryServiceDelegate() { |
179 | 0 | return dictionaryServiceDelegate; |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
@Override |
188 | |
public List<DeliveryMethodTypeInfo> getDeliveryMethodTypes() |
189 | |
throws OperationFailedException { |
190 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfos(luDao |
191 | |
.find(DeliveryMethodType.class)); |
192 | |
} |
193 | |
|
194 | |
@Override |
195 | |
public DeliveryMethodTypeInfo getDeliveryMethodType( |
196 | |
String deliveryMethodTypeKey) throws DoesNotExistException, |
197 | |
InvalidParameterException, MissingParameterException, |
198 | |
OperationFailedException { |
199 | |
|
200 | 0 | checkForMissingParameter(deliveryMethodTypeKey, "deliveryMethodTypeKey"); |
201 | |
|
202 | 0 | return LuServiceAssembler.toDeliveryMethodTypeInfo(luDao.fetch( |
203 | |
DeliveryMethodType.class, deliveryMethodTypeKey)); |
204 | |
} |
205 | |
|
206 | |
@Override |
207 | |
public List<InstructionalFormatTypeInfo> getInstructionalFormatTypes() |
208 | |
throws OperationFailedException { |
209 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfos(luDao |
210 | |
.find(InstructionalFormatType.class)); |
211 | |
} |
212 | |
|
213 | |
@Override |
214 | |
public InstructionalFormatTypeInfo getInstructionalFormatType( |
215 | |
String instructionalFormatTypeKey) throws DoesNotExistException, |
216 | |
InvalidParameterException, MissingParameterException, |
217 | |
OperationFailedException { |
218 | 0 | checkForMissingParameter(instructionalFormatTypeKey, |
219 | |
"instructionalFormatTypeKey"); |
220 | |
|
221 | 0 | return LuServiceAssembler.toInstructionalFormatTypeInfo(luDao.fetch( |
222 | |
InstructionalFormatType.class, instructionalFormatTypeKey)); |
223 | |
} |
224 | |
|
225 | |
@Override |
226 | |
public List<LuTypeInfo> getLuTypes() throws OperationFailedException { |
227 | 0 | return LuServiceAssembler.toLuTypeInfos(luDao.find(LuType.class)); |
228 | |
} |
229 | |
|
230 | |
@Override |
231 | |
public LuTypeInfo getLuType(String luTypeKey) throws DoesNotExistException, |
232 | |
InvalidParameterException, MissingParameterException, |
233 | |
OperationFailedException { |
234 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
235 | |
|
236 | 0 | return LuServiceAssembler.toLuTypeInfo(luDao.fetch(LuType.class, |
237 | |
luTypeKey)); |
238 | |
} |
239 | |
|
240 | |
@Override |
241 | |
public LuCodeTypeInfo getLuCodeType(String luCodeTypeKey) |
242 | |
throws DoesNotExistException, InvalidParameterException, |
243 | |
MissingParameterException, OperationFailedException { |
244 | 0 | checkForMissingParameter(luCodeTypeKey, "luCodeTypeKey"); |
245 | 0 | return LuServiceAssembler.toLuCodeTypeInfo(luDao.fetch( |
246 | |
LuCodeType.class, luCodeTypeKey)); |
247 | |
} |
248 | |
|
249 | |
@Override |
250 | |
public List<LuCodeTypeInfo> getLuCodeTypes() |
251 | |
throws OperationFailedException { |
252 | 0 | return LuServiceAssembler.toLuCodeTypeInfos(luDao |
253 | |
.find(LuCodeType.class)); |
254 | |
} |
255 | |
|
256 | |
@Override |
257 | |
public List<LuLuRelationTypeInfo> getLuLuRelationTypes() |
258 | |
throws OperationFailedException { |
259 | 1 | return LuServiceAssembler.toLuLuRelationTypeInfos(luDao |
260 | |
.find(LuLuRelationType.class)); |
261 | |
} |
262 | |
|
263 | |
@Override |
264 | |
public LuLuRelationTypeInfo getLuLuRelationType(String luLuRelationTypeKey) |
265 | |
throws OperationFailedException, MissingParameterException, |
266 | |
DoesNotExistException { |
267 | 4 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
268 | |
|
269 | 3 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
270 | |
luLuRelationTypeKey); |
271 | 2 | return LuServiceAssembler.toLuLuRelationTypeInfo(luLuRelationType); |
272 | |
} |
273 | |
|
274 | |
@Override |
275 | |
public List<String> getAllowedLuLuRelationTypesForLuType(String luTypeKey, |
276 | |
String relatedLuTypeKey) throws DoesNotExistException, |
277 | |
InvalidParameterException, MissingParameterException, |
278 | |
OperationFailedException { |
279 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
280 | 0 | checkForMissingParameter(relatedLuTypeKey, "relatedLuTypeKey"); |
281 | |
|
282 | 0 | return luDao.getAllowedLuLuRelationTypesForLuType(luTypeKey, |
283 | |
relatedLuTypeKey); |
284 | |
} |
285 | |
|
286 | |
@Override |
287 | |
public List<LuPublicationTypeInfo> getLuPublicationTypes() |
288 | |
throws OperationFailedException { |
289 | 0 | return LuServiceAssembler.toLuPublicationTypeInfos(luDao |
290 | |
.find(LuPublicationType.class)); |
291 | |
} |
292 | |
|
293 | |
@Override |
294 | |
public LuPublicationTypeInfo getLuPublicationType( |
295 | |
String luPublicationTypeKey) throws DoesNotExistException, |
296 | |
InvalidParameterException, MissingParameterException, |
297 | |
OperationFailedException { |
298 | 0 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
299 | |
|
300 | 0 | return LuServiceAssembler.toLuPublicationTypeInfo(luDao.fetch( |
301 | |
LuPublicationType.class, luPublicationTypeKey)); |
302 | |
} |
303 | |
|
304 | |
@Override |
305 | |
public List<String> getLuPublicationTypesForLuType(String luTypeKey) |
306 | |
throws DoesNotExistException, InvalidParameterException, |
307 | |
MissingParameterException, OperationFailedException { |
308 | 0 | throw new UnsupportedOperationException("getLuPublicationTypesForLuType"); |
309 | |
} |
310 | |
|
311 | |
@Override |
312 | |
public List<CluResultTypeInfo> getCluResultTypes() |
313 | |
throws OperationFailedException { |
314 | 0 | return LuServiceAssembler.toCluResultTypeInfos(luDao |
315 | |
.find(CluResultType.class)); |
316 | |
} |
317 | |
|
318 | |
@Override |
319 | |
public CluResultTypeInfo getCluResultType(String cluResultTypeKey) |
320 | |
throws DoesNotExistException, InvalidParameterException, |
321 | |
MissingParameterException, OperationFailedException { |
322 | 0 | return LuServiceAssembler.toCluResultTypeInfo(luDao.fetch( |
323 | |
CluResultType.class, cluResultTypeKey)); |
324 | |
} |
325 | |
|
326 | |
@Override |
327 | |
public List<CluResultTypeInfo> getCluResultTypesForLuType(String luTypeKey) |
328 | |
throws DoesNotExistException, InvalidParameterException, |
329 | |
MissingParameterException, OperationFailedException { |
330 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
331 | 0 | return LuServiceAssembler.toCluResultTypeInfos((luDao |
332 | |
.getAllowedCluResultTypesForLuType(luTypeKey))); |
333 | |
} |
334 | |
|
335 | |
@Override |
336 | |
public List<ResultUsageTypeInfo> getResultUsageTypes() |
337 | |
throws OperationFailedException { |
338 | 1 | return LuServiceAssembler.toResultUsageTypeInfos(luDao |
339 | |
.find(ResultUsageType.class)); |
340 | |
} |
341 | |
|
342 | |
@Override |
343 | |
public ResultUsageTypeInfo getResultUsageType(String resultUsageTypeKey) |
344 | |
throws DoesNotExistException, InvalidParameterException, |
345 | |
MissingParameterException, OperationFailedException { |
346 | 1 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
347 | 1 | return LuServiceAssembler.toResultUsageTypeInfo(luDao.fetch( |
348 | |
ResultUsageType.class, resultUsageTypeKey)); |
349 | |
} |
350 | |
|
351 | |
@Override |
352 | |
public List<String> getAllowedResultUsageTypesForLuType(String luTypeKey) |
353 | |
throws DoesNotExistException, InvalidParameterException, |
354 | |
MissingParameterException, OperationFailedException { |
355 | 0 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
356 | |
|
357 | 0 | return luDao.getAllowedResultUsageTypesForLuType(luTypeKey); |
358 | |
} |
359 | |
|
360 | |
@Override |
361 | |
public List<String> getAllowedResultComponentTypesForResultUsageType( |
362 | |
String resultUsageTypeKey) throws DoesNotExistException, |
363 | |
InvalidParameterException, MissingParameterException, |
364 | |
OperationFailedException { |
365 | |
|
366 | 0 | checkForMissingParameter(resultUsageTypeKey, "resultUsageTypeKey"); |
367 | |
|
368 | 0 | return luDao |
369 | |
.getAllowedResultComponentTypesForResultUsageType(resultUsageTypeKey); |
370 | |
} |
371 | |
|
372 | |
@Override |
373 | |
public CluLoRelationTypeInfo getCluLoRelationType( |
374 | |
String cluLoRelationTypeKey) throws DoesNotExistException, |
375 | |
InvalidParameterException, MissingParameterException, |
376 | |
OperationFailedException { |
377 | 0 | checkForMissingParameter(cluLoRelationTypeKey, "cluLoRelationTypeKey"); |
378 | |
|
379 | 0 | CluLoRelationType cluLoRelationType = luDao.fetch( |
380 | |
CluLoRelationType.class, cluLoRelationTypeKey); |
381 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfo(cluLoRelationType); |
382 | |
} |
383 | |
|
384 | |
@Override |
385 | |
public List<CluLoRelationTypeInfo> getCluLoRelationTypes() |
386 | |
throws OperationFailedException { |
387 | 0 | return LuServiceAssembler.toCluLoRelationTypeInfos(luDao |
388 | |
.find(CluLoRelationType.class)); |
389 | |
} |
390 | |
|
391 | |
@Override |
392 | |
public List<String> getAllowedCluLoRelationTypesForLuType(String luTypeKey) |
393 | |
throws DoesNotExistException, InvalidParameterException, |
394 | |
MissingParameterException, OperationFailedException { |
395 | |
|
396 | 0 | checkForMissingParameter(luTypeKey, luTypeKey); |
397 | |
|
398 | 0 | return luDao.getAllowedCluLoRelationTypesForLuType(luTypeKey); |
399 | |
} |
400 | |
|
401 | |
@Override |
402 | |
public List<CluSetTypeInfo> getCluSetTypes() |
403 | |
throws OperationFailedException { |
404 | 0 | return LuServiceAssembler.toCluSetTypeInfos(luDao |
405 | |
.find(CluSetType.class)); |
406 | |
} |
407 | |
|
408 | |
@Override |
409 | |
public CluSetTypeInfo getCluSetType(String cluSetTypeKey) |
410 | |
throws DoesNotExistException, InvalidParameterException, |
411 | |
MissingParameterException, OperationFailedException { |
412 | 0 | checkForMissingParameter(cluSetTypeKey, "cluSetTypeKey"); |
413 | 0 | return LuServiceAssembler.toCluSetTypeInfo(luDao.fetch( |
414 | |
CluSetType.class, cluSetTypeKey)); |
415 | |
} |
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
@Override |
423 | |
public CluInfo getClu(String cluId) throws DoesNotExistException, |
424 | |
InvalidParameterException, MissingParameterException, |
425 | |
OperationFailedException { |
426 | |
|
427 | 181 | checkForMissingParameter(cluId, "cluId"); |
428 | |
|
429 | 180 | Clu clu = luDao.fetch(Clu.class, cluId); |
430 | 175 | return LuServiceAssembler.toCluInfo(clu); |
431 | |
} |
432 | |
|
433 | |
@Override |
434 | |
public List<CluInfo> getClusByIdList(List<String> cluIdList) |
435 | |
throws DoesNotExistException, InvalidParameterException, |
436 | |
MissingParameterException, OperationFailedException { |
437 | 3 | checkForMissingParameter(cluIdList, "cluIdList"); |
438 | 2 | checkForEmptyList(cluIdList, "cluIdList"); |
439 | 2 | List<Clu> clus = luDao.getClusByIdList(cluIdList); |
440 | 2 | return LuServiceAssembler.toCluInfos(clus); |
441 | |
} |
442 | |
|
443 | |
@Override |
444 | |
public List<CluInfo> getClusByLuType(String luTypeKey, String luState) |
445 | |
throws DoesNotExistException, InvalidParameterException, |
446 | |
MissingParameterException, OperationFailedException { |
447 | 5 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
448 | 4 | checkForMissingParameter(luState, "lustate"); |
449 | 3 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
450 | 3 | return LuServiceAssembler.toCluInfos(clus); |
451 | |
} |
452 | |
|
453 | |
@Override |
454 | |
public List<String> getCluIdsByLuType(String luTypeKey, String luState) |
455 | |
throws DoesNotExistException, InvalidParameterException, |
456 | |
MissingParameterException, OperationFailedException { |
457 | 5 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
458 | 4 | checkForMissingParameter(luState, "luState"); |
459 | 3 | List<Clu> clus = luDao.getClusByLuType(luTypeKey, luState); |
460 | 3 | List<String> ids = new ArrayList<String>(clus.size()); |
461 | 3 | for (Clu clu : clus) { |
462 | 1 | ids.add(clu.getId()); |
463 | |
} |
464 | 3 | return ids; |
465 | |
} |
466 | |
|
467 | |
|
468 | |
|
469 | |
@Override |
470 | |
public List<String> getAllowedLuLuRelationTypesByCluId(String cluId, |
471 | |
String relatedCluId) throws DoesNotExistException, |
472 | |
InvalidParameterException, MissingParameterException, |
473 | |
OperationFailedException { |
474 | 0 | checkForMissingParameter(cluId, "cluId"); |
475 | 0 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
476 | |
|
477 | 0 | return luDao.getAllowedLuLuRelationTypesByCluId(cluId, relatedCluId); |
478 | |
} |
479 | |
|
480 | |
@Override |
481 | |
public List<CluInfo> getClusByRelation(String relatedCluId, |
482 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
483 | |
InvalidParameterException, MissingParameterException, |
484 | |
OperationFailedException { |
485 | 5 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
486 | 4 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
487 | |
|
488 | 3 | List<Clu> clus = luDao.getClusByRelation(relatedCluId, |
489 | |
luLuRelationTypeKey); |
490 | 3 | List<CluInfo> result = LuServiceAssembler.toCluInfos(clus); |
491 | 3 | return result; |
492 | |
|
493 | |
} |
494 | |
|
495 | |
@Override |
496 | |
public List<String> getCluIdsByRelation(String relatedCluId, |
497 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
498 | |
InvalidParameterException, MissingParameterException, |
499 | |
OperationFailedException { |
500 | 19 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
501 | 18 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
502 | |
|
503 | 17 | List<String> cluIds = luDao.getCluIdsByRelatedCluId(relatedCluId, luLuRelationTypeKey); |
504 | 17 | return cluIds; |
505 | |
} |
506 | |
|
507 | |
@Override |
508 | |
public List<CluInfo> getRelatedClusByCluId(String cluId, |
509 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
510 | |
InvalidParameterException, MissingParameterException, |
511 | |
OperationFailedException { |
512 | 64 | checkForMissingParameter(cluId, "cluId"); |
513 | 64 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
514 | 64 | List<Clu> relatedClus = luDao.getRelatedClusByCluId(cluId, |
515 | |
luLuRelationTypeKey); |
516 | 64 | return LuServiceAssembler.toCluInfos(relatedClus); |
517 | |
} |
518 | |
|
519 | |
@Override |
520 | |
public List<String> getRelatedCluIdsByCluId(String cluId, |
521 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
522 | |
InvalidParameterException, MissingParameterException, |
523 | |
OperationFailedException { |
524 | 85 | checkForMissingParameter(cluId, "cluId"); |
525 | 85 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
526 | 85 | List<String> relatedCluIds = luDao.getRelatedCluIdsByCluId(cluId, |
527 | |
luLuRelationTypeKey); |
528 | 85 | return relatedCluIds; |
529 | |
} |
530 | |
|
531 | |
@Override |
532 | |
public CluCluRelationInfo getCluCluRelation(String cluCluRelationId) |
533 | |
throws DoesNotExistException, InvalidParameterException, |
534 | |
MissingParameterException, OperationFailedException { |
535 | 2 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
536 | 2 | return LuServiceAssembler.toCluCluRelationInfo(luDao.fetch( |
537 | |
CluCluRelation.class, cluCluRelationId)); |
538 | |
} |
539 | |
|
540 | |
@Override |
541 | |
public List<CluCluRelationInfo> getCluCluRelationsByClu(String cluId) |
542 | |
throws DoesNotExistException, InvalidParameterException, |
543 | |
MissingParameterException, OperationFailedException { |
544 | 81 | checkForMissingParameter(cluId, "cluId"); |
545 | 80 | List<CluCluRelation> cluCluRelations = luDao |
546 | |
.getCluCluRelationsByClu(cluId); |
547 | 80 | return LuServiceAssembler.toCluCluRelationInfos(cluCluRelations); |
548 | |
} |
549 | |
|
550 | |
|
551 | |
@Override |
552 | |
public List<CluPublicationInfo> getCluPublicationsByCluId(String cluId) |
553 | |
throws DoesNotExistException, InvalidParameterException, |
554 | |
MissingParameterException, OperationFailedException { |
555 | 185 | checkForMissingParameter(cluId, "cluId"); |
556 | 185 | List<CluPublication> cluPublications = luDao.getCluPublicationsByCluId(cluId); |
557 | 185 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
558 | |
} |
559 | |
|
560 | |
@Override |
561 | |
public List<CluPublicationInfo> getCluPublicationsByType( |
562 | |
String luPublicationTypeKey) throws DoesNotExistException, |
563 | |
InvalidParameterException, MissingParameterException, |
564 | |
OperationFailedException { |
565 | 1 | checkForMissingParameter(luPublicationTypeKey, "luPublicationTypeKey"); |
566 | 1 | List<CluPublication> cluPublications = luDao.getCluPublicationsByType(luPublicationTypeKey); |
567 | 1 | return LuServiceAssembler.toCluPublicationInfos(cluPublications); |
568 | |
} |
569 | |
|
570 | |
@Override |
571 | |
public CluPublicationInfo getCluPublication(String cluPublicationId) |
572 | |
throws DoesNotExistException, InvalidParameterException, |
573 | |
MissingParameterException, OperationFailedException { |
574 | 1 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
575 | 1 | CluPublication cluPublication = luDao.fetch(CluPublication.class, cluPublicationId); |
576 | 1 | return LuServiceAssembler.toCluPublicationInfo(cluPublication); |
577 | |
} |
578 | |
|
579 | |
|
580 | |
|
581 | |
@Override |
582 | |
public CluResultInfo getCluResult(String cluResultId) |
583 | |
throws DoesNotExistException, InvalidParameterException, |
584 | |
MissingParameterException, OperationFailedException { |
585 | |
|
586 | 4 | checkForMissingParameter(cluResultId, "cluResultId"); |
587 | |
|
588 | 4 | CluResult cluResult = luDao.fetch(CluResult.class, cluResultId); |
589 | 4 | return LuServiceAssembler.toCluResultInfo(cluResult); |
590 | |
} |
591 | |
|
592 | |
@Override |
593 | |
public List<CluResultInfo> getCluResultByClu(String cluId) |
594 | |
throws DoesNotExistException, InvalidParameterException, |
595 | |
MissingParameterException, OperationFailedException { |
596 | |
|
597 | 124 | checkForMissingParameter(cluId, "cluId"); |
598 | |
|
599 | 124 | return LuServiceAssembler.toCluResultInfos(luDao |
600 | |
.getCluResultByClu(cluId)); |
601 | |
} |
602 | |
|
603 | |
@Override |
604 | |
public List<String> getCluIdsByResultUsageType(String resultUsageTypeKey) |
605 | |
throws DoesNotExistException, InvalidParameterException, |
606 | |
MissingParameterException, OperationFailedException { |
607 | 0 | return luDao.getCluIdsByResultUsageType(resultUsageTypeKey); |
608 | |
} |
609 | |
|
610 | |
@Override |
611 | |
public List<String> getCluIdsByResultComponent(String resultComponentId) |
612 | |
throws DoesNotExistException, InvalidParameterException, |
613 | |
MissingParameterException, OperationFailedException { |
614 | 0 | return luDao.getCluIdsByResultComponentId(resultComponentId); |
615 | |
} |
616 | |
|
617 | |
|
618 | |
|
619 | |
@Override |
620 | |
public CluLoRelationInfo getCluLoRelation(String cluLoRelationId) |
621 | |
throws DoesNotExistException, InvalidParameterException, |
622 | |
MissingParameterException, OperationFailedException, |
623 | |
PermissionDeniedException { |
624 | |
|
625 | 1 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
626 | |
|
627 | 1 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
628 | 1 | return LuServiceAssembler.toCluLoRelationInfo(reltn); |
629 | |
|
630 | |
} |
631 | |
|
632 | |
@Override |
633 | |
public List<CluLoRelationInfo> getCluLoRelationsByClu(String cluId) |
634 | |
throws DoesNotExistException, InvalidParameterException, |
635 | |
MissingParameterException, OperationFailedException { |
636 | |
|
637 | 184 | checkForMissingParameter(cluId, "cluId"); |
638 | 184 | List<CluLoRelation> cluLoRelations = luDao |
639 | |
.getCluLoRelationsByClu(cluId); |
640 | 184 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
641 | |
|
642 | |
} |
643 | |
|
644 | |
@Override |
645 | |
public List<CluLoRelationInfo> getCluLoRelationsByLo(String loId) |
646 | |
throws DoesNotExistException, InvalidParameterException, |
647 | |
MissingParameterException, OperationFailedException { |
648 | 1 | checkForMissingParameter(loId, "loId"); |
649 | 1 | List<CluLoRelation> cluLoRelations = luDao.getCluLoRelationsByLo(loId); |
650 | 1 | return LuServiceAssembler.toCluLoRelationInfos(cluLoRelations); |
651 | |
} |
652 | |
|
653 | |
|
654 | |
|
655 | |
@Override |
656 | |
public List<String> getResourceRequirementsForCluId(String cluId) |
657 | |
throws DoesNotExistException, InvalidParameterException, |
658 | |
MissingParameterException, OperationFailedException { |
659 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
660 | |
} |
661 | |
|
662 | |
|
663 | |
|
664 | |
@Override |
665 | |
public CluSetInfo getCluSetInfo(String cluSetId) |
666 | |
throws DoesNotExistException, InvalidParameterException, |
667 | |
MissingParameterException, OperationFailedException, |
668 | |
PermissionDeniedException { |
669 | 126 | checkForMissingParameter(cluSetId, "cluSetId"); |
670 | 125 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
671 | 122 | CluSetInfo cluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
672 | 122 | setMembershipQuerySearchResult(cluSetInfo); |
673 | 122 | return cluSetInfo; |
674 | |
} |
675 | |
|
676 | |
@Override |
677 | |
public CluSetTreeViewInfo getCluSetTreeView(String cluSetId) |
678 | |
throws DoesNotExistException, InvalidParameterException, |
679 | |
MissingParameterException, OperationFailedException, |
680 | |
PermissionDeniedException { |
681 | |
|
682 | 49 | checkForMissingParameter(cluSetId, "cluSetId"); |
683 | 48 | CluSetInfo cluSet = getCluSetInfo(cluSetId); |
684 | 47 | if (cluSet == null) { |
685 | 0 | return null; |
686 | |
} |
687 | |
|
688 | 47 | CluSetTreeViewInfo cluSetTreeView = new CluSetTreeViewInfo(); |
689 | 47 | getCluSetTreeViewHelper(cluSet, cluSetTreeView); |
690 | 47 | return cluSetTreeView; |
691 | |
} |
692 | |
|
693 | |
|
694 | |
|
695 | |
|
696 | |
|
697 | |
|
698 | |
|
699 | |
|
700 | |
|
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
private void getCluSetTreeViewHelper(CluSetInfo cluSetInfo, |
706 | |
CluSetTreeViewInfo cluSetTreeViewInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
707 | 51 | cluSetTreeViewInfo.setName(cluSetInfo.getName()); |
708 | 51 | cluSetTreeViewInfo.setDescr(cluSetInfo.getDescr()); |
709 | 51 | cluSetTreeViewInfo.setEffectiveDate(cluSetInfo.getEffectiveDate()); |
710 | 51 | cluSetTreeViewInfo.setExpirationDate(cluSetInfo.getExpirationDate()); |
711 | 51 | cluSetTreeViewInfo.setAdminOrg(cluSetInfo.getAdminOrg()); |
712 | 51 | cluSetTreeViewInfo.setIsReusable(cluSetInfo.getIsReusable()); |
713 | 51 | cluSetTreeViewInfo.setIsReferenceable(cluSetInfo.getIsReferenceable()); |
714 | 51 | cluSetTreeViewInfo.setMetaInfo(cluSetInfo.getMetaInfo()); |
715 | 51 | cluSetTreeViewInfo.setAttributes(cluSetInfo.getAttributes()); |
716 | 51 | cluSetTreeViewInfo.setType(cluSetInfo.getType()); |
717 | 51 | cluSetTreeViewInfo.setState(cluSetInfo.getState()); |
718 | 51 | cluSetTreeViewInfo.setId(cluSetInfo.getId()); |
719 | |
|
720 | 51 | if (!cluSetInfo.getCluSetIds().isEmpty()) { |
721 | 2 | for (String cluSetId : cluSetInfo.getCluSetIds()) { |
722 | 4 | CluSetInfo subCluSet = getCluSetInfo(cluSetId); |
723 | 4 | List<CluSetTreeViewInfo> cluSets = |
724 | |
cluSetTreeViewInfo.getCluSets() == null ? |
725 | |
new ArrayList<CluSetTreeViewInfo>(0) : cluSetTreeViewInfo.getCluSets(); |
726 | |
|
727 | 4 | CluSetTreeViewInfo subCluSetTreeViewInfo = new CluSetTreeViewInfo(); |
728 | 4 | getCluSetTreeViewHelper(subCluSet, subCluSetTreeViewInfo); |
729 | 4 | cluSets.add(subCluSetTreeViewInfo); |
730 | |
|
731 | 4 | cluSetTreeViewInfo.setCluSets(cluSets); |
732 | 4 | } |
733 | |
} |
734 | 51 | List<CluInfo> clus = new ArrayList<CluInfo>(); |
735 | 51 | for (String cluId : cluSetInfo.getCluIds()) { |
736 | 194 | if(cluId!=null){ |
737 | |
|
738 | |
|
739 | 194 | Clu clu = luDao.getCurrentCluVersion(cluId); |
740 | 194 | CluInfo cluInfo = new CluInfo(); |
741 | 194 | cluInfo.setId(clu.getId()); |
742 | 194 | cluInfo.setType(clu.getLuType().getId()); |
743 | 194 | cluInfo.setOfficialIdentifier(LuServiceAssembler.toCluIdentifierInfo(clu.getOfficialIdentifier())); |
744 | 194 | clus.add(cluInfo); |
745 | 194 | } |
746 | |
} |
747 | 51 | cluSetTreeViewInfo.setClus(clus); |
748 | 51 | } |
749 | |
|
750 | |
@Override |
751 | |
public List<CluSetInfo> getCluSetInfoByIdList(List<String> cluSetIdList) |
752 | |
throws DoesNotExistException, InvalidParameterException, |
753 | |
MissingParameterException, OperationFailedException, |
754 | |
PermissionDeniedException { |
755 | 5 | checkForMissingParameter(cluSetIdList, "cluSetIdList"); |
756 | 4 | checkForEmptyList(cluSetIdList, "cluSetIdList"); |
757 | 4 | List<CluSet> cluSets = luDao.getCluSetInfoByIdList(cluSetIdList); |
758 | 4 | return LuServiceAssembler.toCluSetInfos(cluSets); |
759 | |
} |
760 | |
|
761 | |
@Override |
762 | |
public List<String> getCluSetIdsFromCluSet(String cluSetId) |
763 | |
throws DoesNotExistException, InvalidParameterException, |
764 | |
MissingParameterException, OperationFailedException, |
765 | |
PermissionDeniedException { |
766 | 0 | checkForMissingParameter(cluSetId, "cluSetId"); |
767 | 0 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
768 | 0 | List<String> ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
769 | 0 | if(cluSet.getCluSets()!=null){ |
770 | 0 | for (CluSet cluSet2 : cluSet.getCluSets()) { |
771 | 0 | ids.add(cluSet2.getId()); |
772 | |
} |
773 | |
} |
774 | 0 | return ids; |
775 | |
} |
776 | |
|
777 | |
@Override |
778 | |
public Boolean isCluSetDynamic(String cluSetId) |
779 | |
throws DoesNotExistException, InvalidParameterException, |
780 | |
MissingParameterException, OperationFailedException, |
781 | |
PermissionDeniedException { |
782 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
783 | |
} |
784 | |
|
785 | |
@Override |
786 | |
public List<CluInfo> getClusFromCluSet(String cluSetId) |
787 | |
throws DoesNotExistException, InvalidParameterException, |
788 | |
MissingParameterException, OperationFailedException, |
789 | |
PermissionDeniedException { |
790 | 3 | checkForMissingParameter(cluSetId, "cluSetId"); |
791 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
792 | 1 | List<CluInfo> clus = new ArrayList<CluInfo>(cluSet.getCluVerIndIds().size()); |
793 | 1 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
794 | 2 | clus.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluSetJnClu.getCluVersionIndId()))); |
795 | |
} |
796 | 1 | return clus; |
797 | |
} |
798 | |
|
799 | |
@Override |
800 | |
public List<String> getCluIdsFromCluSet(String cluSetId) |
801 | |
throws DoesNotExistException, InvalidParameterException, |
802 | |
MissingParameterException, OperationFailedException, |
803 | |
PermissionDeniedException { |
804 | 3 | checkForMissingParameter(cluSetId, "cluSetId"); |
805 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
806 | 1 | List<String> ids = new ArrayList<String>(cluSet.getCluVerIndIds().size()); |
807 | 1 | for (CluSetJoinVersionIndClu cluSetJnClu : cluSet.getCluVerIndIds()) { |
808 | 2 | ids.add(cluSetJnClu.getCluVersionIndId()); |
809 | |
} |
810 | 1 | return ids; |
811 | |
} |
812 | |
|
813 | |
@Override |
814 | |
public List<CluInfo> getAllClusInCluSet(String cluSetId) |
815 | |
throws DoesNotExistException, InvalidParameterException, |
816 | |
MissingParameterException, OperationFailedException, |
817 | |
PermissionDeniedException { |
818 | 2 | checkForMissingParameter(cluSetId, "cluSetId"); |
819 | 2 | List<String> cluIndIds = new ArrayList<String>(); |
820 | 2 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
821 | 2 | findClusInCluSet(cluIndIds, cluSet); |
822 | 2 | List<CluInfo> infos = new ArrayList<CluInfo>(cluIndIds.size()); |
823 | 2 | for (String cluIndId : cluIndIds) { |
824 | 5 | infos.add(LuServiceAssembler.toCluInfo(luDao.getCurrentCluVersion(cluIndId))); |
825 | |
} |
826 | 2 | return infos; |
827 | |
} |
828 | |
|
829 | |
@Override |
830 | |
public List<String> getAllCluIdsInCluSet(String cluSetId) |
831 | |
throws DoesNotExistException, InvalidParameterException, |
832 | |
MissingParameterException, OperationFailedException, |
833 | |
PermissionDeniedException { |
834 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
835 | 0 | List<String> ids = new ArrayList<String>(); |
836 | 0 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
837 | 0 | findClusInCluSet(ids, cluSet); |
838 | 0 | return ids; |
839 | |
} |
840 | |
|
841 | |
@Override |
842 | |
public Boolean isCluInCluSet(String cluId, String cluSetId) |
843 | |
throws DoesNotExistException, InvalidParameterException, |
844 | |
MissingParameterException, OperationFailedException, |
845 | |
PermissionDeniedException { |
846 | 6 | checkForMissingParameter(cluId, "cluId"); |
847 | 5 | checkForMissingParameter(cluSetId, "cluSetId"); |
848 | 4 | return luDao.isCluInCluSet(cluId, cluSetId); |
849 | |
} |
850 | |
|
851 | |
|
852 | |
|
853 | |
|
854 | |
@Override |
855 | |
public LuiInfo getLui(String luiId) throws DoesNotExistException, |
856 | |
InvalidParameterException, MissingParameterException, |
857 | |
OperationFailedException { |
858 | |
|
859 | 4 | checkForMissingParameter(luiId, "luiId"); |
860 | |
|
861 | 3 | Lui lui = luDao.fetch(Lui.class, luiId); |
862 | 2 | return LuServiceAssembler.toLuiInfo(lui); |
863 | |
} |
864 | |
|
865 | |
@Override |
866 | |
public List<LuiInfo> getLuisByIdList(List<String> luiIdList) |
867 | |
throws DoesNotExistException, InvalidParameterException, |
868 | |
MissingParameterException, OperationFailedException { |
869 | 3 | checkForMissingParameter(luiIdList, "luiIdList"); |
870 | 2 | checkForEmptyList(luiIdList, "luiIdList"); |
871 | 2 | List<Lui> luis = luDao.getLuisByIdList(luiIdList); |
872 | 2 | return LuServiceAssembler.toLuiInfos(luis); |
873 | |
} |
874 | |
|
875 | |
@Override |
876 | |
public List<LuiInfo> getLuisInAtpByCluId(String cluId, String atpKey) |
877 | |
throws DoesNotExistException, InvalidParameterException, |
878 | |
MissingParameterException, OperationFailedException { |
879 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
880 | |
} |
881 | |
|
882 | |
@Override |
883 | |
public List<String> getLuiIdsByCluId(String cluId) |
884 | |
throws DoesNotExistException, InvalidParameterException, |
885 | |
MissingParameterException, OperationFailedException { |
886 | |
|
887 | 4 | checkForMissingParameter(cluId, "cluId"); |
888 | |
|
889 | 3 | return luDao.getLuiIdsByCluId(cluId); |
890 | |
} |
891 | |
|
892 | |
@Override |
893 | |
public List<String> getLuiIdsInAtpByCluId(String cluId, String atpKey) |
894 | |
throws DoesNotExistException, InvalidParameterException, |
895 | |
MissingParameterException, OperationFailedException { |
896 | |
|
897 | 6 | checkForMissingParameter(cluId, "cluId"); |
898 | 5 | checkForMissingParameter(atpKey, "atpKey"); |
899 | 4 | return luDao.getLuiIdsInAtpByCluId(cluId, atpKey); |
900 | |
} |
901 | |
|
902 | |
|
903 | |
|
904 | |
@Override |
905 | |
public List<String> getAllowedLuLuRelationTypesByLuiId(String luiId, |
906 | |
String relatedLuiId) throws DoesNotExistException, |
907 | |
InvalidParameterException, MissingParameterException, |
908 | |
OperationFailedException { |
909 | |
|
910 | 0 | checkForMissingParameter(luiId, "luiId"); |
911 | 0 | checkForMissingParameter(relatedLuiId, "relatedLuiId"); |
912 | |
|
913 | 0 | return luDao.getAllowedLuLuRelationTypesByLuiId(luiId, relatedLuiId); |
914 | |
} |
915 | |
|
916 | |
@Override |
917 | |
public List<LuiInfo> getLuisByRelation(String luiId, |
918 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
919 | |
InvalidParameterException, MissingParameterException, |
920 | |
OperationFailedException { |
921 | 2 | checkForMissingParameter(luiId, "luiId"); |
922 | 2 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
923 | |
|
924 | 2 | return LuServiceAssembler.toLuiInfos(luDao.getLuisByRelationType(luiId, |
925 | |
luLuRelationTypeKey)); |
926 | |
} |
927 | |
|
928 | |
@Override |
929 | |
public List<String> getLuiIdsByRelation(String luiId, |
930 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
931 | |
InvalidParameterException, MissingParameterException, |
932 | |
OperationFailedException { |
933 | 2 | checkForMissingParameter(luiId, "luiId"); |
934 | 2 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
935 | |
|
936 | 2 | return luDao.getLuiIdsByRelationType(luiId, luLuRelationTypeKey); |
937 | |
} |
938 | |
|
939 | |
@Override |
940 | |
public List<LuiInfo> getRelatedLuisByLuiId(String luiId, |
941 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
942 | |
InvalidParameterException, MissingParameterException, |
943 | |
OperationFailedException { |
944 | 1 | checkForMissingParameter(luiId, "luiId"); |
945 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
946 | 1 | List<Lui> relatedLuis = luDao.getRelatedLuisByLuiId(luiId, |
947 | |
luLuRelationTypeKey); |
948 | 1 | return LuServiceAssembler.toLuiInfos(relatedLuis); |
949 | |
} |
950 | |
|
951 | |
@Override |
952 | |
public List<String> getRelatedLuiIdsByLuiId(String luiId, |
953 | |
String luLuRelationTypeKey) throws DoesNotExistException, |
954 | |
InvalidParameterException, MissingParameterException, |
955 | |
OperationFailedException { |
956 | 1 | checkForMissingParameter(luiId, "luiId"); |
957 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
958 | 1 | List<String> relatedLuiIds = luDao.getRelatedLuiIdsByLuiId(luiId, |
959 | |
luLuRelationTypeKey); |
960 | 1 | return relatedLuiIds; |
961 | |
} |
962 | |
|
963 | |
@Override |
964 | |
public LuiLuiRelationInfo getLuiLuiRelation(String luiLuiRelationId) |
965 | |
throws DoesNotExistException, InvalidParameterException, |
966 | |
MissingParameterException, OperationFailedException { |
967 | 2 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
968 | 2 | LuiLuiRelation luiLuiRelation = luDao.fetch(LuiLuiRelation.class, |
969 | |
luiLuiRelationId); |
970 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(luiLuiRelation); |
971 | |
} |
972 | |
|
973 | |
@Override |
974 | |
public List<LuiLuiRelationInfo> getLuiLuiRelationsByLui(String luiId) |
975 | |
throws DoesNotExistException, InvalidParameterException, |
976 | |
MissingParameterException, OperationFailedException { |
977 | 3 | checkForMissingParameter(luiId, "luiId"); |
978 | 3 | List<LuiLuiRelation> entities = luDao.getLuiLuiRelations(luiId); |
979 | 3 | return LuServiceAssembler.toLuiLuiRelationInfos(entities); |
980 | |
} |
981 | |
|
982 | |
|
983 | |
|
984 | |
|
985 | |
|
986 | |
@Override |
987 | |
public List<ValidationResultInfo> validateClu(String validationType, |
988 | |
CluInfo cluInfo) throws DoesNotExistException, |
989 | |
InvalidParameterException, MissingParameterException, |
990 | |
OperationFailedException { |
991 | 240 | checkForMissingParameter(validationType, "validationType"); |
992 | 240 | checkForMissingParameter(cluInfo, "cluInfo"); |
993 | |
|
994 | 240 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluInfo.class.getName()); |
995 | 240 | Validator defaultValidator = validatorFactory.getValidator(); |
996 | 240 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluInfo, objStructure); |
997 | |
|
998 | 240 | return validationResults; |
999 | |
} |
1000 | |
|
1001 | |
@Override |
1002 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1003 | |
public CluInfo createClu(String luTypeKey, CluInfo cluInfo) |
1004 | |
throws AlreadyExistsException, DataValidationErrorException, |
1005 | |
DoesNotExistException, InvalidParameterException, |
1006 | |
MissingParameterException, OperationFailedException, |
1007 | |
PermissionDeniedException { |
1008 | 171 | Clu clu = toCluForCreate(luTypeKey,cluInfo); |
1009 | |
|
1010 | 171 | if(clu.getVersion() == null){ |
1011 | 171 | clu.setVersion(new Version()); |
1012 | |
} |
1013 | 171 | clu.getVersion().setCurrentVersionStart(new Date()); |
1014 | 171 | luDao.create(clu); |
1015 | 171 | return LuServiceAssembler.toCluInfo(clu); |
1016 | |
} |
1017 | |
|
1018 | |
public Clu toCluForCreate(String luTypeKey, CluInfo cluInfo) |
1019 | |
throws AlreadyExistsException, DataValidationErrorException, |
1020 | |
DoesNotExistException, InvalidParameterException, |
1021 | |
MissingParameterException, OperationFailedException, |
1022 | |
PermissionDeniedException { |
1023 | 189 | checkForMissingParameter(luTypeKey, "luTypeKey"); |
1024 | 189 | checkForMissingParameter(cluInfo, "cluInfo"); |
1025 | |
|
1026 | |
|
1027 | 189 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo); |
1028 | 189 | if(null != val && val.size() > 0) { |
1029 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1030 | |
} |
1031 | |
|
1032 | 189 | Clu clu = new Clu(); |
1033 | |
|
1034 | 189 | LuType luType = luDao.fetch(LuType.class, luTypeKey); |
1035 | 189 | clu.setLuType(luType); |
1036 | |
|
1037 | 189 | if (cluInfo.getOfficialIdentifier() != null) { |
1038 | 57 | clu.setOfficialIdentifier(LuServiceAssembler.createOfficialIdentifier(cluInfo, luDao)); |
1039 | |
} |
1040 | 189 | clu.setAlternateIdentifiers(LuServiceAssembler.createAlternateIdentifiers(cluInfo, luDao)); |
1041 | 189 | if (cluInfo.getDescr() != null) { |
1042 | 57 | LuRichText descr = LuServiceAssembler.toRichText(LuRichText.class, cluInfo.getDescr()); |
1043 | 57 | if (descr.getPlain() != null || descr.getFormatted() != null) { |
1044 | 57 | clu.setDescr(descr); |
1045 | |
} |
1046 | |
} |
1047 | |
|
1048 | 189 | if (clu.getAdminOrgs() == null) { |
1049 | 189 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>(0)); |
1050 | |
} |
1051 | 189 | List<CluAdminOrg> adminOrgs = clu.getAdminOrgs(); |
1052 | 189 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
1053 | 484 | CluAdminOrg instructor = new CluAdminOrg(); |
1054 | 484 | BeanUtils.copyProperties(orgInfo, instructor, |
1055 | |
new String[] { "attributes" }); |
1056 | 484 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
1057 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
1058 | |
instructor, luDao)); |
1059 | 484 | instructor.setClu(clu); |
1060 | 484 | adminOrgs.add(instructor); |
1061 | 484 | } |
1062 | |
|
1063 | 189 | if (cluInfo.getPrimaryInstructor() != null) { |
1064 | 26 | CluInstructor primaryInstructor = new CluInstructor(); |
1065 | 26 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), |
1066 | |
primaryInstructor, new String[] { "attributes" }); |
1067 | 26 | primaryInstructor.setAttributes(LuServiceAssembler |
1068 | |
.toGenericAttributes(CluInstructorAttribute.class, cluInfo |
1069 | |
.getPrimaryInstructor().getAttributes(), |
1070 | |
primaryInstructor, luDao)); |
1071 | 26 | clu.setPrimaryInstructor(primaryInstructor); |
1072 | |
} |
1073 | |
|
1074 | 189 | if (clu.getInstructors() == null) { |
1075 | 189 | clu.setInstructors(new ArrayList<CluInstructor>(0)); |
1076 | |
} |
1077 | 189 | List<CluInstructor> instructors = clu.getInstructors(); |
1078 | 189 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
1079 | 62 | CluInstructor instructor = new CluInstructor(); |
1080 | 62 | BeanUtils.copyProperties(instructorInfo, instructor, |
1081 | |
new String[] { "attributes" }); |
1082 | 62 | instructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
1083 | |
CluInstructorAttribute.class, instructorInfo |
1084 | |
.getAttributes(), instructor, luDao)); |
1085 | 62 | instructors.add(instructor); |
1086 | 62 | } |
1087 | |
|
1088 | 189 | if (cluInfo.getStdDuration() != null) { |
1089 | 169 | clu.setStdDuration(LuServiceAssembler.toTimeAmount(cluInfo |
1090 | |
.getStdDuration())); |
1091 | |
} |
1092 | |
|
1093 | 189 | if (clu.getLuCodes() == null) { |
1094 | 189 | clu.setLuCodes(new ArrayList<LuCode>(0)); |
1095 | |
} |
1096 | 189 | List<LuCode> luCodes = clu.getLuCodes(); |
1097 | 189 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
1098 | 101 | LuCode luCode = new LuCode(); |
1099 | 101 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
1100 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
1101 | |
luDao)); |
1102 | 101 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[] { |
1103 | |
"attributes", "metaInfo" }); |
1104 | 101 | luCode.setDescr(luCodeInfo.getDescr()); |
1105 | 101 | luCode.setClu(clu); |
1106 | 101 | luCodes.add(luCode); |
1107 | 101 | } |
1108 | |
|
1109 | 189 | if (clu.getOfferedAtpTypes() == null) { |
1110 | 189 | clu.setOfferedAtpTypes(new ArrayList<CluAtpTypeKey>(0)); |
1111 | |
} |
1112 | 189 | List<CluAtpTypeKey> offeredAtpTypes = clu.getOfferedAtpTypes(); |
1113 | 189 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
1114 | 137 | CluAtpTypeKey cluAtpTypeKey = new CluAtpTypeKey(); |
1115 | 137 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
1116 | 137 | cluAtpTypeKey.setClu(clu); |
1117 | 137 | offeredAtpTypes.add(cluAtpTypeKey); |
1118 | 137 | } |
1119 | |
|
1120 | |
|
1121 | 189 | if (cluInfo.getFeeInfo() != null) { |
1122 | 26 | CluFee cluFee = null; |
1123 | |
try { |
1124 | 26 | cluFee = LuServiceAssembler.toCluFee(clu, false, cluInfo |
1125 | |
.getFeeInfo(), luDao); |
1126 | 0 | } catch (VersionMismatchException e) { |
1127 | |
|
1128 | 26 | } |
1129 | 26 | clu.setFee(cluFee); |
1130 | |
} |
1131 | |
|
1132 | 189 | if (cluInfo.getAccountingInfo() != null) { |
1133 | 26 | CluAccounting cluAccounting = new CluAccounting(); |
1134 | 26 | cluAccounting.setAttributes(LuServiceAssembler.toGenericAttributes( |
1135 | |
CluAccountingAttribute.class, cluInfo.getAccountingInfo() |
1136 | |
.getAttributes(), cluAccounting, luDao)); |
1137 | 26 | cluAccounting.setAffiliatedOrgs(LuServiceAssembler |
1138 | |
.toAffiliatedOrgs(false, cluAccounting.getAffiliatedOrgs(), |
1139 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
1140 | |
luDao)); |
1141 | 26 | clu.setAccounting(cluAccounting); |
1142 | |
} |
1143 | |
|
1144 | 189 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
1145 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
1146 | |
|
1147 | |
|
1148 | 189 | if (cluInfo.getIntensity() != null) { |
1149 | 126 | clu.setIntensity(LuServiceAssembler |
1150 | |
.toAmount(cluInfo.getIntensity())); |
1151 | |
} |
1152 | |
|
1153 | 189 | if (clu.getCampusLocations() == null) { |
1154 | 189 | clu.setCampusLocations(new ArrayList<CluCampusLocation>(0)); |
1155 | |
} |
1156 | 189 | List<CluCampusLocation> locations = clu.getCampusLocations(); |
1157 | 189 | for (String locationName : cluInfo.getCampusLocations()) { |
1158 | 84 | CluCampusLocation location = new CluCampusLocation(); |
1159 | 84 | location.setCampusLocation(locationName); |
1160 | 84 | location.setClu(clu); |
1161 | 84 | locations.add(location); |
1162 | 84 | } |
1163 | |
|
1164 | 189 | if (clu.getAccreditations() == null) { |
1165 | 189 | clu.setAccreditations(new ArrayList<CluAccreditation>(0)); |
1166 | |
} |
1167 | 189 | List<CluAccreditation> accreditations = clu.getAccreditations(); |
1168 | 189 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
1169 | 18 | CluAccreditation accreditation = new CluAccreditation(); |
1170 | 18 | BeanUtils.copyProperties(accreditationInfo, accreditation, |
1171 | |
new String[] { "attributes" }); |
1172 | 18 | accreditation.setAttributes(LuServiceAssembler.toGenericAttributes( |
1173 | |
CluAccreditationAttribute.class, accreditationInfo |
1174 | |
.getAttributes(), accreditation, luDao)); |
1175 | 18 | accreditations.add(accreditation); |
1176 | 18 | } |
1177 | |
|
1178 | |
|
1179 | 189 | BeanUtils.copyProperties(cluInfo, clu, new String[] { "luType", |
1180 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
1181 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
1182 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
1183 | |
"metaInfo", "versionInfo", "intensity", |
1184 | |
"campusLocations", "accreditations", |
1185 | |
"adminOrgs" }); |
1186 | |
|
1187 | 189 | return clu; |
1188 | |
} |
1189 | |
|
1190 | |
@Override |
1191 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1192 | |
public CluInfo updateClu(String cluId, CluInfo cluInfo) |
1193 | |
throws DataValidationErrorException, DoesNotExistException, |
1194 | |
InvalidParameterException, MissingParameterException, |
1195 | |
OperationFailedException, PermissionDeniedException, |
1196 | |
VersionMismatchException { |
1197 | |
|
1198 | 50 | checkForMissingParameter(cluId, "cluId"); |
1199 | 50 | checkForMissingParameter(cluInfo, "cluInfo"); |
1200 | |
|
1201 | |
|
1202 | 50 | List<ValidationResultInfo> val = validateClu("SYSTEM", cluInfo); |
1203 | 50 | if(null != val && val.size() > 0) { |
1204 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1205 | |
} |
1206 | |
|
1207 | 50 | Clu clu = luDao.fetch(Clu.class, cluId); |
1208 | |
|
1209 | 50 | if (!String.valueOf(clu.getVersionNumber()).equals( |
1210 | |
cluInfo.getMetaInfo().getVersionInd())) { |
1211 | 2 | throw new VersionMismatchException( |
1212 | |
"Clu to be updated is not the current version."); |
1213 | |
} |
1214 | |
|
1215 | 48 | LuType luType = luDao.fetch(LuType.class, cluInfo.getType()); |
1216 | 48 | clu.setLuType(luType); |
1217 | |
|
1218 | 48 | if (cluInfo.getOfficialIdentifier() != null) { |
1219 | 46 | LuServiceAssembler.updateOfficialIdentifier(clu, cluInfo, luDao); |
1220 | 2 | } else if (clu.getOfficialIdentifier() != null) { |
1221 | 0 | luDao.delete(clu.getOfficialIdentifier()); |
1222 | |
} |
1223 | |
|
1224 | |
|
1225 | |
|
1226 | |
|
1227 | 48 | Map<String, CluIdentifier> oldAltIdMap = new HashMap<String, CluIdentifier>(); |
1228 | 48 | LuServiceAssembler.updateAlternateIdentifier(oldAltIdMap, clu, cluInfo, luDao); |
1229 | |
|
1230 | 48 | for (Entry<String, CluIdentifier> entry : oldAltIdMap.entrySet()) { |
1231 | 1 | luDao.delete(entry.getValue()); |
1232 | |
} |
1233 | |
|
1234 | 48 | if (cluInfo.getDescr() != null && (cluInfo.getDescr().getPlain() != null || cluInfo.getDescr().getFormatted() != null)) { |
1235 | 46 | if (clu.getDescr() == null) { |
1236 | 0 | clu.setDescr(new LuRichText()); |
1237 | |
} |
1238 | 46 | BeanUtils.copyProperties(cluInfo.getDescr(), clu.getDescr()); |
1239 | 2 | } else if (clu.getDescr() != null) { |
1240 | 0 | luDao.delete(clu.getDescr()); |
1241 | 0 | clu.setDescr(null); |
1242 | |
} |
1243 | |
|
1244 | 48 | if (cluInfo.getPrimaryInstructor() != null) { |
1245 | 36 | if (clu.getPrimaryInstructor() == null) { |
1246 | 0 | clu.setPrimaryInstructor(new CluInstructor()); |
1247 | |
} |
1248 | 36 | BeanUtils.copyProperties(cluInfo.getPrimaryInstructor(), clu |
1249 | |
.getPrimaryInstructor(), new String[] { "attributes" }); |
1250 | 36 | clu.getPrimaryInstructor().setAttributes( |
1251 | |
LuServiceAssembler.toGenericAttributes( |
1252 | |
CluInstructorAttribute.class, cluInfo |
1253 | |
.getPrimaryInstructor().getAttributes(), |
1254 | |
clu.getPrimaryInstructor(), luDao)); |
1255 | 12 | } else if (clu.getPrimaryInstructor() != null) { |
1256 | 0 | luDao.delete(clu.getPrimaryInstructor()); |
1257 | |
} |
1258 | |
|
1259 | |
|
1260 | |
|
1261 | |
|
1262 | 48 | Map<String, CluInstructor> oldInstructorMap = new HashMap<String, CluInstructor>(); |
1263 | 48 | for (CluInstructor cluInstructor : clu.getInstructors()) { |
1264 | 30 | oldInstructorMap.put(cluInstructor.getOrgId() + "_" |
1265 | |
+ cluInstructor.getPersonId(), cluInstructor); |
1266 | |
} |
1267 | 48 | clu.getInstructors().clear(); |
1268 | |
|
1269 | |
|
1270 | |
|
1271 | |
|
1272 | 48 | for (CluInstructorInfo instructorInfo : cluInfo.getInstructors()) { |
1273 | 30 | CluInstructor cluInstructor = oldInstructorMap |
1274 | |
.remove(instructorInfo.getOrgId() + "_" |
1275 | |
+ instructorInfo.getPersonId()); |
1276 | 30 | if (cluInstructor == null) { |
1277 | 3 | cluInstructor = new CluInstructor(); |
1278 | |
} |
1279 | |
|
1280 | 30 | BeanUtils.copyProperties(instructorInfo, cluInstructor, |
1281 | |
new String[] { "attributes" }); |
1282 | 30 | cluInstructor.setAttributes(LuServiceAssembler.toGenericAttributes( |
1283 | |
CluInstructorAttribute.class, instructorInfo |
1284 | |
.getAttributes(), cluInstructor, luDao)); |
1285 | 30 | clu.getInstructors().add(cluInstructor); |
1286 | 30 | } |
1287 | |
|
1288 | |
|
1289 | 48 | for (Entry<String, CluInstructor> entry : oldInstructorMap.entrySet()) { |
1290 | 1 | luDao.delete(entry.getValue()); |
1291 | |
} |
1292 | |
|
1293 | 48 | if (cluInfo.getStdDuration() != null) { |
1294 | 37 | if (clu.getStdDuration() == null) { |
1295 | 0 | clu.setStdDuration(new TimeAmount()); |
1296 | |
} |
1297 | 37 | BeanUtils.copyProperties(cluInfo.getStdDuration(), clu |
1298 | |
.getStdDuration()); |
1299 | 11 | } else if (clu.getStdDuration() != null) { |
1300 | 0 | luDao.delete(clu.getStdDuration()); |
1301 | |
} |
1302 | |
|
1303 | |
|
1304 | |
|
1305 | |
|
1306 | 48 | Map<String, LuCode> oldLuCodeMap = new HashMap<String, LuCode>(); |
1307 | 48 | for (LuCode luCode : clu.getLuCodes()) { |
1308 | 138 | oldLuCodeMap.put(luCode.getId(), luCode); |
1309 | |
} |
1310 | 48 | clu.getLuCodes().clear(); |
1311 | |
|
1312 | |
|
1313 | |
|
1314 | |
|
1315 | 48 | for (LuCodeInfo luCodeInfo : cluInfo.getLuCodes()) { |
1316 | 136 | LuCode luCode = oldLuCodeMap.remove(luCodeInfo.getId()); |
1317 | 136 | if (luCode == null) { |
1318 | 135 | luCode = new LuCode(); |
1319 | |
} else { |
1320 | 1 | if (!String.valueOf(luCode.getVersionNumber()).equals( |
1321 | |
luCodeInfo.getMetaInfo().getVersionInd())) { |
1322 | 0 | throw new VersionMismatchException( |
1323 | |
"LuCode to be updated is not the current version"); |
1324 | |
} |
1325 | |
} |
1326 | |
|
1327 | 136 | luCode.setAttributes(LuServiceAssembler.toGenericAttributes( |
1328 | |
LuCodeAttribute.class, luCodeInfo.getAttributes(), luCode, |
1329 | |
luDao)); |
1330 | 136 | BeanUtils.copyProperties(luCodeInfo, luCode, new String[] { |
1331 | |
"attributes", "metaInfo" }); |
1332 | 136 | luCode.setDescr(luCodeInfo.getDescr()); |
1333 | 136 | luCode.setClu(clu); |
1334 | 136 | clu.getLuCodes().add(luCode); |
1335 | 136 | } |
1336 | |
|
1337 | |
|
1338 | 48 | for (Entry<String, LuCode> entry : oldLuCodeMap.entrySet()) { |
1339 | 137 | luDao.delete(entry.getValue()); |
1340 | |
} |
1341 | |
|
1342 | |
|
1343 | |
|
1344 | |
|
1345 | 48 | Map<String, CluAtpTypeKey> oldOfferedAtpTypesMap = new HashMap<String, CluAtpTypeKey>(); |
1346 | 48 | for (CluAtpTypeKey cluAtpTypeKey : clu.getOfferedAtpTypes()) { |
1347 | 22 | oldOfferedAtpTypesMap.put(cluAtpTypeKey.getAtpTypeKey(), |
1348 | |
cluAtpTypeKey); |
1349 | |
} |
1350 | 48 | clu.getOfferedAtpTypes().clear(); |
1351 | |
|
1352 | |
|
1353 | |
|
1354 | |
|
1355 | 48 | for (String atpTypeKey : cluInfo.getOfferedAtpTypes()) { |
1356 | 22 | CluAtpTypeKey cluAtpTypeKey = oldOfferedAtpTypesMap |
1357 | |
.remove(atpTypeKey); |
1358 | 22 | if (cluAtpTypeKey == null) { |
1359 | 1 | cluAtpTypeKey = new CluAtpTypeKey(); |
1360 | |
} |
1361 | |
|
1362 | 22 | cluAtpTypeKey.setAtpTypeKey(atpTypeKey); |
1363 | 22 | cluAtpTypeKey.setClu(clu); |
1364 | 22 | clu.getOfferedAtpTypes().add(cluAtpTypeKey); |
1365 | 22 | } |
1366 | |
|
1367 | |
|
1368 | 48 | for (Entry<String, CluAtpTypeKey> entry : oldOfferedAtpTypesMap |
1369 | |
.entrySet()) { |
1370 | 1 | luDao.delete(entry.getValue()); |
1371 | |
} |
1372 | |
|
1373 | 48 | if (cluInfo.getFeeInfo() != null) { |
1374 | 10 | if (clu.getFee() == null) { |
1375 | 0 | clu.setFee(LuServiceAssembler.toCluFee(clu, false, cluInfo |
1376 | |
.getFeeInfo(), luDao)); |
1377 | |
} else { |
1378 | 10 | clu.setFee(LuServiceAssembler.toCluFee(clu, true, cluInfo |
1379 | |
.getFeeInfo(), luDao)); |
1380 | |
} |
1381 | 38 | } else if (clu.getFee() != null) { |
1382 | 0 | luDao.delete(clu.getFee()); |
1383 | 0 | clu.setFee(null); |
1384 | |
} |
1385 | |
|
1386 | 48 | if (cluInfo.getAccountingInfo() != null) { |
1387 | 10 | if (clu.getAccounting() == null) { |
1388 | 0 | clu.setAccounting(new CluAccounting()); |
1389 | |
} |
1390 | 10 | clu.getAccounting().setAttributes( |
1391 | |
LuServiceAssembler.toGenericAttributes( |
1392 | |
CluAccountingAttribute.class, cluInfo |
1393 | |
.getAccountingInfo().getAttributes(), clu |
1394 | |
.getAccounting(), luDao)); |
1395 | 10 | clu.getAccounting().setAffiliatedOrgs(LuServiceAssembler |
1396 | |
.toAffiliatedOrgs(true, clu.getAccounting().getAffiliatedOrgs(), |
1397 | |
cluInfo.getAccountingInfo().getAffiliatedOrgs(), |
1398 | |
luDao)); |
1399 | |
|
1400 | 38 | } else if (clu.getAccounting() != null) { |
1401 | 0 | clu.setAccounting(null); |
1402 | |
} |
1403 | |
|
1404 | 48 | clu.setAttributes(LuServiceAssembler.toGenericAttributes( |
1405 | |
CluAttribute.class, cluInfo.getAttributes(), clu, luDao)); |
1406 | |
|
1407 | 48 | if (cluInfo.getIntensity() != null) { |
1408 | 36 | if (clu.getIntensity() == null) { |
1409 | 0 | clu.setIntensity(new Amount()); |
1410 | |
} |
1411 | 36 | BeanUtils |
1412 | |
.copyProperties(cluInfo.getIntensity(), clu.getIntensity()); |
1413 | 12 | } else if (clu.getIntensity() != null) { |
1414 | 0 | luDao.delete(clu.getIntensity()); |
1415 | |
} |
1416 | |
|
1417 | |
|
1418 | |
|
1419 | |
|
1420 | 48 | Map<String, CluCampusLocation> oldLocationsMap = new HashMap<String, CluCampusLocation>(); |
1421 | 48 | for (CluCampusLocation campus : clu.getCampusLocations()) { |
1422 | 75 | oldLocationsMap.put(campus.getCampusLocation(), campus); |
1423 | |
} |
1424 | 48 | clu.getCampusLocations().clear(); |
1425 | |
|
1426 | |
|
1427 | |
|
1428 | |
|
1429 | 48 | for (String locationName : cluInfo.getCampusLocations()) { |
1430 | 77 | CluCampusLocation location = oldLocationsMap.remove(locationName); |
1431 | 77 | if (location == null) { |
1432 | 4 | location = new CluCampusLocation(); |
1433 | |
} |
1434 | |
|
1435 | 77 | location.setCampusLocation(locationName); |
1436 | 77 | location.setClu(clu); |
1437 | 77 | clu.getCampusLocations().add(location); |
1438 | 77 | } |
1439 | |
|
1440 | |
|
1441 | 48 | for (Entry<String, CluCampusLocation> entry : oldLocationsMap |
1442 | |
.entrySet()) { |
1443 | 2 | luDao.delete(entry.getValue()); |
1444 | |
} |
1445 | |
|
1446 | |
|
1447 | |
|
1448 | |
|
1449 | 48 | Map<String, CluAccreditation> oldAccreditationMap = new HashMap<String, CluAccreditation>(); |
1450 | 48 | for (CluAccreditation cluAccreditation : clu.getAccreditations()) { |
1451 | 12 | oldAccreditationMap.put(cluAccreditation.getId(), |
1452 | |
cluAccreditation); |
1453 | |
} |
1454 | 48 | clu.getAccreditations().clear(); |
1455 | |
|
1456 | |
|
1457 | |
|
1458 | |
|
1459 | 48 | for (AccreditationInfo accreditationInfo : cluInfo.getAccreditations()) { |
1460 | 13 | CluAccreditation cluAccreditation = null; |
1461 | 13 | if(accreditationInfo.getId()!=null){ |
1462 | 11 | cluAccreditation = oldAccreditationMap.remove(accreditationInfo.getId()); |
1463 | |
} |
1464 | |
|
1465 | 13 | if (cluAccreditation == null) { |
1466 | 2 | cluAccreditation = new CluAccreditation(); |
1467 | |
} |
1468 | |
|
1469 | 13 | BeanUtils.copyProperties(accreditationInfo, cluAccreditation, |
1470 | |
new String[] { "attributes" }); |
1471 | 13 | cluAccreditation.setAttributes(LuServiceAssembler |
1472 | |
.toGenericAttributes(CluAccreditationAttribute.class, |
1473 | |
accreditationInfo.getAttributes(), |
1474 | |
cluAccreditation, luDao)); |
1475 | 13 | clu.getAccreditations().add(cluAccreditation); |
1476 | 13 | } |
1477 | |
|
1478 | |
|
1479 | 48 | for (Entry<String, CluAccreditation> entry : oldAccreditationMap |
1480 | |
.entrySet()) { |
1481 | 1 | luDao.delete(entry.getValue()); |
1482 | |
} |
1483 | |
|
1484 | |
|
1485 | |
|
1486 | |
|
1487 | 48 | Map<String, CluAdminOrg> oldAdminOrgsMap = new HashMap<String, CluAdminOrg>(); |
1488 | 48 | if(clu.getAdminOrgs()!=null){ |
1489 | 48 | for (CluAdminOrg cluOrg : clu.getAdminOrgs()) { |
1490 | 413 | oldAdminOrgsMap.put(cluOrg.getId(), cluOrg); |
1491 | |
} |
1492 | |
} |
1493 | 48 | clu.setAdminOrgs(new ArrayList<CluAdminOrg>()); |
1494 | |
|
1495 | |
|
1496 | |
|
1497 | |
|
1498 | 48 | for (AdminOrgInfo orgInfo : cluInfo.getAdminOrgs()) { |
1499 | 412 | CluAdminOrg cluOrg = null; |
1500 | 412 | if(orgInfo.getId() != null){ |
1501 | 2 | cluOrg = oldAdminOrgsMap.remove(orgInfo.getId()); |
1502 | |
} |
1503 | |
|
1504 | 412 | if (cluOrg == null) { |
1505 | 410 | cluOrg = new CluAdminOrg(); |
1506 | |
} |
1507 | |
|
1508 | |
|
1509 | 412 | BeanUtils.copyProperties(orgInfo, cluOrg, |
1510 | |
new String[] { "attributes","id" }); |
1511 | 412 | cluOrg.setAttributes(LuServiceAssembler.toGenericAttributes( |
1512 | |
CluAdminOrgAttribute.class, orgInfo.getAttributes(), |
1513 | |
cluOrg, luDao)); |
1514 | 412 | cluOrg.setClu(clu); |
1515 | 412 | clu.getAdminOrgs().add(cluOrg); |
1516 | 412 | } |
1517 | |
|
1518 | 48 | for (Entry<String, CluAdminOrg> entry : oldAdminOrgsMap.entrySet()) { |
1519 | 411 | luDao.delete(entry.getValue()); |
1520 | |
} |
1521 | |
|
1522 | |
|
1523 | 48 | BeanUtils.copyProperties(cluInfo, clu, new String[] { "luType", |
1524 | |
"officialIdentifier", "alternateIdentifiers", "descr", |
1525 | |
"luCodes", "primaryInstructor", "instructors", "stdDuration", |
1526 | |
"offeredAtpTypes", "feeInfo", "accountingInfo", "attributes", |
1527 | |
"metaInfo","intensity", |
1528 | |
"campusLocations", "accreditations", |
1529 | |
"adminOrgs" }); |
1530 | 48 | Clu updated = null; |
1531 | |
try { |
1532 | 48 | updated = luDao.update(clu); |
1533 | 0 | } catch (Exception e) { |
1534 | 0 | logger.error("Exception occured: ", e); |
1535 | 48 | } |
1536 | 48 | return LuServiceAssembler.toCluInfo(updated); |
1537 | |
} |
1538 | |
|
1539 | |
@Override |
1540 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1541 | |
public StatusInfo deleteClu(String cluId) throws DoesNotExistException, |
1542 | |
InvalidParameterException, MissingParameterException, |
1543 | |
DependentObjectsExistException, OperationFailedException, |
1544 | |
PermissionDeniedException { |
1545 | 14 | checkForMissingParameter(cluId, "cluId"); |
1546 | |
|
1547 | 14 | luDao.delete(Clu.class, cluId); |
1548 | |
|
1549 | 14 | StatusInfo statusInfo = new StatusInfo(); |
1550 | 14 | statusInfo.setSuccess(true); |
1551 | |
|
1552 | 14 | return statusInfo; |
1553 | |
} |
1554 | |
|
1555 | |
@Override |
1556 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1557 | |
public CluInfo updateCluState(String cluId, String luState) |
1558 | |
throws DataValidationErrorException, DoesNotExistException, |
1559 | |
InvalidParameterException, MissingParameterException, |
1560 | |
OperationFailedException, PermissionDeniedException { |
1561 | |
|
1562 | 0 | checkForMissingParameter(cluId, "cluId"); |
1563 | 0 | checkForMissingParameter(luState, "luState"); |
1564 | 0 | Clu clu = luDao.fetch(Clu.class, cluId); |
1565 | 0 | clu.setState(luState); |
1566 | 0 | Clu updated = luDao.update(clu); |
1567 | 0 | return LuServiceAssembler.toCluInfo(updated); |
1568 | |
} |
1569 | |
|
1570 | |
@Override |
1571 | |
public List<ValidationResultInfo> validateCluCluRelation( |
1572 | |
String validationType, CluCluRelationInfo cluCluRelationInfo) |
1573 | |
throws DoesNotExistException, InvalidParameterException, |
1574 | |
MissingParameterException, OperationFailedException { |
1575 | 184 | checkForMissingParameter(validationType, "validationType"); |
1576 | 184 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
1577 | |
|
1578 | 184 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluCluRelationInfo.class.getName()); |
1579 | 184 | Validator defaultValidator = validatorFactory.getValidator(); |
1580 | 184 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluCluRelationInfo, objStructure); |
1581 | |
|
1582 | 184 | return validationResults; |
1583 | |
} |
1584 | |
|
1585 | |
@Override |
1586 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1587 | |
public CluCluRelationInfo createCluCluRelation(String cluId, |
1588 | |
String relatedCluId, String luLuRelationTypeKey, |
1589 | |
CluCluRelationInfo cluCluRelationInfo) |
1590 | |
throws AlreadyExistsException, DataValidationErrorException, |
1591 | |
DoesNotExistException, InvalidParameterException, |
1592 | |
MissingParameterException, OperationFailedException, |
1593 | |
PermissionDeniedException, CircularRelationshipException { |
1594 | 182 | checkForMissingParameter(cluId, "cluId"); |
1595 | 182 | checkForMissingParameter(relatedCluId, "relatedCluId"); |
1596 | 182 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
1597 | 182 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
1598 | |
|
1599 | 182 | if (cluId.equals(relatedCluId)) { |
1600 | 0 | throw new CircularRelationshipException( |
1601 | |
"Can not relate a Clu to itself"); |
1602 | |
} |
1603 | |
|
1604 | |
|
1605 | 182 | List<ValidationResultInfo> val = validateCluCluRelation("SYSTEM", cluCluRelationInfo); |
1606 | 182 | if(null != val && val.size() > 0) { |
1607 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1608 | |
} |
1609 | |
|
1610 | |
|
1611 | 182 | Clu clu = luDao.fetch(Clu.class, cluId); |
1612 | 182 | Clu relatedClu = luDao.fetch(Clu.class, relatedCluId); |
1613 | |
|
1614 | 182 | CluCluRelation cluCluRelation = new CluCluRelation(); |
1615 | 182 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
1616 | |
new String[] { "cluId", "relatedCluId", |
1617 | |
"isCluRelationRequired", "attributes", "metaInfo" }); |
1618 | |
|
1619 | 182 | cluCluRelation.setClu(clu); |
1620 | 182 | cluCluRelation.setRelatedClu(relatedClu); |
1621 | 182 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo |
1622 | |
.getIsCluRelationRequired() == null ? true : cluCluRelationInfo |
1623 | |
.getIsCluRelationRequired()); |
1624 | |
|
1625 | 182 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
1626 | |
CluCluRelationAttribute.class, cluCluRelationInfo |
1627 | |
.getAttributes(), cluCluRelation, luDao)); |
1628 | |
|
1629 | 182 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
1630 | |
luLuRelationTypeKey); |
1631 | |
|
1632 | 182 | cluCluRelation.setLuLuRelationType(luLuRelationType); |
1633 | |
|
1634 | 182 | luDao.create(cluCluRelation); |
1635 | |
|
1636 | 182 | return LuServiceAssembler.toCluCluRelationInfo(cluCluRelation); |
1637 | |
} |
1638 | |
|
1639 | |
@Override |
1640 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1641 | |
public CluCluRelationInfo updateCluCluRelation( |
1642 | |
final String cluCluRelationId, |
1643 | |
final CluCluRelationInfo cluCluRelationInfo) |
1644 | |
throws DataValidationErrorException, DoesNotExistException, |
1645 | |
InvalidParameterException, MissingParameterException, |
1646 | |
OperationFailedException, PermissionDeniedException, |
1647 | |
VersionMismatchException { |
1648 | 2 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
1649 | 2 | checkForMissingParameter(cluCluRelationInfo, "cluCluRelationInfo"); |
1650 | |
|
1651 | |
|
1652 | 2 | List<ValidationResultInfo> val = validateCluCluRelation("SYSTEM", cluCluRelationInfo); |
1653 | 2 | if(null != val && val.size() > 0) { |
1654 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1655 | |
} |
1656 | |
|
1657 | 2 | final CluCluRelation cluCluRelation = luDao.fetch(CluCluRelation.class, |
1658 | |
cluCluRelationId); |
1659 | 2 | BeanUtils.copyProperties(cluCluRelationInfo, cluCluRelation, |
1660 | |
new String[] { "cluId", "relatedCluId", |
1661 | |
"isCluRelationRequired", "attributes", "metaInfo" }); |
1662 | |
|
1663 | 2 | cluCluRelation.setClu(luDao.fetch(Clu.class, cluCluRelationInfo |
1664 | |
.getCluId())); |
1665 | 2 | cluCluRelation.setRelatedClu(luDao.fetch(Clu.class, cluCluRelationInfo |
1666 | |
.getRelatedCluId())); |
1667 | 2 | cluCluRelation.setCluRelationRequired(cluCluRelationInfo |
1668 | |
.getIsCluRelationRequired() == null ? true : cluCluRelationInfo |
1669 | |
.getIsCluRelationRequired()); |
1670 | |
|
1671 | 2 | cluCluRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
1672 | |
CluCluRelationAttribute.class, cluCluRelationInfo |
1673 | |
.getAttributes(), cluCluRelation, luDao)); |
1674 | |
|
1675 | 2 | cluCluRelation.setLuLuRelationType(luDao.fetch(LuLuRelationType.class, |
1676 | |
cluCluRelationInfo.getType())); |
1677 | |
|
1678 | 2 | final CluCluRelation update = luDao.update(cluCluRelation); |
1679 | |
|
1680 | 2 | return LuServiceAssembler.toCluCluRelationInfo(update); |
1681 | |
} |
1682 | |
|
1683 | |
@Override |
1684 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1685 | |
public StatusInfo deleteCluCluRelation(String cluCluRelationId) |
1686 | |
throws DoesNotExistException, InvalidParameterException, |
1687 | |
MissingParameterException, OperationFailedException, |
1688 | |
PermissionDeniedException { |
1689 | 20 | checkForMissingParameter(cluCluRelationId, "cluCluRelationId"); |
1690 | |
|
1691 | 20 | luDao.delete(CluCluRelation.class, cluCluRelationId); |
1692 | |
|
1693 | 20 | StatusInfo statusInfo = new StatusInfo(); |
1694 | 20 | statusInfo.setSuccess(true); |
1695 | |
|
1696 | 20 | return statusInfo; |
1697 | |
} |
1698 | |
|
1699 | |
@Override |
1700 | |
public List<ValidationResultInfo> validateCluPublication( |
1701 | |
String validationType, CluPublicationInfo cluPublicationInfo) |
1702 | |
throws DoesNotExistException, InvalidParameterException, |
1703 | |
MissingParameterException, OperationFailedException { |
1704 | |
|
1705 | 90 | checkForMissingParameter(validationType, "validationType"); |
1706 | 90 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
1707 | |
|
1708 | 90 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluPublicationInfo.class.getName()); |
1709 | 90 | Validator defaultValidator = validatorFactory.getValidator(); |
1710 | 90 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluPublicationInfo, objStructure); |
1711 | 90 | return validationResults; |
1712 | |
} |
1713 | |
|
1714 | |
@Override |
1715 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1716 | |
public CluPublicationInfo createCluPublication(String cluId, |
1717 | |
String luPublicationType, CluPublicationInfo cluPublicationInfo) |
1718 | |
throws AlreadyExistsException, DataValidationErrorException, |
1719 | |
InvalidParameterException, MissingParameterException, |
1720 | |
OperationFailedException, PermissionDeniedException { |
1721 | 58 | checkForMissingParameter(cluId, "cluId"); |
1722 | 58 | checkForMissingParameter(luPublicationType, "luPublicationType"); |
1723 | 58 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
1724 | |
|
1725 | |
|
1726 | |
List<ValidationResultInfo> val; |
1727 | |
try { |
1728 | 58 | val = validateCluPublication("SYSTEM", cluPublicationInfo); |
1729 | 58 | if(null != val && val.size() > 0) { |
1730 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1731 | |
} |
1732 | 0 | } catch (DoesNotExistException e) { |
1733 | 0 | throw new OperationFailedException("Error creating clu",e); |
1734 | 58 | } |
1735 | |
|
1736 | |
|
1737 | 58 | CluPublication cluPub = new CluPublication(); |
1738 | |
Clu clu; |
1739 | |
try { |
1740 | 58 | clu = luDao.fetch(Clu.class, cluId); |
1741 | 0 | } catch (DoesNotExistException e) { |
1742 | 0 | throw new InvalidParameterException("Clu does not exist for id:"+cluId); |
1743 | 58 | } |
1744 | |
|
1745 | |
CluPublicationType type; |
1746 | |
try{ |
1747 | 58 | type = luDao.fetch(CluPublicationType.class, luPublicationType); |
1748 | 0 | } catch (DoesNotExistException e) { |
1749 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + luPublicationType); |
1750 | 58 | } |
1751 | |
|
1752 | 58 | cluPub.setClu(clu); |
1753 | 58 | cluPub.setId(cluPublicationInfo.getId()); |
1754 | 58 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
1755 | 58 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
1756 | 58 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
1757 | 58 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
1758 | 58 | cluPub.setState(cluPublicationInfo.getState()); |
1759 | 58 | cluPub.setType(type); |
1760 | 58 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
1761 | 58 | cluPub.setVariants(LuServiceAssembler.toCluPublicationVariants(cluPublicationInfo.getVariants(), cluPub, luDao)); |
1762 | |
|
1763 | 58 | luDao.create(cluPub); |
1764 | |
|
1765 | 58 | return LuServiceAssembler.toCluPublicationInfo(cluPub); |
1766 | |
} |
1767 | |
|
1768 | |
@Override |
1769 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1770 | |
public CluPublicationInfo updateCluPublication(String cluPublicationId, |
1771 | |
CluPublicationInfo cluPublicationInfo) |
1772 | |
throws DataValidationErrorException, DoesNotExistException, |
1773 | |
InvalidParameterException, MissingParameterException, |
1774 | |
OperationFailedException, PermissionDeniedException, |
1775 | |
VersionMismatchException { |
1776 | 32 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
1777 | 32 | checkForMissingParameter(cluPublicationInfo, "cluPublicationInfo"); |
1778 | |
|
1779 | |
|
1780 | |
List<ValidationResultInfo> val; |
1781 | |
try { |
1782 | 32 | val = validateCluPublication("SYSTEM", cluPublicationInfo); |
1783 | 32 | if(null != val && val.size() > 0) { |
1784 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1785 | |
} |
1786 | 0 | } catch (DoesNotExistException e) { |
1787 | 0 | throw new OperationFailedException("Error creating clu",e); |
1788 | 32 | } |
1789 | |
|
1790 | 32 | CluPublication cluPub = luDao.fetch(CluPublication.class, cluPublicationId); |
1791 | |
|
1792 | 32 | if (!String.valueOf(cluPub.getVersionNumber()).equals( |
1793 | |
cluPublicationInfo.getMetaInfo().getVersionInd())) { |
1794 | 1 | throw new VersionMismatchException( |
1795 | |
"CluPublication to be updated is not the current version"); |
1796 | |
} |
1797 | |
|
1798 | |
Clu clu; |
1799 | |
try { |
1800 | 31 | clu = luDao.fetch(Clu.class, cluPublicationInfo.getCluId()); |
1801 | 0 | } catch (DoesNotExistException e) { |
1802 | 0 | throw new InvalidParameterException("Clu does not exist for id:"+cluPublicationInfo.getCluId()); |
1803 | 31 | } |
1804 | |
|
1805 | |
CluPublicationType type; |
1806 | |
try{ |
1807 | 31 | type = luDao.fetch(CluPublicationType.class, cluPublicationInfo.getType()); |
1808 | 0 | } catch (DoesNotExistException e) { |
1809 | 0 | throw new InvalidParameterException("CluPublication Type does not exist for id:" + cluPublicationInfo.getType()); |
1810 | 31 | } |
1811 | |
|
1812 | |
|
1813 | |
|
1814 | |
|
1815 | 31 | Map<String, CluPublicationVariant> oldVariantMap = new HashMap<String, CluPublicationVariant>(); |
1816 | 31 | for (CluPublicationVariant variant : cluPub.getVariants()) { |
1817 | 21 | oldVariantMap.put(variant.getKey(), variant); |
1818 | |
} |
1819 | 31 | cluPub.getVariants().clear(); |
1820 | |
|
1821 | |
|
1822 | |
|
1823 | 31 | CluPublicationVariant variant = null; |
1824 | 31 | for (FieldInfo fieldInfo : cluPublicationInfo.getVariants()) { |
1825 | 21 | if (!oldVariantMap.containsKey(fieldInfo.getId())) { |
1826 | |
|
1827 | 2 | variant = new CluPublicationVariant(); |
1828 | 2 | variant.setKey(fieldInfo.getId()); |
1829 | 2 | variant.setValue(fieldInfo.getValue()); |
1830 | |
} else { |
1831 | |
|
1832 | 19 | variant = oldVariantMap.get(fieldInfo.getId()); |
1833 | 19 | variant.setValue(fieldInfo.getValue()); |
1834 | 19 | oldVariantMap.remove(fieldInfo.getId()); |
1835 | |
} |
1836 | |
|
1837 | 21 | cluPub.getVariants().add(variant); |
1838 | |
} |
1839 | |
|
1840 | |
|
1841 | 31 | for (Entry<String, CluPublicationVariant> entry : oldVariantMap.entrySet()) { |
1842 | 2 | luDao.delete(entry.getValue()); |
1843 | |
} |
1844 | |
|
1845 | 31 | cluPub.setClu(clu); |
1846 | 31 | cluPub.setEndCycle(cluPublicationInfo.getEndCycle()); |
1847 | 31 | cluPub.setStartCycle(cluPublicationInfo.getStartCycle()); |
1848 | 31 | cluPub.setEffectiveDate(cluPublicationInfo.getEffectiveDate()); |
1849 | 31 | cluPub.setExpirationDate(cluPublicationInfo.getExpirationDate()); |
1850 | 31 | cluPub.setState(cluPublicationInfo.getState()); |
1851 | 31 | cluPub.setType(type); |
1852 | 31 | cluPub.setAttributes(LuServiceAssembler.toGenericAttributes(CluPublicationAttribute.class, cluPublicationInfo.getAttributes(), cluPub, luDao)); |
1853 | |
|
1854 | 31 | CluPublication updated = luDao.update(cluPub); |
1855 | |
|
1856 | 31 | return LuServiceAssembler.toCluPublicationInfo(updated); |
1857 | |
} |
1858 | |
|
1859 | |
@Override |
1860 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1861 | |
public StatusInfo deleteCluPublication(String cluPublicationId) |
1862 | |
throws DoesNotExistException, InvalidParameterException, |
1863 | |
MissingParameterException, DependentObjectsExistException, |
1864 | |
OperationFailedException, PermissionDeniedException { |
1865 | 0 | checkForMissingParameter(cluPublicationId, "cluPublicationId"); |
1866 | |
|
1867 | 0 | luDao.delete(CluPublication.class, cluPublicationId); |
1868 | |
|
1869 | 0 | StatusInfo statusInfo = new StatusInfo(); |
1870 | 0 | statusInfo.setSuccess(true); |
1871 | |
|
1872 | 0 | return statusInfo; } |
1873 | |
|
1874 | |
@Override |
1875 | |
public List<ValidationResultInfo> validateCluResult(String validationType, |
1876 | |
CluResultInfo cluResultInfo) throws DoesNotExistException, |
1877 | |
InvalidParameterException, MissingParameterException, |
1878 | |
OperationFailedException { |
1879 | 110 | checkForMissingParameter(validationType, "validationType"); |
1880 | 110 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
1881 | |
|
1882 | 110 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluResultInfo.class.getName()); |
1883 | 110 | Validator defaultValidator = validatorFactory.getValidator(); |
1884 | 110 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluResultInfo, objStructure); |
1885 | 110 | return validationResults; |
1886 | |
} |
1887 | |
|
1888 | |
@Override |
1889 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1890 | |
public CluResultInfo createCluResult(String cluId, String cluResultTypeKey, |
1891 | |
CluResultInfo cluResultInfo) throws AlreadyExistsException, |
1892 | |
DataValidationErrorException, InvalidParameterException, |
1893 | |
MissingParameterException, OperationFailedException, |
1894 | |
PermissionDeniedException, DoesNotExistException { |
1895 | |
|
1896 | 89 | checkForMissingParameter(cluId, "cluId"); |
1897 | 89 | checkForMissingParameter(cluResultTypeKey, "cluResultTypeKey"); |
1898 | 89 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
1899 | |
|
1900 | |
|
1901 | 89 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", cluResultInfo); |
1902 | 89 | if(null != val && val.size() > 0) { |
1903 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1904 | |
} |
1905 | |
|
1906 | 89 | cluResultInfo.setType(cluResultTypeKey); |
1907 | 89 | cluResultInfo.setCluId(cluId); |
1908 | |
|
1909 | 89 | List<ResultOption> resOptList = new ArrayList<ResultOption>(); |
1910 | 89 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
1911 | 125 | ResultOption resOpt = new ResultOption(); |
1912 | 125 | BeanUtils.copyProperties(resOptInfo, resOpt, new String[] { "id", |
1913 | |
"metaInfo", "resultUsageType", "desc" }); |
1914 | |
|
1915 | 125 | if(resOptInfo.getResultUsageTypeKey() != null) { |
1916 | 0 | ResultUsageType resUsageType = luDao.fetch(ResultUsageType.class, |
1917 | |
resOptInfo.getResultUsageTypeKey()); |
1918 | 0 | resOpt.setResultUsageType(resUsageType); |
1919 | |
} |
1920 | 125 | resOpt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDesc())); |
1921 | 125 | luDao.create(resOpt); |
1922 | 125 | resOptList.add(resOpt); |
1923 | 125 | } |
1924 | |
|
1925 | 89 | CluResult cluResult = new CluResult(); |
1926 | 89 | BeanUtils.copyProperties(cluResultInfo, cluResult, new String[] { "id", |
1927 | |
"desc", "resultOptions", "metaInfo" }); |
1928 | |
|
1929 | 89 | cluResult.setDesc(LuServiceAssembler |
1930 | |
.toRichText(LuRichText.class, cluResultInfo.getDesc())); |
1931 | 89 | cluResult.setResultOptions(resOptList); |
1932 | |
|
1933 | 89 | Clu clu = luDao.fetch(Clu.class, cluId); |
1934 | 89 | cluResult.setClu(clu); |
1935 | |
|
1936 | 89 | CluResultType type = luDao.fetch(CluResultType.class, cluResultTypeKey); |
1937 | 89 | cluResult.setCluResultType(type); |
1938 | |
|
1939 | 89 | luDao.create(cluResult); |
1940 | |
|
1941 | 89 | return LuServiceAssembler.toCluResultInfo(cluResult); |
1942 | |
} |
1943 | |
|
1944 | |
@Override |
1945 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1946 | |
public CluResultInfo updateCluResult(String cluResultId, |
1947 | |
CluResultInfo cluResultInfo) throws DataValidationErrorException, |
1948 | |
DoesNotExistException, InvalidParameterException, |
1949 | |
MissingParameterException, OperationFailedException, |
1950 | |
PermissionDeniedException, VersionMismatchException { |
1951 | |
|
1952 | 21 | checkForMissingParameter(cluResultId, "cluResultId"); |
1953 | 21 | checkForMissingParameter(cluResultInfo, "cluResultInfo"); |
1954 | |
|
1955 | |
|
1956 | 21 | List<ValidationResultInfo> val = validateCluResult("SYSTEM", cluResultInfo); |
1957 | 21 | if(null != val && val.size() > 0) { |
1958 | 0 | throw new DataValidationErrorException("Validation error!", val); |
1959 | |
} |
1960 | |
|
1961 | 21 | CluResult result = luDao.fetch(CluResult.class, cluResultId); |
1962 | 21 | if (!String.valueOf(result.getVersionNumber()).equals( |
1963 | |
cluResultInfo.getMetaInfo().getVersionInd())) { |
1964 | 0 | throw new VersionMismatchException( |
1965 | |
"CluResult to be updated is not the current version"); |
1966 | |
} |
1967 | |
|
1968 | |
|
1969 | |
|
1970 | |
|
1971 | 21 | Map<String, ResultOption> oldResultOptionMap = new HashMap<String, ResultOption>(); |
1972 | 21 | for (ResultOption opt : result.getResultOptions()) { |
1973 | 28 | oldResultOptionMap.put(opt.getId(), opt); |
1974 | |
} |
1975 | 21 | result.getResultOptions().clear(); |
1976 | |
|
1977 | |
|
1978 | |
|
1979 | 21 | for (ResultOptionInfo resOptInfo : cluResultInfo.getResultOptions()) { |
1980 | 27 | ResultOption opt = oldResultOptionMap.remove(resOptInfo.getId()); |
1981 | 27 | if (opt == null) { |
1982 | |
|
1983 | 1 | opt = new ResultOption(); |
1984 | |
|
1985 | 1 | BeanUtils.copyProperties(resOptInfo, opt, new String[] { |
1986 | |
"resultUsageType", "desc" }); |
1987 | |
} else { |
1988 | |
|
1989 | 26 | opt = luDao.fetch(ResultOption.class, resOptInfo.getId()); |
1990 | |
|
1991 | 26 | BeanUtils.copyProperties(resOptInfo, opt, new String[] { |
1992 | |
"id", "resultUsageType", "desc" }); |
1993 | |
} |
1994 | 27 | if(resOptInfo.getResultUsageTypeKey() != null && !resOptInfo.getResultUsageTypeKey().isEmpty()) { |
1995 | 1 | ResultUsageType resUsageType = luDao.fetch(ResultUsageType.class, |
1996 | |
resOptInfo.getResultUsageTypeKey()); |
1997 | 1 | opt.setResultUsageType(resUsageType); |
1998 | |
} |
1999 | 27 | opt.setDesc(LuServiceAssembler.toRichText(LuRichText.class, resOptInfo.getDesc())); |
2000 | 27 | result.getResultOptions().add(opt); |
2001 | 27 | } |
2002 | |
|
2003 | |
|
2004 | 21 | for (Entry<String, ResultOption> entry : oldResultOptionMap.entrySet()) { |
2005 | 2 | luDao.delete(entry.getValue()); |
2006 | |
} |
2007 | |
|
2008 | 21 | BeanUtils.copyProperties(cluResultInfo, result, new String[] { "id", |
2009 | |
"desc", "resultOptions" }); |
2010 | |
|
2011 | 21 | result.setDesc(LuServiceAssembler.toRichText(LuRichText.class, cluResultInfo.getDesc())); |
2012 | 21 | CluResultType type = luDao.fetch(CluResultType.class, cluResultInfo.getType()); |
2013 | 21 | result.setCluResultType(type); |
2014 | |
|
2015 | 21 | CluResult updated = luDao.update(result); |
2016 | |
|
2017 | 21 | return LuServiceAssembler.toCluResultInfo(updated); |
2018 | |
} |
2019 | |
|
2020 | |
@Override |
2021 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2022 | |
public StatusInfo deleteCluResult(String cluResultId) |
2023 | |
throws DoesNotExistException, InvalidParameterException, |
2024 | |
MissingParameterException, DependentObjectsExistException, |
2025 | |
OperationFailedException, PermissionDeniedException { |
2026 | |
|
2027 | 4 | checkForMissingParameter(cluResultId, "cluResultId"); |
2028 | |
|
2029 | 4 | luDao.delete(CluResult.class, cluResultId); |
2030 | |
|
2031 | 4 | StatusInfo statusInfo = new StatusInfo(); |
2032 | 4 | statusInfo.setSuccess(true); |
2033 | |
|
2034 | 4 | return statusInfo; |
2035 | |
} |
2036 | |
|
2037 | |
@Override |
2038 | |
public List<ValidationResultInfo> validateCluLoRelation( |
2039 | |
String validationType, CluLoRelationInfo cluLoRelationInfo) |
2040 | |
throws DoesNotExistException, InvalidParameterException, |
2041 | |
MissingParameterException, OperationFailedException { |
2042 | |
|
2043 | 104 | checkForMissingParameter(validationType, "validationType"); |
2044 | 104 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
2045 | |
|
2046 | 104 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluLoRelation.class.getName()); |
2047 | 104 | Validator defaultValidator = validatorFactory.getValidator(); |
2048 | 104 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluLoRelationInfo, objStructure); |
2049 | 104 | return validationResults; |
2050 | |
} |
2051 | |
|
2052 | |
@Override |
2053 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2054 | |
public CluLoRelationInfo createCluLoRelation(String cluId, String loId, |
2055 | |
String cluLoRelationType, CluLoRelationInfo cluLoRelationInfo) |
2056 | |
throws AlreadyExistsException, DoesNotExistException, |
2057 | |
InvalidParameterException, MissingParameterException, |
2058 | |
OperationFailedException, PermissionDeniedException, DataValidationErrorException { |
2059 | 103 | checkForMissingParameter(loId, "loId"); |
2060 | 103 | checkForMissingParameter(cluId, "cluId"); |
2061 | 103 | checkForEmptyList(cluLoRelationType, "cluLoRelationType"); |
2062 | 103 | checkForEmptyList(cluLoRelationInfo, "cluLoRelationInfo"); |
2063 | |
|
2064 | |
|
2065 | 103 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", cluLoRelationInfo); |
2066 | 103 | if(null != val && val.size() > 0) { |
2067 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2068 | |
} |
2069 | |
|
2070 | 103 | Clu clu = luDao.fetch(Clu.class, cluId); |
2071 | 102 | if (clu == null) { |
2072 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
2073 | |
+ cluId); |
2074 | |
} |
2075 | |
|
2076 | 102 | CluLoRelationType cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationType); |
2077 | 102 | if (cluLoRelationTypeEntity == null) { |
2078 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
2079 | |
+ cluLoRelationType); |
2080 | |
} |
2081 | |
|
2082 | |
|
2083 | 102 | List<CluLoRelation> reltns = luDao.getCluLoRelationsByCludIdAndLoId( |
2084 | |
cluId, loId); |
2085 | 102 | if (reltns.size() > 0) { |
2086 | 1 | throw new AlreadyExistsException( |
2087 | |
"Relation already exists for cluId:" + cluId + " and Lo:" |
2088 | |
+ loId); |
2089 | |
} |
2090 | |
|
2091 | 101 | CluLoRelation cluLoRelation = new CluLoRelation(); |
2092 | 101 | BeanUtils.copyProperties(cluLoRelationInfo, cluLoRelation, |
2093 | |
new String[] { "cluId", "attributes", "metaInfo", "type" }); |
2094 | |
|
2095 | 101 | cluLoRelation.setClu(clu); |
2096 | 101 | cluLoRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
2097 | |
CluLoRelationAttribute.class, |
2098 | |
cluLoRelationInfo.getAttributes(), cluLoRelation, luDao)); |
2099 | 101 | cluLoRelation.setType(cluLoRelationTypeEntity); |
2100 | |
|
2101 | 101 | luDao.create(cluLoRelation); |
2102 | |
|
2103 | 101 | return LuServiceAssembler.toCluLoRelationInfo(cluLoRelation); |
2104 | |
} |
2105 | |
|
2106 | |
@Override |
2107 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2108 | |
public CluLoRelationInfo updateCluLoRelation(String cluLoRelationId, |
2109 | |
CluLoRelationInfo cluLoRelationInfo) |
2110 | |
throws DataValidationErrorException, DoesNotExistException, |
2111 | |
InvalidParameterException, MissingParameterException, |
2112 | |
OperationFailedException, PermissionDeniedException, |
2113 | |
VersionMismatchException { |
2114 | 1 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
2115 | 1 | checkForMissingParameter(cluLoRelationInfo, "cluLoRelationInfo"); |
2116 | |
|
2117 | |
|
2118 | 1 | List<ValidationResultInfo> val = validateCluLoRelation("SYSTEM", cluLoRelationInfo); |
2119 | 1 | if(null != val && val.size() > 0) { |
2120 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2121 | |
} |
2122 | |
|
2123 | 1 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
2124 | |
|
2125 | 1 | if (!String.valueOf(reltn.getVersionNumber()).equals( |
2126 | |
cluLoRelationInfo.getMetaInfo().getVersionInd())) { |
2127 | 0 | throw new VersionMismatchException( |
2128 | |
"CluLoRelation to be updated is not the current version"); |
2129 | |
} |
2130 | |
|
2131 | 1 | Clu clu = luDao.fetch(Clu.class, cluLoRelationInfo.getCluId()); |
2132 | 1 | if (clu == null) { |
2133 | 0 | throw new DoesNotExistException("Clu does not exist for id: " |
2134 | |
+ cluLoRelationInfo.getCluId()); |
2135 | |
} |
2136 | |
|
2137 | 1 | CluLoRelationType cluLoRelationTypeEntity = luDao.fetch(CluLoRelationType.class, cluLoRelationInfo.getType()); |
2138 | 1 | if (cluLoRelationTypeEntity == null) { |
2139 | 0 | throw new DoesNotExistException("CluLoRelationType does not exist for id: " |
2140 | |
+ cluLoRelationInfo.getType()); |
2141 | |
} |
2142 | |
|
2143 | 1 | BeanUtils.copyProperties(cluLoRelationInfo, reltn, new String[] { |
2144 | |
"cluId", "attributes", "metaInfo", "type"}); |
2145 | |
|
2146 | 1 | reltn.setClu(clu); |
2147 | 1 | reltn.setAttributes(LuServiceAssembler.toGenericAttributes( |
2148 | |
CluLoRelationAttribute.class, |
2149 | |
cluLoRelationInfo.getAttributes(), reltn, luDao)); |
2150 | 1 | reltn.setType(cluLoRelationTypeEntity); |
2151 | 1 | CluLoRelation updated = luDao.update(reltn); |
2152 | |
|
2153 | 1 | return LuServiceAssembler.toCluLoRelationInfo(updated); |
2154 | |
} |
2155 | |
|
2156 | |
@Override |
2157 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2158 | |
public StatusInfo deleteCluLoRelation(String cluLoRelationId) |
2159 | |
throws DoesNotExistException, InvalidParameterException, |
2160 | |
MissingParameterException, OperationFailedException, |
2161 | |
PermissionDeniedException { |
2162 | 7 | checkForMissingParameter(cluLoRelationId, "cluLoRelationId"); |
2163 | |
|
2164 | 7 | CluLoRelation reltn = luDao.fetch(CluLoRelation.class, cluLoRelationId); |
2165 | 7 | if (reltn == null) { |
2166 | 0 | throw new DoesNotExistException( |
2167 | |
"CluLoRelation does not exist for id: " + cluLoRelationId); |
2168 | |
} |
2169 | |
|
2170 | 7 | luDao.delete(CluLoRelation.class, cluLoRelationId); |
2171 | |
|
2172 | 7 | StatusInfo statusInfo = new StatusInfo(); |
2173 | 7 | statusInfo.setSuccess(true); |
2174 | |
|
2175 | 7 | return statusInfo; |
2176 | |
} |
2177 | |
|
2178 | |
@Override |
2179 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2180 | |
public StatusInfo addCluResourceRequirement(String resourceTypeKey, |
2181 | |
String cluId) throws AlreadyExistsException, DoesNotExistException, |
2182 | |
InvalidParameterException, MissingParameterException, |
2183 | |
OperationFailedException, PermissionDeniedException { |
2184 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
2185 | |
} |
2186 | |
|
2187 | |
@Override |
2188 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2189 | |
public StatusInfo removeCluResourceRequirement(String resourceTypeKey, |
2190 | |
String cluId) throws DoesNotExistException, |
2191 | |
InvalidParameterException, MissingParameterException, |
2192 | |
OperationFailedException, PermissionDeniedException { |
2193 | |
|
2194 | 0 | return null; |
2195 | |
} |
2196 | |
|
2197 | |
@Override |
2198 | |
public List<ValidationResultInfo> validateCluSet(String validationType, |
2199 | |
CluSetInfo cluSetInfo) throws DoesNotExistException, |
2200 | |
InvalidParameterException, MissingParameterException, |
2201 | |
OperationFailedException { |
2202 | 46 | checkForMissingParameter(validationType, "validationType"); |
2203 | 46 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
2204 | |
|
2205 | 46 | ObjectStructureDefinition objStructure = this.getObjectStructure(CluSetInfo.class.getName()); |
2206 | 46 | Validator defaultValidator = validatorFactory.getValidator(); |
2207 | 46 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(cluSetInfo, objStructure); |
2208 | 46 | return validationResults; |
2209 | |
} |
2210 | |
|
2211 | |
@Override |
2212 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2213 | |
public CluSetInfo createCluSet(String cluSetType, CluSetInfo cluSetInfo) |
2214 | |
throws AlreadyExistsException, DataValidationErrorException, |
2215 | |
InvalidParameterException, MissingParameterException, |
2216 | |
OperationFailedException, PermissionDeniedException, |
2217 | |
UnsupportedActionException { |
2218 | |
|
2219 | 39 | checkForMissingParameter(cluSetType, "cluSetType"); |
2220 | 39 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
2221 | |
|
2222 | 39 | cluSetInfo.setType(cluSetType); |
2223 | |
|
2224 | 39 | validateCluSet(cluSetInfo); |
2225 | |
|
2226 | |
|
2227 | |
List<ValidationResultInfo> val; |
2228 | |
try { |
2229 | 36 | val = validateCluSet("SYSTEM", cluSetInfo); |
2230 | 0 | } catch (DoesNotExistException e) { |
2231 | 0 | throw new DataValidationErrorException("Validation error! " + e.getMessage()); |
2232 | 36 | } |
2233 | 36 | if(null != val && val.size() > 0) { |
2234 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2235 | |
} |
2236 | |
|
2237 | 36 | List<String> cluIdList = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
2238 | |
|
2239 | 36 | CluSet cluSet = null; |
2240 | |
try { |
2241 | 36 | cluSet = LuServiceAssembler.toCluSetEntity(cluSetInfo, this.luDao); |
2242 | 0 | } catch (DoesNotExistException e) { |
2243 | 0 | throw new DataValidationErrorException("Creating CluSet entity failed. Clu or CluSet does not exist: " + e.getMessage()); |
2244 | 36 | } |
2245 | |
|
2246 | 36 | cluSet = luDao.create(cluSet); |
2247 | |
|
2248 | 36 | CluSetInfo newCluSetInfo = LuServiceAssembler.toCluSetInfo(cluSet); |
2249 | |
|
2250 | 36 | if(cluIdList != null) { |
2251 | 6 | newCluSetInfo.getCluIds().addAll(cluIdList); |
2252 | |
} |
2253 | |
|
2254 | 36 | return newCluSetInfo; |
2255 | |
} |
2256 | |
|
2257 | |
private void setMembershipQuerySearchResult(CluSetInfo cluSetInfo) throws MissingParameterException { |
2258 | 122 | if(cluSetInfo.getMembershipQuery() == null) { |
2259 | 117 | return; |
2260 | |
} |
2261 | 5 | List<String> cluIds = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
2262 | 5 | cluSetInfo.getCluIds().addAll(cluIds); |
2263 | 5 | } |
2264 | |
|
2265 | |
private List<String> getMembershipQuerySearchResult(MembershipQueryInfo query) throws MissingParameterException { |
2266 | 51 | if(query == null) { |
2267 | 39 | return null; |
2268 | |
} |
2269 | 12 | SearchRequest sr = new SearchRequest(); |
2270 | 12 | sr.setSearchKey(query.getSearchTypeKey()); |
2271 | 12 | sr.setParams(query.getQueryParamValueList()); |
2272 | |
|
2273 | 12 | SearchResult result = search(sr); |
2274 | |
|
2275 | 12 | Set<String> cluIds = new HashSet<String>(); |
2276 | 12 | List<SearchResultRow> rows = result.getRows(); |
2277 | 12 | for(SearchResultRow row : rows) { |
2278 | 827 | List<SearchResultCell> cells = row.getCells(); |
2279 | 827 | for(SearchResultCell cell : cells) { |
2280 | 2481 | if((cell.getKey().equals("lu.resultColumn.luOptionalVersionIndId") || cell.getKey().equals("lo.resultColumn.loLuOptionalVersionIndId")) |
2281 | |
&& (cell.getValue() != null)) { |
2282 | 799 | cluIds.add(cell.getValue()); |
2283 | |
} |
2284 | |
} |
2285 | 827 | } |
2286 | 12 | return new ArrayList<String>(cluIds); |
2287 | |
} |
2288 | |
|
2289 | |
private void validateCluSet(CluSetInfo cluSetInfo) throws UnsupportedActionException { |
2290 | 49 | MembershipQueryInfo mqInfo = cluSetInfo.getMembershipQuery(); |
2291 | |
|
2292 | 49 | if (cluSetInfo.getType() == null) { |
2293 | 0 | throw new UnsupportedActionException("CluSet type cannot be null. CluSet id="+cluSetInfo.getId()); |
2294 | |
} |
2295 | 49 | else if(mqInfo != null && mqInfo.getSearchTypeKey() != null && !mqInfo.getSearchTypeKey().isEmpty() && |
2296 | |
(cluSetInfo.getCluIds().size() > 0 || cluSetInfo.getCluSetIds().size() > 0)) { |
2297 | 2 | throw new UnsupportedActionException("Dynamic CluSet cannot contain Clus and/or CluSets. CluSet id="+cluSetInfo.getId()); |
2298 | |
} |
2299 | 47 | else if (cluSetInfo.getCluIds().size() > 0 && cluSetInfo.getCluSetIds().size() > 0) { |
2300 | 1 | throw new UnsupportedActionException("CluSet cannot contain both Clus and CluSets. CluSet id="+cluSetInfo.getId()); |
2301 | |
} |
2302 | 46 | } |
2303 | |
|
2304 | |
@Override |
2305 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2306 | |
public CluSetInfo updateCluSet(String cluSetId, CluSetInfo cluSetInfo) |
2307 | |
throws DataValidationErrorException, DoesNotExistException, |
2308 | |
InvalidParameterException, MissingParameterException, |
2309 | |
OperationFailedException, PermissionDeniedException, |
2310 | |
VersionMismatchException, CircularRelationshipException, |
2311 | |
UnsupportedActionException { |
2312 | |
|
2313 | |
|
2314 | 10 | checkForMissingParameter(cluSetId, "cluSetId"); |
2315 | 10 | checkForMissingParameter(cluSetInfo, "cluSetInfo"); |
2316 | |
|
2317 | |
|
2318 | 10 | List<ValidationResultInfo> val = validateCluSet("SYSTEM", cluSetInfo); |
2319 | 10 | if(null != val && val.size() > 0) { |
2320 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2321 | |
} |
2322 | |
|
2323 | 10 | cluSetInfo.setId(cluSetId); |
2324 | |
|
2325 | 10 | validateCluSet(cluSetInfo); |
2326 | |
|
2327 | 10 | List<String> cluIdList = getMembershipQuerySearchResult(cluSetInfo.getMembershipQuery()); |
2328 | |
|
2329 | 10 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
2330 | |
|
2331 | 10 | if (!cluSetInfo.getType().equals(cluSet.getType())) { |
2332 | 0 | throw new UnsupportedActionException("CluSet type is set at creation time and cannot be updated. CluSet id="+cluSetId); |
2333 | |
} |
2334 | |
|
2335 | 10 | if (!String.valueOf(cluSet.getVersionNumber()).equals( |
2336 | |
cluSetInfo.getMetaInfo().getVersionInd())) { |
2337 | 1 | throw new VersionMismatchException( |
2338 | |
"CluSet (id=" + cluSetId + |
2339 | |
") to be updated is not the current version " + |
2340 | |
"(version=" + cluSetInfo.getMetaInfo().getVersionInd() + |
2341 | |
"), current version="+cluSet.getVersionNumber()); |
2342 | |
} |
2343 | |
|
2344 | |
|
2345 | 9 | Map<String, CluSetJoinVersionIndClu> oldClus = new HashMap<String, CluSetJoinVersionIndClu>(); |
2346 | 9 | for(CluSetJoinVersionIndClu join:cluSet.getCluVerIndIds()){ |
2347 | 8 | oldClus.put(join.getCluVersionIndId(), join); |
2348 | |
} |
2349 | |
|
2350 | 9 | cluSet.getCluVerIndIds().clear(); |
2351 | |
|
2352 | 9 | for (String newCluId : cluSetInfo.getCluIds()) { |
2353 | 6 | CluSetJoinVersionIndClu join = oldClus.remove(newCluId); |
2354 | 6 | if (join == null) { |
2355 | 2 | join = new CluSetJoinVersionIndClu(); |
2356 | 2 | join.setCluSet(cluSet); |
2357 | 2 | join.setCluVersionIndId(newCluId); |
2358 | |
} |
2359 | 6 | cluSet.getCluVerIndIds().add(join); |
2360 | 6 | } |
2361 | |
|
2362 | |
|
2363 | 9 | for (Entry<String, CluSetJoinVersionIndClu> entry : oldClus.entrySet()) { |
2364 | 4 | luDao.delete(entry.getValue()); |
2365 | |
} |
2366 | |
|
2367 | |
|
2368 | 9 | if (cluSetInfo.getId() != null) { |
2369 | 9 | CluSetInfo originalCluSet = getCluSetInfo(cluSetInfo.getId()); |
2370 | 9 | List<CluSetInfo> origSubCSs = null; |
2371 | 9 | List<String> origSubCSIds = originalCluSet.getCluSetIds(); |
2372 | 9 | if (origSubCSIds != null && !origSubCSIds.isEmpty()) { |
2373 | 2 | origSubCSs = getCluSetInfoByIdList(origSubCSIds); |
2374 | |
} |
2375 | 9 | if (origSubCSs != null) { |
2376 | 2 | for (CluSetInfo origSubCS : origSubCSs) { |
2377 | 6 | if (!origSubCS.getIsReusable()) { |
2378 | 0 | deleteCluSet(origSubCS.getId()); |
2379 | |
} |
2380 | |
} |
2381 | |
} |
2382 | |
} |
2383 | |
|
2384 | |
|
2385 | 9 | if(cluSet.getCluSets()==null){ |
2386 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
2387 | |
} |
2388 | 9 | cluSet.setCluSets(null); |
2389 | 9 | if(!cluSetInfo.getCluSetIds().isEmpty()) { |
2390 | 3 | Set<String> newCluSetIds = new HashSet<String>(cluSetInfo.getCluSetIds()); |
2391 | 3 | if(cluSet.getCluSets()!=null){ |
2392 | 0 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
2393 | 0 | if (!newCluSetIds.remove(i.next().getId())) { |
2394 | 0 | i.remove(); |
2395 | |
} |
2396 | |
} |
2397 | |
} |
2398 | 3 | List<CluSet> cluSetList = luDao.getCluSetInfoByIdList(new ArrayList<String>(newCluSetIds)); |
2399 | 3 | cluSet.setCluSets(cluSetList); |
2400 | |
} |
2401 | |
|
2402 | 9 | BeanUtils.copyProperties(cluSetInfo, cluSet, new String[] { "descr", |
2403 | |
"attributes", "metaInfo", "membershipQuery" }); |
2404 | 9 | cluSet.setAttributes(LuServiceAssembler.toGenericAttributes( |
2405 | |
CluSetAttribute.class, cluSetInfo.getAttributes(), cluSet, luDao)); |
2406 | 9 | cluSet.setDescr(LuServiceAssembler.toRichText(LuRichText.class, cluSetInfo.getDescr())); |
2407 | |
|
2408 | 9 | MembershipQuery mq = LuServiceAssembler.toMembershipQueryEntity(cluSetInfo.getMembershipQuery()); |
2409 | 9 | cluSet.setMembershipQuery(mq); |
2410 | |
|
2411 | 9 | CluSet updated = luDao.update(cluSet); |
2412 | |
|
2413 | 9 | CluSetInfo updatedCluSetInfo = LuServiceAssembler.toCluSetInfo(updated); |
2414 | |
|
2415 | 9 | if(cluIdList != null) { |
2416 | 1 | updatedCluSetInfo.getCluIds().addAll(cluIdList); |
2417 | |
} |
2418 | |
|
2419 | 9 | return updatedCluSetInfo; |
2420 | |
} |
2421 | |
|
2422 | |
@Override |
2423 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2424 | |
public StatusInfo deleteCluSet(String cluSetId) |
2425 | |
throws DoesNotExistException, InvalidParameterException, |
2426 | |
MissingParameterException, OperationFailedException, |
2427 | |
PermissionDeniedException { |
2428 | |
|
2429 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
2430 | |
|
2431 | 1 | luDao.delete(CluSet.class, cluSetId); |
2432 | |
|
2433 | 1 | StatusInfo statusInfo = new StatusInfo(); |
2434 | 1 | statusInfo.setSuccess(true); |
2435 | |
|
2436 | 1 | return statusInfo; |
2437 | |
} |
2438 | |
|
2439 | |
@Override |
2440 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2441 | |
public StatusInfo addCluSetToCluSet(String cluSetId, String addedCluSetId) |
2442 | |
throws DoesNotExistException, InvalidParameterException, |
2443 | |
MissingParameterException, OperationFailedException, |
2444 | |
PermissionDeniedException, UnsupportedActionException, |
2445 | |
CircularRelationshipException { |
2446 | 27 | checkForMissingParameter(cluSetId, "cluSetId"); |
2447 | 27 | checkForMissingParameter(addedCluSetId, "addedCluSetId"); |
2448 | |
|
2449 | 27 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
2450 | |
|
2451 | 27 | checkCluSetAlreadyAdded(cluSet, addedCluSetId); |
2452 | |
|
2453 | 25 | CluSet addedCluSet = luDao.fetch(CluSet.class, addedCluSetId); |
2454 | |
|
2455 | 23 | checkCluSetCircularReference(addedCluSet, cluSetId); |
2456 | |
|
2457 | 19 | if(cluSet.getCluSets()==null){ |
2458 | 0 | cluSet.setCluSets(new ArrayList<CluSet>()); |
2459 | |
} |
2460 | 19 | cluSet.getCluSets().add(addedCluSet); |
2461 | |
|
2462 | 19 | luDao.update(cluSet); |
2463 | |
|
2464 | 19 | StatusInfo statusInfo = new StatusInfo(); |
2465 | 19 | statusInfo.setSuccess(true); |
2466 | |
|
2467 | 19 | return statusInfo; |
2468 | |
} |
2469 | |
|
2470 | |
@Override |
2471 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2472 | |
public StatusInfo removeCluSetFromCluSet(String cluSetId, |
2473 | |
String removedCluSetId) throws DoesNotExistException, |
2474 | |
InvalidParameterException, MissingParameterException, |
2475 | |
OperationFailedException, PermissionDeniedException, |
2476 | |
UnsupportedActionException { |
2477 | |
|
2478 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
2479 | 1 | checkForMissingParameter(removedCluSetId, "removedCluSetId"); |
2480 | |
|
2481 | 1 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
2482 | 1 | if(cluSet.getCluSets()!=null){ |
2483 | 1 | for (Iterator<CluSet> i = cluSet.getCluSets().iterator(); i.hasNext();) { |
2484 | 2 | CluSet childCluSet = i.next(); |
2485 | 2 | if (childCluSet.getId().equals(removedCluSetId)) { |
2486 | 1 | i.remove(); |
2487 | 1 | luDao.update(cluSet); |
2488 | 1 | StatusInfo statusInfo = new StatusInfo(); |
2489 | 1 | statusInfo.setSuccess(true); |
2490 | |
|
2491 | 1 | return statusInfo; |
2492 | |
} |
2493 | 1 | } |
2494 | |
} |
2495 | |
|
2496 | 0 | StatusInfo statusInfo = new StatusInfo(); |
2497 | 0 | statusInfo.setSuccess(false); |
2498 | 0 | statusInfo.setMessage("CluSet does not contain CluSet:" |
2499 | |
+ removedCluSetId); |
2500 | |
|
2501 | 0 | return statusInfo; |
2502 | |
} |
2503 | |
|
2504 | |
@Override |
2505 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2506 | |
public StatusInfo addCluToCluSet(String cluId, String cluSetId) |
2507 | |
throws DoesNotExistException, InvalidParameterException, |
2508 | |
MissingParameterException, OperationFailedException, |
2509 | |
PermissionDeniedException, UnsupportedActionException { |
2510 | |
|
2511 | 14 | checkForMissingParameter(cluId, "cluId"); |
2512 | 14 | checkForMissingParameter(cluSetId, "cluSetId"); |
2513 | |
|
2514 | 14 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
2515 | |
|
2516 | 13 | checkCluAlreadyAdded(cluSet, cluId); |
2517 | |
|
2518 | |
try{ |
2519 | 11 | luDao.getCurrentCluVersionInfo(cluId, LuServiceConstants.CLU_NAMESPACE_URI); |
2520 | 1 | }catch(NoResultException e){ |
2521 | 1 | throw new DoesNotExistException(); |
2522 | 10 | } |
2523 | |
|
2524 | 10 | CluSetJoinVersionIndClu join = new CluSetJoinVersionIndClu(); |
2525 | 10 | join.setCluSet(cluSet); |
2526 | 10 | join.setCluVersionIndId(cluId); |
2527 | |
|
2528 | 10 | cluSet.getCluVerIndIds().add(join); |
2529 | |
|
2530 | 10 | luDao.update(cluSet); |
2531 | |
|
2532 | 10 | StatusInfo statusInfo = new StatusInfo(); |
2533 | 10 | statusInfo.setSuccess(true); |
2534 | |
|
2535 | 10 | return statusInfo; |
2536 | |
} |
2537 | |
|
2538 | |
@Override |
2539 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2540 | |
public StatusInfo removeCluFromCluSet(String cluId, String cluSetId) |
2541 | |
throws DoesNotExistException, InvalidParameterException, |
2542 | |
MissingParameterException, OperationFailedException, |
2543 | |
PermissionDeniedException, UnsupportedActionException { |
2544 | |
|
2545 | 1 | checkForMissingParameter(cluId, "cluId"); |
2546 | 1 | checkForMissingParameter(cluSetId, "cluSetId"); |
2547 | |
|
2548 | 1 | CluSet cluSet = luDao.fetch(CluSet.class, cluSetId); |
2549 | |
|
2550 | 1 | for (Iterator<CluSetJoinVersionIndClu> i = cluSet.getCluVerIndIds().iterator(); i.hasNext();) { |
2551 | 2 | CluSetJoinVersionIndClu join = i.next(); |
2552 | 2 | if (join.getCluVersionIndId().equals(cluId)) { |
2553 | 1 | i.remove(); |
2554 | 1 | luDao.delete(join); |
2555 | 1 | luDao.update(cluSet); |
2556 | 1 | StatusInfo statusInfo = new StatusInfo(); |
2557 | 1 | statusInfo.setSuccess(true); |
2558 | |
|
2559 | 1 | return statusInfo; |
2560 | |
} |
2561 | 1 | } |
2562 | |
|
2563 | 0 | StatusInfo statusInfo = new StatusInfo(); |
2564 | 0 | statusInfo.setSuccess(false); |
2565 | 0 | statusInfo.setMessage("Clu set does not contain Clu:" + cluId); |
2566 | |
|
2567 | 0 | return statusInfo; |
2568 | |
} |
2569 | |
|
2570 | |
@Override |
2571 | |
public List<ValidationResultInfo> validateLui(String validationType, |
2572 | |
LuiInfo luiInfo) throws DoesNotExistException, |
2573 | |
InvalidParameterException, MissingParameterException, |
2574 | |
OperationFailedException { |
2575 | 4 | checkForMissingParameter(validationType, "validationType"); |
2576 | 4 | checkForMissingParameter(luiInfo, "luiInfo"); |
2577 | |
|
2578 | 4 | ObjectStructureDefinition objStructure = this.getObjectStructure(LuiInfo.class.getName()); |
2579 | 4 | Validator defaultValidator = validatorFactory.getValidator(); |
2580 | 4 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(luiInfo, objStructure); |
2581 | 4 | return validationResults; |
2582 | |
} |
2583 | |
|
2584 | |
@Override |
2585 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2586 | |
public LuiInfo createLui(String cluId, String atpKey, LuiInfo luiInfo) |
2587 | |
throws AlreadyExistsException, DataValidationErrorException, |
2588 | |
DoesNotExistException, InvalidParameterException, |
2589 | |
MissingParameterException, OperationFailedException, |
2590 | |
PermissionDeniedException { |
2591 | 2 | checkForMissingParameter(cluId, "cludId"); |
2592 | 2 | checkForMissingParameter(atpKey, "atpKey"); |
2593 | 2 | checkForMissingParameter(luiInfo, "luiInfo"); |
2594 | |
|
2595 | |
|
2596 | 2 | List<ValidationResultInfo> val = validateLui("SYSTEM", luiInfo); |
2597 | 2 | if(null != val && val.size() > 0) { |
2598 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2599 | |
} |
2600 | |
|
2601 | 2 | Lui lui = new Lui(); |
2602 | 2 | luiInfo.setCluId(cluId); |
2603 | 2 | luiInfo.setAtpId(atpKey); |
2604 | |
|
2605 | |
try { |
2606 | 2 | lui = LuServiceAssembler.toLui(false, luiInfo, luDao); |
2607 | 0 | } catch (VersionMismatchException vme) { |
2608 | 2 | } |
2609 | |
|
2610 | 2 | luDao.create(lui); |
2611 | |
|
2612 | 2 | return LuServiceAssembler.toLuiInfo(lui); |
2613 | |
} |
2614 | |
|
2615 | |
@Override |
2616 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2617 | |
public LuiInfo updateLui(String luiId, LuiInfo luiInfo) |
2618 | |
throws DataValidationErrorException, DoesNotExistException, |
2619 | |
InvalidParameterException, MissingParameterException, |
2620 | |
OperationFailedException, PermissionDeniedException, |
2621 | |
VersionMismatchException { |
2622 | |
|
2623 | 2 | checkForMissingParameter(luiId, "luiId"); |
2624 | 2 | checkForMissingParameter(luiInfo, "luiInfo"); |
2625 | |
|
2626 | |
|
2627 | 2 | List<ValidationResultInfo> val = validateLui("SYSTEM", luiInfo); |
2628 | 2 | if(null != val && val.size() > 0) { |
2629 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2630 | |
} |
2631 | |
|
2632 | 2 | Lui lui = luDao.fetch(Lui.class, luiId); |
2633 | |
|
2634 | 2 | if (!String.valueOf(lui.getVersionNumber()).equals( |
2635 | |
luiInfo.getMetaInfo().getVersionInd())) { |
2636 | 1 | throw new VersionMismatchException( |
2637 | |
"Lui to be updated is not the current version"); |
2638 | |
} |
2639 | |
|
2640 | 1 | Clu clu = luDao.fetch(Clu.class, luiInfo.getCluId()); |
2641 | 1 | lui.setClu(clu); |
2642 | |
|
2643 | 1 | lui.setAttributes(LuServiceAssembler.toGenericAttributes( |
2644 | |
LuiAttribute.class, luiInfo.getAttributes(), lui, luDao)); |
2645 | |
|
2646 | |
|
2647 | 1 | BeanUtils.copyProperties(luiInfo, lui, new String[] { "cluId", |
2648 | |
"attributes" }); |
2649 | |
|
2650 | 1 | Lui updated = luDao.update(lui); |
2651 | |
|
2652 | 1 | return LuServiceAssembler.toLuiInfo(updated); |
2653 | |
} |
2654 | |
|
2655 | |
@Override |
2656 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2657 | |
public StatusInfo deleteLui(String luiId) |
2658 | |
throws DependentObjectsExistException, DoesNotExistException, |
2659 | |
InvalidParameterException, MissingParameterException, |
2660 | |
OperationFailedException, PermissionDeniedException { |
2661 | |
|
2662 | 3 | checkForMissingParameter(luiId, "luiId"); |
2663 | |
|
2664 | 3 | luDao.delete(Lui.class, luiId); |
2665 | |
|
2666 | 2 | StatusInfo statusInfo = new StatusInfo(); |
2667 | 2 | statusInfo.setSuccess(true); |
2668 | |
|
2669 | 2 | return statusInfo; |
2670 | |
} |
2671 | |
|
2672 | |
@Override |
2673 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2674 | |
public LuiInfo updateLuiState(String luiId, String luiState) |
2675 | |
throws DataValidationErrorException, DoesNotExistException, |
2676 | |
InvalidParameterException, MissingParameterException, |
2677 | |
OperationFailedException, PermissionDeniedException { |
2678 | |
|
2679 | |
|
2680 | 3 | checkForMissingParameter(luiId, "luiId"); |
2681 | 2 | checkForMissingParameter(luiState, "luiState"); |
2682 | 1 | Lui lui = luDao.fetch(Lui.class, luiId); |
2683 | 1 | lui.setState(luiState); |
2684 | 1 | Lui updated = luDao.update(lui); |
2685 | 1 | return LuServiceAssembler.toLuiInfo(updated); |
2686 | |
} |
2687 | |
|
2688 | |
@Override |
2689 | |
public List<ValidationResultInfo> validateLuiLuiRelation( |
2690 | |
String validationType, LuiLuiRelationInfo luiLuiRelationInfo) |
2691 | |
throws DoesNotExistException, InvalidParameterException, |
2692 | |
MissingParameterException, OperationFailedException { |
2693 | 3 | checkForMissingParameter(validationType, "validationType"); |
2694 | 3 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
2695 | |
|
2696 | 3 | ObjectStructureDefinition objStructure = this.getObjectStructure(LuiLuiRelation.class.getName()); |
2697 | 3 | Validator defaultValidator = validatorFactory.getValidator(); |
2698 | 3 | List<ValidationResultInfo> validationResults = defaultValidator.validateObject(luiLuiRelationInfo, objStructure); |
2699 | 3 | return validationResults; |
2700 | |
} |
2701 | |
|
2702 | |
@Override |
2703 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2704 | |
public LuiLuiRelationInfo createLuiLuiRelation(String luiId, |
2705 | |
String relatedLuiId, String luLuRelationTypeKey, |
2706 | |
LuiLuiRelationInfo luiLuiRelationInfo) |
2707 | |
throws AlreadyExistsException, CircularRelationshipException, |
2708 | |
DataValidationErrorException, DoesNotExistException, |
2709 | |
InvalidParameterException, MissingParameterException, |
2710 | |
OperationFailedException, PermissionDeniedException { |
2711 | 1 | checkForMissingParameter(luiId, "luiId"); |
2712 | 1 | checkForMissingParameter(relatedLuiId, "relatedLuiId"); |
2713 | 1 | checkForMissingParameter(luLuRelationTypeKey, "luLuRelationTypeKey"); |
2714 | 1 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
2715 | |
|
2716 | |
|
2717 | 1 | List<ValidationResultInfo> val = validateLuiLuiRelation("SYSTEM", luiLuiRelationInfo); |
2718 | 1 | if(null != val && val.size() > 0) { |
2719 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2720 | |
} |
2721 | |
|
2722 | 1 | if (luiId.equals(relatedLuiId)) { |
2723 | 0 | throw new CircularRelationshipException( |
2724 | |
"Can not relate a Lui to itself"); |
2725 | |
} |
2726 | |
|
2727 | 1 | Lui lui = luDao.fetch(Lui.class, luiId); |
2728 | 1 | Lui relatedLui = luDao.fetch(Lui.class, relatedLuiId); |
2729 | |
|
2730 | 1 | LuiLuiRelation luiLuiRelation = new LuiLuiRelation(); |
2731 | 1 | BeanUtils.copyProperties(luiLuiRelationInfo, luiLuiRelation, |
2732 | |
new String[] { "luiId", "relatedLuiId", "attributes", |
2733 | |
"metaInfo" }); |
2734 | |
|
2735 | 1 | luiLuiRelation.setLui(lui); |
2736 | 1 | luiLuiRelation.setRelatedLui(relatedLui); |
2737 | 1 | luiLuiRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
2738 | |
LuiLuiRelationAttribute.class, luiLuiRelationInfo |
2739 | |
.getAttributes(), luiLuiRelation, luDao)); |
2740 | |
|
2741 | 1 | LuLuRelationType luLuRelationType = luDao.fetch(LuLuRelationType.class, |
2742 | |
luLuRelationTypeKey); |
2743 | |
|
2744 | 1 | luiLuiRelation.setLuLuRelationType(luLuRelationType); |
2745 | |
|
2746 | 1 | luDao.create(luiLuiRelation); |
2747 | |
|
2748 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(luiLuiRelation); |
2749 | |
} |
2750 | |
|
2751 | |
@Override |
2752 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2753 | |
public LuiLuiRelationInfo updateLuiLuiRelation(String luiLuiRelationId, |
2754 | |
LuiLuiRelationInfo luiLuiRelationInfo) |
2755 | |
throws DataValidationErrorException, DoesNotExistException, |
2756 | |
InvalidParameterException, MissingParameterException, |
2757 | |
OperationFailedException, PermissionDeniedException, |
2758 | |
VersionMismatchException { |
2759 | |
|
2760 | 2 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
2761 | 2 | checkForMissingParameter(luiLuiRelationInfo, "luiLuiRelationInfo"); |
2762 | |
|
2763 | |
|
2764 | 2 | List<ValidationResultInfo> val = validateLuiLuiRelation("SYSTEM", luiLuiRelationInfo); |
2765 | 2 | if(null != val && val.size() > 0) { |
2766 | 0 | throw new DataValidationErrorException("Validation error!", val); |
2767 | |
} |
2768 | |
|
2769 | 2 | LuiLuiRelation luiLuiRelation = luDao.fetch(LuiLuiRelation.class, |
2770 | |
luiLuiRelationId); |
2771 | |
|
2772 | 2 | if (!String.valueOf(luiLuiRelation.getVersionNumber()).equals( |
2773 | |
luiLuiRelationInfo.getMetaInfo().getVersionInd())) { |
2774 | 1 | throw new VersionMismatchException( |
2775 | |
"LuiLuiRelation to be updated is not the current version"); |
2776 | |
} |
2777 | |
|
2778 | 1 | BeanUtils.copyProperties(luiLuiRelationInfo, luiLuiRelation, |
2779 | |
new String[] { "luiId", "relatedLuiId", "attributes", |
2780 | |
"metaInfo" }); |
2781 | |
|
2782 | 1 | if (!luiLuiRelationInfo.getLuiId().equals( |
2783 | |
luiLuiRelation.getLui().getId())) { |
2784 | 1 | luiLuiRelation.setLui(luDao.fetch(Lui.class, luiLuiRelationInfo |
2785 | |
.getLuiId())); |
2786 | |
} |
2787 | |
|
2788 | 1 | if (!luiLuiRelationInfo.getRelatedLuiId().equals( |
2789 | |
luiLuiRelation.getRelatedLui().getId())) { |
2790 | 1 | luiLuiRelation.setRelatedLui(luDao.fetch(Lui.class, |
2791 | |
luiLuiRelationInfo.getRelatedLuiId())); |
2792 | |
} |
2793 | |
|
2794 | 1 | luiLuiRelation.setAttributes(LuServiceAssembler.toGenericAttributes( |
2795 | |
LuiLuiRelationAttribute.class, luiLuiRelationInfo |
2796 | |
.getAttributes(), luiLuiRelation, luDao)); |
2797 | |
|
2798 | 1 | if (!luiLuiRelationInfo.getType().equals( |
2799 | |
luiLuiRelation.getLuLuRelationType().getId())) { |
2800 | 1 | luiLuiRelation.setLuLuRelationType(luDao.fetch( |
2801 | |
LuLuRelationType.class, luiLuiRelationInfo.getType())); |
2802 | |
} |
2803 | |
|
2804 | 1 | LuiLuiRelation updated = luDao.update(luiLuiRelation); |
2805 | |
|
2806 | 1 | return LuServiceAssembler.toLuiLuiRelationInfo(updated); |
2807 | |
} |
2808 | |
|
2809 | |
@Override |
2810 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
2811 | |
public StatusInfo deleteLuiLuiRelation(String luiLuiRelationId) |
2812 | |
throws DoesNotExistException, InvalidParameterException, |
2813 | |
MissingParameterException, OperationFailedException, |
2814 | |
PermissionDeniedException { |
2815 | |
|
2816 | 1 | checkForMissingParameter(luiLuiRelationId, "luiLuiRelationId"); |
2817 | |
|
2818 | 1 | luDao.delete(LuiLuiRelation.class, luiLuiRelationId); |
2819 | |
|
2820 | 1 | StatusInfo statusInfo = new StatusInfo(); |
2821 | 1 | statusInfo.setSuccess(true); |
2822 | |
|
2823 | 1 | return statusInfo; |
2824 | |
} |
2825 | |
|
2826 | |
|
2827 | |
|
2828 | |
|
2829 | |
|
2830 | |
@Override |
2831 | |
public SearchCriteriaTypeInfo getSearchCriteriaType( |
2832 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
2833 | |
InvalidParameterException, MissingParameterException, |
2834 | |
OperationFailedException { |
2835 | |
|
2836 | 0 | return searchManager.getSearchCriteriaType(searchCriteriaTypeKey); |
2837 | |
} |
2838 | |
|
2839 | |
@Override |
2840 | |
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
2841 | |
throws OperationFailedException { |
2842 | 0 | return searchManager.getSearchCriteriaTypes(); |
2843 | |
} |
2844 | |
|
2845 | |
@Override |
2846 | |
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
2847 | |
throws DoesNotExistException, InvalidParameterException, |
2848 | |
MissingParameterException, OperationFailedException { |
2849 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
2850 | 0 | return searchManager.getSearchResultType(searchResultTypeKey); |
2851 | |
} |
2852 | |
|
2853 | |
@Override |
2854 | |
public List<SearchResultTypeInfo> getSearchResultTypes() |
2855 | |
throws OperationFailedException { |
2856 | 0 | return searchManager.getSearchResultTypes(); |
2857 | |
} |
2858 | |
|
2859 | |
@Override |
2860 | |
public SearchTypeInfo getSearchType(String searchTypeKey) |
2861 | |
throws DoesNotExistException, InvalidParameterException, |
2862 | |
MissingParameterException, OperationFailedException { |
2863 | 0 | checkForMissingParameter(searchTypeKey, "searchTypeKey"); |
2864 | 0 | return searchManager.getSearchType(searchTypeKey); |
2865 | |
} |
2866 | |
|
2867 | |
@Override |
2868 | |
public List<SearchTypeInfo> getSearchTypes() |
2869 | |
throws OperationFailedException { |
2870 | 0 | return searchManager.getSearchTypes(); |
2871 | |
} |
2872 | |
|
2873 | |
@Override |
2874 | |
public List<SearchTypeInfo> getSearchTypesByCriteria( |
2875 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
2876 | |
InvalidParameterException, MissingParameterException, |
2877 | |
OperationFailedException { |
2878 | 0 | checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey"); |
2879 | 0 | return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey); |
2880 | |
} |
2881 | |
|
2882 | |
@Override |
2883 | |
public List<SearchTypeInfo> getSearchTypesByResult( |
2884 | |
String searchResultTypeKey) throws DoesNotExistException, |
2885 | |
InvalidParameterException, MissingParameterException, |
2886 | |
OperationFailedException { |
2887 | 0 | checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey"); |
2888 | 0 | return searchManager.getSearchTypesByResult(searchResultTypeKey); |
2889 | |
} |
2890 | |
|
2891 | |
private void checkCluAlreadyAdded(CluSet cluSet, String cluId) |
2892 | |
throws OperationFailedException { |
2893 | 13 | for (CluSetJoinVersionIndClu join : cluSet.getCluVerIndIds()) { |
2894 | 13 | if (join.getCluVersionIndId().equals(cluId)) { |
2895 | 2 | throw new OperationFailedException("CluSet already contains Clu (id='" + cluId + "')"); |
2896 | |
} |
2897 | |
} |
2898 | 11 | } |
2899 | |
|
2900 | |
private void checkCluSetAlreadyAdded(CluSet cluSet, String cluSetIdToAdd) |
2901 | |
throws OperationFailedException { |
2902 | 27 | if(cluSet.getCluSets()!=null){ |
2903 | 27 | for (CluSet childCluSet : cluSet.getCluSets()) { |
2904 | 20 | if (childCluSet.getId().equals(cluSetIdToAdd)) { |
2905 | 2 | throw new OperationFailedException("CluSet (id=" + cluSet.getId() + |
2906 | |
") already contains CluSet (id='" + cluSetIdToAdd + "')"); |
2907 | |
} |
2908 | |
} |
2909 | |
} |
2910 | 25 | } |
2911 | |
|
2912 | |
private void checkCluSetCircularReference(CluSet addedCluSet, String hostCluSetId) |
2913 | |
throws CircularRelationshipException { |
2914 | 77 | if (addedCluSet.getId().equals(hostCluSetId)) { |
2915 | 2 | throw new CircularRelationshipException( |
2916 | |
"Cannot add a CluSet (id=" + hostCluSetId + ") to ifself"); |
2917 | |
} |
2918 | 75 | if(addedCluSet.getCluSets()!=null){ |
2919 | 75 | for (CluSet childSet : addedCluSet.getCluSets()) { |
2920 | 56 | if (childSet.getId().equals(hostCluSetId)) { |
2921 | 2 | throw new CircularRelationshipException( |
2922 | |
"CluSet (id=" + hostCluSetId + |
2923 | |
") already contains this CluSet (id=" + |
2924 | |
childSet.getId() + ")"); |
2925 | |
} |
2926 | 54 | checkCluSetCircularReference(childSet, hostCluSetId); |
2927 | |
} |
2928 | |
} |
2929 | 71 | } |
2930 | |
|
2931 | |
private void findClusInCluSet(List<String> clus, CluSet parentCluSet) |
2932 | |
throws DoesNotExistException { |
2933 | 2 | List<String> processedCluSetIds = new ArrayList<String>(); |
2934 | 2 | doFindClusInCluSet(processedCluSetIds, clus, parentCluSet); |
2935 | 2 | } |
2936 | |
|
2937 | |
private void doFindClusInCluSet(List<String> processedCluSetIds, |
2938 | |
List<String> clus, CluSet parentCluSet) { |
2939 | 4 | for (CluSetJoinVersionIndClu join : parentCluSet.getCluVerIndIds()) { |
2940 | 7 | if (!clus.contains(join.getCluVersionIndId())) { |
2941 | 5 | clus.add(join.getCluVersionIndId()); |
2942 | |
} |
2943 | |
} |
2944 | 4 | if(parentCluSet.getCluSets()!=null){ |
2945 | 4 | for (CluSet cluSet : parentCluSet.getCluSets()) { |
2946 | |
|
2947 | 2 | if (!processedCluSetIds.contains(cluSet.getId())) { |
2948 | 2 | processedCluSetIds.add(cluSet.getId()); |
2949 | 2 | doFindClusInCluSet(processedCluSetIds, clus, cluSet); |
2950 | |
} |
2951 | |
} |
2952 | |
} |
2953 | 4 | } |
2954 | |
|
2955 | |
private SearchResult doSearchProposalsByCourseCode(String courseCode) throws MissingParameterException{ |
2956 | 0 | if(courseCode==null||courseCode.isEmpty()){ |
2957 | 0 | return new SearchResult(); |
2958 | |
} |
2959 | |
|
2960 | 0 | SearchRequest sr = new SearchRequest("lu.search.mostCurrent.union"); |
2961 | 0 | sr.addParam("lu.queryParam.luOptionalCode", courseCode); |
2962 | 0 | sr.addParam("lu.queryParam.luOptionalType","kuali.lu.type.CreditCourse"); |
2963 | 0 | SearchResult results = search(sr); |
2964 | 0 | Map<String,String> cluIdToCodeMap = new HashMap<String,String>(); |
2965 | 0 | for(SearchResultRow row:results.getRows()){ |
2966 | 0 | String cluId = null; |
2967 | 0 | String code = null; |
2968 | 0 | for(SearchResultCell cell:row.getCells()){ |
2969 | 0 | if("lu.resultColumn.cluId".equals(cell.getKey())){ |
2970 | 0 | cluId = cell.getValue(); |
2971 | 0 | }else if("lu.resultColumn.luOptionalCode".equals(cell.getKey())){ |
2972 | 0 | code = cell.getValue(); |
2973 | |
} |
2974 | |
} |
2975 | |
|
2976 | 0 | if(code!=null&&cluId!=null){ |
2977 | 0 | cluIdToCodeMap.put(cluId, code); |
2978 | |
} |
2979 | 0 | } |
2980 | |
|
2981 | |
|
2982 | 0 | sr = new SearchRequest("proposal.search.proposalsForReferenceIds"); |
2983 | 0 | sr.addParam("proposal.queryParam.proposalOptionalReferenceIds", new ArrayList<String>(cluIdToCodeMap.keySet())); |
2984 | 0 | results = searchDispatcher.dispatchSearch(sr); |
2985 | 0 | for(SearchResultRow row:results.getRows()){ |
2986 | 0 | String cluId = null; |
2987 | 0 | SearchResultCell proposalNameCell = null; |
2988 | |
|
2989 | 0 | for(SearchResultCell cell:row.getCells()){ |
2990 | 0 | if("proposal.resultColumn.proposalOptionalName".equals(cell.getKey())){ |
2991 | 0 | proposalNameCell = cell; |
2992 | 0 | cell.setKey("lu.resultColumn.proposalOptionalName"); |
2993 | 0 | }else if("proposal.resultColumn.proposalOptionalReferenceId".equals(cell.getKey())){ |
2994 | 0 | cluId = cell.getValue(); |
2995 | 0 | cell.setKey("lu.resultColumn.proposalOptionalReferenceId"); |
2996 | 0 | }else if("proposal.resultColumn.proposalId".equals(cell.getKey())){ |
2997 | 0 | cell.setKey("lu.resultColumn.proposalId"); |
2998 | |
} |
2999 | |
} |
3000 | |
|
3001 | 0 | proposalNameCell.setValue(cluIdToCodeMap.get(cluId)+" ("+proposalNameCell.getValue()+")"); |
3002 | 0 | } |
3003 | |
|
3004 | 0 | return results; |
3005 | |
} |
3006 | |
|
3007 | |
@Override |
3008 | |
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
3009 | 781 | return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
3010 | |
} |
3011 | |
|
3012 | |
@Override |
3013 | |
public List<String> getObjectTypes() { |
3014 | 0 | return dictionaryServiceDelegate.getObjectTypes(); |
3015 | |
} |
3016 | |
|
3017 | |
public LuDao getLuDao() { |
3018 | 0 | return luDao; |
3019 | |
} |
3020 | |
|
3021 | |
public void setLuDao(LuDao luDao) { |
3022 | 4 | this.luDao = luDao; |
3023 | 4 | } |
3024 | |
|
3025 | |
@Override |
3026 | |
public SearchResult search(SearchRequest searchRequest) throws MissingParameterException { |
3027 | 18 | checkForMissingParameter(searchRequest, "searchRequest"); |
3028 | |
|
3029 | 18 | if(SEARCH_KEY_DEPENDENCY_ANALYSIS.equals(searchRequest.getSearchKey())){ |
3030 | 0 | String cluId = null; |
3031 | 0 | for(SearchParam param:searchRequest.getParams()){ |
3032 | 0 | if("lu.queryParam.luOptionalCluId".equals(param.getKey())){ |
3033 | 0 | cluId = (String)param.getValue(); |
3034 | 0 | break; |
3035 | |
} |
3036 | |
} |
3037 | |
try { |
3038 | 0 | return doDependencyAnalysisSearch(cluId); |
3039 | 0 | } catch (DoesNotExistException e) { |
3040 | 0 | throw new RuntimeException("Error performing search"); |
3041 | |
} |
3042 | 18 | }else if(SEARCH_KEY_BROWSE_PROGRAM.equals(searchRequest.getSearchKey())){ |
3043 | 0 | return doBrowseProgramSearch(); |
3044 | 18 | }else if(SEARCH_KEY_PROPOSALS_BY_COURSE_CODE.equals(searchRequest.getSearchKey())){ |
3045 | 0 | String courseCode = null; |
3046 | 0 | for(SearchParam param:searchRequest.getParams()){ |
3047 | 0 | if("lu.queryParam.luOptionalCode".equals(param.getKey())){ |
3048 | 0 | courseCode = (String)param.getValue(); |
3049 | 0 | break; |
3050 | |
} |
3051 | |
} |
3052 | 0 | return doSearchProposalsByCourseCode(courseCode); |
3053 | 18 | }else if(SEARCH_KEY_BROWSE_VERSIONS.equals(searchRequest.getSearchKey())){ |
3054 | 1 | return doBrowseVersionsSearch(searchRequest); |
3055 | 17 | }else if(SEARCH_KEY_LU_RESULT_COMPONENTS.equals(searchRequest.getSearchKey())){ |
3056 | 0 | return doResultComponentTypesForCluSearch(searchRequest); |
3057 | |
} |
3058 | 17 | return searchManager.search(searchRequest, luDao); |
3059 | |
} |
3060 | |
|
3061 | |
|
3062 | |
|
3063 | |
|
3064 | |
|
3065 | |
|
3066 | |
|
3067 | |
|
3068 | |
private SearchResult doResultComponentTypesForCluSearch(SearchRequest cluSearchRequest) throws MissingParameterException { |
3069 | |
|
3070 | 0 | SearchResult searchResult = searchManager.search(cluSearchRequest, luDao); |
3071 | |
|
3072 | |
|
3073 | 0 | Map<String,List<SearchResultRow>> rcIdToRowMapping = new HashMap<String,List<SearchResultRow>>(); |
3074 | |
|
3075 | |
|
3076 | 0 | for(SearchResultRow row:searchResult.getRows()){ |
3077 | 0 | for(SearchResultCell cell:row.getCells()){ |
3078 | 0 | if(cell.getValue()!=null && |
3079 | |
"lu.resultColumn.resultComponentId".equals(cell.getKey())) { |
3080 | 0 | List<SearchResultRow> rows = rcIdToRowMapping.get(cell.getValue()); |
3081 | 0 | if(rows==null){ |
3082 | 0 | rows = new ArrayList<SearchResultRow>(); |
3083 | 0 | rcIdToRowMapping.put(cell.getValue(), rows); |
3084 | |
} |
3085 | 0 | rows.add(row); |
3086 | 0 | } |
3087 | |
} |
3088 | |
} |
3089 | |
|
3090 | |
|
3091 | 0 | SearchRequest lrcSearchRequest = new SearchRequest(SEARCH_KEY_LRC_RESULT_COMPONENT); |
3092 | 0 | lrcSearchRequest.addParam("lrc.queryParam.resultComponent.idRestrictionList", new ArrayList<String>(rcIdToRowMapping.keySet())); |
3093 | 0 | SearchResult lrcSearchResults = searchDispatcher.dispatchSearch(lrcSearchRequest); |
3094 | |
|
3095 | |
|
3096 | 0 | for(SearchResultRow row:lrcSearchResults.getRows()){ |
3097 | 0 | String lrcId = null; |
3098 | 0 | String lrcName = null; |
3099 | 0 | for(SearchResultCell cell:row.getCells()){ |
3100 | 0 | if("lrc.resultColumn.resultComponent.id".equals(cell.getKey())){ |
3101 | 0 | lrcId = cell.getValue(); |
3102 | 0 | }else if("lrc.resultColumn.resultComponent.name".equals(cell.getKey())){ |
3103 | 0 | lrcName = cell.getValue(); |
3104 | |
} |
3105 | |
} |
3106 | 0 | if(lrcId!=null && rcIdToRowMapping.get(lrcId)!=null){ |
3107 | 0 | for(SearchResultRow resultRow : rcIdToRowMapping.get(lrcId)){ |
3108 | 0 | resultRow.addCell("lu.resultColumn.resultComponentName",lrcName); |
3109 | |
} |
3110 | |
} |
3111 | 0 | } |
3112 | |
|
3113 | 0 | return searchResult; |
3114 | |
} |
3115 | |
|
3116 | |
|
3117 | |
|
3118 | |
|
3119 | |
|
3120 | |
|
3121 | |
|
3122 | |
private SearchResult doBrowseVersionsSearch(SearchRequest searchRequest) throws MissingParameterException { |
3123 | 1 | SearchResult searchResult = searchManager.search(searchRequest, luDao); |
3124 | |
|
3125 | 1 | Map<String,List<SearchResultCell>> atpIdToCellMapping = new HashMap<String,List<SearchResultCell>>(); |
3126 | |
|
3127 | 1 | for(SearchResultRow row:searchResult.getRows()){ |
3128 | 3 | for(SearchResultCell cell:row.getCells()){ |
3129 | 48 | if(cell.getValue()!=null && |
3130 | |
("lu.resultColumn.luOptionalExpFirstAtpDisplay".equals(cell.getKey()) || |
3131 | |
"lu.resultColumn.luOptionalLastAtpDisplay".equals(cell.getKey()))) { |
3132 | 0 | List<SearchResultCell> cells = atpIdToCellMapping.get(cell.getValue()); |
3133 | 0 | if(cells==null){ |
3134 | 0 | cells = new ArrayList<SearchResultCell>(); |
3135 | 0 | atpIdToCellMapping.put(cell.getValue(), cells); |
3136 | |
} |
3137 | 0 | cells.add(cell); |
3138 | 48 | } |
3139 | |
} |
3140 | |
} |
3141 | |
|
3142 | |
|
3143 | 1 | SearchRequest atpSearchRequest = new SearchRequest("atp.search.advancedAtpSearch"); |
3144 | 1 | atpSearchRequest.addParam("atp.advancedAtpSearchParam.optionalAtpIds", new ArrayList<String>(atpIdToCellMapping.keySet())); |
3145 | 1 | SearchResult atpSearchResults = searchDispatcher.dispatchSearch(atpSearchRequest); |
3146 | 1 | for(SearchResultRow row:atpSearchResults.getRows()){ |
3147 | 1 | String atpId = null; |
3148 | 1 | String atpName = null; |
3149 | 1 | for(SearchResultCell cell:row.getCells()){ |
3150 | 0 | if("atp.resultColumn.atpId".equals(cell.getKey())){ |
3151 | 0 | atpId = cell.getValue(); |
3152 | 0 | }else if("atp.resultColumn.atpShortName".equals(cell.getKey())){ |
3153 | 0 | atpName = cell.getValue(); |
3154 | |
} |
3155 | |
} |
3156 | 1 | if(atpId!=null && atpIdToCellMapping.get(atpId)!=null){ |
3157 | 0 | for(SearchResultCell cell : atpIdToCellMapping.get(atpId)){ |
3158 | 0 | cell.setValue(atpName); |
3159 | |
} |
3160 | |
} |
3161 | 1 | } |
3162 | |
|
3163 | 1 | return searchResult; |
3164 | |
} |
3165 | |
|
3166 | |
private SearchResult doBrowseProgramSearch() throws MissingParameterException { |
3167 | |
|
3168 | 0 | SearchResult programSearchResults = searchManager.search(new SearchRequest(SEARCH_KEY_BROWSE_PROGRAM), luDao); |
3169 | |
|
3170 | |
|
3171 | 0 | SearchResult variationSearchResults = searchManager.search(new SearchRequest(SEARCH_KEY_BROWSE_VARIATIONS), luDao); |
3172 | |
|
3173 | |
|
3174 | 0 | Map<String,List<String>> variationMapping = new HashMap<String,List<String>>(); |
3175 | 0 | for(SearchResultRow row:variationSearchResults.getRows()){ |
3176 | 0 | String programId = null; |
3177 | 0 | String variationLongName = null; |
3178 | 0 | for(SearchResultCell cell:row.getCells()){ |
3179 | 0 | if("lu.resultColumn.cluId".equals(cell.getKey())){ |
3180 | 0 | programId = cell.getValue(); |
3181 | 0 | }else if("lu.resultColumn.luOptionalLongName".equals(cell.getKey())){ |
3182 | 0 | variationLongName = cell.getValue(); |
3183 | |
} |
3184 | |
} |
3185 | 0 | List<String> variationLongNames = variationMapping.get(programId); |
3186 | 0 | if(variationLongNames == null){ |
3187 | 0 | variationLongNames = new ArrayList<String>(); |
3188 | 0 | variationMapping.put(programId, variationLongNames); |
3189 | |
} |
3190 | 0 | variationLongNames.add(variationLongName); |
3191 | 0 | } |
3192 | |
|
3193 | |
|
3194 | |
|
3195 | 0 | SearchRequest resultComponentSearchRequest = new SearchRequest(SEARCH_KEY_LRC_RESULT_COMPONENT); |
3196 | 0 | resultComponentSearchRequest.addParam("lrc.queryParam.resultComponent.type", "kuali.resultComponentType.degree"); |
3197 | 0 | SearchResult resultComponentSearchResults = searchDispatcher.dispatchSearch(resultComponentSearchRequest); |
3198 | |
|
3199 | |
|
3200 | 0 | Map<String,String> resultComponentMapping = new HashMap<String,String>(); |
3201 | 0 | for(SearchResultRow row:resultComponentSearchResults.getRows()){ |
3202 | 0 | String resultComponentTypeId = null; |
3203 | 0 | String resultComponentTypeName = null; |
3204 | 0 | for(SearchResultCell cell:row.getCells()){ |
3205 | 0 | if("lrc.resultColumn.resultComponent.id".equals(cell.getKey())){ |
3206 | 0 | resultComponentTypeId = cell.getValue(); |
3207 | 0 | }else if("lrc.resultColumn.resultComponent.name".equals(cell.getKey())){ |
3208 | 0 | resultComponentTypeName = cell.getValue(); |
3209 | |
} |
3210 | |
} |
3211 | 0 | resultComponentMapping.put(resultComponentTypeId, resultComponentTypeName); |
3212 | 0 | } |
3213 | |
|
3214 | 0 | Map<String, Set<SearchResultCell>> orgIdToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
3215 | 0 | Map<String, Set<SearchResultCell>> resultComponentToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
3216 | 0 | Map<String, Set<SearchResultCell>> campusToCellMapping = new HashMap<String, Set<SearchResultCell>>(); |
3217 | 0 | Map<String, SearchResultCell> progIdToOrgCellMapping = new HashMap<String, SearchResultCell>(); |
3218 | 0 | Map<String, SearchResultCell> progIdToResultComponentCellMapping = new HashMap<String, SearchResultCell>(); |
3219 | 0 | Map<String, SearchResultCell> progIdToCampusCellMapping = new HashMap<String, SearchResultCell>(); |
3220 | |
|
3221 | |
|
3222 | |
|
3223 | 0 | for(Iterator<SearchResultRow> rowIter = programSearchResults.getRows().iterator();rowIter.hasNext();){ |
3224 | 0 | SearchResultRow row = rowIter.next(); |
3225 | 0 | String programId = null; |
3226 | 0 | String orgId = null; |
3227 | 0 | String resultComponentName = null; |
3228 | 0 | String campusCode = null; |
3229 | 0 | SearchResultCell orgCell = null; |
3230 | 0 | SearchResultCell resultComponentCell = null; |
3231 | 0 | SearchResultCell variationCell = null; |
3232 | 0 | SearchResultCell campusLocationCell = null; |
3233 | |
|
3234 | 0 | for(SearchResultCell cell:row.getCells()){ |
3235 | 0 | if("lu.resultColumn.cluId".equals(cell.getKey())){ |
3236 | 0 | programId = cell.getValue(); |
3237 | 0 | }else if("lu.resultColumn.luOptionalAdminOrg".equals(cell.getKey())){ |
3238 | 0 | orgId = cell.getValue(); |
3239 | 0 | orgCell = cell; |
3240 | 0 | }else if("lu.resultColumn.resultComponentId".equals(cell.getKey())){ |
3241 | 0 | resultComponentName = resultComponentMapping.get(cell.getValue()); |
3242 | 0 | resultComponentCell = cell; |
3243 | 0 | }else if("lu.resultColumn.variationId".equals(cell.getKey())){ |
3244 | 0 | variationCell = cell; |
3245 | 0 | }else if("lu.resultColumn.luOptionalCampusLocation".equals(cell.getKey())){ |
3246 | 0 | campusLocationCell = cell; |
3247 | 0 | campusCode = cell.getValue(); |
3248 | |
} |
3249 | |
} |
3250 | 0 | if(!progIdToOrgCellMapping.containsKey(programId)){ |
3251 | |
|
3252 | 0 | List<String> variations = variationMapping.get(programId); |
3253 | 0 | variationCell.setValue(""); |
3254 | 0 | if(variations!=null){ |
3255 | 0 | for(Iterator<String> variationIter = variations.iterator();variationIter.hasNext();){ |
3256 | 0 | String variation = variationIter.next(); |
3257 | 0 | if(variationIter.hasNext()){ |
3258 | 0 | variation += "<br/>"; |
3259 | |
} |
3260 | 0 | variationCell.setValue(variationCell.getValue()+variation); |
3261 | 0 | } |
3262 | |
} |
3263 | |
|
3264 | |
|
3265 | 0 | Set<SearchResultCell> orgCells = orgIdToCellMapping.get(orgId); |
3266 | 0 | if(orgCells == null){ |
3267 | 0 | orgCells = new HashSet<SearchResultCell>(); |
3268 | 0 | orgIdToCellMapping.put(orgId, orgCells); |
3269 | |
} |
3270 | 0 | orgCells.add(orgCell); |
3271 | 0 | orgCell.setValue(null); |
3272 | |
|
3273 | |
|
3274 | |
|
3275 | 0 | Set<SearchResultCell> campusCells = campusToCellMapping.get(campusCode); |
3276 | 0 | if(campusCells == null){ |
3277 | 0 | campusCells = new HashSet<SearchResultCell>(); |
3278 | 0 | campusToCellMapping.put(campusCode, campusCells); |
3279 | |
} |
3280 | 0 | campusCells.add(campusLocationCell); |
3281 | 0 | campusLocationCell.setValue(null); |
3282 | |
|
3283 | |
|
3284 | 0 | Set<SearchResultCell> resultCells = resultComponentToCellMapping.get(resultComponentName); |
3285 | 0 | if(resultCells == null){ |
3286 | 0 | resultCells = new HashSet<SearchResultCell>(); |
3287 | 0 | resultComponentToCellMapping.put(resultComponentName, resultCells); |
3288 | |
} |
3289 | 0 | resultCells.add(resultComponentCell); |
3290 | 0 | resultComponentCell.setValue(null); |
3291 | |
|
3292 | 0 | progIdToOrgCellMapping.put(programId, orgCell); |
3293 | 0 | progIdToResultComponentCellMapping.put(programId, resultComponentCell); |
3294 | 0 | progIdToCampusCellMapping.put(programId, campusLocationCell); |
3295 | 0 | }else{ |
3296 | |
|
3297 | |
|
3298 | 0 | Set<SearchResultCell> resultCells = resultComponentToCellMapping.get(resultComponentName); |
3299 | 0 | if(resultCells == null){ |
3300 | 0 | resultCells = new HashSet<SearchResultCell>(); |
3301 | 0 | resultComponentToCellMapping.put(resultComponentName, resultCells); |
3302 | |
} |
3303 | 0 | resultCells.add(progIdToResultComponentCellMapping.get(programId)); |
3304 | |
|
3305 | |
|
3306 | 0 | Set<SearchResultCell> orgCells = orgIdToCellMapping.get(orgId); |
3307 | 0 | if(orgCells == null){ |
3308 | 0 | orgCells = new HashSet<SearchResultCell>(); |
3309 | 0 | orgIdToCellMapping.put(orgId, orgCells); |
3310 | |
} |
3311 | 0 | orgCells.add(progIdToOrgCellMapping.get(programId)); |
3312 | |
|
3313 | |
|
3314 | 0 | Set<SearchResultCell> campusCells = campusToCellMapping.get(campusCode); |
3315 | 0 | if(campusCells == null){ |
3316 | 0 | campusCells = new HashSet<SearchResultCell>(); |
3317 | 0 | campusToCellMapping.put(campusCode, campusCells); |
3318 | |
} |
3319 | 0 | campusCells.add(progIdToCampusCellMapping.get(programId)); |
3320 | |
|
3321 | |
|
3322 | 0 | rowIter.remove(); |
3323 | |
} |
3324 | 0 | } |
3325 | |
|
3326 | 0 | if(!resultComponentToCellMapping.isEmpty()){ |
3327 | 0 | List<String> resultComponentNames = new ArrayList<String>(resultComponentToCellMapping.keySet()); |
3328 | 0 | Collections.sort(resultComponentNames); |
3329 | 0 | for(String resultComponentName:resultComponentNames){ |
3330 | |
|
3331 | 0 | Set<SearchResultCell> cells = resultComponentToCellMapping.get(resultComponentName); |
3332 | 0 | if(cells!=null){ |
3333 | 0 | for(SearchResultCell cell:cells){ |
3334 | 0 | if(cell.getValue()==null){ |
3335 | 0 | cell.setValue(resultComponentName); |
3336 | |
}else{ |
3337 | 0 | cell.setValue(cell.getValue()+"<br/>"+resultComponentName); |
3338 | |
} |
3339 | |
} |
3340 | |
} |
3341 | 0 | } |
3342 | |
} |
3343 | |
|
3344 | 0 | if(!campusToCellMapping.isEmpty()){ |
3345 | 0 | List<String> campusCodes = new ArrayList<String>(campusToCellMapping.keySet()); |
3346 | 0 | Collections.sort(campusCodes); |
3347 | 0 | for(String campusCode:campusCodes){ |
3348 | |
|
3349 | 0 | Set<SearchResultCell> cells = campusToCellMapping.get(campusCode); |
3350 | 0 | if(cells!=null){ |
3351 | 0 | for(SearchResultCell cell:cells){ |
3352 | 0 | if(cell.getValue()==null){ |
3353 | 0 | cell.setValue(campusCode); |
3354 | |
}else{ |
3355 | 0 | cell.setValue(cell.getValue()+"<br/>"+campusCode); |
3356 | |
} |
3357 | |
} |
3358 | |
} |
3359 | 0 | } |
3360 | |
} |
3361 | |
|
3362 | |
|
3363 | 0 | if(!orgIdToCellMapping.isEmpty()){ |
3364 | |
|
3365 | 0 | SearchRequest orgIdTranslationSearchRequest = new SearchRequest("org.search.generic"); |
3366 | 0 | orgIdTranslationSearchRequest.addParam("org.queryParam.orgOptionalIds", new ArrayList<String>(orgIdToCellMapping.keySet())); |
3367 | 0 | orgIdTranslationSearchRequest.setSortColumn("org.resultColumn.orgShortName"); |
3368 | 0 | SearchResult orgIdTranslationSearchResult = searchDispatcher.dispatchSearch(orgIdTranslationSearchRequest); |
3369 | |
|
3370 | |
|
3371 | 0 | for(SearchResultRow row:orgIdTranslationSearchResult.getRows()){ |
3372 | |
|
3373 | |
|
3374 | 0 | String orgId=""; |
3375 | 0 | String orgName=""; |
3376 | 0 | for(SearchResultCell cell:row.getCells()){ |
3377 | 0 | if("org.resultColumn.orgId".equals(cell.getKey())){ |
3378 | 0 | orgId = cell.getValue(); |
3379 | 0 | continue; |
3380 | 0 | }else if("org.resultColumn.orgShortName".equals(cell.getKey())){ |
3381 | 0 | orgName = cell.getValue(); |
3382 | |
} |
3383 | |
} |
3384 | |
|
3385 | |
|
3386 | 0 | Set<SearchResultCell> cells = orgIdToCellMapping.get(orgId); |
3387 | 0 | if(cells!=null){ |
3388 | 0 | for(SearchResultCell cell:cells){ |
3389 | 0 | if(cell.getValue()==null){ |
3390 | 0 | cell.setValue(orgName); |
3391 | |
}else{ |
3392 | 0 | cell.setValue(cell.getValue()+"<br/>"+orgName); |
3393 | |
} |
3394 | |
} |
3395 | |
} |
3396 | 0 | } |
3397 | |
} |
3398 | |
|
3399 | 0 | return programSearchResults; |
3400 | |
} |
3401 | |
|
3402 | |
|
3403 | |
private SearchResult doDependencyAnalysisSearch(String cluId) throws MissingParameterException, DoesNotExistException { |
3404 | |
|
3405 | 0 | checkForMissingParameter(cluId, "cluId"); |
3406 | |
|
3407 | 0 | Clu triggerClu = luDao.fetch(Clu.class, cluId); |
3408 | |
|
3409 | 0 | List<String> cluVersionIndIds = new ArrayList<String>(); |
3410 | 0 | cluVersionIndIds.add(triggerClu.getVersion().getVersionIndId()); |
3411 | |
|
3412 | |
|
3413 | 0 | List<CluSet> cluSets = luDao.getCluSetsByCluVersionIndId(cluVersionIndIds); |
3414 | |
|
3415 | |
|
3416 | 0 | Map<String, CluSet> cluSetMap = new HashMap<String, CluSet>(); |
3417 | 0 | if(cluSets!=null){ |
3418 | 0 | for(CluSet cluSet:cluSets){ |
3419 | 0 | cluSetMap.put(cluSet.getId(), cluSet); |
3420 | |
} |
3421 | |
} |
3422 | |
|
3423 | |
|
3424 | 0 | List<CluSet> dynamicCluSets = luDao.getAllDynamicCluSets(); |
3425 | 0 | if(dynamicCluSets!=null){ |
3426 | 0 | for(CluSet cluSet:dynamicCluSets){ |
3427 | 0 | MembershipQueryInfo queryInfo = LuServiceAssembler.toMembershipQueryInfo(cluSet.getMembershipQuery()); |
3428 | 0 | List<String> memberCluVersionIndIds = getMembershipQuerySearchResult(queryInfo); |
3429 | 0 | if(memberCluVersionIndIds!=null){ |
3430 | 0 | for(String cluVersionIndId:cluVersionIndIds){ |
3431 | 0 | if(memberCluVersionIndIds.contains(cluVersionIndId)){ |
3432 | 0 | cluSetMap.put(cluSet.getId(),cluSet); |
3433 | 0 | break; |
3434 | |
} |
3435 | |
} |
3436 | |
} |
3437 | 0 | } |
3438 | |
} |
3439 | |
|
3440 | |
|
3441 | |
|
3442 | |
|
3443 | |
|
3444 | |
|
3445 | 0 | SearchRequest statementSearchRequest = new SearchRequest("stmt.search.dependencyAnalysis"); |
3446 | |
|
3447 | 0 | statementSearchRequest.addParam("stmt.queryParam.cluSetIds", new ArrayList<String>(cluSetMap.keySet())); |
3448 | 0 | statementSearchRequest.addParam("stmt.queryParam.cluVersionIndIds", cluVersionIndIds); |
3449 | |
|
3450 | 0 | SearchResult statementSearchResult = searchDispatcher.dispatchSearch(statementSearchRequest); |
3451 | |
|
3452 | |
|
3453 | 0 | SearchResult searchResult = new SearchResult(); |
3454 | |
|
3455 | 0 | Map<String,List<SearchResultCell>> orgIdToCellMapping = new HashMap<String,List<SearchResultCell>>(); |
3456 | |
|
3457 | |
|
3458 | |
|
3459 | |
|
3460 | 0 | Set<String> processed = new HashSet<String>(); |
3461 | 0 | for(SearchResultRow stmtRow:statementSearchResult.getRows()){ |
3462 | |
|
3463 | |
|
3464 | 0 | String refObjId = null; |
3465 | 0 | String statementType = null; |
3466 | 0 | String statementTypeName = null; |
3467 | 0 | String rootId = null; |
3468 | 0 | String requirementComponentIds = null; |
3469 | |
|
3470 | 0 | for(SearchResultCell stmtCell:stmtRow.getCells()){ |
3471 | 0 | if("stmt.resultColumn.refObjId".equals(stmtCell.getKey())){ |
3472 | 0 | refObjId = stmtCell.getValue(); |
3473 | 0 | continue; |
3474 | 0 | }else if("stmt.resultColumn.statementTypeId".equals(stmtCell.getKey())){ |
3475 | 0 | statementType = stmtCell.getValue(); |
3476 | 0 | continue; |
3477 | 0 | }else if("stmt.resultColumn.statementTypeName".equals(stmtCell.getKey())){ |
3478 | 0 | statementTypeName = stmtCell.getValue(); |
3479 | 0 | continue; |
3480 | 0 | }else if("stmt.resultColumn.rootId".equals(stmtCell.getKey())){ |
3481 | 0 | rootId = stmtCell.getValue(); |
3482 | 0 | continue; |
3483 | 0 | }else if("stmt.resultColumn.requirementComponentIds".equals(stmtCell.getKey())){ |
3484 | 0 | requirementComponentIds = stmtCell.getValue(); |
3485 | |
} |
3486 | |
} |
3487 | |
|
3488 | |
|
3489 | 0 | Clu clu = luDao.fetch(Clu.class, refObjId); |
3490 | |
|
3491 | |
|
3492 | 0 | if("kuali.lu.type.Requirement".equals(clu.getLuType().getId())){ |
3493 | |
|
3494 | 0 | List<Clu> clus = luDao.getClusByRelatedCluId(clu.getId(), "kuali.lu.lu.relation.type.hasProgramRequirement"); |
3495 | |
|
3496 | 0 | rootId = clu.getId(); |
3497 | |
|
3498 | 0 | if(clus==null||clus.size()==0){ |
3499 | 0 | throw new RuntimeException("Statement Dependency clu found, but no parent Program exists"); |
3500 | 0 | }else if(clus.size()>1){ |
3501 | 0 | throw new RuntimeException("Statement Dependency clu can only have one parent Program relation"); |
3502 | |
} |
3503 | 0 | clu = clus.get(0); |
3504 | |
} |
3505 | |
|
3506 | |
|
3507 | 0 | String rowId = clu.getId()+"|"+statementType+"|"+rootId; |
3508 | |
|
3509 | 0 | if("Active".equals(clu.getState()) && !processed.contains(rowId)){ |
3510 | |
|
3511 | 0 | processed.add(rowId); |
3512 | |
|
3513 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
3514 | |
|
3515 | |
|
3516 | 0 | resultRow.addCell("lu.resultColumn.cluId",clu.getId()); |
3517 | 0 | resultRow.addCell("lu.resultColumn.cluType",clu.getLuType().getId()); |
3518 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode",clu.getOfficialIdentifier().getCode()); |
3519 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName",clu.getOfficialIdentifier().getShortName()); |
3520 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName",clu.getOfficialIdentifier().getLongName()); |
3521 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType",statementType); |
3522 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName",statementTypeName); |
3523 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRootId",rootId); |
3524 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRequirementComponentIds",requirementComponentIds); |
3525 | |
|
3526 | |
try{ |
3527 | |
|
3528 | |
|
3529 | 0 | List<String> relatedClus = this.getCluIdsByRelation(clu.getId(), "kuali.lu.lu.relation.type.hasVariationProgram"); |
3530 | 0 | for(String parentCluId: relatedClus){ |
3531 | 0 | resultRow.addCell("lu.resultColumn.parentCluId", parentCluId); |
3532 | |
} |
3533 | 0 | } catch(InvalidParameterException ex){ |
3534 | 0 | throw new RuntimeException("Error performing getCluIdsByRelation search", ex); |
3535 | 0 | } catch (OperationFailedException e) { |
3536 | 0 | throw new RuntimeException("Error performing getCluIdsByRelation search", e); |
3537 | 0 | } |
3538 | |
|
3539 | |
|
3540 | |
|
3541 | 0 | SearchResultCell orgIdsCell = new SearchResultCell("lu.resultColumn.luOptionalOversightCommitteeIds",null); |
3542 | 0 | resultRow.getCells().add(orgIdsCell); |
3543 | |
|
3544 | |
|
3545 | 0 | SearchResultCell orgNamesCell = new SearchResultCell("lu.resultColumn.luOptionalOversightCommitteeNames",null); |
3546 | 0 | resultRow.getCells().add(orgNamesCell); |
3547 | |
|
3548 | |
|
3549 | |
|
3550 | |
|
3551 | 0 | boolean differentAdminOrg = true; |
3552 | 0 | for(CluAdminOrg adminOrg:clu.getAdminOrgs()){ |
3553 | 0 | if("kuali.adminOrg.type.CurriculumOversight".equals(adminOrg.getType()) || |
3554 | |
"kuali.adminOrg.type.CurriculumOversightUnit".equals(adminOrg.getType())){ |
3555 | |
|
3556 | |
|
3557 | 0 | List<SearchResultCell> cells = orgIdToCellMapping.get(adminOrg.getOrgId()); |
3558 | 0 | if(cells == null){ |
3559 | 0 | cells = new ArrayList<SearchResultCell>(); |
3560 | 0 | orgIdToCellMapping.put(adminOrg.getOrgId(), cells); |
3561 | |
} |
3562 | 0 | cells.add(orgNamesCell); |
3563 | |
|
3564 | |
|
3565 | 0 | if(orgIdsCell.getValue()==null){ |
3566 | 0 | orgIdsCell.setValue(adminOrg.getId()); |
3567 | |
}else{ |
3568 | 0 | orgIdsCell.setValue(orgIdsCell.getValue()+","+adminOrg.getId()); |
3569 | |
} |
3570 | |
|
3571 | 0 | for(CluAdminOrg triggerAdminOrg:triggerClu.getAdminOrgs()){ |
3572 | 0 | if(triggerAdminOrg.getOrgId().equals(adminOrg.getOrgId())){ |
3573 | 0 | differentAdminOrg = false; |
3574 | |
} |
3575 | |
} |
3576 | 0 | } |
3577 | |
} |
3578 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyRequirementDifferentAdminOrg", String.valueOf(differentAdminOrg)); |
3579 | |
|
3580 | |
|
3581 | 0 | searchResult.getRows().add(resultRow); |
3582 | |
} |
3583 | 0 | } |
3584 | |
|
3585 | |
|
3586 | 0 | if(!orgIdToCellMapping.isEmpty()){ |
3587 | |
|
3588 | 0 | SearchRequest orgIdTranslationSearchRequest = new SearchRequest("org.search.generic"); |
3589 | 0 | orgIdTranslationSearchRequest.addParam("org.queryParam.orgOptionalIds", new ArrayList<String>(orgIdToCellMapping.keySet())); |
3590 | 0 | SearchResult orgIdTranslationSearchResult = searchDispatcher.dispatchSearch(orgIdTranslationSearchRequest); |
3591 | |
|
3592 | |
|
3593 | 0 | for(SearchResultRow row:orgIdTranslationSearchResult.getRows()){ |
3594 | |
|
3595 | |
|
3596 | 0 | String orgId=""; |
3597 | 0 | String orgName=""; |
3598 | 0 | for(SearchResultCell cell:row.getCells()){ |
3599 | 0 | if("org.resultColumn.orgId".equals(cell.getKey())){ |
3600 | 0 | orgId = cell.getValue(); |
3601 | 0 | continue; |
3602 | 0 | }else if("org.resultColumn.orgShortName".equals(cell.getKey())){ |
3603 | 0 | orgName = cell.getValue(); |
3604 | |
} |
3605 | |
} |
3606 | |
|
3607 | |
|
3608 | 0 | List<SearchResultCell> cells = orgIdToCellMapping.get(orgId); |
3609 | 0 | if(cells!=null){ |
3610 | 0 | for(SearchResultCell cell:cells){ |
3611 | 0 | if(cell.getValue()==null){ |
3612 | 0 | cell.setValue(orgName); |
3613 | |
}else{ |
3614 | 0 | cell.setValue(cell.getValue()+", "+orgName); |
3615 | |
} |
3616 | |
} |
3617 | |
} |
3618 | 0 | } |
3619 | |
} |
3620 | |
|
3621 | |
|
3622 | 0 | for(CluSet cluSet:cluSetMap.values()){ |
3623 | 0 | if(!"AdHock".equals(cluSet.getName())){ |
3624 | |
|
3625 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
3626 | |
|
3627 | 0 | resultRow.addCell("lu.resultColumn.cluId",cluSet.getId()); |
3628 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName",cluSet.getName()); |
3629 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName",cluSet.getName()); |
3630 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType","cluSet"); |
3631 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "Course Set"); |
3632 | |
|
3633 | 0 | searchResult.getRows().add(resultRow); |
3634 | 0 | } |
3635 | |
} |
3636 | |
|
3637 | |
|
3638 | 0 | List<String> luStateList = new ArrayList(); |
3639 | 0 | luStateList.add(DtoConstants.STATE_ACTIVE); |
3640 | 0 | luStateList.add(DtoConstants.STATE_APPROVED); |
3641 | 0 | List<Clu> joints = luDao.getClusByRelationSt(cluId, "kuali.lu.relation.type.co-located", luStateList); |
3642 | 0 | if(joints!=null){ |
3643 | 0 | for(Clu clu:joints){ |
3644 | |
|
3645 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
3646 | |
|
3647 | 0 | resultRow.addCell("lu.resultColumn.cluId", clu.getId()); |
3648 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode", clu.getOfficialIdentifier().getCode()); |
3649 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName", clu.getOfficialIdentifier().getShortName()); |
3650 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName", clu.getOfficialIdentifier().getLongName()); |
3651 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType", "joint"); |
3652 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "jointly offered"); |
3653 | |
|
3654 | 0 | searchResult.getRows().add(resultRow); |
3655 | 0 | } |
3656 | |
} |
3657 | |
|
3658 | |
|
3659 | 0 | for(CluIdentifier altId:triggerClu.getAlternateIdentifiers()){ |
3660 | 0 | if("kuali.lu.type.CreditCourse.identifier.crosslisting".equals(altId.getType())){ |
3661 | 0 | SearchResultRow resultRow = new SearchResultRow(); |
3662 | |
|
3663 | 0 | resultRow.addCell("lu.resultColumn.luOptionalCode", altId.getCode()); |
3664 | 0 | resultRow.addCell("lu.resultColumn.luOptionalShortName", altId.getShortName()); |
3665 | 0 | resultRow.addCell("lu.resultColumn.luOptionalLongName", altId.getLongName()); |
3666 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyType", "crossListed"); |
3667 | 0 | resultRow.addCell("lu.resultColumn.luOptionalDependencyTypeName", "cross-listed"); |
3668 | |
|
3669 | 0 | searchResult.getRows().add(resultRow); |
3670 | 0 | } |
3671 | |
} |
3672 | |
|
3673 | |
|
3674 | 0 | Collections.sort(searchResult.getRows(), new SearchResultRowComparator("lu.resultColumn.luOptionalCode")); |
3675 | |
|
3676 | 0 | return searchResult; |
3677 | |
} |
3678 | |
|
3679 | 8 | public class SearchResultRowComparator implements Comparator<SearchResultRow>{ |
3680 | |
private String sortColumn; |
3681 | |
|
3682 | 0 | SearchResultRowComparator(String sortColumn){ |
3683 | 0 | super(); |
3684 | 0 | this.sortColumn = sortColumn; |
3685 | 0 | } |
3686 | |
|
3687 | |
@Override |
3688 | |
public int compare(SearchResultRow o1, SearchResultRow o2) { |
3689 | 0 | String o1SortValue = null; |
3690 | 0 | String o2SortValue = null; |
3691 | 0 | for(SearchResultCell cell:o1.getCells()){ |
3692 | 0 | if(sortColumn.equals(cell.getKey())){ |
3693 | 0 | o1SortValue = cell.getValue(); |
3694 | 0 | break; |
3695 | |
} |
3696 | |
} |
3697 | 0 | for(SearchResultCell cell:o2.getCells()){ |
3698 | 0 | if(sortColumn.equals(cell.getKey())){ |
3699 | 0 | o2SortValue = cell.getValue(); |
3700 | 0 | break; |
3701 | |
} |
3702 | |
} |
3703 | 0 | if(o1SortValue!=null){ |
3704 | 0 | if(o2SortValue==null){ |
3705 | 0 | return 1; |
3706 | |
} |
3707 | 0 | return o1SortValue.compareTo(o2SortValue); |
3708 | 0 | }if(o2SortValue==null){ |
3709 | 0 | return 0; |
3710 | |
} |
3711 | 0 | return -1; |
3712 | |
} |
3713 | |
|
3714 | |
} |
3715 | |
|
3716 | |
|
3717 | |
|
3718 | |
|
3719 | |
|
3720 | |
|
3721 | |
|
3722 | |
|
3723 | |
|
3724 | |
private void checkForMissingParameter(Object param, String paramName) |
3725 | |
throws MissingParameterException { |
3726 | 5198 | if (param == null) { |
3727 | 27 | throw new MissingParameterException(paramName + " can not be null"); |
3728 | |
} |
3729 | 5171 | } |
3730 | |
|
3731 | |
|
3732 | |
|
3733 | |
|
3734 | |
|
3735 | |
|
3736 | |
private void checkForEmptyList(Object param, String paramName) |
3737 | |
throws MissingParameterException { |
3738 | 214 | if (param != null && param instanceof List<?> |
3739 | |
&& ((List<?>) param).size() == 0) { |
3740 | 0 | throw new MissingParameterException(paramName |
3741 | |
+ " can not be an empty list"); |
3742 | |
} |
3743 | 214 | } |
3744 | |
|
3745 | |
@Override |
3746 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
3747 | |
public StatusInfo addCluSetsToCluSet(String cluSetId, List<String> cluSetIdList) |
3748 | |
throws CircularRelationshipException, |
3749 | |
DoesNotExistException, InvalidParameterException, |
3750 | |
MissingParameterException, OperationFailedException, |
3751 | |
PermissionDeniedException, UnsupportedActionException { |
3752 | |
|
3753 | 7 | checkForMissingParameter(cluSetId, "cluSetId"); |
3754 | 7 | checkForMissingParameter(cluSetIdList, "cluSetIdList"); |
3755 | |
|
3756 | |
|
3757 | 7 | luDao.fetch(CluSet.class, cluSetId); |
3758 | |
|
3759 | 7 | for(String cluSetIdToAdd : cluSetIdList) { |
3760 | 19 | StatusInfo status = addCluSetToCluSet(cluSetId, cluSetIdToAdd); |
3761 | 15 | if (!status.getSuccess()) { |
3762 | 0 | return status; |
3763 | |
} |
3764 | 15 | } |
3765 | |
|
3766 | 3 | StatusInfo statusInfo = new StatusInfo(); |
3767 | 3 | statusInfo.setSuccess(true); |
3768 | |
|
3769 | 3 | return statusInfo; |
3770 | |
} |
3771 | |
|
3772 | |
@Override |
3773 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
3774 | |
public StatusInfo addClusToCluSet(List<String> cluIdList, String cluSetId) |
3775 | |
throws DoesNotExistException, InvalidParameterException, |
3776 | |
MissingParameterException, OperationFailedException, |
3777 | |
PermissionDeniedException, UnsupportedActionException { |
3778 | |
|
3779 | 4 | checkForMissingParameter(cluIdList, "cluIdList"); |
3780 | 4 | checkForMissingParameter(cluSetId, "cluSetId"); |
3781 | |
|
3782 | 4 | for(String cluId : cluIdList) { |
3783 | 11 | StatusInfo status = addCluToCluSet(cluId, cluSetId); |
3784 | 8 | if (!status.getSuccess()) { |
3785 | 0 | return status; |
3786 | |
} |
3787 | 8 | } |
3788 | |
|
3789 | 1 | StatusInfo statusInfo = new StatusInfo(); |
3790 | 1 | statusInfo.setSuccess(true); |
3791 | |
|
3792 | 1 | return statusInfo; |
3793 | |
} |
3794 | |
|
3795 | |
public ValidatorFactory getValidatorFactory() { |
3796 | 0 | return validatorFactory; |
3797 | |
} |
3798 | |
|
3799 | |
public void setValidatorFactory(ValidatorFactory validatorFactory) { |
3800 | 3 | this.validatorFactory = validatorFactory; |
3801 | 3 | } |
3802 | |
|
3803 | |
|
3804 | |
|
3805 | |
@Override |
3806 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
3807 | |
public CluInfo createNewCluVersion(String versionIndCluId, String versionComment) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
3808 | |
Clu latestClu; |
3809 | |
Clu currentClu; |
3810 | |
try{ |
3811 | 18 | latestClu = luDao.getLatestCluVersion(versionIndCluId); |
3812 | 0 | }catch(NoResultException e){ |
3813 | 0 | throw new DoesNotExistException("There are no matching versions of this clu", e); |
3814 | 18 | } |
3815 | |
try{ |
3816 | 18 | currentClu = luDao.getCurrentCluVersion(versionIndCluId); |
3817 | 0 | }catch(NoResultException e){ |
3818 | 0 | throw new DoesNotExistException("There is no current version of this clu. Only current clus can be versioned. Use setCurrentCluVersion to make a clu current.", e); |
3819 | 18 | } |
3820 | |
|
3821 | 18 | CluInfo cluInfo = LuServiceAssembler.toCluInfo(currentClu); |
3822 | |
|
3823 | |
|
3824 | 18 | clearCluIds(cluInfo); |
3825 | |
|
3826 | |
|
3827 | 18 | CluInfo newClu = null; |
3828 | |
|
3829 | |
try { |
3830 | 18 | Clu clu = toCluForCreate(cluInfo.getType(), cluInfo); |
3831 | |
|
3832 | 18 | Version version = new Version(); |
3833 | 18 | version.setSequenceNumber(latestClu.getVersion().getSequenceNumber() + 1); |
3834 | 18 | version.setVersionIndId(versionIndCluId); |
3835 | 18 | version.setCurrentVersionStart(null); |
3836 | 18 | version.setCurrentVersionEnd(null); |
3837 | 18 | version.setVersionComment(versionComment); |
3838 | 18 | version.setVersionedFromId(currentClu.getId()); |
3839 | 18 | clu.setVersion(version); |
3840 | 18 | luDao.create(clu); |
3841 | 18 | newClu = LuServiceAssembler.toCluInfo(clu); |
3842 | 0 | } catch (AlreadyExistsException e) { |
3843 | 0 | throw new OperationFailedException("Error creating a new clu version", e); |
3844 | 18 | } |
3845 | |
|
3846 | 18 | return newClu; |
3847 | |
} |
3848 | |
|
3849 | |
private void clearCluIds(CluInfo clu) { |
3850 | |
|
3851 | 18 | clu.setState(DtoConstants.STATE_DRAFT); |
3852 | 18 | clu.setId(null); |
3853 | |
|
3854 | 18 | if(clu.getAccountingInfo()!=null){ |
3855 | 10 | clu.getAccountingInfo().setId(null); |
3856 | |
|
3857 | 10 | for(AffiliatedOrgInfo affiliatedOrg:clu.getAccountingInfo().getAffiliatedOrgs()){ |
3858 | 16 | affiliatedOrg.setId(null); |
3859 | |
} |
3860 | |
} |
3861 | 18 | for(AccreditationInfo accredation:clu.getAccreditations()){ |
3862 | 8 | accredation.setId(null); |
3863 | |
} |
3864 | 18 | for(AdminOrgInfo adminOrg:clu.getAdminOrgs()){ |
3865 | 174 | adminOrg.setId(null); |
3866 | |
} |
3867 | 18 | for(CluIdentifierInfo alternateIdentifier:clu.getAlternateIdentifiers()){ |
3868 | 34 | alternateIdentifier.setId(null); |
3869 | |
} |
3870 | 18 | if(clu.getFeeInfo()!=null){ |
3871 | 10 | clu.getFeeInfo().setId(null); |
3872 | 10 | for(CluFeeRecordInfo cluFeeRecord:clu.getFeeInfo().getCluFeeRecords()){ |
3873 | 36 | cluFeeRecord.setId(null); |
3874 | 36 | for(AffiliatedOrgInfo affiliatedOrg:cluFeeRecord.getAffiliatedOrgs()){ |
3875 | 40 | affiliatedOrg.setId(null); |
3876 | |
} |
3877 | 36 | for(CurrencyAmountInfo feeAmount:cluFeeRecord.getFeeAmounts()){ |
3878 | 38 | feeAmount.setId(null); |
3879 | |
} |
3880 | |
} |
3881 | |
} |
3882 | 18 | for(LuCodeInfo luCode:clu.getLuCodes()){ |
3883 | 36 | luCode.setId(null); |
3884 | |
} |
3885 | 18 | if(clu.getOfficialIdentifier()!=null){ |
3886 | 18 | clu.getOfficialIdentifier().setId(null); |
3887 | |
} |
3888 | 18 | } |
3889 | |
|
3890 | |
|
3891 | |
|
3892 | |
|
3893 | |
|
3894 | |
|
3895 | |
|
3896 | |
@Override |
3897 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
3898 | |
public StatusInfo setCurrentCluVersion(String cluVersionId, Date currentVersionStart) throws DoesNotExistException, InvalidParameterException, MissingParameterException, IllegalVersionSequencingException, OperationFailedException, PermissionDeniedException { |
3899 | |
|
3900 | 8 | Date currentDbDate = new Date(); |
3901 | 8 | if(currentVersionStart!=null&¤tVersionStart.compareTo(currentDbDate)<0){ |
3902 | 1 | throw new InvalidParameterException("currentVersionStart must be in the future."); |
3903 | |
} |
3904 | |
|
3905 | 7 | if(currentVersionStart==null){ |
3906 | 5 | currentVersionStart = currentDbDate; |
3907 | |
} |
3908 | |
|
3909 | |
|
3910 | 7 | Clu clu = luDao.fetch(Clu.class, cluVersionId); |
3911 | 7 | String versionIndId = clu.getVersion().getVersionIndId(); |
3912 | |
|
3913 | 7 | Clu oldClu = null; |
3914 | |
try{ |
3915 | 7 | oldClu = luDao.getCurrentCluVersion(versionIndId); |
3916 | 7 | }catch(NoResultException e){} |
3917 | |
|
3918 | |
|
3919 | 7 | if(oldClu!=null){ |
3920 | 7 | if(clu.getVersion().getSequenceNumber()<=oldClu.getVersion().getSequenceNumber()){ |
3921 | 0 | throw new OperationFailedException("Clu to make current must have been versioned from the current Clu"); |
3922 | |
} |
3923 | |
}else{ |
3924 | |
|
3925 | 0 | currentVersionStart = currentDbDate; |
3926 | |
} |
3927 | |
|
3928 | |
|
3929 | |
|
3930 | 7 | List<VersionDisplayInfo> versionsInFuture = luDao.getVersionsInDateRange(versionIndId, null, currentDbDate, null); |
3931 | 7 | for(VersionDisplayInfo versionInFuture:versionsInFuture){ |
3932 | 0 | if(oldClu==null || !versionInFuture.getId().equals(oldClu.getId())){ |
3933 | 0 | VersionEntity futureClu = luDao.fetch(Clu.class, versionInFuture.getId()); |
3934 | 0 | futureClu.getVersion().setCurrentVersionStart(null); |
3935 | 0 | futureClu.getVersion().setCurrentVersionEnd(null); |
3936 | 0 | futureClu = luDao.update(futureClu); |
3937 | 0 | } |
3938 | |
} |
3939 | |
|
3940 | |
|
3941 | 7 | if(oldClu!=null){ |
3942 | 7 | oldClu.getVersion().setCurrentVersionEnd(currentVersionStart); |
3943 | 7 | oldClu = luDao.update(oldClu); |
3944 | |
} |
3945 | |
|
3946 | |
|
3947 | 7 | clu.getVersion().setCurrentVersionStart(currentVersionStart); |
3948 | 7 | clu.getVersion().setCurrentVersionEnd(null); |
3949 | 7 | clu = luDao.update(clu); |
3950 | |
|
3951 | 7 | StatusInfo statusInfo = new StatusInfo(); |
3952 | 7 | statusInfo.setSuccess(true); |
3953 | 7 | return statusInfo; |
3954 | |
} |
3955 | |
|
3956 | |
@Override |
3957 | |
public VersionDisplayInfo getLatestVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
3958 | 0 | VersionDisplayInfo versionInfo = null; |
3959 | 0 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
3960 | |
try{ |
3961 | 0 | versionInfo = luDao.getLatestVersion(refObjectId, refObjectTypeURI); |
3962 | 0 | }catch(NoResultException e){ |
3963 | 0 | throw new DoesNotExistException(); |
3964 | 0 | } |
3965 | |
}else{ |
3966 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
3967 | |
} |
3968 | 0 | return versionInfo; |
3969 | |
} |
3970 | |
|
3971 | |
@Override |
3972 | |
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
3973 | 25 | VersionDisplayInfo versionInfo = null; |
3974 | 25 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
3975 | |
try{ |
3976 | 25 | versionInfo = luDao.getCurrentCluVersionInfo(refObjectId, refObjectTypeURI); |
3977 | 0 | }catch(NoResultException e){ |
3978 | 0 | throw new DoesNotExistException(); |
3979 | 25 | } |
3980 | |
}else{ |
3981 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
3982 | |
} |
3983 | 25 | return versionInfo; |
3984 | |
} |
3985 | |
|
3986 | |
@Override |
3987 | |
public VersionDisplayInfo getCurrentVersionOnDate(String refObjectTypeURI, String refObjectId, Date date) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
3988 | 3 | VersionDisplayInfo versionInfo = null; |
3989 | 3 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
3990 | |
try{ |
3991 | 3 | versionInfo = luDao.getCurrentVersionOnDate(refObjectId, refObjectTypeURI, date); |
3992 | 0 | }catch(NoResultException e){ |
3993 | 0 | throw new DoesNotExistException(); |
3994 | 3 | } |
3995 | |
}else{ |
3996 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
3997 | |
} |
3998 | 3 | return versionInfo; |
3999 | |
} |
4000 | |
|
4001 | |
@Override |
4002 | |
public VersionDisplayInfo getFirstVersion(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
4003 | 1 | VersionDisplayInfo versionInfo = null; |
4004 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
4005 | |
try{ |
4006 | 1 | versionInfo = luDao.getFirstVersion(refObjectId, refObjectTypeURI); |
4007 | 0 | }catch(NoResultException e){ |
4008 | 0 | throw new DoesNotExistException(); |
4009 | 1 | } |
4010 | |
}else{ |
4011 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
4012 | |
} |
4013 | 1 | return versionInfo; |
4014 | |
} |
4015 | |
|
4016 | |
@Override |
4017 | |
public VersionDisplayInfo getVersionBySequenceNumber(String refObjectTypeURI, String refObjectId, Long sequence) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
4018 | 1 | VersionDisplayInfo versionInfo = null; |
4019 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
4020 | |
try{ |
4021 | 1 | versionInfo = luDao.getVersionBySequenceNumber(refObjectId, refObjectTypeURI, sequence); |
4022 | 0 | }catch(NoResultException e){ |
4023 | 0 | throw new DoesNotExistException(); |
4024 | 1 | } |
4025 | |
}else{ |
4026 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
4027 | |
} |
4028 | 1 | return versionInfo; |
4029 | |
} |
4030 | |
|
4031 | |
@Override |
4032 | |
public List<VersionDisplayInfo> getVersions(String refObjectTypeURI, String refObjectId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
4033 | 2 | List<VersionDisplayInfo> versionInfos = null; |
4034 | 2 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
4035 | 2 | versionInfos = luDao.getVersions(refObjectId, refObjectTypeURI); |
4036 | 2 | if(versionInfos==null){ |
4037 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
4038 | |
} |
4039 | |
}else{ |
4040 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
4041 | |
} |
4042 | 2 | return versionInfos; |
4043 | |
} |
4044 | |
|
4045 | |
@Override |
4046 | |
public List<VersionDisplayInfo> getVersionsInDateRange(String refObjectTypeURI, String refObjectId, Date from, Date to) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
4047 | 1 | List<VersionDisplayInfo> versionInfos = null; |
4048 | 1 | if(LuServiceConstants.CLU_NAMESPACE_URI.equals(refObjectTypeURI)){ |
4049 | 1 | versionInfos = luDao.getVersionsInDateRange(refObjectId, refObjectTypeURI, from, to); |
4050 | 1 | if(versionInfos==null){ |
4051 | 0 | versionInfos = Collections.<VersionDisplayInfo>emptyList(); |
4052 | |
} |
4053 | |
}else{ |
4054 | 0 | throw new UnsupportedOperationException("This method does not know how to handle object type:"+refObjectTypeURI); |
4055 | |
} |
4056 | 1 | return versionInfos; |
4057 | |
} |
4058 | |
|
4059 | |
public void setSearchDispatcher(SearchDispatcher searchDispatcher) { |
4060 | 1 | this.searchDispatcher = searchDispatcher; |
4061 | 1 | } |
4062 | |
} |