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