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