1 | |
package org.kuali.student.lum.program.service.impl; |
2 | |
|
3 | |
import java.util.ArrayList; |
4 | |
import java.util.Date; |
5 | |
import java.util.Iterator; |
6 | |
import java.util.List; |
7 | |
|
8 | |
import org.apache.log4j.Logger; |
9 | |
import org.kuali.student.common.assembly.BaseDTOAssemblyNode; |
10 | |
import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation; |
11 | |
import org.kuali.student.common.assembly.BusinessServiceMethodInvoker; |
12 | |
import org.kuali.student.common.assembly.data.AssemblyException; |
13 | |
import org.kuali.student.common.dictionary.dto.DataType; |
14 | |
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
15 | |
import org.kuali.student.common.dictionary.service.DictionaryService; |
16 | |
import org.kuali.student.common.dto.DtoConstants; |
17 | |
import org.kuali.student.common.dto.StatusInfo; |
18 | |
import org.kuali.student.common.exceptions.AlreadyExistsException; |
19 | |
import org.kuali.student.common.exceptions.CircularReferenceException; |
20 | |
import org.kuali.student.common.exceptions.CircularRelationshipException; |
21 | |
import org.kuali.student.common.exceptions.DataValidationErrorException; |
22 | |
import org.kuali.student.common.exceptions.DependentObjectsExistException; |
23 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
24 | |
import org.kuali.student.common.exceptions.IllegalVersionSequencingException; |
25 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
26 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
27 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
28 | |
import org.kuali.student.common.exceptions.PermissionDeniedException; |
29 | |
import org.kuali.student.common.exceptions.UnsupportedActionException; |
30 | |
import org.kuali.student.common.exceptions.VersionMismatchException; |
31 | |
import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo; |
32 | |
import org.kuali.student.common.search.dto.SearchRequest; |
33 | |
import org.kuali.student.common.search.dto.SearchResult; |
34 | |
import org.kuali.student.common.search.dto.SearchResultTypeInfo; |
35 | |
import org.kuali.student.common.search.dto.SearchTypeInfo; |
36 | |
import org.kuali.student.common.search.service.SearchManager; |
37 | |
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
38 | |
import org.kuali.student.common.validator.ServerDateParser; |
39 | |
import org.kuali.student.common.validator.Validator; |
40 | |
import org.kuali.student.common.validator.ValidatorFactory; |
41 | |
import org.kuali.student.common.validator.ValidatorUtils; |
42 | |
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
43 | |
import org.kuali.student.core.atp.dto.AtpInfo; |
44 | |
import org.kuali.student.core.atp.service.AtpService; |
45 | |
import org.kuali.student.core.document.dto.RefDocRelationInfo; |
46 | |
import org.kuali.student.core.document.service.DocumentService; |
47 | |
import org.kuali.student.core.statement.dto.ReqCompFieldInfo; |
48 | |
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
49 | |
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
50 | |
import org.kuali.student.lum.course.dto.LoDisplayInfo; |
51 | |
import org.kuali.student.lum.course.service.impl.CourseServiceUtils; |
52 | |
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
53 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
54 | |
import org.kuali.student.lum.lu.dto.CluSetInfo; |
55 | |
import org.kuali.student.lum.lu.dto.LuTypeInfo; |
56 | |
import org.kuali.student.lum.lu.service.LuService; |
57 | |
import org.kuali.student.lum.lu.service.LuServiceConstants; |
58 | |
import org.kuali.student.lum.program.dto.CoreProgramInfo; |
59 | |
import org.kuali.student.lum.program.dto.CredentialProgramInfo; |
60 | |
import org.kuali.student.lum.program.dto.HonorsProgramInfo; |
61 | |
import org.kuali.student.lum.program.dto.MajorDisciplineInfo; |
62 | |
import org.kuali.student.lum.program.dto.MinorDisciplineInfo; |
63 | |
import org.kuali.student.lum.program.dto.ProgramRequirementInfo; |
64 | |
import org.kuali.student.lum.program.dto.ProgramVariationInfo; |
65 | |
import org.kuali.student.lum.program.service.ProgramService; |
66 | |
import org.kuali.student.lum.program.service.ProgramServiceConstants; |
67 | |
import org.kuali.student.lum.program.service.assembler.CoreProgramAssembler; |
68 | |
import org.kuali.student.lum.program.service.assembler.CredentialProgramAssembler; |
69 | |
import org.kuali.student.lum.program.service.assembler.MajorDisciplineAssembler; |
70 | |
import org.kuali.student.lum.program.service.assembler.ProgramAssemblerConstants; |
71 | |
import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; |
72 | |
import org.springframework.transaction.annotation.Transactional; |
73 | |
|
74 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
75 | 2 | public class ProgramServiceImpl implements ProgramService { |
76 | 1 | final static Logger LOG = Logger.getLogger(ProgramServiceImpl.class); |
77 | |
|
78 | |
private LuService luService; |
79 | |
private ValidatorFactory validatorFactory; |
80 | |
private BusinessServiceMethodInvoker programServiceMethodInvoker; |
81 | |
private DictionaryService dictionaryService; |
82 | |
private SearchManager searchManager; |
83 | |
private MajorDisciplineAssembler majorDisciplineAssembler; |
84 | |
private ProgramRequirementAssembler programRequirementAssembler; |
85 | |
private CredentialProgramAssembler credentialProgramAssembler; |
86 | |
private CoreProgramAssembler coreProgramAssembler; |
87 | |
|
88 | |
private AtpService atpService; |
89 | |
private DocumentService documentService; |
90 | |
|
91 | |
|
92 | |
@Override |
93 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
94 | |
public CredentialProgramInfo createCredentialProgram( |
95 | |
CredentialProgramInfo credentialProgramInfo) |
96 | |
throws AlreadyExistsException, DataValidationErrorException, |
97 | |
InvalidParameterException, MissingParameterException, |
98 | |
OperationFailedException, PermissionDeniedException { |
99 | |
|
100 | 1 | checkForMissingParameter(credentialProgramInfo, "CredentialProgramInfo"); |
101 | |
|
102 | |
|
103 | 1 | List<ValidationResultInfo> validationResults = validateCredentialProgram("OBJECT", credentialProgramInfo); |
104 | 1 | if (ValidatorUtils.hasErrors(validationResults)) { |
105 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
106 | |
} |
107 | |
|
108 | |
try { |
109 | 1 | return processCredentialProgramInfo(credentialProgramInfo, NodeOperation.CREATE); |
110 | 0 | } catch (AssemblyException e) { |
111 | 0 | LOG.error("Error disassembling Credential Program", e); |
112 | 0 | throw new OperationFailedException("Error disassembling Credential Program"); |
113 | |
} |
114 | |
} |
115 | |
|
116 | |
@Override |
117 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
118 | |
public HonorsProgramInfo createHonorsProgram( |
119 | |
HonorsProgramInfo honorsProgramInfo) throws AlreadyExistsException, |
120 | |
DataValidationErrorException, InvalidParameterException, |
121 | |
MissingParameterException, OperationFailedException, |
122 | |
PermissionDeniedException { |
123 | |
|
124 | 1 | return null; |
125 | |
} |
126 | |
|
127 | |
@Override |
128 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
129 | |
public ProgramRequirementInfo createProgramRequirement( |
130 | |
ProgramRequirementInfo programRequirementInfo) |
131 | |
throws AlreadyExistsException, DataValidationErrorException, |
132 | |
InvalidParameterException, MissingParameterException, |
133 | |
OperationFailedException, PermissionDeniedException { |
134 | 7 | checkForMissingParameter(programRequirementInfo, "programRequirementInfo"); |
135 | |
|
136 | |
|
137 | 6 | List<ValidationResultInfo> validationResults = validateProgramRequirement("OBJECT", programRequirementInfo); |
138 | 6 | if (ValidatorUtils.hasErrors(validationResults)) { |
139 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
140 | |
} |
141 | |
|
142 | |
try { |
143 | 6 | return processProgramRequirement(programRequirementInfo, NodeOperation.CREATE); |
144 | 0 | } catch (AssemblyException e) { |
145 | 0 | LOG.error("Error disassembling Program Requirement", e); |
146 | 0 | throw new OperationFailedException("Error disassembling Program Requirement", e); |
147 | |
} |
148 | |
} |
149 | |
|
150 | |
@Override |
151 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
152 | |
public MajorDisciplineInfo createMajorDiscipline( |
153 | |
MajorDisciplineInfo majorDisciplineInfo) |
154 | |
throws AlreadyExistsException, DataValidationErrorException, |
155 | |
InvalidParameterException, MissingParameterException, |
156 | |
OperationFailedException, PermissionDeniedException { |
157 | |
|
158 | 3 | checkForMissingParameter(majorDisciplineInfo, "MajorDisciplineInfo"); |
159 | |
|
160 | |
|
161 | 3 | List<ValidationResultInfo> validationResults = validateMajorDiscipline("OBJECT", majorDisciplineInfo); |
162 | 3 | if (ValidatorUtils.hasErrors(validationResults)) { |
163 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
164 | |
} |
165 | |
|
166 | |
try { |
167 | 3 | return processMajorDisciplineInfo(majorDisciplineInfo, NodeOperation.CREATE); |
168 | 0 | } catch (AssemblyException e) { |
169 | 0 | LOG.error("Error creating Major Discipline", e); |
170 | 0 | throw new OperationFailedException("Error creating Major Discipline"); |
171 | |
} |
172 | |
} |
173 | |
|
174 | |
@Override |
175 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
176 | |
public MajorDisciplineInfo createNewMajorDisciplineVersion( |
177 | |
String majorDisciplineVerIndId, String versionComment) |
178 | |
throws DoesNotExistException, InvalidParameterException, |
179 | |
MissingParameterException, OperationFailedException, |
180 | |
PermissionDeniedException, VersionMismatchException, DataValidationErrorException { |
181 | |
|
182 | 2 | VersionDisplayInfo currentVersion = luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, majorDisciplineVerIndId); |
183 | 2 | MajorDisciplineInfo originalMajorDiscipline = getMajorDiscipline(currentVersion.getId()); |
184 | |
|
185 | |
|
186 | 2 | CluInfo newVersionClu = luService.createNewCluVersion(majorDisciplineVerIndId, versionComment); |
187 | |
|
188 | |
try { |
189 | |
BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> results; |
190 | |
|
191 | |
|
192 | 2 | majorDisciplineAssembler.assemble(newVersionClu, originalMajorDiscipline, true); |
193 | |
|
194 | |
|
195 | 2 | processCopy(originalMajorDiscipline, currentVersion.getId()); |
196 | |
|
197 | |
|
198 | |
|
199 | 2 | List<String> programRequirementIds = originalMajorDiscipline.getProgramRequirements(); |
200 | 2 | updateRequirementsState(programRequirementIds, DtoConstants.STATE_DRAFT); |
201 | |
|
202 | |
|
203 | 2 | results = majorDisciplineAssembler.disassemble(originalMajorDiscipline, NodeOperation.UPDATE); |
204 | |
|
205 | |
|
206 | 2 | programServiceMethodInvoker.invokeServiceCalls(results); |
207 | |
|
208 | 2 | return results.getBusinessDTORef(); |
209 | 0 | } catch(AssemblyException e) { |
210 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
211 | 0 | } catch (AlreadyExistsException e) { |
212 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
213 | 0 | } catch (DependentObjectsExistException e) { |
214 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
215 | 0 | } catch (CircularRelationshipException e) { |
216 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
217 | 0 | } catch (UnsupportedActionException e) { |
218 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
219 | 0 | } catch (CircularReferenceException e) { |
220 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
221 | |
} |
222 | |
} |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
private void updateRequirementsState(List<String> programRequirementIds, String newState) throws DoesNotExistException, |
234 | |
InvalidParameterException, MissingParameterException, |
235 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException, DataValidationErrorException { |
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | 2 | for (String programRequirementId : programRequirementIds) { |
246 | |
|
247 | |
|
248 | 0 | ProgramRequirementInfo programRequirementInfo = getProgramRequirement(programRequirementId, null, null); |
249 | |
|
250 | |
|
251 | 0 | StatementTreeViewInfo statementTree = programRequirementInfo.getStatement(); |
252 | |
|
253 | |
|
254 | 0 | updateStatementTreeViewInfoState(newState, statementTree); |
255 | |
|
256 | |
|
257 | 0 | programRequirementInfo.setState(newState); |
258 | |
|
259 | |
|
260 | 0 | updateProgramRequirement(programRequirementInfo); |
261 | |
|
262 | 0 | } |
263 | 2 | } |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
private static void updateStatementTreeViewInfoState(String state, StatementTreeViewInfo statementTreeViewInfo) { |
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | 0 | statementTreeViewInfo.setState(state); |
285 | |
|
286 | |
|
287 | 0 | List<ReqComponentInfo> reqComponents = statementTreeViewInfo.getReqComponents(); |
288 | |
|
289 | |
|
290 | 0 | for(Iterator<ReqComponentInfo> it = reqComponents.iterator(); it.hasNext();) |
291 | 0 | it.next().setState(state); |
292 | |
|
293 | |
|
294 | 0 | for(Iterator<StatementTreeViewInfo> itr = statementTreeViewInfo.getStatements().iterator(); itr.hasNext();) |
295 | 0 | updateStatementTreeViewInfoState(state, (StatementTreeViewInfo)itr.next()); |
296 | 0 | } |
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
private void clearStatementTreeViewIdsRecursively(StatementTreeViewInfo statementTreeView) throws OperationFailedException{ |
307 | 0 | if(statementTreeView!=null){ |
308 | 0 | statementTreeView.setId(null); |
309 | 0 | for(ReqComponentInfo reqComp:statementTreeView.getReqComponents()){ |
310 | 0 | reqComp.setId(null); |
311 | 0 | for(ReqCompFieldInfo field:reqComp.getReqCompFields()){ |
312 | 0 | field.setId(null); |
313 | |
|
314 | 0 | if(ReqComponentFieldTypes.COURSE_CLUSET_KEY.getId().equals(field.getType())|| |
315 | |
ReqComponentFieldTypes.PROGRAM_CLUSET_KEY.getId().equals(field.getType())|| |
316 | |
ReqComponentFieldTypes.CLUSET_KEY.getId().equals(field.getType())){ |
317 | |
try { |
318 | 0 | CluSetInfo cluSet = luService.getCluSetInfo(field.getValue()); |
319 | 0 | cluSet.setId(null); |
320 | |
|
321 | 0 | if (cluSet.getMembershipQuery() != null){ |
322 | 0 | cluSet.getCluIds().clear(); |
323 | 0 | cluSet.getCluSetIds().clear(); |
324 | |
} |
325 | 0 | cluSet = luService.createCluSet(cluSet.getType(), cluSet); |
326 | 0 | field.setValue(cluSet.getId()); |
327 | 0 | } catch (Exception e) { |
328 | 0 | throw new OperationFailedException("Error copying clusets.", e); |
329 | 0 | } |
330 | |
} |
331 | |
|
332 | |
} |
333 | |
} |
334 | |
|
335 | 0 | for(StatementTreeViewInfo child: statementTreeView.getStatements()){ |
336 | 0 | clearStatementTreeViewIdsRecursively(child); |
337 | |
} |
338 | |
} |
339 | 0 | } |
340 | |
|
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
|
352 | |
|
353 | |
|
354 | |
|
355 | |
|
356 | |
private void processCopy(MajorDisciplineInfo majorDiscipline,String originalId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, AlreadyExistsException, DataValidationErrorException, VersionMismatchException, CircularRelationshipException { |
357 | |
|
358 | 2 | majorDiscipline.setStartTerm(null); |
359 | 2 | majorDiscipline.setEndTerm(null); |
360 | 2 | majorDiscipline.setEndProgramEntryTerm(null); |
361 | 2 | majorDiscipline.getAttributes().remove("endInstAdmitTerm"); |
362 | |
|
363 | |
|
364 | 2 | for(LoDisplayInfo lo:majorDiscipline.getLearningObjectives()){ |
365 | 4 | resetLoRecursively(lo); |
366 | |
} |
367 | |
|
368 | 2 | if(majorDiscipline.getOrgCoreProgram()!=null){ |
369 | 0 | majorDiscipline.getOrgCoreProgram().setId(null); |
370 | |
|
371 | 0 | if(majorDiscipline.getOrgCoreProgram().getLearningObjectives()!=null){ |
372 | 0 | for(LoDisplayInfo lo:majorDiscipline.getOrgCoreProgram().getLearningObjectives()){ |
373 | 0 | resetLoRecursively(lo); |
374 | |
} |
375 | |
} |
376 | |
} |
377 | |
|
378 | 2 | for(ProgramVariationInfo variation:majorDiscipline.getVariations()){ |
379 | |
|
380 | 4 | variation.setStartTerm(null); |
381 | 4 | variation.setEndTerm(null); |
382 | 4 | variation.setEndProgramEntryTerm(null); |
383 | 4 | variation.getAttributes().remove("endInstAdmitTerm"); |
384 | |
|
385 | |
|
386 | 4 | String variationVersionIndId = variation.getVersionInfo().getVersionIndId(); |
387 | 4 | CluInfo newVariationClu = luService.createNewCluVersion(variationVersionIndId, "Variation version for MajorDiscipline version " + majorDiscipline.getVersionInfo().getSequenceNumber()); |
388 | |
|
389 | |
|
390 | 4 | CluCluRelationInfo relation = new CluCluRelationInfo(); |
391 | 4 | relation.setCluId(majorDiscipline.getId()); |
392 | 4 | relation.setRelatedCluId(newVariationClu.getId()); |
393 | 4 | relation.setType(ProgramAssemblerConstants.HAS_PROGRAM_VARIATION); |
394 | |
|
395 | |
|
396 | |
|
397 | 4 | relation.setState(DtoConstants.STATE_ACTIVE); |
398 | 4 | luService.createCluCluRelation(relation.getCluId(), relation.getRelatedCluId(), relation.getType(), relation); |
399 | |
|
400 | |
|
401 | 4 | variation.setId(newVariationClu.getId()); |
402 | 4 | variation.setMetaInfo(newVariationClu.getMetaInfo()); |
403 | |
|
404 | |
|
405 | 4 | variation.setState(majorDiscipline.getState()); |
406 | |
|
407 | 4 | for(LoDisplayInfo lo:variation.getLearningObjectives()){ |
408 | 8 | resetLoRecursively(lo); |
409 | |
} |
410 | |
|
411 | 4 | copyProgramRequirements(variation.getProgramRequirements(),majorDiscipline.getState()); |
412 | 4 | } |
413 | |
|
414 | |
|
415 | 2 | copyProgramRequirements(majorDiscipline.getProgramRequirements(),majorDiscipline.getState()); |
416 | |
|
417 | |
|
418 | 2 | List<RefDocRelationInfo> docRelations = documentService.getRefDocRelationsByRef("kuali.org.RefObjectType.ProposalInfo", originalId); |
419 | 2 | if(docRelations!=null){ |
420 | 0 | for(RefDocRelationInfo docRelation:docRelations){ |
421 | 0 | docRelation.setId(null); |
422 | 0 | docRelation.setRefObjectId(majorDiscipline.getId()); |
423 | 0 | documentService.createRefDocRelation("kuali.org.RefObjectType.ProposalInfo", majorDiscipline.getId(), docRelation.getDocumentId(), docRelation.getType(), docRelation); |
424 | |
} |
425 | |
} |
426 | 2 | } |
427 | |
|
428 | |
private void processCopy(CredentialProgramInfo originaCredentialProgram, |
429 | |
String originalId) throws OperationFailedException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, PermissionDeniedException, DoesNotExistException { |
430 | |
|
431 | 0 | originaCredentialProgram.setStartTerm(null); |
432 | 0 | originaCredentialProgram.setEndTerm(null); |
433 | 0 | originaCredentialProgram.setEndProgramEntryTerm(null); |
434 | |
|
435 | |
|
436 | 0 | if (originaCredentialProgram.getLearningObjectives() != null){ |
437 | 0 | for(LoDisplayInfo lo:originaCredentialProgram.getLearningObjectives()){ |
438 | 0 | resetLoRecursively(lo); |
439 | |
} |
440 | |
} |
441 | |
|
442 | |
|
443 | 0 | copyProgramRequirements(originaCredentialProgram.getProgramRequirements(),originaCredentialProgram.getState()); |
444 | |
|
445 | |
|
446 | 0 | List<RefDocRelationInfo> docRelations = documentService.getRefDocRelationsByRef("kuali.org.RefObjectType.ProposalInfo", originalId); |
447 | 0 | if(docRelations!=null){ |
448 | 0 | for(RefDocRelationInfo docRelation:docRelations){ |
449 | 0 | docRelation.setId(null); |
450 | 0 | docRelation.setRefObjectId(originaCredentialProgram.getId()); |
451 | 0 | documentService.createRefDocRelation("kuali.org.RefObjectType.ProposalInfo", originaCredentialProgram.getId(), docRelation.getDocumentId(), docRelation.getType(), docRelation); |
452 | |
} |
453 | |
} |
454 | 0 | } |
455 | |
|
456 | |
private void processCopy(CoreProgramInfo originalCoreProgram, String originalId) throws OperationFailedException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, PermissionDeniedException, DoesNotExistException { |
457 | |
|
458 | 2 | originalCoreProgram.setStartTerm(null); |
459 | 2 | originalCoreProgram.setEndTerm(null); |
460 | 2 | originalCoreProgram.setEndProgramEntryTerm(null); |
461 | |
|
462 | |
|
463 | 2 | for(LoDisplayInfo lo:originalCoreProgram.getLearningObjectives()){ |
464 | 4 | resetLoRecursively(lo); |
465 | |
} |
466 | |
|
467 | 2 | copyProgramRequirements(originalCoreProgram.getProgramRequirements(),originalCoreProgram.getState()); |
468 | |
|
469 | |
|
470 | 2 | List<RefDocRelationInfo> docRelations = documentService.getRefDocRelationsByRef("kuali.org.RefObjectType.ProposalInfo", originalId); |
471 | 2 | if(docRelations!=null){ |
472 | 0 | for(RefDocRelationInfo docRelation:docRelations){ |
473 | 0 | docRelation.setId(null); |
474 | 0 | docRelation.setRefObjectId(originalCoreProgram.getId()); |
475 | 0 | documentService.createRefDocRelation("kuali.org.RefObjectType.ProposalInfo", originalCoreProgram.getId(), docRelation.getDocumentId(), docRelation.getType(), docRelation); |
476 | |
} |
477 | |
} |
478 | 2 | } |
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
|
492 | |
private void copyProgramRequirements(List<String> originalProgramRequirementIds,String state) throws OperationFailedException, AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, PermissionDeniedException, DoesNotExistException{ |
493 | |
|
494 | 8 | List<String> programRequirementIds = new ArrayList<String>(originalProgramRequirementIds); |
495 | 8 | originalProgramRequirementIds.clear(); |
496 | |
|
497 | 8 | for(String programRequirementId:programRequirementIds){ |
498 | |
|
499 | 0 | ProgramRequirementInfo programRequirementInfo = getProgramRequirement(programRequirementId, null, null); |
500 | |
|
501 | 0 | programRequirementInfo.setId(null); |
502 | |
|
503 | 0 | programRequirementInfo.setState(state); |
504 | |
|
505 | 0 | clearStatementTreeViewIdsRecursively(programRequirementInfo.getStatement()); |
506 | |
|
507 | 0 | for(LoDisplayInfo lo:programRequirementInfo.getLearningObjectives()){ |
508 | 0 | resetLoRecursively(lo); |
509 | |
} |
510 | |
|
511 | 0 | ProgramRequirementInfo createdProgramRequirement = createProgramRequirement(programRequirementInfo); |
512 | |
|
513 | 0 | originalProgramRequirementIds.add(createdProgramRequirement.getId()); |
514 | 0 | } |
515 | 8 | } |
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
|
521 | |
private void resetLoRecursively(LoDisplayInfo lo){ |
522 | 112 | lo.getLoInfo().setId(null); |
523 | 112 | for(LoDisplayInfo nestedLo:lo.getLoDisplayInfoList()){ |
524 | 96 | resetLoRecursively(nestedLo); |
525 | |
} |
526 | 112 | } |
527 | |
|
528 | |
@Override |
529 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
530 | |
public StatusInfo setCurrentMajorDisciplineVersion( |
531 | |
String majorDisciplineId, Date currentVersionStart) |
532 | |
throws DoesNotExistException, InvalidParameterException, |
533 | |
MissingParameterException, IllegalVersionSequencingException, |
534 | |
OperationFailedException, PermissionDeniedException { |
535 | 1 | StatusInfo status = luService.setCurrentCluVersion(majorDisciplineId, currentVersionStart); |
536 | |
|
537 | |
|
538 | 1 | List<ProgramVariationInfo> variationList = getVariationsByMajorDisciplineId(majorDisciplineId); |
539 | 1 | for (ProgramVariationInfo variationInfo:variationList){ |
540 | 2 | String variationId = variationInfo.getId(); |
541 | |
|
542 | 2 | if (variationInfo.getVersionInfo().getCurrentVersionStart() == null){ |
543 | 2 | luService.setCurrentCluVersion(variationId, currentVersionStart); |
544 | |
} |
545 | 2 | } |
546 | |
|
547 | 1 | return status; |
548 | |
} |
549 | |
|
550 | |
@Override |
551 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
552 | |
public MinorDisciplineInfo createMinorDiscipline( |
553 | |
MinorDisciplineInfo minorDisciplineInfo) |
554 | |
throws AlreadyExistsException, DataValidationErrorException, |
555 | |
InvalidParameterException, MissingParameterException, |
556 | |
OperationFailedException, PermissionDeniedException { |
557 | |
|
558 | 1 | return null; |
559 | |
} |
560 | |
|
561 | |
@Override |
562 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
563 | |
public StatusInfo deleteCredentialProgram(String credentialProgramId) |
564 | |
throws DoesNotExistException, InvalidParameterException, |
565 | |
MissingParameterException, OperationFailedException, |
566 | |
PermissionDeniedException { |
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
|
576 | |
|
577 | |
|
578 | |
|
579 | 1 | throw new OperationFailedException("Deletion of CredentialProgram is not supported."); |
580 | |
} |
581 | |
|
582 | |
@Override |
583 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
584 | |
public StatusInfo deleteHonorsProgram(String honorsProgramId) |
585 | |
throws DoesNotExistException, InvalidParameterException, |
586 | |
MissingParameterException, OperationFailedException, |
587 | |
PermissionDeniedException { |
588 | |
|
589 | 1 | return null; |
590 | |
} |
591 | |
|
592 | |
@Override |
593 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
594 | |
public StatusInfo deleteMajorDiscipline(String majorDisciplineId) |
595 | |
throws DoesNotExistException, InvalidParameterException, |
596 | |
MissingParameterException, OperationFailedException, |
597 | |
PermissionDeniedException { |
598 | |
|
599 | |
try { |
600 | 0 | MajorDisciplineInfo majorDiscipline = getMajorDiscipline(majorDisciplineId); |
601 | |
|
602 | 0 | processMajorDisciplineInfo(majorDiscipline, NodeOperation.DELETE); |
603 | |
|
604 | 0 | return getStatus(); |
605 | |
|
606 | 0 | } catch (AssemblyException e) { |
607 | 0 | LOG.error("Error disassembling MajorDiscipline", e); |
608 | 0 | throw new OperationFailedException("Error disassembling MajorDiscipline"); |
609 | |
} |
610 | |
} |
611 | |
|
612 | |
@Override |
613 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
614 | |
public StatusInfo deleteMinorDiscipline(String minorDisciplineId) |
615 | |
throws DoesNotExistException, InvalidParameterException, |
616 | |
MissingParameterException, OperationFailedException, |
617 | |
PermissionDeniedException { |
618 | |
|
619 | 1 | return null; |
620 | |
} |
621 | |
|
622 | |
@Override |
623 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
624 | |
public StatusInfo deleteProgramRequirement(String programRequirementId) |
625 | |
throws DoesNotExistException, InvalidParameterException, |
626 | |
MissingParameterException, OperationFailedException, |
627 | |
PermissionDeniedException { |
628 | 2 | checkForMissingParameter(programRequirementId, "programRequirementId"); |
629 | |
try { |
630 | 2 | ProgramRequirementInfo programRequirement = getProgramRequirement(programRequirementId, null, null); |
631 | |
|
632 | 2 | processProgramRequirement(programRequirement, NodeOperation.DELETE); |
633 | |
|
634 | 2 | return getStatus(); |
635 | |
|
636 | 0 | } catch (AssemblyException e) { |
637 | 0 | LOG.error("Error disassembling MajorDiscipline", e); |
638 | 0 | throw new OperationFailedException("Error disassembling ProgramRequirement", e); |
639 | |
} |
640 | |
|
641 | |
} |
642 | |
|
643 | |
@Override |
644 | |
public CredentialProgramInfo getCredentialProgram(String credentialProgramId) |
645 | |
throws DoesNotExistException, InvalidParameterException, |
646 | |
MissingParameterException, OperationFailedException, |
647 | |
PermissionDeniedException { |
648 | |
|
649 | 4 | CredentialProgramInfo credentialProgramInfo = null; |
650 | |
|
651 | |
try { |
652 | 4 | CluInfo clu = luService.getClu(credentialProgramId); |
653 | |
|
654 | 4 | if ( ! ProgramAssemblerConstants.CREDENTIAL_PROGRAM_TYPES.contains(clu.getType()) ) { |
655 | 0 | throw new DoesNotExistException("Specified CLU is not a Credential Program"); |
656 | |
} |
657 | |
|
658 | 4 | credentialProgramInfo = credentialProgramAssembler.assemble(clu, null, false); |
659 | 0 | } catch (AssemblyException e) { |
660 | 0 | LOG.error("Error assembling CredentialProgram", e); |
661 | 0 | throw new OperationFailedException("Error assembling CredentialProgram"); |
662 | 4 | } |
663 | 4 | return credentialProgramInfo; |
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
|
672 | |
} |
673 | |
|
674 | |
@Override |
675 | |
public LuTypeInfo getCredentialProgramType(String credentialProgramTypeKey) |
676 | |
throws DoesNotExistException, InvalidParameterException, |
677 | |
MissingParameterException, OperationFailedException { |
678 | |
|
679 | 1 | return null; |
680 | |
} |
681 | |
|
682 | |
@Override |
683 | |
public List<LuTypeInfo> getCredentialProgramTypes() |
684 | |
throws OperationFailedException { |
685 | |
|
686 | 1 | return null; |
687 | |
} |
688 | |
|
689 | |
@Override |
690 | |
public List<String> getHonorsByCredentialProgramType(String programType) |
691 | |
throws DoesNotExistException, InvalidParameterException, |
692 | |
MissingParameterException, OperationFailedException { |
693 | |
|
694 | 1 | return null; |
695 | |
} |
696 | |
|
697 | |
@Override |
698 | |
public HonorsProgramInfo getHonorsProgram(String honorsProgramId) |
699 | |
throws DoesNotExistException, InvalidParameterException, |
700 | |
MissingParameterException, OperationFailedException, |
701 | |
PermissionDeniedException { |
702 | |
|
703 | 1 | return null; |
704 | |
} |
705 | |
|
706 | |
@Override |
707 | |
public MajorDisciplineInfo getMajorDiscipline(String majorDisciplineId) |
708 | |
throws DoesNotExistException, InvalidParameterException, |
709 | |
MissingParameterException, OperationFailedException, |
710 | |
PermissionDeniedException { |
711 | |
|
712 | |
|
713 | 15 | MajorDisciplineInfo majorDiscipline = null; |
714 | |
|
715 | |
try { |
716 | 15 | CluInfo clu = luService.getClu(majorDisciplineId); |
717 | 15 | if ( ! ProgramAssemblerConstants.MAJOR_DISCIPLINE.equals(clu.getType()) ) { |
718 | 1 | throw new DoesNotExistException("Specified CLU is not a Major Discipline"); |
719 | |
} |
720 | 14 | majorDiscipline = majorDisciplineAssembler.assemble(clu, null, false); |
721 | 0 | } catch (AssemblyException e) { |
722 | 0 | LOG.error("Error assembling MajorDiscipline", e); |
723 | 0 | throw new OperationFailedException("Error assembling MajorDiscipline"); |
724 | 14 | } |
725 | 14 | return majorDiscipline; |
726 | |
|
727 | |
|
728 | |
|
729 | |
|
730 | |
|
731 | |
|
732 | |
|
733 | |
} |
734 | |
|
735 | |
@Override |
736 | |
public List<String> getMajorIdsByCredentialProgramType(String programType) |
737 | |
throws DoesNotExistException, InvalidParameterException, |
738 | |
MissingParameterException, OperationFailedException { |
739 | |
|
740 | 1 | return null; |
741 | |
} |
742 | |
|
743 | |
@Override |
744 | |
public MinorDisciplineInfo getMinorDiscipline(String minorDisciplineId) |
745 | |
throws DoesNotExistException, InvalidParameterException, |
746 | |
MissingParameterException, OperationFailedException, |
747 | |
PermissionDeniedException { |
748 | |
|
749 | 1 | return null; |
750 | |
} |
751 | |
|
752 | |
@Override |
753 | |
public List<String> getMinorsByCredentialProgramType(String programType) |
754 | |
throws DoesNotExistException, InvalidParameterException, |
755 | |
MissingParameterException, OperationFailedException { |
756 | |
|
757 | 1 | return null; |
758 | |
} |
759 | |
|
760 | |
@Override |
761 | |
public ProgramRequirementInfo getProgramRequirement(String programRequirementId, String nlUsageTypeKey, String language) throws DoesNotExistException, |
762 | |
InvalidParameterException, MissingParameterException, |
763 | |
OperationFailedException, PermissionDeniedException { |
764 | |
|
765 | 8 | checkForMissingParameter(programRequirementId, "programRequirementId"); |
766 | |
|
767 | 7 | CluInfo clu = luService.getClu(programRequirementId); |
768 | 5 | if (!ProgramAssemblerConstants.PROGRAM_REQUIREMENT.equals(clu.getType())) { |
769 | 0 | throw new DoesNotExistException("Specified CLU is not a Program Requirement"); |
770 | |
} |
771 | |
try { |
772 | 5 | ProgramRequirementInfo progReqInfo = programRequirementAssembler.assemble(clu, null, false); |
773 | 5 | return progReqInfo; |
774 | 0 | } catch (AssemblyException e) { |
775 | 0 | LOG.error("Error assembling program requirement", e); |
776 | 0 | throw new OperationFailedException("Error assembling program requirement: " + e.getMessage(), e); |
777 | |
} |
778 | |
} |
779 | |
|
780 | |
@Override |
781 | |
public List<ProgramVariationInfo> getVariationsByMajorDisciplineId( |
782 | |
String majorDisciplineId) throws DoesNotExistException, |
783 | |
InvalidParameterException, MissingParameterException, |
784 | |
OperationFailedException { |
785 | 5 | List<ProgramVariationInfo> pvInfos = new ArrayList<ProgramVariationInfo>(); |
786 | |
|
787 | |
try { |
788 | 5 | List<CluInfo> clus = luService.getRelatedClusByCluId(majorDisciplineId, ProgramAssemblerConstants.HAS_PROGRAM_VARIATION); |
789 | |
|
790 | 5 | if(clus != null && clus.size() > 0){ |
791 | 5 | for(CluInfo clu : clus){ |
792 | 12 | ProgramVariationInfo pvInfo = majorDisciplineAssembler.getProgramVariationAssembler().assemble(clu, null, false); |
793 | 12 | if(pvInfo != null){ |
794 | 12 | pvInfos.add(pvInfo); |
795 | |
} |
796 | 12 | } |
797 | |
} |
798 | 0 | } catch (AssemblyException e) { |
799 | 0 | LOG.error("Error assembling ProgramVariation", e); |
800 | 0 | throw new OperationFailedException("Error assembling ProgramVariation"); |
801 | 5 | } |
802 | |
|
803 | 5 | return pvInfos; |
804 | |
} |
805 | |
|
806 | |
@Override |
807 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
808 | |
public CredentialProgramInfo updateCredentialProgram( |
809 | |
CredentialProgramInfo credentialProgramInfo) |
810 | |
throws DataValidationErrorException, DoesNotExistException, |
811 | |
InvalidParameterException, MissingParameterException, |
812 | |
VersionMismatchException, OperationFailedException, |
813 | |
PermissionDeniedException { |
814 | |
|
815 | 1 | checkForMissingParameter(credentialProgramInfo, "CredentialProgramInfo"); |
816 | |
|
817 | |
|
818 | 1 | List<ValidationResultInfo> validationResults = validateCredentialProgram("OBJECT", credentialProgramInfo); |
819 | 1 | if (ValidatorUtils.hasErrors(validationResults)) { |
820 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
821 | |
} |
822 | |
|
823 | |
try { |
824 | |
|
825 | 1 | return processCredentialProgramInfo(credentialProgramInfo, NodeOperation.UPDATE); |
826 | |
|
827 | 0 | } catch (AssemblyException e) { |
828 | 0 | LOG.error("Error disassembling Credential Program", e); |
829 | 0 | throw new OperationFailedException("Error disassembling Credential Program"); |
830 | |
} |
831 | |
} |
832 | |
|
833 | |
@Override |
834 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
835 | |
public HonorsProgramInfo updateHonorsProgram( |
836 | |
HonorsProgramInfo honorsProgramInfo) |
837 | |
throws DataValidationErrorException, DoesNotExistException, |
838 | |
InvalidParameterException, MissingParameterException, |
839 | |
VersionMismatchException, OperationFailedException, |
840 | |
PermissionDeniedException { |
841 | |
|
842 | 1 | return null; |
843 | |
} |
844 | |
|
845 | |
@Override |
846 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
847 | |
public MajorDisciplineInfo updateMajorDiscipline( |
848 | |
MajorDisciplineInfo majorDisciplineInfo) |
849 | |
throws DataValidationErrorException, DoesNotExistException, |
850 | |
InvalidParameterException, MissingParameterException, |
851 | |
VersionMismatchException, OperationFailedException, |
852 | |
PermissionDeniedException { |
853 | |
|
854 | 6 | checkForMissingParameter(majorDisciplineInfo, "MajorDisciplineInfo"); |
855 | |
|
856 | |
|
857 | 6 | List<ValidationResultInfo> validationResults = validateMajorDiscipline("OBJECT", majorDisciplineInfo); |
858 | 6 | if (ValidatorUtils.hasErrors(validationResults)) { |
859 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
860 | |
} |
861 | |
|
862 | |
try { |
863 | |
|
864 | 6 | return processMajorDisciplineInfo(majorDisciplineInfo, NodeOperation.UPDATE); |
865 | |
|
866 | 0 | } catch (AssemblyException e) { |
867 | 0 | LOG.error("Error disassembling majorDiscipline", e); |
868 | 0 | throw new OperationFailedException("Error disassembling majorDiscipline"); |
869 | |
} |
870 | |
} |
871 | |
|
872 | |
@Override |
873 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
874 | |
public MinorDisciplineInfo updateMinorDiscipline( |
875 | |
MinorDisciplineInfo minorDisciplineInfo) |
876 | |
throws DataValidationErrorException, DoesNotExistException, |
877 | |
InvalidParameterException, MissingParameterException, |
878 | |
VersionMismatchException, OperationFailedException, |
879 | |
PermissionDeniedException { |
880 | |
|
881 | 1 | return null; |
882 | |
} |
883 | |
|
884 | |
@Override |
885 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
886 | |
public ProgramRequirementInfo updateProgramRequirement( |
887 | |
ProgramRequirementInfo programRequirementInfo) |
888 | |
throws DataValidationErrorException, DoesNotExistException, |
889 | |
InvalidParameterException, MissingParameterException, |
890 | |
VersionMismatchException, OperationFailedException, |
891 | |
PermissionDeniedException { |
892 | 1 | checkForMissingParameter(programRequirementInfo, "programRequirementInfo"); |
893 | |
|
894 | 1 | List<ValidationResultInfo> validationResults = validateProgramRequirement("OBJECT", programRequirementInfo); |
895 | 1 | if (ValidatorUtils.hasErrors(validationResults)) { |
896 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
897 | |
} |
898 | |
|
899 | |
try { |
900 | 1 | return processProgramRequirement(programRequirementInfo, NodeOperation.UPDATE); |
901 | 0 | } catch (AssemblyException e) { |
902 | 0 | throw new OperationFailedException("Unable to update ProgramRequirement", e); |
903 | |
} |
904 | |
} |
905 | |
|
906 | |
@Override |
907 | |
public List<ValidationResultInfo> validateCredentialProgram( |
908 | |
String validationType, CredentialProgramInfo credentialProgramInfo) |
909 | |
throws InvalidParameterException, |
910 | |
MissingParameterException, OperationFailedException { |
911 | |
|
912 | 2 | List<ValidationResultInfo> validationResults = new ArrayList<ValidationResultInfo>(); |
913 | |
|
914 | 2 | ObjectStructureDefinition objStructure = this.getObjectStructure(CredentialProgramInfo.class.getName()); |
915 | 2 | Validator validator = validatorFactory.getValidator(); |
916 | 2 | validationResults.addAll(validator.validateObject(credentialProgramInfo, objStructure)); |
917 | |
|
918 | |
|
919 | 2 | return validationResults; |
920 | |
} |
921 | |
|
922 | |
@Override |
923 | |
public List<ValidationResultInfo> validateHonorsProgram( |
924 | |
String validationType, HonorsProgramInfo honorsProgramInfo) |
925 | |
throws InvalidParameterException, |
926 | |
MissingParameterException, OperationFailedException { |
927 | |
|
928 | 1 | return null; |
929 | |
} |
930 | |
|
931 | |
@Override |
932 | |
public List<ValidationResultInfo> validateMajorDiscipline( |
933 | |
String validationType, MajorDisciplineInfo majorDisciplineInfo) |
934 | |
throws InvalidParameterException, |
935 | |
MissingParameterException, OperationFailedException { |
936 | |
|
937 | 9 | List<ValidationResultInfo> validationResults = new ArrayList<ValidationResultInfo>(); |
938 | |
|
939 | 9 | ObjectStructureDefinition objStructure = this.getObjectStructure(MajorDisciplineInfo.class.getName()); |
940 | 9 | Validator validator = validatorFactory.getValidator(); |
941 | 9 | validationResults.addAll(validator.validateObject(majorDisciplineInfo, objStructure)); |
942 | |
|
943 | 9 | validateMajorDisciplineAtps(majorDisciplineInfo,validationResults); |
944 | 9 | return validationResults; |
945 | |
} |
946 | |
|
947 | |
@Override |
948 | |
public List<ValidationResultInfo> validateMinorDiscipline( |
949 | |
String validationType, MinorDisciplineInfo minorDisciplineInfo) |
950 | |
throws InvalidParameterException, |
951 | |
MissingParameterException, OperationFailedException { |
952 | |
|
953 | 1 | return null; |
954 | |
} |
955 | |
|
956 | |
@Override |
957 | |
public List<ValidationResultInfo> validateProgramRequirement( |
958 | |
String validationType, ProgramRequirementInfo programRequirementInfo) |
959 | |
throws InvalidParameterException, |
960 | |
MissingParameterException, OperationFailedException { |
961 | |
|
962 | 7 | ObjectStructureDefinition objStructure = this.getObjectStructure(ProgramRequirementInfo.class.getName()); |
963 | 7 | Validator validator = validatorFactory.getValidator(); |
964 | 7 | List<ValidationResultInfo> validationResults = validator.validateObject(programRequirementInfo, objStructure); |
965 | |
|
966 | 7 | return validationResults; |
967 | |
} |
968 | |
|
969 | |
@Override |
970 | |
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
971 | 23 | return dictionaryService.getObjectStructure(objectTypeKey); |
972 | |
} |
973 | |
|
974 | |
@Override |
975 | |
public List<String> getObjectTypes() { |
976 | 1 | return dictionaryService.getObjectTypes(); |
977 | |
} |
978 | |
|
979 | |
@Override |
980 | |
public SearchCriteriaTypeInfo getSearchCriteriaType( |
981 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
982 | |
InvalidParameterException, MissingParameterException, |
983 | |
OperationFailedException { |
984 | |
|
985 | 1 | return null; |
986 | |
} |
987 | |
|
988 | |
@Override |
989 | |
public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() |
990 | |
throws OperationFailedException { |
991 | |
|
992 | 1 | return null; |
993 | |
} |
994 | |
|
995 | |
@Override |
996 | |
public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) |
997 | |
throws DoesNotExistException, InvalidParameterException, |
998 | |
MissingParameterException, OperationFailedException { |
999 | |
|
1000 | 1 | return null; |
1001 | |
} |
1002 | |
|
1003 | |
@Override |
1004 | |
public List<SearchResultTypeInfo> getSearchResultTypes() |
1005 | |
throws OperationFailedException { |
1006 | |
|
1007 | 1 | return null; |
1008 | |
} |
1009 | |
|
1010 | |
@Override |
1011 | |
public SearchTypeInfo getSearchType(String searchTypeKey) |
1012 | |
throws DoesNotExistException, InvalidParameterException, |
1013 | |
MissingParameterException, OperationFailedException { |
1014 | |
|
1015 | 1 | return null; |
1016 | |
} |
1017 | |
|
1018 | |
@Override |
1019 | |
public List<SearchTypeInfo> getSearchTypes() |
1020 | |
throws OperationFailedException { |
1021 | |
|
1022 | 1 | return null; |
1023 | |
} |
1024 | |
|
1025 | |
@Override |
1026 | |
public List<SearchTypeInfo> getSearchTypesByCriteria( |
1027 | |
String searchCriteriaTypeKey) throws DoesNotExistException, |
1028 | |
InvalidParameterException, MissingParameterException, |
1029 | |
OperationFailedException { |
1030 | |
|
1031 | 1 | return null; |
1032 | |
} |
1033 | |
|
1034 | |
@Override |
1035 | |
public List<SearchTypeInfo> getSearchTypesByResult( |
1036 | |
String searchResultTypeKey) throws DoesNotExistException, |
1037 | |
InvalidParameterException, MissingParameterException, |
1038 | |
OperationFailedException { |
1039 | |
|
1040 | 1 | return null; |
1041 | |
} |
1042 | |
|
1043 | |
@Override |
1044 | |
public SearchResult search(SearchRequest searchRequest) |
1045 | |
throws MissingParameterException { |
1046 | |
|
1047 | 1 | return null; |
1048 | |
} |
1049 | |
|
1050 | |
|
1051 | |
|
1052 | |
|
1053 | |
|
1054 | |
|
1055 | |
|
1056 | |
|
1057 | |
private void checkForMissingParameter(Object param, String paramName) |
1058 | |
throws MissingParameterException { |
1059 | 33 | if (param == null) { |
1060 | 2 | throw new MissingParameterException(paramName + " can not be null"); |
1061 | |
} |
1062 | 31 | } |
1063 | |
|
1064 | |
|
1065 | |
|
1066 | |
private MajorDisciplineInfo processMajorDisciplineInfo(MajorDisciplineInfo majorDisciplineInfo, NodeOperation operation) throws AssemblyException { |
1067 | |
|
1068 | 9 | BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> results = majorDisciplineAssembler.disassemble(majorDisciplineInfo, operation); |
1069 | 9 | invokeServiceCalls(results); |
1070 | 9 | return results.getBusinessDTORef(); |
1071 | |
} |
1072 | |
|
1073 | |
private CredentialProgramInfo processCredentialProgramInfo(CredentialProgramInfo credentialProgramInfo, NodeOperation operation) throws AssemblyException { |
1074 | |
|
1075 | 2 | BaseDTOAssemblyNode<CredentialProgramInfo, CluInfo> results = credentialProgramAssembler.disassemble(credentialProgramInfo, operation); |
1076 | 2 | invokeServiceCalls(results); |
1077 | 2 | return results.getBusinessDTORef(); |
1078 | |
} |
1079 | |
|
1080 | |
private ProgramRequirementInfo processProgramRequirement(ProgramRequirementInfo programRequirementInfo, NodeOperation operation) throws AssemblyException { |
1081 | 9 | BaseDTOAssemblyNode<ProgramRequirementInfo, CluInfo> results = programRequirementAssembler.disassemble(programRequirementInfo, operation); |
1082 | 9 | invokeServiceCalls(results); |
1083 | 9 | return results.getBusinessDTORef(); |
1084 | |
} |
1085 | |
|
1086 | |
private void invokeServiceCalls(BaseDTOAssemblyNode<?, CluInfo> results) throws AssemblyException{ |
1087 | |
|
1088 | |
try { |
1089 | 24 | programServiceMethodInvoker.invokeServiceCalls(results); |
1090 | 0 | } catch (AssemblyException e) { |
1091 | 0 | throw e; |
1092 | 0 | } catch (Exception e) { |
1093 | 0 | throw new AssemblyException(e); |
1094 | 24 | } |
1095 | 24 | } |
1096 | |
|
1097 | |
|
1098 | |
|
1099 | |
public void setLuService(LuService luService) { |
1100 | 1 | this.luService = luService; |
1101 | 1 | } |
1102 | |
|
1103 | |
public LuService getLuService() { |
1104 | 0 | return luService; |
1105 | |
} |
1106 | |
|
1107 | |
public void setDictionaryService(DictionaryService dictionaryService) { |
1108 | 1 | this.dictionaryService = dictionaryService; |
1109 | 1 | } |
1110 | |
|
1111 | |
public DictionaryService getDictionaryService() { |
1112 | 0 | return dictionaryService; |
1113 | |
} |
1114 | |
|
1115 | |
public void setSearchManager(SearchManager searchManager) { |
1116 | 0 | this.searchManager = searchManager; |
1117 | 0 | } |
1118 | |
|
1119 | |
public SearchManager getSearchManager() { |
1120 | 0 | return searchManager; |
1121 | |
} |
1122 | |
|
1123 | |
public void setMajorDisciplineAssembler(MajorDisciplineAssembler majorDisciplineAssembler) { |
1124 | 1 | this.majorDisciplineAssembler = majorDisciplineAssembler; |
1125 | 1 | } |
1126 | |
|
1127 | |
public MajorDisciplineAssembler getMajorDisciplineAssembler() { |
1128 | 0 | return majorDisciplineAssembler; |
1129 | |
} |
1130 | |
|
1131 | |
public void setCredentialProgramAssembler( |
1132 | |
CredentialProgramAssembler credentialProgramAssembler) { |
1133 | 1 | this.credentialProgramAssembler = credentialProgramAssembler; |
1134 | 1 | } |
1135 | |
|
1136 | |
public CredentialProgramAssembler getCredentialProgramAssembler() { |
1137 | 0 | return credentialProgramAssembler; |
1138 | |
} |
1139 | |
|
1140 | |
public void setProgramRequirementAssembler(ProgramRequirementAssembler programRequirementAssembler) { |
1141 | 1 | this.programRequirementAssembler = programRequirementAssembler; |
1142 | 1 | } |
1143 | |
|
1144 | |
public ProgramRequirementAssembler getProgramRequirementAssembler() { |
1145 | 0 | return programRequirementAssembler; |
1146 | |
} |
1147 | |
|
1148 | |
public void setProgramServiceMethodInvoker(BusinessServiceMethodInvoker serviceMethodInvoker) { |
1149 | 1 | this.programServiceMethodInvoker = serviceMethodInvoker; |
1150 | 1 | } |
1151 | |
|
1152 | |
public BusinessServiceMethodInvoker getProgramServiceMethodInvoker() { |
1153 | 0 | return programServiceMethodInvoker; |
1154 | |
} |
1155 | |
|
1156 | |
public void setValidatorFactory(ValidatorFactory validatorFactory) { |
1157 | 1 | this.validatorFactory = validatorFactory; |
1158 | 1 | } |
1159 | |
|
1160 | |
public ValidatorFactory getValidatorFactory() { |
1161 | 0 | return validatorFactory; |
1162 | |
} |
1163 | |
|
1164 | |
public void setCoreProgramAssembler(CoreProgramAssembler coreProgramAssembler) { |
1165 | 1 | this.coreProgramAssembler = coreProgramAssembler; |
1166 | 1 | } |
1167 | |
|
1168 | |
public CoreProgramAssembler getCoreProgramAssembler() { |
1169 | 0 | return coreProgramAssembler; |
1170 | |
} |
1171 | |
|
1172 | |
private StatusInfo getStatus(){ |
1173 | 2 | StatusInfo status = new StatusInfo(); |
1174 | 2 | status.setSuccess(true); |
1175 | 2 | return status; |
1176 | |
} |
1177 | |
|
1178 | |
private CoreProgramInfo processCoreProgramInfo(CoreProgramInfo coreProgramInfo, NodeOperation operation) throws AssemblyException { |
1179 | |
|
1180 | 4 | BaseDTOAssemblyNode<CoreProgramInfo, CluInfo> results = coreProgramAssembler.disassemble(coreProgramInfo, operation); |
1181 | 4 | invokeServiceCalls(results); |
1182 | 4 | return results.getBusinessDTORef(); |
1183 | |
} |
1184 | |
|
1185 | |
@Override |
1186 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1187 | |
public CoreProgramInfo createCoreProgram(CoreProgramInfo coreProgramInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
1188 | 3 | checkForMissingParameter(coreProgramInfo, "CoreProgramInfo"); |
1189 | |
|
1190 | |
|
1191 | 3 | List<ValidationResultInfo> validationResults = validateCoreProgram("OBJECT", coreProgramInfo); |
1192 | 3 | if (ValidatorUtils.hasErrors(validationResults)) { |
1193 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
1194 | |
} |
1195 | |
|
1196 | |
try { |
1197 | 3 | return processCoreProgramInfo(coreProgramInfo, NodeOperation.CREATE); |
1198 | 0 | } catch (AssemblyException e) { |
1199 | 0 | LOG.error("Error disassembling CoreProgram", e); |
1200 | 0 | throw new OperationFailedException("Error disassembling CoreProgram"); |
1201 | |
} |
1202 | |
} |
1203 | |
|
1204 | |
@Override |
1205 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1206 | |
public CoreProgramInfo createNewCoreProgramVersion( |
1207 | |
String coreProgramId, String versionComment) |
1208 | |
throws DoesNotExistException, InvalidParameterException, |
1209 | |
MissingParameterException, OperationFailedException, |
1210 | |
PermissionDeniedException, VersionMismatchException, |
1211 | |
DataValidationErrorException { |
1212 | |
|
1213 | 2 | VersionDisplayInfo currentVersion = luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, coreProgramId); |
1214 | 2 | CoreProgramInfo originalCoreProgram = getCoreProgram(currentVersion.getId()); |
1215 | |
|
1216 | |
|
1217 | 2 | CluInfo newVersionClu = luService.createNewCluVersion(coreProgramId, versionComment); |
1218 | |
|
1219 | |
try { |
1220 | |
BaseDTOAssemblyNode<CoreProgramInfo, CluInfo> results; |
1221 | |
|
1222 | |
|
1223 | 2 | coreProgramAssembler.assemble(newVersionClu, originalCoreProgram, true); |
1224 | |
|
1225 | |
|
1226 | 2 | processCopy(originalCoreProgram, currentVersion.getId()); |
1227 | |
|
1228 | |
|
1229 | 2 | results = coreProgramAssembler.disassemble(originalCoreProgram, NodeOperation.UPDATE); |
1230 | |
|
1231 | |
|
1232 | 2 | programServiceMethodInvoker.invokeServiceCalls(results); |
1233 | |
|
1234 | 2 | return results.getBusinessDTORef(); |
1235 | 0 | } catch(AssemblyException e) { |
1236 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1237 | 0 | } catch (AlreadyExistsException e) { |
1238 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1239 | 0 | } catch (DependentObjectsExistException e) { |
1240 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1241 | 0 | } catch (CircularRelationshipException e) { |
1242 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1243 | 0 | } catch (UnsupportedActionException e) { |
1244 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1245 | 0 | } catch (CircularReferenceException e) { |
1246 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1247 | |
} |
1248 | |
} |
1249 | |
|
1250 | |
|
1251 | |
|
1252 | |
@Override |
1253 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1254 | |
public StatusInfo deleteCoreProgram(String coreProgramId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
1255 | |
|
1256 | |
|
1257 | |
|
1258 | |
|
1259 | |
|
1260 | |
|
1261 | |
|
1262 | |
|
1263 | |
|
1264 | |
|
1265 | |
|
1266 | 1 | throw new OperationFailedException("Deletion of CoreProgram is not supported."); |
1267 | |
} |
1268 | |
|
1269 | |
@Override |
1270 | |
public CoreProgramInfo getCoreProgram(String coreProgramId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
1271 | 7 | CoreProgramInfo coreProgramInfo = null; |
1272 | |
|
1273 | |
try { |
1274 | 7 | CluInfo clu = luService.getClu(coreProgramId); |
1275 | 7 | if ( ! ProgramAssemblerConstants.CORE_PROGRAM.equals(clu.getType()) ) { |
1276 | 1 | throw new DoesNotExistException("Specified CLU is not a CoreProgram"); |
1277 | |
} |
1278 | 6 | coreProgramInfo = coreProgramAssembler.assemble(clu, null, false); |
1279 | 0 | } catch (AssemblyException e) { |
1280 | 0 | LOG.error("Error assembling CoreProgram", e); |
1281 | 0 | throw new OperationFailedException("Error assembling CoreProgram"); |
1282 | 6 | } |
1283 | 6 | return coreProgramInfo; |
1284 | |
|
1285 | |
|
1286 | |
|
1287 | |
|
1288 | |
|
1289 | |
|
1290 | |
|
1291 | |
} |
1292 | |
|
1293 | |
@Override |
1294 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1295 | |
public CoreProgramInfo updateCoreProgram(CoreProgramInfo coreProgramInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, VersionMismatchException, OperationFailedException, PermissionDeniedException { |
1296 | 1 | checkForMissingParameter(coreProgramInfo, "CoreProgramInfo"); |
1297 | |
|
1298 | |
|
1299 | 1 | List<ValidationResultInfo> validationResults = validateCoreProgram("OBJECT", coreProgramInfo); |
1300 | 1 | if (ValidatorUtils.hasErrors(validationResults)) { |
1301 | 0 | throw new DataValidationErrorException("Validation error!", validationResults); |
1302 | |
} |
1303 | |
|
1304 | |
try { |
1305 | |
|
1306 | 1 | return processCoreProgramInfo(coreProgramInfo, NodeOperation.UPDATE); |
1307 | |
|
1308 | 0 | } catch (AssemblyException e) { |
1309 | 0 | LOG.error("Error disassembling CoreProgram", e); |
1310 | 0 | throw new OperationFailedException("Error disassembling CoreProgram"); |
1311 | |
} |
1312 | |
} |
1313 | |
|
1314 | |
@Override |
1315 | |
public List<ValidationResultInfo> validateCoreProgram(String validationType, CoreProgramInfo coreProgramInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
1316 | 4 | List<ValidationResultInfo> validationResults = new ArrayList<ValidationResultInfo>(); |
1317 | |
|
1318 | 4 | ObjectStructureDefinition objStructure = this.getObjectStructure(CoreProgramInfo.class.getName()); |
1319 | 4 | Validator validator = validatorFactory.getValidator(); |
1320 | 4 | validationResults.addAll(validator.validateObject(coreProgramInfo, objStructure)); |
1321 | |
|
1322 | 4 | return validationResults; |
1323 | |
} |
1324 | |
|
1325 | |
|
1326 | |
@Override |
1327 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1328 | |
public CredentialProgramInfo createNewCredentialProgramVersion( |
1329 | |
String credentialProgramId, String versionComment) |
1330 | |
throws DoesNotExistException, InvalidParameterException, |
1331 | |
MissingParameterException, OperationFailedException, |
1332 | |
PermissionDeniedException, VersionMismatchException, |
1333 | |
DataValidationErrorException { |
1334 | |
|
1335 | 0 | VersionDisplayInfo currentVersion = luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, credentialProgramId); |
1336 | 0 | CredentialProgramInfo originaCredentialProgram = getCredentialProgram(currentVersion.getId()); |
1337 | |
|
1338 | |
|
1339 | 0 | CluInfo newVersionClu = luService.createNewCluVersion(credentialProgramId, versionComment); |
1340 | |
|
1341 | |
try { |
1342 | |
BaseDTOAssemblyNode<CredentialProgramInfo, CluInfo> results; |
1343 | |
|
1344 | |
|
1345 | 0 | credentialProgramAssembler.assemble(newVersionClu, originaCredentialProgram, true); |
1346 | |
|
1347 | |
|
1348 | 0 | processCopy(originaCredentialProgram, currentVersion.getId()); |
1349 | |
|
1350 | |
|
1351 | 0 | results = credentialProgramAssembler.disassemble(originaCredentialProgram, NodeOperation.UPDATE); |
1352 | |
|
1353 | |
|
1354 | 0 | programServiceMethodInvoker.invokeServiceCalls(results); |
1355 | |
|
1356 | 0 | return results.getBusinessDTORef(); |
1357 | 0 | } catch(AssemblyException e) { |
1358 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1359 | 0 | } catch (AlreadyExistsException e) { |
1360 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1361 | 0 | } catch (DependentObjectsExistException e) { |
1362 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1363 | 0 | } catch (CircularRelationshipException e) { |
1364 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1365 | 0 | } catch (UnsupportedActionException e) { |
1366 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1367 | 0 | } catch (CircularReferenceException e) { |
1368 | 0 | throw new OperationFailedException("Error creating new MajorDiscipline version",e); |
1369 | |
} |
1370 | |
} |
1371 | |
|
1372 | |
|
1373 | |
@Override |
1374 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1375 | |
public StatusInfo setCurrentCoreProgramVersion(String coreProgramId, |
1376 | |
Date currentVersionStart) throws DoesNotExistException, |
1377 | |
InvalidParameterException, MissingParameterException, |
1378 | |
IllegalVersionSequencingException, OperationFailedException, |
1379 | |
PermissionDeniedException { |
1380 | 1 | StatusInfo status = luService.setCurrentCluVersion(coreProgramId, currentVersionStart); |
1381 | |
|
1382 | 1 | return status; |
1383 | |
} |
1384 | |
|
1385 | |
@Override |
1386 | |
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
1387 | |
public StatusInfo setCurrentCredentialProgramVersion( |
1388 | |
String credentialProgramId, Date currentVersionStart) |
1389 | |
throws DoesNotExistException, InvalidParameterException, |
1390 | |
MissingParameterException, IllegalVersionSequencingException, |
1391 | |
OperationFailedException, PermissionDeniedException { |
1392 | 0 | StatusInfo status = luService.setCurrentCluVersion(credentialProgramId, currentVersionStart); |
1393 | |
|
1394 | 0 | return status; |
1395 | |
} |
1396 | |
|
1397 | |
@Override |
1398 | |
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, |
1399 | |
String refObjectId) throws DoesNotExistException, |
1400 | |
InvalidParameterException, MissingParameterException, |
1401 | |
OperationFailedException, PermissionDeniedException { |
1402 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1403 | 0 | return luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
1404 | |
} |
1405 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1406 | |
} |
1407 | |
|
1408 | |
@Override |
1409 | |
public VersionDisplayInfo getCurrentVersionOnDate(String refObjectTypeURI, |
1410 | |
String refObjectId, Date date) throws DoesNotExistException, |
1411 | |
InvalidParameterException, MissingParameterException, |
1412 | |
OperationFailedException, PermissionDeniedException { |
1413 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1414 | 0 | return luService.getCurrentVersionOnDate(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, date); |
1415 | |
} |
1416 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1417 | |
} |
1418 | |
|
1419 | |
@Override |
1420 | |
public VersionDisplayInfo getFirstVersion(String refObjectTypeURI, |
1421 | |
String refObjectId) throws DoesNotExistException, |
1422 | |
InvalidParameterException, MissingParameterException, |
1423 | |
OperationFailedException, PermissionDeniedException { |
1424 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1425 | 0 | return luService.getFirstVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
1426 | |
} |
1427 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1428 | |
|
1429 | |
} |
1430 | |
|
1431 | |
@Override |
1432 | |
public VersionDisplayInfo getLatestVersion(String refObjectTypeURI, |
1433 | |
String refObjectId) throws DoesNotExistException, |
1434 | |
InvalidParameterException, MissingParameterException, |
1435 | |
OperationFailedException, PermissionDeniedException { |
1436 | 0 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1437 | 0 | return luService.getLatestVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
1438 | |
} |
1439 | 0 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1440 | |
|
1441 | |
} |
1442 | |
|
1443 | |
@Override |
1444 | |
public VersionDisplayInfo getVersionBySequenceNumber( |
1445 | |
String refObjectTypeURI, String refObjectId, Long sequence) |
1446 | |
throws DoesNotExistException, InvalidParameterException, |
1447 | |
MissingParameterException, OperationFailedException, |
1448 | |
PermissionDeniedException { |
1449 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1450 | 0 | return luService.getVersionBySequenceNumber(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, sequence); |
1451 | |
} |
1452 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1453 | |
} |
1454 | |
|
1455 | |
@Override |
1456 | |
public List<VersionDisplayInfo> getVersions(String refObjectTypeURI, |
1457 | |
String refObjectId) throws DoesNotExistException, |
1458 | |
InvalidParameterException, MissingParameterException, |
1459 | |
OperationFailedException, PermissionDeniedException { |
1460 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1461 | 0 | return luService.getVersions(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
1462 | |
} |
1463 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1464 | |
} |
1465 | |
|
1466 | |
@Override |
1467 | |
public List<VersionDisplayInfo> getVersionsInDateRange( |
1468 | |
String refObjectTypeURI, String refObjectId, Date from, Date to) |
1469 | |
throws DoesNotExistException, InvalidParameterException, |
1470 | |
MissingParameterException, OperationFailedException, |
1471 | |
PermissionDeniedException { |
1472 | 1 | if(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI.equals(refObjectTypeURI)){ |
1473 | 0 | return luService.getVersionsInDateRange(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, from, to); |
1474 | |
} |
1475 | 1 | throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
1476 | |
} |
1477 | |
|
1478 | |
public void setAtpService(AtpService atpService) { |
1479 | 1 | this.atpService = atpService; |
1480 | 1 | } |
1481 | |
|
1482 | |
public AtpService getAtpService() { |
1483 | 0 | return atpService; |
1484 | |
} |
1485 | |
|
1486 | |
private void validateMajorDisciplineAtps(MajorDisciplineInfo majorDisciplineInfo, List<ValidationResultInfo> validationResults) throws InvalidParameterException, MissingParameterException, OperationFailedException{ |
1487 | |
|
1488 | 9 | String startTerm = majorDisciplineInfo.getStartTerm(); |
1489 | |
|
1490 | 9 | if(!isEmpty(majorDisciplineInfo.getAttributes().get("endInstAdmitTerm"))){ |
1491 | 0 | compareAtps(startTerm, majorDisciplineInfo.getAttributes().get("endInstAdmitTerm"), validationResults, "End Inst Admin Term", "endInstAdmitTerm"); |
1492 | |
} |
1493 | |
|
1494 | 9 | if(!isEmpty(majorDisciplineInfo.getEndProgramEntryTerm())){ |
1495 | 9 | compareAtps(startTerm, majorDisciplineInfo.getEndProgramEntryTerm(), validationResults, "End Program Entry Term", "endProgramEntryTerm"); |
1496 | |
} |
1497 | |
|
1498 | 9 | if(!isEmpty(majorDisciplineInfo.getEndTerm())){ |
1499 | 9 | compareAtps(startTerm, majorDisciplineInfo.getEndTerm(), validationResults, "End Program Enroll Term", "endTerm"); |
1500 | |
} |
1501 | |
|
1502 | 9 | List<ProgramVariationInfo> variations = majorDisciplineInfo.getVariations(); |
1503 | 9 | if(variations != null && !variations.isEmpty()){ |
1504 | 9 | int idx = 0; |
1505 | 9 | for(ProgramVariationInfo variation : variations){ |
1506 | 19 | validateVariationAtps(variation, validationResults, idx); |
1507 | 19 | idx ++; |
1508 | |
} |
1509 | |
} |
1510 | 9 | } |
1511 | |
|
1512 | |
|
1513 | |
private void validateVariationAtps(ProgramVariationInfo programVariationInfo, List<ValidationResultInfo> validationResults, int idx) throws InvalidParameterException, MissingParameterException, OperationFailedException{ |
1514 | |
|
1515 | 19 | String startTerm = programVariationInfo.getStartTerm(); |
1516 | |
|
1517 | 19 | if(!isEmpty(programVariationInfo.getAttributes().get("endInstAdmitTerm"))){ |
1518 | 0 | compareAtps(startTerm, programVariationInfo.getAttributes().get("endInstAdmitTerm"), validationResults, "End Inst Admin Term", "variations/" + idx + "/endInstAdmitTerm"); |
1519 | |
} |
1520 | |
|
1521 | 19 | if(!isEmpty(programVariationInfo.getEndProgramEntryTerm())){ |
1522 | 19 | compareAtps(startTerm, programVariationInfo.getEndProgramEntryTerm(), validationResults, "End Program Entry Term", "variations/" + idx + "/endProgramEntryTerm"); |
1523 | |
} |
1524 | |
|
1525 | 19 | if(!isEmpty(programVariationInfo.getEndTerm())){ |
1526 | 19 | compareAtps(startTerm, programVariationInfo.getEndTerm(), validationResults, "End Program Enroll Term", "variations/" + idx + "/endTerm"); |
1527 | |
} |
1528 | 19 | } |
1529 | |
|
1530 | |
private AtpInfo getAtpInfo(String atpKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException{ |
1531 | 56 | if(atpKey==null){ |
1532 | 0 | return null; |
1533 | |
} |
1534 | 56 | return atpService.getAtp(atpKey); |
1535 | |
} |
1536 | |
|
1537 | |
private void compareAtps(String aptKey1, String aptKey2, List<ValidationResultInfo> validationResults, String field, String path) throws InvalidParameterException, MissingParameterException, OperationFailedException{ |
1538 | 56 | AtpInfo atpInfo1 = null; |
1539 | 56 | AtpInfo atpInfo2 = null; |
1540 | |
|
1541 | |
try{ |
1542 | 56 | atpInfo1 = getAtpInfo(aptKey1); |
1543 | 0 | atpInfo2 = getAtpInfo(aptKey2); |
1544 | 0 | }catch(DoesNotExistException e){} |
1545 | |
|
1546 | 56 | if(atpInfo1 != null && atpInfo1 != null){ |
1547 | 0 | if(atpInfo1.getStartDate()!= null && atpInfo2.getStartDate() != null){ |
1548 | 0 | boolean compareResult = ValidatorUtils.compareValues(atpInfo2.getStartDate(), atpInfo1.getStartDate(), DataType.DATE, "greater_than_equal", true, new ServerDateParser()); |
1549 | 0 | if(!compareResult){ |
1550 | 0 | ValidationResultInfo vri = new ValidationResultInfo(); |
1551 | 0 | vri.setElement(path); |
1552 | 0 | vri.setError(field + " should be greater than Start Term"); |
1553 | 0 | validationResults.add(vri); |
1554 | |
} |
1555 | |
} |
1556 | |
} |
1557 | |
|
1558 | 56 | } |
1559 | |
|
1560 | |
private boolean isEmpty(String value){ |
1561 | 84 | return value == null || (value != null && "".equals(value)); |
1562 | |
} |
1563 | |
|
1564 | |
public void setDocumentService(DocumentService documentService) { |
1565 | 1 | this.documentService = documentService; |
1566 | 1 | } |
1567 | |
|
1568 | |
public DocumentService getDocumentService() { |
1569 | 0 | return documentService; |
1570 | |
} |
1571 | |
|
1572 | |
} |