Coverage Report - org.kuali.student.lum.lo.service.impl.LearningObjectiveServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LearningObjectiveServiceImpl
81%
241/297
60%
52/86
2.196
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.lum.lo.service.impl;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.jws.WebService;
 22  
 
 23  
 import org.kuali.student.common.validator.Validator;
 24  
 import org.kuali.student.common.validator.ValidatorFactory;
 25  
 import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition;
 26  
 import org.kuali.student.core.dictionary.service.DictionaryService;
 27  
 import org.kuali.student.core.dto.StatusInfo;
 28  
 import org.kuali.student.core.exceptions.AlreadyExistsException;
 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.InvalidParameterException;
 33  
 import org.kuali.student.core.exceptions.MissingParameterException;
 34  
 import org.kuali.student.core.exceptions.OperationFailedException;
 35  
 import org.kuali.student.core.exceptions.PermissionDeniedException;
 36  
 import org.kuali.student.core.exceptions.UnsupportedActionException;
 37  
 import org.kuali.student.core.exceptions.VersionMismatchException;
 38  
 import org.kuali.student.core.search.dto.SearchCriteriaTypeInfo;
 39  
 import org.kuali.student.core.search.dto.SearchParam;
 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.SearchResultCell;
 43  
 import org.kuali.student.core.search.dto.SearchResultRow;
 44  
 import org.kuali.student.core.search.dto.SearchResultTypeInfo;
 45  
 import org.kuali.student.core.search.dto.SearchTypeInfo;
 46  
 import org.kuali.student.core.search.service.SearchManager;
 47  
 import org.kuali.student.core.validation.dto.ValidationResultInfo;
 48  
 import org.kuali.student.lum.lo.dao.LoDao;
 49  
 import org.kuali.student.lum.lo.dto.LoCategoryInfo;
 50  
 import org.kuali.student.lum.lo.dto.LoCategoryTypeInfo;
 51  
 import org.kuali.student.lum.lo.dto.LoInfo;
 52  
 import org.kuali.student.lum.lo.dto.LoLoRelationInfo;
 53  
 import org.kuali.student.lum.lo.dto.LoLoRelationTypeInfo;
 54  
 import org.kuali.student.lum.lo.dto.LoRepositoryInfo;
 55  
 import org.kuali.student.lum.lo.dto.LoTypeInfo;
 56  
 import org.kuali.student.lum.lo.entity.Lo;
 57  
 import org.kuali.student.lum.lo.entity.LoCategory;
 58  
 import org.kuali.student.lum.lo.entity.LoCategoryType;
 59  
 import org.kuali.student.lum.lo.entity.LoLoRelation;
 60  
 import org.kuali.student.lum.lo.entity.LoLoRelationType;
 61  
 import org.kuali.student.lum.lo.entity.LoRepository;
 62  
 import org.kuali.student.lum.lo.entity.LoType;
 63  
 import org.kuali.student.lum.lo.service.LearningObjectiveService;
 64  
 import org.springframework.transaction.annotation.Transactional;
 65  
 
 66  
 /*n
 67  
  * @author Kuali Student team
 68  
  *
 69  
  */
 70  
 @WebService(endpointInterface = "org.kuali.student.lum.lo.service.LearningObjectiveService", serviceName = "LearningObjectiveService", portName = "LearningObjectiveService", targetNamespace = "http://student.kuali.org/wsdl/lo")
 71  
 @Transactional(noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 72  6
 public class LearningObjectiveServiceImpl implements LearningObjectiveService {
 73  
     private LoDao loDao;
 74  
         private SearchManager searchManager;
 75  
     private DictionaryService dictionaryServiceDelegate;
 76  
         private ValidatorFactory validatorFactory;
 77  
 
 78  
         public LoDao getLoDao() {
 79  0
         return loDao;
 80  
     }
 81  
 
 82  
     public void setLoDao(LoDao dao) {
 83  3
         this.loDao = dao;
 84  3
     }
 85  
 
 86  
         public void setSearchManager(SearchManager searchManager) {
 87  3
                 this.searchManager = searchManager;
 88  3
         }
 89  
 
 90  
     public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {
 91  3
         this.dictionaryServiceDelegate = dictionaryServiceDelegate;
 92  3
     }
 93  
 
 94  
         public ValidatorFactory getValidatorFactory() {
 95  0
         return validatorFactory;
 96  
     }
 97  
 
 98  
     public void setValidatorFactory(ValidatorFactory validatorFactory) {
 99  3
         this.validatorFactory = validatorFactory;
 100  3
     }
 101  
 
 102  
     /*
 103  
      * (non-Javadoc)
 104  
      * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoRepositories()
 105  
      */
 106  
         @Override
 107  
         public List<LoRepositoryInfo> getLoRepositories()
 108  
                         throws OperationFailedException {
 109  1
             List<LoRepository> repositories = loDao.find(LoRepository.class);
 110  1
                 return LearningObjectiveServiceAssembler.toLoRepositoryInfos(repositories);
 111  
         }
 112  
         
 113  
         /*
 114  
          * (non-Javadoc)
 115  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoRepository(java.lang.String)
 116  
          */
 117  
         @Override
 118  
         public LoRepositoryInfo getLoRepository(String loRepositoryKey)
 119  
                         throws DoesNotExistException, InvalidParameterException,
 120  
                         MissingParameterException, OperationFailedException {
 121  2
             checkForMissingParameter(loRepositoryKey, "loRepositoryKey");
 122  1
                 return LearningObjectiveServiceAssembler.toLoRepositoryInfo(loDao.fetch(LoRepository.class, loRepositoryKey));
 123  
         }
 124  
 
 125  
         /*
 126  
          * (non-Javadoc)
 127  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoTypes()
 128  
          */
 129  
         @Override
 130  
         public List<LoTypeInfo> getLoTypes() throws OperationFailedException {
 131  1
             List<LoType> find = loDao.find(LoType.class);
 132  1
                 return LearningObjectiveServiceAssembler.toLoTypeInfos(find);
 133  
         }
 134  
 
 135  
         /*
 136  
          * (non-Javadoc)
 137  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoType(java.lang.String)
 138  
          */
 139  
         @Override
 140  
         public LoTypeInfo getLoType(String loTypeKey) throws DoesNotExistException,
 141  
                         InvalidParameterException, MissingParameterException,
 142  
                         OperationFailedException {
 143  3
             checkForMissingParameter(loTypeKey, "loTypeKey");
 144  2
             LoType fetch = loDao.fetch(LoType.class, loTypeKey);
 145  2
                 return LearningObjectiveServiceAssembler.toLoTypeInfo(fetch);
 146  
         }
 147  
 
 148  
         /*
 149  
          * (non-Javadoc)
 150  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoLoRelationTypes()
 151  
          */
 152  
         @Override
 153  
         public List<LoLoRelationTypeInfo> getLoLoRelationTypes()
 154  
                         throws OperationFailedException {
 155  1
             List<LoLoRelationType> fetch = loDao.find(LoLoRelationType.class);
 156  1
                 return LearningObjectiveServiceAssembler.toLoLoRelationTypeInfos(fetch);
 157  
         }
 158  
 
 159  
         /*
 160  
          * (non-Javadoc)
 161  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoLoRelationType(java.lang.String)
 162  
          */
 163  
         @Override
 164  
         public LoLoRelationTypeInfo getLoLoRelationType(String loLoRelationTypeKey)
 165  
                         throws OperationFailedException, MissingParameterException, DoesNotExistException {
 166  2
             checkForMissingParameter(loLoRelationTypeKey, "loLoRelationTypeKey");
 167  1
                 return LearningObjectiveServiceAssembler.toLoLoRelationTypeInfo(loDao.fetch(LoLoRelationType.class, loLoRelationTypeKey));
 168  
         }
 169  
 
 170  
         @Override
 171  
         public List<String> getAllowedLoLoRelationTypesForLoType(String loTypeKey, String relatedLoTypeKey)
 172  
                         throws DoesNotExistException, InvalidParameterException,
 173  
                                         MissingParameterException, OperationFailedException {
 174  2
             checkForMissingParameter(loTypeKey, "loTypeKey");
 175  2
             checkForMissingParameter(relatedLoTypeKey, "relatedLoTypeKey");
 176  
             
 177  2
             return loDao.getAllowedLoLoRelationTypesForLoType(loTypeKey, relatedLoTypeKey);
 178  
         }
 179  
 
 180  
     /*
 181  
          * (non-Javadoc)
 182  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#addLoCategoryToLo(java.lang.String, java.lang.String)
 183  
          */
 184  
         @Override
 185  
         public StatusInfo addLoCategoryToLo(String loCategoryId, String loId)
 186  
                         throws AlreadyExistsException, DoesNotExistException,
 187  
                         InvalidParameterException, MissingParameterException,
 188  
                         OperationFailedException, PermissionDeniedException,
 189  
                         UnsupportedActionException {
 190  1263
             checkForMissingParameter(loCategoryId, "loCategoryId");
 191  1263
             checkForMissingParameter(loId, "loId");
 192  1263
         StatusInfo statusInfo = new StatusInfo();
 193  1263
         statusInfo.setSuccess(loDao.addLoCategoryToLo(loCategoryId, loId));
 194  1263
         return statusInfo;
 195  
         }
 196  
 
 197  
         /* (non-Javadoc)
 198  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#createLo(java.lang.String, java.lang.String, org.kuali.student.lum.lo.dto.LoInfo)
 199  
          */
 200  
         @Override
 201  
         public LoInfo createLo(String repositoryId, String loType, LoInfo loInfo)
 202  
                         throws DataValidationErrorException, DoesNotExistException,
 203  
                         InvalidParameterException, MissingParameterException,
 204  
                         OperationFailedException, PermissionDeniedException {
 205  642
             checkForMissingParameter(repositoryId, "repositoryId");
 206  641
             checkForMissingParameter(loType, "loType");
 207  640
             checkForMissingParameter(loInfo, "loInfo");
 208  
             
 209  
             
 210  
                 // Validate LO
 211  639
                 List<ValidationResultInfo> val = validateLo("SYSTEM", loInfo);
 212  638
                 if(null != val && val.size() > 0) {
 213  0
                         for (ValidationResultInfo result : val) {
 214  0
                                 System.err.println("Validation error. Element: " + result.getElement() + ",  Value: " + result.getMessage());
 215  
                         }
 216  0
                         throw new DataValidationErrorException("Validation error!");
 217  
                 }
 218  
                 
 219  
             // make sure LoType and LoRepository exist before trying to create
 220  
             // if checkForMissingParameter above did its job, we don't have to null-check these id's
 221  638
             LoType type = null;
 222  638
             LoRepository repository = null;
 223  
             try {
 224  638
                     type = loDao.fetch(LoType.class, loType);
 225  638
                     repository = loDao.fetch(LoRepository.class, repositoryId); 
 226  0
             } catch (DoesNotExistException dnee) {
 227  0
                     throw new DoesNotExistException("Specified " + (null == type ? "LoType" : "LoRepository") + " does not exist", dnee);
 228  638
             }
 229  
             
 230  638
             loInfo.setLoRepositoryKey(repositoryId);
 231  638
             loInfo.setType(loType);
 232  
             
 233  638
             Lo lo = null;
 234  
             try {
 235  638
                     lo = LearningObjectiveServiceAssembler.toLo(false, loInfo, loDao);
 236  0
             } catch (VersionMismatchException vme) {
 237  
                     // should never happen in a create call, but
 238  0
                     throw new OperationFailedException("VersionMismatchException caught during Learning Objective creation");
 239  638
             }
 240  638
             lo.setLoType(type);
 241  638
             lo.setLoRepository(repository);
 242  638
             loDao.create(lo);
 243  
             
 244  638
                 return LearningObjectiveServiceAssembler.toLoInfo(lo);
 245  
         }
 246  
 
 247  
         /* (non-Javadoc)
 248  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#deleteLo(java.lang.String)
 249  
          */
 250  
         @Override
 251  
         public StatusInfo deleteLo(String loId)
 252  
                         throws DependentObjectsExistException, DoesNotExistException,
 253  
                         InvalidParameterException, MissingParameterException,
 254  
                         OperationFailedException, PermissionDeniedException {
 255  25
             checkForMissingParameter(loId, "loId");
 256  
             
 257  25
             StatusInfo returnStatus = new StatusInfo();
 258  25
             returnStatus.setSuccess(loDao.deleteLo(loId));
 259  24
                 return returnStatus;
 260  
         }
 261  
 
 262  
         /* (non-Javadoc)
 263  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#deleteLoCategory(java.lang.String)
 264  
          */
 265  
         @Override
 266  
         public StatusInfo deleteLoCategory(String loCategoryId)
 267  
                         throws DependentObjectsExistException, DoesNotExistException,
 268  
                         InvalidParameterException, MissingParameterException,
 269  
                         OperationFailedException, PermissionDeniedException {
 270  6
             checkForMissingParameter(loCategoryId, "loCategoryId");
 271  
             
 272  6
             loDao.deleteLoCategory(loCategoryId);
 273  
             
 274  5
                 return new StatusInfo();
 275  
         }
 276  
 
 277  
         /* (non-Javadoc)
 278  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLo(java.lang.String)
 279  
          */
 280  
         @Override
 281  
         public LoInfo getLo(String loId) throws DoesNotExistException,
 282  
                         InvalidParameterException, MissingParameterException,
 283  
                         OperationFailedException {
 284  84
             checkForMissingParameter(loId, "loId");
 285  
             
 286  83
                 return LearningObjectiveServiceAssembler.toLoInfo(loDao.fetch(Lo.class, loId));
 287  
         }
 288  
 
 289  
         /* (non-Javadoc)
 290  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoByIdList(java.util.List)
 291  
          */
 292  
         @Override
 293  
         public List<LoInfo> getLoByIdList(List<String> loIds)
 294  
                         throws InvalidParameterException, MissingParameterException,
 295  
                         OperationFailedException {
 296  1
             checkForMissingParameter(loIds, "loId");
 297  1
             checkForEmptyList(loIds, "loId");
 298  1
             List<Lo> los = loDao.getLoByIdList(loIds);
 299  1
                 return LearningObjectiveServiceAssembler.toLoInfos(los);
 300  
         }
 301  
 
 302  
         /* (non-Javadoc)
 303  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoCategories(java.lang.String)
 304  
          */
 305  
         @Override
 306  
         public List<LoCategoryInfo> getLoCategories(String loRepositoryKey)
 307  
                         throws DoesNotExistException, InvalidParameterException,
 308  
                         MissingParameterException, OperationFailedException {
 309  3
             checkForMissingParameter(loRepositoryKey, "loRepositoryKey");
 310  3
             List<LoCategory> categories = loDao.getLoCategories(loRepositoryKey);
 311  3
         return LearningObjectiveServiceAssembler.toLoCategoryInfos(categories);
 312  
         }
 313  
 
 314  
         /* (non-Javadoc)
 315  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoCategoriesForLo(java.lang.String)
 316  
          */
 317  
         @Override
 318  
         public List<LoCategoryInfo> getLoCategoriesForLo(String loId)
 319  
                         throws DoesNotExistException, InvalidParameterException,
 320  
                         MissingParameterException, OperationFailedException {
 321  432
             checkForMissingParameter(loId, "loId");
 322  432
             List<LoCategory> categories = loDao.getLoCategoriesForLo(loId);
 323  432
                 return LearningObjectiveServiceAssembler.toLoCategoryInfos(categories);
 324  
         }
 325  
 
 326  
         /* (non-Javadoc)
 327  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoCategory(java.lang.String)
 328  
          */
 329  
         @Override
 330  
         public LoCategoryInfo getLoCategory(String loCategoryId)
 331  
                         throws DoesNotExistException, InvalidParameterException,
 332  
                         MissingParameterException, OperationFailedException {
 333  3
             checkForMissingParameter(loCategoryId, "loCategoryId");
 334  
             
 335  3
                 return LearningObjectiveServiceAssembler.toLoCategoryInfo(loDao.fetch(LoCategory.class, loCategoryId));
 336  
         }
 337  
 
 338  
         /* (non-Javadoc)
 339  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLoParents(java.lang.String)
 340  
         public List<LoInfo> getLoParents(String loId) throws DoesNotExistException,
 341  
                         InvalidParameterException, MissingParameterException,
 342  
                         OperationFailedException {
 343  
             checkForMissingParameter(loId, "loId");
 344  
             List<Lo> loParents = loDao.getLoParents(loId);
 345  
                 return LearningObjectiveServiceAssembler.toLoInfos(loParents);
 346  
         }
 347  
          */
 348  
 
 349  
         /* (non-Javadoc)
 350  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#getLosByLoCategory(java.lang.String)
 351  
          */
 352  
         @Override
 353  
         public List<LoInfo> getLosByLoCategory(String loCategoryId)
 354  
                         throws DoesNotExistException, InvalidParameterException,
 355  
                         MissingParameterException, OperationFailedException {
 356  5
             checkForMissingParameter(loCategoryId, "loCategoryId");
 357  5
             List<Lo> los = loDao.getLosByLoCategory(loCategoryId);
 358  5
                 return LearningObjectiveServiceAssembler.toLoInfos(los);
 359  
         }
 360  
 
 361  
         /* (non-Javadoc)
 362  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#isDescendant(java.lang.String, java.lang.String)
 363  
         @Override
 364  
         public Boolean isDescendant(String loId, String descendantLoId)
 365  
                         throws DoesNotExistException, InvalidParameterException,
 366  
                         MissingParameterException, OperationFailedException {
 367  
             checkForMissingParameter(loId, "loId");
 368  
             checkForMissingParameter(descendantLoId, "descendantLoId");
 369  
                 return loDao.isDescendant(loId, descendantLoId);
 370  
         }
 371  
          */
 372  
 
 373  
         /* (non-Javadoc)
 374  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#isEquivalent(java.lang.String, java.lang.String)
 375  
         @Override
 376  
         public Boolean isEquivalent(String loId, String equivalentLoId)
 377  
                         throws DoesNotExistException, InvalidParameterException,
 378  
                         MissingParameterException, OperationFailedException {
 379  
             checkForMissingParameter(loId, "loId");
 380  
             checkForMissingParameter(equivalentLoId, "equivalentLoId");
 381  
                 return loDao.isEquivalent(loId, equivalentLoId);
 382  
         }
 383  
          */
 384  
 
 385  
         /* (non-Javadoc)
 386  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#removeChildLoFromLo(java.lang.String, java.lang.String)
 387  
         @Override
 388  
         public StatusInfo removeChildLoFromLo(String loId, String parentLoId)
 389  
                         throws DependentObjectsExistException, DoesNotExistException,
 390  
                         InvalidParameterException, MissingParameterException,
 391  
                         OperationFailedException, PermissionDeniedException {
 392  
             checkForMissingParameter(loId, "loId");
 393  
             checkForMissingParameter(parentLoId, "parentLoId");
 394  
             
 395  
             StatusInfo statusInfo = new StatusInfo();
 396  
             statusInfo.setSuccess(loDao.removeChildLoFromLo(loId, parentLoId));
 397  
                 return statusInfo;
 398  
         }
 399  
          */
 400  
 
 401  
         /* (non-Javadoc)
 402  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#removeEquivalentLoFromLo(java.lang.String, java.lang.String)
 403  
         @Override
 404  
         public StatusInfo removeEquivalentLoFromLo(String loId,
 405  
                         String equivalentLoId) throws DoesNotExistException,
 406  
                         InvalidParameterException, MissingParameterException,
 407  
                         OperationFailedException, PermissionDeniedException {
 408  
             checkForMissingParameter(loId, "loId");
 409  
             checkForMissingParameter(equivalentLoId, "equivalentLoId");
 410  
             
 411  
         StatusInfo statusInfo = new StatusInfo();
 412  
         statusInfo.setSuccess(loDao.removeEquivalentLoFromLo(loId, equivalentLoId));
 413  
         return statusInfo;
 414  
         }
 415  
          */
 416  
 
 417  
         /* (non-Javadoc)
 418  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#removeLoCategoryFromLo(java.lang.String, java.lang.String)
 419  
          */
 420  
         @Override
 421  
         public StatusInfo removeLoCategoryFromLo(String loCategoryId, String loId)
 422  
                         throws DoesNotExistException, InvalidParameterException,
 423  
                         MissingParameterException, OperationFailedException,
 424  
                         PermissionDeniedException, UnsupportedActionException {
 425  44
             checkForMissingParameter(loCategoryId, "loCategoryId");
 426  44
             checkForMissingParameter(loId, "loId");
 427  
             
 428  44
         StatusInfo statusInfo = new StatusInfo();
 429  44
         statusInfo.setSuccess(loDao.removeLoCategoryFromLo(loCategoryId, loId));
 430  44
         return statusInfo;
 431  
         }
 432  
 
 433  
         /* (non-Javadoc)
 434  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#updateLo(java.lang.String, org.kuali.student.lum.lo.dto.LoInfo)
 435  
          */
 436  
         @Override
 437  
         public LoInfo updateLo(String loId, LoInfo loInfo)
 438  
                         throws DataValidationErrorException, DoesNotExistException,
 439  
                         InvalidParameterException, MissingParameterException,
 440  
                         OperationFailedException, PermissionDeniedException,
 441  
                         VersionMismatchException {
 442  25
             checkForMissingParameter(loId, "loId");
 443  24
             checkForMissingParameter(loInfo, "loInfo");
 444  
 
 445  
                 // Validate LO
 446  23
                 List<ValidationResultInfo> val = validateLo("SYSTEM", loInfo);
 447  23
                 if(null != val && val.size() > 0) {
 448  0
                         for (ValidationResultInfo result : val) {
 449  0
                                 System.err.println("Validation error. Element: " + result.getElement() + ",  Value: " + result.getMessage());
 450  
                         }
 451  0
                         throw new DataValidationErrorException("Validation error!");
 452  
                 }
 453  
                 
 454  23
             Lo lo = loDao.fetch(Lo.class, loId);
 455  
         
 456  23
         if (!String.valueOf(lo.getVersionNumber()).equals(loInfo.getMetaInfo().getVersionInd())){
 457  1
             throw new VersionMismatchException("LO to be updated is not the current version");
 458  
         }
 459  
         
 460  22
         lo = LearningObjectiveServiceAssembler.toLo(true, lo, loInfo, loDao);
 461  22
         loDao.update(lo);
 462  22
         return LearningObjectiveServiceAssembler.toLoInfo(lo);
 463  
         }
 464  
 
 465  
         /* (non-Javadoc)
 466  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#updateLoCategory(java.lang.String, org.kuali.student.lum.lo.dto.LoCategoryInfo)
 467  
          */
 468  
         @Override
 469  
         public LoCategoryInfo updateLoCategory(String loCategoryId,
 470  
                         LoCategoryInfo loCategoryInfo) throws DataValidationErrorException,
 471  
                         DoesNotExistException, InvalidParameterException,
 472  
                         MissingParameterException, OperationFailedException,
 473  
                         PermissionDeniedException, VersionMismatchException {
 474  3
             checkForMissingParameter(loCategoryId, "loCategoryId");
 475  3
             checkForMissingParameter(loCategoryInfo, "loCategoryInfo");
 476  
             
 477  
                 // Validate LoCategory
 478  3
                 List<ValidationResultInfo> val = validateLoCategory("SYSTEM", loCategoryInfo);
 479  
 
 480  
                 //kslum-136 - don't allow dups w/ same name (case insensitive), type, state & repository
 481  3
         if (doesLoCategoryExist(loCategoryInfo.getLoRepository(), loCategoryInfo, loCategoryId)) {
 482  2
             ValidationResultInfo vr = new ValidationResultInfo();
 483  2
             vr.setElement("LO Category Name");
 484  2
             vr.setError("LO Category already exists");
 485  2
             val.add(vr);
 486  
         }
 487  3
         if(null != val && val.size() > 0) {
 488  2
             for (ValidationResultInfo result : val) {
 489  2
                 System.err.println("Validation error. Element: " + result.getElement() + ",  Value: " + result.getMessage());
 490  
             }
 491  2
             throw new DataValidationErrorException("Validation error!", val);
 492  
         }
 493  1
             LoCategory loCategory = loDao.fetch(LoCategory.class, loCategoryId);
 494  
         
 495  1
         if (!String.valueOf(loCategory.getVersionNumber()).equals(loCategoryInfo.getMetaInfo().getVersionInd())){
 496  0
             throw new VersionMismatchException("LoCategory to be updated is not the current version");
 497  
         }
 498  
         
 499  
         // if state is changing from "active"
 500  1
         if (loCategory.getState().equals("active") && ( ! loCategoryInfo.getState().equals("active") )) {
 501  
                     // N.B. - ability to 'retire' LoCategory's that are still associated w/ active
 502  
                     // LO's is configured and enforced on the client
 503  0
                 List<LoInfo> loInfos = getLosByLoCategory(loCategoryId);
 504  0
                     if (null != loInfos) {
 505  
                                 // remove associations of this LoCategory from active LO's
 506  0
                             for (LoInfo info : loInfos) {
 507  0
                                     if (info.getState().equals("active"))  {
 508  
                                             try {
 509  0
                                                         removeLoCategoryFromLo(loCategoryId, info.getId());
 510  0
                                                 } catch (UnsupportedActionException uaee) {
 511  0
                                                     throw new OperationFailedException("Unable to update LoCategory: could not remove association with active LearningObjective", uaee);
 512  0
                                                 }
 513  
                                     }
 514  
                             }
 515  
                     }
 516  
         }
 517  
                 
 518  
         // if type is changing
 519  1
         if ( ! loCategory.getLoCategoryType().getId().equals(loCategoryInfo.getType()) ) {
 520  1
                 loCategory = cloneLoCategory(loCategory, loCategoryInfo);
 521  
         } else {
 522  0
                 loCategory = LearningObjectiveServiceAssembler.toLoCategory(loCategory, loCategoryInfo, loDao);
 523  0
                 loDao.update(loCategory);
 524  
         }
 525  1
         return LearningObjectiveServiceAssembler.toLoCategoryInfo(loCategory);
 526  
         }
 527  
 
 528  
     // inactivate current LoCategory & clone it w/ its relationships,
 529  
         // used when changing immutable type of LoCategory
 530  
         // https://test.kuali.org/confluence/display/KULSTG/DS+-+LO+Centrally+Maintain+Categories
 531  
         private LoCategory cloneLoCategory(LoCategory loCategory, LoCategoryInfo loCategoryInfo) throws DoesNotExistException, InvalidParameterException, OperationFailedException {
 532  1
             LoCategoryType catType = null;
 533  
             
 534  
             try {
 535  1
                 catType = loDao.fetch(LoCategoryType.class, loCategoryInfo.getType());
 536  0
             } catch (DoesNotExistException dnee) {
 537  0
                     throw new DoesNotExistException("Attempt to set LoCategory's type to nonexistent LoCategoryType", dnee);
 538  1
             }
 539  
                 
 540  
             // clone the existing LO
 541  1
             LoCategoryInfo newLoCategoryInfo = LearningObjectiveServiceAssembler.toLoCategoryInfo(loCategory);
 542  1
             newLoCategoryInfo.setType(catType.getId());
 543  1
             newLoCategoryInfo.setName(loCategoryInfo.getName());
 544  1
             LoCategory newLoCategory = loDao.create(LearningObjectiveServiceAssembler.toLoCategory(newLoCategoryInfo, loDao));
 545  
                 
 546  
             // clone Lo-LoCategory relations
 547  1
             List<Lo> catsLos = loDao.getLosByLoCategory(loCategory.getId());                 
 548  1
             for (Lo lo : catsLos) {
 549  
                     try {
 550  
                             // create the new one
 551  2
                                 loDao.addLoCategoryToLo(newLoCategory.getId(), lo.getId());
 552  
                                 // remove the old one
 553  2
                                 loDao.removeLoCategoryFromLo(loCategory.getId(), lo.getId());
 554  0
                         } catch (UnsupportedActionException uae) {
 555  0
                                 throw new OperationFailedException(uae.getMessage(), uae);
 556  2
                         }
 557  
             }
 558  
                 
 559  
             // inactivate old LoCategory
 560  1
             loCategory.setState("inactive");
 561  1
             loDao.update(loCategory);
 562  
                 
 563  1
             return newLoCategory;
 564  
         }
 565  
 
 566  
         /* (non-Javadoc)
 567  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#validateLo(java.lang.String, org.kuali.student.lum.lo.dto.LoInfo)
 568  
          */
 569  
         @Override
 570  
         public List<ValidationResultInfo> validateLo(String validationType,
 571  
                         LoInfo loInfo) throws DoesNotExistException,
 572  
                         InvalidParameterException, MissingParameterException,
 573  
                         OperationFailedException {
 574  662
             checkForMissingParameter(validationType, "validationType");
 575  662
             checkForMissingParameter(loInfo, "loInfo");
 576  
             
 577  
             try{
 578  662
                     String loDesc = loInfo.getDesc().getPlain(); 
 579  662
                     checkForEmptyString(loDesc, "loInfo.Desc");
 580  0
             } catch (NullPointerException e){
 581  
                         //do not checkForEmptyString
 582  661
                 }
 583  
             
 584  661
             ObjectStructureDefinition objStructure = this.getObjectStructure(LoInfo.class.getName());
 585  661
             Validator validator = validatorFactory.getValidator();
 586  661
             return validator.validateObject(loInfo, objStructure);
 587  
         }
 588  
 
 589  
         /* (non-Javadoc)
 590  
          * @see org.kuali.student.lum.lo.service.LearningObjectiveService#validateLoCategory(java.lang.String, org.kuali.student.lum.lo.dto.LoCategoryInfo)
 591  
          */
 592  
         @Override
 593  
         public List<ValidationResultInfo> validateLoCategory(String validationType,
 594  
                         LoCategoryInfo loCategoryInfo) throws DoesNotExistException,
 595  
                         InvalidParameterException, MissingParameterException,
 596  
                         OperationFailedException {
 597  10
             checkForMissingParameter(validationType, "validationType");
 598  10
             checkForMissingParameter(loCategoryInfo, "loCategoryInfo");
 599  
             
 600  
             try{
 601  10
                     String catDesc = loCategoryInfo.getDesc().getPlain(); 
 602  3
                     checkForEmptyString(catDesc, "loCategoryInfo.Desc");
 603  7
             } catch (NullPointerException e){
 604  
                         //do not checkForEmptyString
 605  2
                 }
 606  
 
 607  9
         ObjectStructureDefinition objStructure = this.getObjectStructure(LoCategoryInfo.class.getName());
 608  9
         Validator validator = validatorFactory.getValidator();
 609  9
         return validator.validateObject(loCategoryInfo, objStructure);
 610  
 
 611  
         }
 612  
 
 613  
         @Override
 614  
         public List<ValidationResultInfo> validateLoLoRelation(
 615  
                         String validationType, LoLoRelationInfo loLoRelationInfo)
 616  
                         throws DoesNotExistException, InvalidParameterException,
 617  
                         MissingParameterException, OperationFailedException {
 618  
 
 619  542
         ObjectStructureDefinition objStructure = this.getObjectStructure(LoLoRelationInfo.class.getName());
 620  542
         Validator validator = validatorFactory.getValidator();
 621  542
         return validator.validateObject(loLoRelationInfo, objStructure);
 622  
         }
 623  
 
 624  
     /**
 625  
      * Check for missing parameter and throw localized exception if missing
 626  
      *
 627  
      * @param param
 628  
      * @param parameter name
 629  
      * @throws MissingParameterException
 630  
      */
 631  
     private void checkForMissingParameter(Object param, String paramName)
 632  
             throws MissingParameterException {
 633  9488
         if (param == null) {
 634  16
             throw new MissingParameterException(paramName + " can not be null");
 635  
         }
 636  9472
     }
 637  
 
 638  
     /**
 639  
      * @param param
 640  
      * @param paramName
 641  
      * @throws MissingParameterException
 642  
      */
 643  
     private void checkForEmptyList(Object param, String paramName)
 644  
             throws MissingParameterException {
 645  1
         if (param != null && param instanceof List && ((List<?>)param).size() == 0) {
 646  0
             throw new MissingParameterException(paramName + " can not be an empty list");
 647  
         }
 648  1
     }
 649  
 
 650  
     /**
 651  
      * @param param
 652  
      * @param paramName
 653  
      * @throws MissingParameterException
 654  
      */
 655  
     private void checkForEmptyString(String param, String paramName)
 656  
             throws MissingParameterException {
 657  665
         if (param != null && "".equals(param.trim())) {
 658  2
             throw new MissingParameterException(paramName + " can not be empty");
 659  
         }
 660  663
     }
 661  
     
 662  
     /**
 663  
      * @param loRepositoryKey
 664  
      * @param loCategoryInfo
 665  
      * @param loCategoryId
 666  
      * @throws MissingParameterException,OperationFailedException
 667  
      */
 668  
     private boolean doesLoCategoryExist(String loRepositoryKey, LoCategoryInfo loCategoryInfo, String loCategoryId)
 669  
             throws MissingParameterException, DataValidationErrorException {
 670  
 
 671  9
         boolean exists = false;
 672  9
             SearchRequest request = new SearchRequest();
 673  9
             request.setSearchKey("lo.search.loCategoriesByNameRepoTypeState");
 674  
             
 675  9
                  List<SearchParam> searchParams = new ArrayList<SearchParam>();
 676  9
                 SearchParam qpv1 = new SearchParam();
 677  9
                 qpv1.setKey("lo.queryParam.loCategoryName");
 678  9
                 qpv1.setValue(loCategoryInfo.getName().toLowerCase());
 679  9
                 searchParams.add(qpv1);
 680  9
                 SearchParam qpv2 = new SearchParam();
 681  9
                 qpv2.setKey("lo.queryParam.loCategoryRepo");
 682  9
                 qpv2.setValue(loRepositoryKey);
 683  9
                 searchParams.add(qpv2);
 684  9
                 SearchParam qpv3 = new SearchParam();
 685  9
                 qpv3.setKey("lo.queryParam.loCategoryType");
 686  9
                 qpv3.setValue(loCategoryInfo.getType());
 687  9
                 searchParams.add(qpv3);
 688  9
                 SearchParam qpv4 = new SearchParam();
 689  9
                 qpv4.setKey("lo.queryParam.loCategoryState");
 690  9
                 qpv4.setValue(loCategoryInfo.getState());
 691  9
                 searchParams.add(qpv4);
 692  
                 
 693  9
                 request.setParams(searchParams);
 694  
                 
 695  9
                 SearchResult result = search(request);
 696  
                 
 697  9
                 if(loCategoryId != null && !loCategoryId.trim().equals("")){
 698  3
                         if (result.getRows().size() > 0) {
 699  2
                                 for(SearchResultRow srrow : result.getRows()){
 700  2
                                         List<SearchResultCell> srCells = srrow.getCells();
 701  2
                                         if(srCells != null && srCells.size() > 0){
 702  2
                                                 for(SearchResultCell srcell : srCells){
 703  2
                                                         if(!srcell.getValue().equals(loCategoryId)) {
 704  2
                                 exists = true;
 705  
                             }
 706  
                                                 }
 707  
                                         }
 708  2
                                 }
 709  
                         }
 710  
                 }
 711  
                 else{
 712  6
                         if (result.getRows().size() > 0) {
 713  2
                 exists = true;
 714  
                         }
 715  
                 }
 716  9
         return exists;
 717  
     }
 718  
     
 719  
     @Override
 720  
     public ObjectStructureDefinition getObjectStructure(String objectTypeKey) {
 721  1212
         return dictionaryServiceDelegate.getObjectStructure(objectTypeKey);
 722  
     }
 723  
 
 724  
     @Override
 725  
     public List<String> getObjectTypes() {
 726  0
         return dictionaryServiceDelegate.getObjectTypes();
 727  
     }
 728  
 
 729  
         /* (non-Javadoc)
 730  
          * @see org.kuali.student.core.search.service.SearchService#getSearchCriteriaType(java.lang.String)
 731  
          */
 732  
     @Override
 733  
     public SearchCriteriaTypeInfo getSearchCriteriaType(
 734  
             String searchCriteriaTypeKey) throws DoesNotExistException,
 735  
             InvalidParameterException, MissingParameterException,
 736  
             OperationFailedException {
 737  
 
 738  0
         return searchManager.getSearchCriteriaType(searchCriteriaTypeKey);
 739  
     }
 740  
 
 741  
         /* (non-Javadoc)
 742  
          * @see org.kuali.student.core.search.service.SearchService#getSearchCriteriaTypes()
 743  
          */
 744  
     @Override
 745  
     public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes()
 746  
     throws OperationFailedException {
 747  0
         return searchManager.getSearchCriteriaTypes();
 748  
     }
 749  
 
 750  
         /* (non-Javadoc)
 751  
          * @see org.kuali.student.core.search.service.SearchService#getSearchResultType(java.lang.String)
 752  
          */
 753  
     @Override
 754  
     public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey)
 755  
     throws DoesNotExistException, InvalidParameterException,
 756  
     MissingParameterException, OperationFailedException {
 757  0
         checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 758  0
         return searchManager.getSearchResultType(searchResultTypeKey);
 759  
     }
 760  
 
 761  
         /* (non-Javadoc)
 762  
          * @see org.kuali.student.core.search.service.SearchService#getSearchResultTypes()
 763  
          */
 764  
     @Override
 765  
     public List<SearchResultTypeInfo> getSearchResultTypes()
 766  
     throws OperationFailedException {
 767  0
         return searchManager.getSearchResultTypes();
 768  
     }
 769  
 
 770  
         /* (non-Javadoc)
 771  
          * @see org.kuali.student.core.search.service.SearchService#getSearchType(java.lang.String)
 772  
          */
 773  
     @Override
 774  
     public SearchTypeInfo getSearchType(String searchTypeKey)
 775  
     throws DoesNotExistException, InvalidParameterException,
 776  
     MissingParameterException, OperationFailedException {
 777  0
         checkForMissingParameter(searchTypeKey, "searchTypeKey");
 778  0
         return searchManager.getSearchType(searchTypeKey);
 779  
     }
 780  
 
 781  
         /* (non-Javadoc)
 782  
          * @see org.kuali.student.core.search.service.SearchService#getSearchTypes()
 783  
          */
 784  
     @Override
 785  
     public List<SearchTypeInfo> getSearchTypes()
 786  
     throws OperationFailedException {
 787  0
         return searchManager.getSearchTypes();
 788  
     }
 789  
 
 790  
         /* (non-Javadoc)
 791  
          * @see org.kuali.student.core.search.service.SearchService#getSearchTypesByCriteria(java.lang.String)
 792  
          */
 793  
     @Override
 794  
     public List<SearchTypeInfo> getSearchTypesByCriteria(
 795  
             String searchCriteriaTypeKey) throws DoesNotExistException,
 796  
             InvalidParameterException, MissingParameterException,
 797  
             OperationFailedException {
 798  0
         checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey");
 799  0
         return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey);
 800  
     }
 801  
 
 802  
         /* (non-Javadoc)
 803  
          * @see org.kuali.student.core.search.service.SearchService#getSearchTypesByResult(java.lang.String)
 804  
          */
 805  
     @Override
 806  
     public List<SearchTypeInfo> getSearchTypesByResult(
 807  
             String searchResultTypeKey) throws DoesNotExistException,
 808  
             InvalidParameterException, MissingParameterException,
 809  
             OperationFailedException {
 810  0
         checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 811  0
         return searchManager.getSearchTypesByResult(searchResultTypeKey);
 812  
     }
 813  
 
 814  
         @Override
 815  
         public LoLoRelationInfo createLoLoRelation(String loId, String relatedLoId,
 816  
                         String loLoRelationType, LoLoRelationInfo loLoRelationInfo)
 817  
                         throws AlreadyExistsException, 
 818  
                         DataValidationErrorException, DoesNotExistException,
 819  
                         InvalidParameterException, MissingParameterException,
 820  
                         OperationFailedException, PermissionDeniedException {
 821  546
             checkForMissingParameter(loId, "loId");
 822  545
             checkForMissingParameter(relatedLoId, "relatedLoId");
 823  544
             checkForMissingParameter(loLoRelationType, "loLoRelationType");
 824  543
             checkForMissingParameter(loLoRelationInfo, "loLoRelationInfo");
 825  
             
 826  
                 // Validate LoLoRelation
 827  542
                 List<ValidationResultInfo> val = validateLoLoRelation("SYSTEM", loLoRelationInfo);
 828  542
                 if(null != val && val.size() > 0) {
 829  0
                         for (ValidationResultInfo result : val) {
 830  0
                                 System.err.println("Validation error. Element: " + result.getElement() + ",  Value: " + result.getMessage());
 831  
                         }
 832  0
                         throw new DataValidationErrorException("Validation error!");
 833  
                 }
 834  
             
 835  542
             if (null == loLoRelationInfo.getState()) {
 836  2
                     loLoRelationInfo.setState("draft"); // TODO - enum of allowed states? retrieve allowed states from dictionary?
 837  
             }
 838  542
             Lo lo = loDao.fetch(Lo.class, loId);
 839  542
             Lo relatedLo = loDao.fetch(Lo.class, relatedLoId);
 840  542
             LoLoRelationType type = loDao.fetch(LoLoRelationType.class, loLoRelationType);
 841  542
             loLoRelationInfo.setLoId(loId);
 842  542
             loLoRelationInfo.setRelatedLoId(relatedLoId);
 843  542
             loLoRelationInfo.setType(loLoRelationType);
 844  
             
 845  542
             LoLoRelation relation = null;
 846  
             try {
 847  542
                     relation = LearningObjectiveServiceAssembler.toLoLoRelation(false, loLoRelationInfo, loDao);
 848  0
             } catch (VersionMismatchException vme) {
 849  
                     // should never happen in a create call, but
 850  0
                     throw new OperationFailedException("VersionMismatchException caught during LoLoRelation creation");
 851  542
             }
 852  542
             relation.setLo(lo);
 853  542
             relation.setRelatedLo(relatedLo);
 854  542
             relation.setLoLoRelationType(type);
 855  
             
 856  542
             relation = loDao.create(relation);
 857  
             
 858  542
                 return LearningObjectiveServiceAssembler.toLoLoRelationInfo(relation);
 859  
         }
 860  
 
 861  
         @Override
 862  
         public StatusInfo deleteLoLoRelation(String loLoRelationId)
 863  
                         throws DoesNotExistException, InvalidParameterException,
 864  
                         MissingParameterException, OperationFailedException,
 865  
                         PermissionDeniedException {
 866  18
             checkForMissingParameter(loLoRelationId, "loLoRelationId");
 867  
             
 868  18
             loDao.deleteLoLoRelation(loLoRelationId);
 869  
             
 870  18
                 return new StatusInfo();
 871  
         }
 872  
 
 873  
         @Override
 874  
         public LoLoRelationInfo getLoLoRelation(String loLoRelationId)
 875  
                         throws DoesNotExistException, InvalidParameterException,
 876  
                         MissingParameterException, OperationFailedException {
 877  4
             checkForMissingParameter(loLoRelationId, "loLoRelationId");
 878  3
                 return LearningObjectiveServiceAssembler.toLoLoRelationInfo(loDao.fetch(LoLoRelation.class, loLoRelationId));
 879  
         }
 880  
 
 881  
         @Override
 882  
         public List<LoLoRelationInfo> getLoLoRelationsByLoId(String loId)
 883  
                         throws DoesNotExistException, InvalidParameterException,
 884  
                         MissingParameterException, OperationFailedException {
 885  52
                 List<LoLoRelation> llRelations = loDao.getLoLoRelationsByLoId(loId);
 886  52
                 return LearningObjectiveServiceAssembler.toLoLoRelationInfos(llRelations);
 887  
         }
 888  
 
 889  
         @Override
 890  
         public List<LoInfo> getLosByRelatedLoId(String relatedLoId,
 891  
                         String loLoRelationType) throws DoesNotExistException,
 892  
                         InvalidParameterException, MissingParameterException,
 893  
                         OperationFailedException {
 894  0
                 List<Lo> relatedLos = loDao.getLosByRelatedLoId(relatedLoId, loLoRelationType);
 895  0
                 return LearningObjectiveServiceAssembler.toLoInfos(relatedLos);
 896  
         }
 897  
 
 898  
         @Override
 899  
         public List<LoInfo> getRelatedLosByLoId(String loId, String loLoRelationTypeKey)
 900  
                         throws DoesNotExistException, InvalidParameterException,
 901  
                         MissingParameterException, OperationFailedException {
 902  376
             checkForMissingParameter(loId, "loId");
 903  375
             checkForMissingParameter(loLoRelationTypeKey, "loLoRelationTypeKey");
 904  374
             List<Lo> relatedLos = loDao.getRelatedLosByLoId(loId, loLoRelationTypeKey);
 905  374
                 return LearningObjectiveServiceAssembler.toLoInfos(relatedLos);
 906  
         }
 907  
 
 908  
         @Override
 909  
         public LoLoRelationInfo updateLoLoRelation(String loLoRelationId,
 910  
                         LoLoRelationInfo loLoRelationInfo)
 911  
                         throws DataValidationErrorException, DoesNotExistException,
 912  
                         InvalidParameterException, MissingParameterException,
 913  
                         OperationFailedException, PermissionDeniedException,
 914  
                         VersionMismatchException {
 915  
                 
 916  
                 // TODO - this is never called; why does it exist?
 917  
                 /*
 918  
                 // Validate LoLoRelation
 919  
                 List<ValidationResultInfo> val = validateLoLoRelation("SYSTEM", loLoRelationInfo);
 920  
                 if(null != val && val.size() > 0) {
 921  
                         throw new DataValidationErrorException("Validation error!");
 922  
                 }
 923  
                 */
 924  
             
 925  0
                 return null;
 926  
         }
 927  
 
 928  
         @Override
 929  
         public LoCategoryInfo createLoCategory(String loRepositoryKey,
 930  
                         String loCategoryTypeKey, LoCategoryInfo loCategoryInfo)
 931  
                         throws DataValidationErrorException, DoesNotExistException,
 932  
                         InvalidParameterException, MissingParameterException,
 933  
                         OperationFailedException, PermissionDeniedException {
 934  7
             checkForMissingParameter(loRepositoryKey, "loRepositoryKey");
 935  7
             checkForMissingParameter(loCategoryTypeKey, "loCategoryTypeKey");
 936  7
             checkForMissingParameter(loCategoryInfo, "loCategoryInfo");
 937  
             
 938  
                 // Validate LoCategory
 939  7
                 List<ValidationResultInfo> val = validateLoCategory("SYSTEM", loCategoryInfo);
 940  
 
 941  
         //kslum-136 - don't allow dups w/ same name (case insensitive), type, state & repository       
 942  6
         if (doesLoCategoryExist(loRepositoryKey, loCategoryInfo, null)) {
 943  2
             ValidationResultInfo vr = new ValidationResultInfo();
 944  2
             vr.setElement("LO Category Name");
 945  2
             vr.setError("LO Category already exists");
 946  2
             val.add(vr);
 947  
         }
 948  6
         if(null != val && val.size() > 0) {
 949  2
                         for (ValidationResultInfo result : val) {
 950  2
                                 System.err.println("Validation error. Element: " + result.getElement() + ",  Value: " + result.getMessage());
 951  
                         }
 952  2
                         throw new DataValidationErrorException("Validation error!", val);
 953  
                 }
 954  
 
 955  4
             LoCategory category = LearningObjectiveServiceAssembler.toLoCategory(loCategoryInfo, loDao);
 956  4
             LoCategoryType loCatType = loDao.fetch(LoCategoryType.class, loCategoryTypeKey);
 957  4
             category.setLoCategoryType(loCatType);
 958  4
             LoRepository loRepository = loDao.fetch(LoRepository.class, loRepositoryKey);
 959  4
             category.setLoRepository(loRepository);
 960  4
             loDao.create(category);
 961  4
                 return LearningObjectiveServiceAssembler.toLoCategoryInfo(category);
 962  
         }
 963  
 
 964  
         @Override
 965  
         public LoCategoryTypeInfo getLoCategoryType(String loCategoryTypeKey)
 966  
                         throws DoesNotExistException, InvalidParameterException,
 967  
                         MissingParameterException, OperationFailedException {
 968  0
             checkForMissingParameter(loCategoryTypeKey, "loCategoryTypeKey");
 969  0
             LoCategoryType loCatType = loDao.fetch(LoCategoryType.class, loCategoryTypeKey);
 970  0
             return LearningObjectiveServiceAssembler.toLoCategoryTypeInfo(loCatType);
 971  
         }
 972  
 
 973  
         @Override
 974  
         public List<LoCategoryTypeInfo> getLoCategoryTypes()
 975  
                         throws OperationFailedException {
 976  1
                 List<LoCategoryType> categoryTypes = loDao.find(LoCategoryType.class);
 977  1
                 return LearningObjectiveServiceAssembler.toLoCategoryTypeInfos(categoryTypes);
 978  
         }
 979  
 
 980  
         @Override
 981  
         public List<LoInfo> getLosByRepository(String loRepositoryKey,
 982  
                         String loTypeKey, String loStateKey)
 983  
                         throws InvalidParameterException, MissingParameterException,
 984  
                         OperationFailedException {
 985  0
             checkForMissingParameter(loRepositoryKey, "loRepositoryKey");
 986  0
             List<Lo> los = loDao.getLosByRepository(loRepositoryKey);
 987  0
                 return LearningObjectiveServiceAssembler.toLoInfos(los);
 988  
         }
 989  
 
 990  
         @Override
 991  
         public SearchResult search(SearchRequest searchRequest) throws MissingParameterException {
 992  10
         checkForMissingParameter(searchRequest, "searchRequest");
 993  10
         return searchManager.search(searchRequest, loDao);
 994  
         }
 995  
 
 996  
 }