Coverage Report - org.kuali.student.lum.lrc.service.impl.LrcServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
LrcServiceImpl
51%
40/77
100%
4/4
1.537
 
 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.lrc.service.impl;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.jws.WebService;
 21  
 
 22  
 import org.kuali.student.core.dto.StatusInfo;
 23  
 import org.kuali.student.core.exceptions.AlreadyExistsException;
 24  
 import org.kuali.student.core.exceptions.DataValidationErrorException;
 25  
 import org.kuali.student.core.exceptions.DoesNotExistException;
 26  
 import org.kuali.student.core.exceptions.InvalidParameterException;
 27  
 import org.kuali.student.core.exceptions.MissingParameterException;
 28  
 import org.kuali.student.core.exceptions.OperationFailedException;
 29  
 import org.kuali.student.core.exceptions.PermissionDeniedException;
 30  
 import org.kuali.student.core.exceptions.VersionMismatchException;
 31  
 import org.kuali.student.core.search.dto.SearchCriteriaTypeInfo;
 32  
 import org.kuali.student.core.search.dto.SearchRequest;
 33  
 import org.kuali.student.core.search.dto.SearchResult;
 34  
 import org.kuali.student.core.search.dto.SearchResultTypeInfo;
 35  
 import org.kuali.student.core.search.dto.SearchTypeInfo;
 36  
 import org.kuali.student.core.search.service.SearchManager;
 37  
 import org.kuali.student.lum.lrc.dao.LrcDao;
 38  
 import org.kuali.student.lum.lrc.dto.CredentialInfo;
 39  
 import org.kuali.student.lum.lrc.dto.CredentialTypeInfo;
 40  
 import org.kuali.student.lum.lrc.dto.CreditInfo;
 41  
 import org.kuali.student.lum.lrc.dto.CreditTypeInfo;
 42  
 import org.kuali.student.lum.lrc.dto.GradeInfo;
 43  
 import org.kuali.student.lum.lrc.dto.GradeTypeInfo;
 44  
 import org.kuali.student.lum.lrc.dto.ResultComponentInfo;
 45  
 import org.kuali.student.lum.lrc.dto.ResultComponentTypeInfo;
 46  
 import org.kuali.student.lum.lrc.dto.ScaleInfo;
 47  
 import org.kuali.student.lum.lrc.entity.ResultComponent;
 48  
 import org.kuali.student.lum.lrc.entity.ResultComponentType;
 49  
 import org.kuali.student.lum.lrc.entity.Scale;
 50  
 import org.kuali.student.lum.lrc.service.LrcService;
 51  
 import org.springframework.transaction.annotation.Transactional;
 52  
 
 53  
 /**
 54  
  * @author lindholm
 55  
  *
 56  
  */
 57  
 @WebService(endpointInterface = "org.kuali.student.lum.lrc.service.LrcService", serviceName = "LrcService", portName = "LrcService", targetNamespace = "http://student.kuali.org/wsdl/lrc")
 58  
 @Transactional(noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 59  10
 public class LrcServiceImpl implements LrcService {
 60  
         private LrcDao lrcDao;
 61  
     private SearchManager searchManager;
 62  
 
 63  
         /* (non-Javadoc)
 64  
          * @see org.kuali.student.lum.lrc.service.LrcService#compareGrades(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
 65  
          */
 66  
         @Override
 67  
         public String compareGrades(String gradeKey, String scaleKey,
 68  
                         String compareGradeKey, String compareScaleKey)
 69  
                         throws InvalidParameterException, MissingParameterException,
 70  
                         OperationFailedException {
 71  0
                 throw new UnsupportedOperationException("Method not yet implemented!");
 72  
         }
 73  
 
 74  
         /* (non-Javadoc)
 75  
          * @see org.kuali.student.lum.lrc.service.LrcService#createResultComponent(java.lang.String, org.kuali.student.lum.lrc.dto.ResultComponentInfo)
 76  
          */
 77  
         @Override
 78  
         public ResultComponentInfo createResultComponent(
 79  
                         String resultComponentTypeKey,
 80  
                         ResultComponentInfo resultComponentInfo)
 81  
                         throws AlreadyExistsException, DataValidationErrorException,
 82  
                         DoesNotExistException, InvalidParameterException,
 83  
                         MissingParameterException, OperationFailedException,
 84  
                         PermissionDeniedException {
 85  7
             checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey");
 86  6
             checkForMissingParameter(resultComponentInfo, "resultComponentInfo");
 87  
 
 88  5
             ResultComponent rc = LrcServiceAssembler.toResultComponent(resultComponentTypeKey, resultComponentInfo, lrcDao);
 89  5
             lrcDao.create(rc);
 90  5
             return LrcServiceAssembler.toResultComponentInfo(rc);
 91  
         }
 92  
 
 93  
         /* (non-Javadoc)
 94  
          * @see org.kuali.student.lum.lrc.service.LrcService#deleteResultComponent(java.lang.String)
 95  
          */
 96  
         @Override
 97  
         public StatusInfo deleteResultComponent(String resultComponentId)
 98  
                         throws DoesNotExistException, InvalidParameterException,
 99  
                         MissingParameterException, OperationFailedException,
 100  
                         PermissionDeniedException {
 101  3
             checkForMissingParameter(resultComponentId, "resultComponentId");
 102  2
                 lrcDao.delete(ResultComponent.class, resultComponentId);
 103  1
                 StatusInfo statusInfo = new StatusInfo();
 104  1
                 return statusInfo;
 105  
         }
 106  
 
 107  
         /* (non-Javadoc)
 108  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredential(java.lang.String)
 109  
          */
 110  
         @Override
 111  
         public CredentialInfo getCredential(String credentialKey)
 112  
                         throws DoesNotExistException, InvalidParameterException,
 113  
                         MissingParameterException, OperationFailedException {
 114  0
                 throw new UnsupportedOperationException();
 115  
         }
 116  
 
 117  
         /* (non-Javadoc)
 118  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialKeysByCredentialType(java.lang.String)
 119  
          */
 120  
         @Override
 121  
         public List<String> getCredentialKeysByCredentialType(
 122  
                         String credentialTypeKey) throws DoesNotExistException,
 123  
                         InvalidParameterException, MissingParameterException,
 124  
                         OperationFailedException {
 125  0
                 throw new UnsupportedOperationException();
 126  
         }
 127  
 
 128  
         /* (non-Javadoc)
 129  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialType(java.lang.String)
 130  
          */
 131  
         @Override
 132  
         public CredentialTypeInfo getCredentialType(String credentialTypeKey)
 133  
                         throws DoesNotExistException, InvalidParameterException,
 134  
                         MissingParameterException, OperationFailedException {
 135  0
                 throw new UnsupportedOperationException();
 136  
         }
 137  
 
 138  
         /* (non-Javadoc)
 139  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialTypes()
 140  
          */
 141  
         @Override
 142  
         public List<CredentialTypeInfo> getCredentialTypes()
 143  
                         throws OperationFailedException {
 144  0
                 throw new UnsupportedOperationException();
 145  
         }
 146  
 
 147  
         /* (non-Javadoc)
 148  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredentialsByKeyList(java.util.List)
 149  
          */
 150  
         @Override
 151  
         public List<CredentialInfo> getCredentialsByKeyList(
 152  
                         List<String> credentialKeyList) throws DoesNotExistException,
 153  
                         InvalidParameterException, MissingParameterException,
 154  
                         OperationFailedException {
 155  0
                 throw new UnsupportedOperationException();
 156  
         }
 157  
 
 158  
         /* (non-Javadoc)
 159  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCredit(java.lang.String)
 160  
          */
 161  
         @Override
 162  
         public CreditInfo getCredit(String creditKey) throws DoesNotExistException,
 163  
                         InvalidParameterException, MissingParameterException,
 164  
                         OperationFailedException {
 165  0
                 throw new UnsupportedOperationException();
 166  
         }
 167  
 
 168  
         /* (non-Javadoc)
 169  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCreditKeysByCreditType(java.lang.String)
 170  
          */
 171  
         @Override
 172  
         public List<String> getCreditKeysByCreditType(String creditTypeKey)
 173  
                         throws DoesNotExistException, InvalidParameterException,
 174  
                         MissingParameterException, OperationFailedException {
 175  0
                 throw new UnsupportedOperationException();
 176  
         }
 177  
 
 178  
         /* (non-Javadoc)
 179  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCreditType(java.lang.String)
 180  
          */
 181  
         @Override
 182  
         public CreditTypeInfo getCreditType(String creditTypeKey)
 183  
                         throws DoesNotExistException, InvalidParameterException,
 184  
                         MissingParameterException, OperationFailedException {
 185  0
                 throw new UnsupportedOperationException();
 186  
         }
 187  
 
 188  
         /* (non-Javadoc)
 189  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCreditTypes()
 190  
          */
 191  
         @Override
 192  
         public List<CreditTypeInfo> getCreditTypes()
 193  
                         throws OperationFailedException {
 194  0
                 throw new UnsupportedOperationException();
 195  
         }
 196  
 
 197  
         /* (non-Javadoc)
 198  
          * @see org.kuali.student.lum.lrc.service.LrcService#getCreditsByKeyList(java.util.List)
 199  
          */
 200  
         @Override
 201  
         public List<CreditInfo> getCreditsByKeyList(List<String> creditKeyList)
 202  
                         throws DoesNotExistException, InvalidParameterException,
 203  
                         MissingParameterException, OperationFailedException {
 204  0
                 throw new UnsupportedOperationException();
 205  
         }
 206  
 
 207  
     /* (non-Javadoc)
 208  
      * @see org.kuali.student.lum.lrc.service.LrcService#getGrade(java.lang.String)
 209  
      */
 210  
     @Override
 211  
     public GradeInfo getGrade(String gradeKey) throws DoesNotExistException,
 212  
             InvalidParameterException, MissingParameterException,
 213  
             OperationFailedException {
 214  0
                 throw new UnsupportedOperationException();
 215  
     }
 216  
 
 217  
     /* (non-Javadoc)
 218  
      * @see org.kuali.student.lum.lrc.service.LrcService#getGradeKeysByGradeType(java.lang.String)
 219  
      */
 220  
     @Override
 221  
     public List<String> getGradeKeysByGradeType(String gradeTypeKey)
 222  
             throws DoesNotExistException, InvalidParameterException,
 223  
             MissingParameterException, OperationFailedException {
 224  0
                 throw new UnsupportedOperationException();
 225  
     }
 226  
 
 227  
     /* (non-Javadoc)
 228  
      * @see org.kuali.student.lum.lrc.service.LrcService#getGradeType(java.lang.String)
 229  
      */
 230  
     @Override
 231  
     public GradeTypeInfo getGradeType(String gradeTypeKey)
 232  
             throws DoesNotExistException, InvalidParameterException,
 233  
             MissingParameterException, OperationFailedException {
 234  0
                 throw new UnsupportedOperationException();
 235  
     }
 236  
 
 237  
     /* (non-Javadoc)
 238  
      * @see org.kuali.student.lum.lrc.service.LrcService#getGradeTypes()
 239  
      */
 240  
     @Override
 241  
     public List<GradeTypeInfo> getGradeTypes() throws OperationFailedException {
 242  0
                 throw new UnsupportedOperationException();
 243  
     }
 244  
 
 245  
     /* (non-Javadoc)
 246  
      * @see org.kuali.student.lum.lrc.service.LrcService#getGradesByKeyList(java.util.List)
 247  
      */
 248  
     @Override
 249  
     public List<GradeInfo> getGradesByKeyList(List<String> gradeKeyList)
 250  
             throws DoesNotExistException, InvalidParameterException,
 251  
             MissingParameterException, OperationFailedException {
 252  0
                 throw new UnsupportedOperationException();
 253  
     }
 254  
         /* (non-Javadoc)
 255  
          * @see org.kuali.student.lum.lrc.service.LrcService#getGradesByScale(java.lang.String)
 256  
          */
 257  
         @Override
 258  
         public List<GradeInfo> getGradesByScale(String scale)
 259  
                         throws DoesNotExistException, InvalidParameterException,
 260  
                         MissingParameterException, OperationFailedException {
 261  0
                 throw new UnsupportedOperationException();
 262  
         }
 263  
 
 264  
         /* (non-Javadoc)
 265  
          * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponent(java.lang.String)
 266  
          */
 267  
         @Override
 268  
         public ResultComponentInfo getResultComponent(String resultComponentId)
 269  
                         throws DoesNotExistException, InvalidParameterException,
 270  
                         MissingParameterException, OperationFailedException {
 271  104
             checkForMissingParameter(resultComponentId, "resultComponentId");
 272  103
             ResultComponent resultComponent = lrcDao.fetch(ResultComponent.class, resultComponentId);
 273  
 
 274  102
             return LrcServiceAssembler.toResultComponentInfo(resultComponent);
 275  
         }
 276  
 
 277  
         /* (non-Javadoc)
 278  
          * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentIdsByResult(java.lang.String, java.lang.String)
 279  
          */
 280  
         @Override
 281  
         public List<String> getResultComponentIdsByResult(String resultValueId,
 282  
                         String resultComponentTypeKey) throws DoesNotExistException,
 283  
                         InvalidParameterException, MissingParameterException,
 284  
                         OperationFailedException {
 285  5
             checkForMissingParameter(resultValueId, "resultValueId");
 286  4
             checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey");
 287  3
             List<String> ids = lrcDao.getResultComponentIdsByResult(resultValueId, resultComponentTypeKey);
 288  3
             return ids;
 289  
         }
 290  
 
 291  
         /* (non-Javadoc)
 292  
          * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentIdsByResultComponentType(java.lang.String)
 293  
          */
 294  
         @Override
 295  
         public List<String> getResultComponentIdsByResultComponentType(
 296  
                         String resultComponentTypeKey) throws DoesNotExistException,
 297  
                         InvalidParameterException, MissingParameterException,
 298  
                         OperationFailedException {
 299  117
             checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey");
 300  116
         List<String> ids = lrcDao.getResultComponentIdsByResultComponentType(resultComponentTypeKey);
 301  116
         return ids;
 302  
         }
 303  
 
 304  
         /* (non-Javadoc)
 305  
          * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentType(java.lang.String)
 306  
          */
 307  
         @Override
 308  
         public ResultComponentTypeInfo getResultComponentType(
 309  
                         String resultComponentTypeKey) throws DoesNotExistException,
 310  
                         InvalidParameterException, MissingParameterException,
 311  
                         OperationFailedException {
 312  2
                 checkForMissingParameter(resultComponentTypeKey, "resultComponentTypeKey");
 313  2
                 ResultComponentType entity = lrcDao.getResultComponentType(resultComponentTypeKey);
 314  1
                 return LrcServiceAssembler.toResultComponentTypeInfo(entity);
 315  
         }
 316  
 
 317  
         /* (non-Javadoc)
 318  
          * @see org.kuali.student.lum.lrc.service.LrcService#getResultComponentTypes()
 319  
          */
 320  
         @Override
 321  
         public List<ResultComponentTypeInfo> getResultComponentTypes()
 322  
                         throws OperationFailedException {
 323  10
                 List<ResultComponentType> rct = lrcDao.find(ResultComponentType.class);
 324  10
                 return LrcServiceAssembler.toResultComponentTypeInfos(rct);
 325  
         }
 326  
 
 327  
         /* (non-Javadoc)
 328  
          * @see org.kuali.student.lum.lrc.service.LrcService#getScale(java.lang.String)
 329  
          */
 330  
         @Override
 331  
         public ScaleInfo getScale(String scaleKey) throws DoesNotExistException,
 332  
                         InvalidParameterException, MissingParameterException,
 333  
                         OperationFailedException {
 334  0
                 checkForMissingParameter(scaleKey, "scaleKey");
 335  0
                 Scale scale = lrcDao.fetch(Scale.class, scaleKey);
 336  0
                 return LrcServiceAssembler.toScaleInfo(scale);
 337  
         }
 338  
 
 339  
         /* (non-Javadoc)
 340  
          * @see org.kuali.student.lum.lrc.service.LrcService#translateGrade(java.lang.String, java.lang.String, java.lang.String)
 341  
          */
 342  
         @Override
 343  
         public List<GradeInfo> translateGrade(String gradeKey, String scaleKey,
 344  
                         String translateScaleKey) throws InvalidParameterException,
 345  
                         MissingParameterException, OperationFailedException {
 346  0
                 throw new UnsupportedOperationException("Method not yet implemented!");
 347  
         }
 348  
 
 349  
         /* (non-Javadoc)
 350  
          * @see org.kuali.student.lum.lrc.service.LrcService#updateResultComponent(java.lang.String, org.kuali.student.lum.lrc.dto.ResultComponentInfo)
 351  
          */
 352  
         @Override
 353  
         public ResultComponentInfo updateResultComponent(String resultComponentId,
 354  
                         ResultComponentInfo resultComponentInfo)
 355  
                         throws DataValidationErrorException, DoesNotExistException,
 356  
                         InvalidParameterException, MissingParameterException,
 357  
                         OperationFailedException, PermissionDeniedException,
 358  
                         VersionMismatchException {
 359  5
             checkForMissingParameter(resultComponentId, "resultComponentId");
 360  4
         checkForMissingParameter(resultComponentInfo, "resultComponentInfo");
 361  
 
 362  3
         ResultComponent entity = lrcDao.fetch(ResultComponent.class, resultComponentId);
 363  
         
 364  3
                 if (!String.valueOf(entity.getVersionNumber()).equals(resultComponentInfo.getMetaInfo().getVersionInd())){
 365  1
                         throw new VersionMismatchException("ResultComponent to be updated is not the current version");
 366  
                 }
 367  
         
 368  2
         LrcServiceAssembler.toResultComponent(entity, resultComponentInfo, lrcDao);
 369  2
         lrcDao.update(entity);
 370  2
         return LrcServiceAssembler.toResultComponentInfo(entity);
 371  
     }
 372  
 
 373  
         /**
 374  
          * @return the lrcDao
 375  
          */
 376  
         public LrcDao getLrcDao() {
 377  0
                 return lrcDao;
 378  
         }
 379  
 
 380  
         /**
 381  
          * @param lrcDao the lrcDao to set
 382  
          */
 383  
         public void setLrcDao(LrcDao lrcDao) {
 384  5
                 this.lrcDao = lrcDao;
 385  5
         }
 386  
 
 387  
     /**
 388  
      * Check for missing parameter and throw localized exception if missing
 389  
      *
 390  
      * @param param
 391  
      * @param parameter name
 392  
      * @throws MissingParameterException
 393  
      */
 394  
     private void checkForMissingParameter(Object param, String paramName)
 395  
             throws MissingParameterException {
 396  257
         if (param == null) {
 397  9
             throw new MissingParameterException(paramName + " can not be null");
 398  
         }
 399  248
     }
 400  
 
 401  
         @Override
 402  
         public SearchCriteriaTypeInfo getSearchCriteriaType(
 403  
                         String searchCriteriaTypeKey) throws DoesNotExistException,
 404  
                         InvalidParameterException, MissingParameterException,
 405  
                         OperationFailedException {
 406  
 
 407  0
                 return searchManager.getSearchCriteriaType(searchCriteriaTypeKey);
 408  
         }
 409  
 
 410  
         @Override
 411  
         public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes()
 412  
                         throws OperationFailedException {
 413  0
                 return searchManager.getSearchCriteriaTypes();
 414  
         }
 415  
 
 416  
         @Override
 417  
         public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey)
 418  
                         throws DoesNotExistException, InvalidParameterException,
 419  
                         MissingParameterException, OperationFailedException {
 420  0
                 checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 421  0
                 return searchManager.getSearchResultType(searchResultTypeKey);
 422  
         }
 423  
 
 424  
         @Override
 425  
         public List<SearchResultTypeInfo> getSearchResultTypes()
 426  
                         throws OperationFailedException {
 427  0
                 return searchManager.getSearchResultTypes();
 428  
         }
 429  
 
 430  
         @Override
 431  
         public SearchTypeInfo getSearchType(String searchTypeKey)
 432  
                         throws DoesNotExistException, InvalidParameterException,
 433  
                         MissingParameterException, OperationFailedException {
 434  0
                 checkForMissingParameter(searchTypeKey, "searchTypeKey");
 435  0
                 return searchManager.getSearchType(searchTypeKey);
 436  
         }
 437  
 
 438  
         @Override
 439  
         public List<SearchTypeInfo> getSearchTypes()
 440  
                         throws OperationFailedException {
 441  0
                 return searchManager.getSearchTypes();
 442  
         }
 443  
 
 444  
         @Override
 445  
         public List<SearchTypeInfo> getSearchTypesByCriteria(
 446  
                         String searchCriteriaTypeKey) throws DoesNotExistException,
 447  
                         InvalidParameterException, MissingParameterException,
 448  
                         OperationFailedException {
 449  0
                 checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey");
 450  0
                 return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey);
 451  
         }
 452  
 
 453  
         @Override
 454  
         public List<SearchTypeInfo> getSearchTypesByResult(
 455  
                         String searchResultTypeKey) throws DoesNotExistException,
 456  
                         InvalidParameterException, MissingParameterException,
 457  
                         OperationFailedException {
 458  0
                 checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 459  0
                 return searchManager.getSearchTypesByResult(searchResultTypeKey);
 460  
         }
 461  
 
 462  
         public SearchManager getSearchManager() {
 463  0
                 return searchManager;
 464  
         }
 465  
 
 466  
         public void setSearchManager(SearchManager searchManager) {
 467  4
                 this.searchManager = searchManager;
 468  4
         }
 469  
 
 470  
         @Override
 471  
         public SearchResult search(SearchRequest searchRequest) throws MissingParameterException {
 472  0
         checkForMissingParameter(searchRequest, "searchRequest");
 473  0
         return searchManager.search(searchRequest, lrcDao);
 474  
         }
 475  
 
 476  
 }