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