Coverage Report - org.kuali.student.core.atp.service.impl.AtpServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AtpServiceImpl
0%
0/190
0%
0/38
1.732
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
 5  
  * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 6  
  * implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 
 9  
 package org.kuali.student.core.atp.service.impl;
 10  
 
 11  
 import java.util.Date;
 12  
 import java.util.List;
 13  
 
 14  
 import javax.jws.WebService;
 15  
 
 16  
 import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
 17  
 import org.kuali.student.common.dictionary.service.DictionaryService;
 18  
 import org.kuali.student.common.dto.StatusInfo;
 19  
 import org.kuali.student.common.exceptions.AlreadyExistsException;
 20  
 import org.kuali.student.common.exceptions.DataValidationErrorException;
 21  
 import org.kuali.student.common.exceptions.DoesNotExistException;
 22  
 import org.kuali.student.common.exceptions.InvalidParameterException;
 23  
 import org.kuali.student.common.exceptions.MissingParameterException;
 24  
 import org.kuali.student.common.exceptions.OperationFailedException;
 25  
 import org.kuali.student.common.exceptions.PermissionDeniedException;
 26  
 import org.kuali.student.common.exceptions.VersionMismatchException;
 27  
 import org.kuali.student.common.search.dto.SearchCriteriaTypeInfo;
 28  
 import org.kuali.student.common.search.dto.SearchRequest;
 29  
 import org.kuali.student.common.search.dto.SearchResult;
 30  
 import org.kuali.student.common.search.dto.SearchResultTypeInfo;
 31  
 import org.kuali.student.common.search.dto.SearchTypeInfo;
 32  
 import org.kuali.student.common.search.service.SearchManager;
 33  
 import org.kuali.student.common.validation.dto.ValidationResultInfo;
 34  
 import org.kuali.student.common.validator.Validator;
 35  
 import org.kuali.student.common.validator.ValidatorFactory;
 36  
 import org.kuali.student.core.atp.dao.AtpDao;
 37  
 import org.kuali.student.core.atp.dto.AtpDurationTypeInfo;
 38  
 import org.kuali.student.core.atp.dto.AtpInfo;
 39  
 import org.kuali.student.core.atp.dto.AtpSeasonalTypeInfo;
 40  
 import org.kuali.student.core.atp.dto.AtpTypeInfo;
 41  
 import org.kuali.student.core.atp.dto.DateRangeInfo;
 42  
 import org.kuali.student.core.atp.dto.DateRangeTypeInfo;
 43  
 import org.kuali.student.core.atp.dto.MilestoneInfo;
 44  
 import org.kuali.student.core.atp.dto.MilestoneTypeInfo;
 45  
 import org.kuali.student.core.atp.entity.Atp;
 46  
 import org.kuali.student.core.atp.entity.AtpDurationType;
 47  
 import org.kuali.student.core.atp.entity.AtpSeasonalType;
 48  
 import org.kuali.student.core.atp.entity.AtpType;
 49  
 import org.kuali.student.core.atp.entity.DateRange;
 50  
 import org.kuali.student.core.atp.entity.DateRangeType;
 51  
 import org.kuali.student.core.atp.entity.Milestone;
 52  
 import org.kuali.student.core.atp.entity.MilestoneType;
 53  
 import org.kuali.student.core.atp.service.AtpService;
 54  
 import org.springframework.transaction.annotation.Transactional;
 55  
 
 56  
 @WebService(endpointInterface = "org.kuali.student.core.atp.service.AtpService", serviceName = "AtpService", portName = "AtpService", targetNamespace = "http://student.kuali.org/wsdl/atp")
 57  0
 public class AtpServiceImpl implements AtpService {
 58  
 
 59  
     private AtpDao atpDao;
 60  
     private SearchManager searchManager;
 61  
     private DictionaryService dictionaryServiceDelegate;
 62  
     private ValidatorFactory validatorFactory;
 63  
 
 64  
     @Override
 65  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 66  
     public DateRangeInfo addDateRange(String atpKey, String dateRangeKey, DateRangeInfo dateRangeInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 67  
 
 68  0
         CheckMissingParameters(new String[]{"atpKey", "dateRangeKey", "dateRangeInfo"}, new Object[]{atpKey, dateRangeKey, dateRangeInfo});
 69  
 
 70  0
         dateRangeInfo.setAtpId(atpKey);
 71  0
         dateRangeInfo.setId(dateRangeKey);
 72  
         
 73  
         // Validate Daterange
 74  
         List<ValidationResultInfo> validationResults;
 75  
         try {
 76  0
             validationResults = validateDateRange("OBJECT", dateRangeInfo);
 77  0
         } catch (DoesNotExistException e1) {
 78  0
             throw new OperationFailedException("Validation call failed." + e1.getMessage());
 79  0
         }
 80  0
         if (null != validationResults && validationResults.size() > 0) {
 81  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 82  
         }
 83  
         
 84  
         
 85  0
         DateRange dateRange = null;
 86  
 
 87  
         try {
 88  0
             dateRange = AtpAssembler.toDateRange(false, dateRangeInfo, atpDao);
 89  0
         } catch (DoesNotExistException e) {} catch (VersionMismatchException e) {}
 90  
 
 91  0
         atpDao.create(dateRange);
 92  
 
 93  0
         return AtpAssembler.toDateRangeInfo(dateRange);
 94  
     }
 95  
 
 96  
     private void CheckMissingParameters(String[] paramNames, Object[] params) throws MissingParameterException {
 97  0
         String errors = null;
 98  0
         int i = 0;
 99  0
         for (Object param : params) {
 100  0
             if (param == null) {
 101  0
                 errors = errors == null ? paramNames[i] : errors + ", " + paramNames[i];
 102  
             }
 103  0
             i++;
 104  
         }
 105  0
         if (errors != null) {
 106  0
             throw new MissingParameterException("Missing Parameters: " + errors);
 107  
         }
 108  0
     }
 109  
 
 110  
     @Override
 111  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 112  
     public MilestoneInfo addMilestone(String atpKey, String milestoneKey, MilestoneInfo milestoneInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 113  
 
 114  0
         CheckMissingParameters(new String[]{"atpKey", "milestoneKey", "milestoneInfo"}, new Object[]{atpKey, milestoneKey, milestoneInfo});
 115  
 
 116  0
         milestoneInfo.setAtpId(atpKey);
 117  0
         milestoneInfo.setId(milestoneKey);
 118  
 
 119  
         // Validate Milestone
 120  
         List<ValidationResultInfo> validationResults;
 121  
         try {
 122  0
             validationResults = validateMilestone("OBJECT", milestoneInfo);
 123  0
         } catch (DoesNotExistException e1) {
 124  0
             throw new OperationFailedException("Validation call failed." + e1.getMessage());
 125  0
         }
 126  0
         if (null != validationResults && validationResults.size() > 0) {
 127  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 128  
         }
 129  
                 
 130  0
         Milestone milestone = null;
 131  
         try {
 132  0
             milestone = AtpAssembler.toMilestone(false, milestoneInfo, atpDao);
 133  0
         } catch (DoesNotExistException e) {} catch (VersionMismatchException e) {}
 134  
 
 135  0
         atpDao.create(milestone);
 136  
 
 137  0
         return AtpAssembler.toMilestoneInfo(milestone);
 138  
     }
 139  
 
 140  
     @Override
 141  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 142  
     public AtpInfo createAtp(String atpTypeKey, String atpKey, AtpInfo atpInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 143  
 
 144  0
         CheckMissingParameters(new String[]{"atpTypeKey", "atpKey", "atpInfo"}, new Object[]{atpTypeKey, atpKey, atpInfo});
 145  
 
 146  0
         atpInfo.setType(atpTypeKey);
 147  0
         atpInfo.setId(atpKey);
 148  
 
 149  
         // Validate Atp
 150  
         List<ValidationResultInfo> validationResults;
 151  
         try {
 152  0
             validationResults = validateAtp("OBJECT", atpInfo);
 153  0
         } catch (DoesNotExistException e1) {
 154  0
             throw new OperationFailedException("Validation call failed." + e1.getMessage());
 155  0
         }
 156  0
         if (null != validationResults && validationResults.size() > 0) {
 157  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 158  
         }
 159  
         
 160  0
         Atp atp = null;
 161  
         try {
 162  0
             atp = AtpAssembler.toAtp(false, atpInfo, atpDao);
 163  0
         } catch (DoesNotExistException e) {} catch (VersionMismatchException e) {}
 164  
 
 165  0
         atpDao.create(atp);
 166  
 
 167  0
         AtpInfo result = AtpAssembler.toAtpInfo(atp);
 168  0
         return result;
 169  
     }
 170  
 
 171  
     @Override
 172  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 173  
     public StatusInfo deleteAtp(String atpKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 174  
 
 175  0
         atpDao.delete(Atp.class, atpKey);
 176  
 
 177  0
         StatusInfo statusInfo = new StatusInfo();
 178  0
         statusInfo.setSuccess(true);
 179  
 
 180  0
         return statusInfo;
 181  
     }
 182  
 
 183  
     @Override
 184  
     @Transactional(readOnly=true)
 185  
     public AtpInfo getAtp(String atpKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 186  
 
 187  0
         Atp atp = atpDao.fetch(Atp.class, atpKey);
 188  
 
 189  0
         return AtpAssembler.toAtpInfo(atp);
 190  
     }
 191  
 
 192  
     @Override
 193  
     @Transactional(readOnly=true)
 194  
     public AtpDurationTypeInfo getAtpDurationType(String atpDurationTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 195  
 
 196  0
         AtpDurationType atpDurationType = atpDao.fetch(AtpDurationType.class, atpDurationTypeKey);
 197  
 
 198  0
         return AtpAssembler.toGenericTypeInfo(AtpDurationTypeInfo.class, atpDurationType);
 199  
     }
 200  
 
 201  
     @Override
 202  
     @Transactional(readOnly=true)
 203  
     public AtpSeasonalTypeInfo getAtpSeasonalType(String atpSeasonalTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 204  
 
 205  0
         AtpSeasonalType atpSeasonalType = atpDao.fetch(AtpSeasonalType.class, atpSeasonalTypeKey);
 206  
 
 207  0
         return AtpAssembler.toGenericTypeInfo(AtpSeasonalTypeInfo.class, atpSeasonalType);
 208  
     }
 209  
 
 210  
     @Override
 211  
     @Transactional(readOnly=true)
 212  
     public AtpTypeInfo getAtpType(String atpTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 213  
 
 214  0
         AtpType atpType = atpDao.fetch(AtpType.class, atpTypeKey);
 215  
 
 216  0
         return AtpAssembler.toAtpTypeInfo(atpType);
 217  
     }
 218  
 
 219  
     @Override
 220  
     @Transactional(readOnly=true)
 221  
     public DateRangeInfo getDateRange(String dateRangeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 222  
 
 223  0
         DateRange dateRange = atpDao.fetch(DateRange.class, dateRangeKey);
 224  
 
 225  0
         return AtpAssembler.toDateRangeInfo(dateRange);
 226  
 
 227  
     }
 228  
 
 229  
     @Override
 230  
     @Transactional(readOnly=true)
 231  
     public DateRangeTypeInfo getDateRangeType(String dateRangeTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 232  
 
 233  0
         DateRangeType dateRangeType = atpDao.fetch(DateRangeType.class, dateRangeTypeKey);
 234  
 
 235  0
         return AtpAssembler.toGenericTypeInfo(DateRangeTypeInfo.class, dateRangeType);
 236  
     }
 237  
 
 238  
     @Override
 239  
     @Transactional(readOnly=true)
 240  
     public MilestoneInfo getMilestone(String milestoneKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 241  
 
 242  0
         Milestone milestone = atpDao.fetch(Milestone.class, milestoneKey);
 243  
 
 244  0
         return AtpAssembler.toMilestoneInfo(milestone);
 245  
 
 246  
     }
 247  
 
 248  
     @Override
 249  
     @Transactional(readOnly=true)
 250  
     public MilestoneTypeInfo getMilestoneType(String milestoneTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 251  
 
 252  0
         MilestoneType milestoneType = atpDao.fetch(MilestoneType.class, milestoneTypeKey);
 253  
 
 254  0
         return AtpAssembler.toGenericTypeInfo(MilestoneTypeInfo.class, milestoneType);
 255  
     }
 256  
 
 257  
     @Override
 258  
     @Transactional(readOnly=true)
 259  
     public List<AtpDurationTypeInfo> getAtpDurationTypes() throws OperationFailedException {
 260  
 
 261  0
         List<AtpDurationType> atpDurationTypes = atpDao.find(AtpDurationType.class);
 262  
 
 263  0
         return AtpAssembler.toGenericTypeInfoList(AtpDurationTypeInfo.class, atpDurationTypes);
 264  
     }
 265  
 
 266  
     @Override
 267  
     @Transactional(readOnly=true)
 268  
     public List<AtpSeasonalTypeInfo> getAtpSeasonalTypes() throws OperationFailedException {
 269  
 
 270  0
         List<AtpSeasonalType> atpSeasonalTypes = atpDao.find(AtpSeasonalType.class);
 271  
 
 272  0
         return AtpAssembler.toGenericTypeInfoList(AtpSeasonalTypeInfo.class, atpSeasonalTypes);
 273  
     }
 274  
 
 275  
     @Override
 276  
     @Transactional(readOnly=true)
 277  
     public List<AtpTypeInfo> getAtpTypes() throws OperationFailedException {
 278  
 
 279  0
         List<AtpType> atpTypes = atpDao.find(AtpType.class);
 280  
 
 281  0
         return AtpAssembler.toAtpTypeInfoList(atpTypes);
 282  
     }
 283  
 
 284  
     @Override
 285  
     @Transactional(readOnly=true)
 286  
     public List<AtpInfo> getAtpsByAtpType(String atpTypeKey) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 287  
 
 288  0
         List<Atp> atps = atpDao.findAtpsByAtpType(atpTypeKey);
 289  
 
 290  0
         return AtpAssembler.toAtpInfoList(atps);
 291  
     }
 292  
 
 293  
     @Override
 294  
     @Transactional(readOnly=true)
 295  
     public List<AtpInfo> getAtpsByDate(Date searchDate) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 296  
 
 297  0
         List<Atp> atps = atpDao.findAtpsByDate(searchDate);
 298  
 
 299  0
         return AtpAssembler.toAtpInfoList(atps);
 300  
     }
 301  
 
 302  
     @Override
 303  
     @Transactional(readOnly=true)
 304  
     public List<AtpInfo> getAtpsByDates(Date startDate, Date endDate) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 305  
 
 306  0
         List<Atp> atps = atpDao.findAtpsByDates(startDate, endDate);
 307  
 
 308  0
         return AtpAssembler.toAtpInfoList(atps);
 309  
     }
 310  
 
 311  
     @Override
 312  
     @Transactional(readOnly=true)
 313  
     public List<DateRangeTypeInfo> getDateRangeTypes() throws OperationFailedException {
 314  
 
 315  0
         List<DateRangeType> dateRangeTypes = atpDao.find(DateRangeType.class);
 316  
 
 317  0
         return AtpAssembler.toGenericTypeInfoList(DateRangeTypeInfo.class, dateRangeTypes);
 318  
     }
 319  
 
 320  
     @Override
 321  
     @Transactional(readOnly=true)
 322  
     public List<DateRangeTypeInfo> getDateRangeTypesForAtpType(String atpTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 323  
 
 324  0
         List<DateRangeType> dateRangeTypes = atpDao.findDateRangeTypesForAtpType(atpTypeKey);
 325  
 
 326  0
         return AtpAssembler.toGenericTypeInfoList(DateRangeTypeInfo.class, dateRangeTypes);
 327  
     }
 328  
 
 329  
     @Override
 330  
     @Transactional(readOnly=true)
 331  
     public List<DateRangeInfo> getDateRangesByAtp(String atpKey) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 332  
 
 333  0
         List<DateRange> dateRanges = atpDao.findDateRangesByAtp(atpKey);
 334  
 
 335  0
         return AtpAssembler.toDateRangeInfoList(dateRanges);
 336  
     }
 337  
 
 338  
     @Override
 339  
     @Transactional(readOnly=true)
 340  
     public List<DateRangeInfo> getDateRangesByDate(Date searchDate) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 341  
 
 342  0
         List<DateRange> dateRanges = atpDao.findDateRangesByDate(searchDate);
 343  
 
 344  0
         return AtpAssembler.toDateRangeInfoList(dateRanges);
 345  
     }
 346  
 
 347  
     @Override
 348  
     @Transactional(readOnly=true)
 349  
     public List<MilestoneTypeInfo> getMilestoneTypes() throws OperationFailedException {
 350  
 
 351  0
         List<MilestoneType> milestoneTypes = atpDao.find(MilestoneType.class);
 352  
 
 353  0
         return AtpAssembler.toGenericTypeInfoList(MilestoneTypeInfo.class, milestoneTypes);
 354  
     }
 355  
 
 356  
     @Override
 357  
     @Transactional(readOnly=true)
 358  
     public List<MilestoneTypeInfo> getMilestoneTypesForAtpType(String atpTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 359  
 
 360  0
         List<MilestoneType> milestoneTypes = atpDao.findMilestoneTypesForAtpType(atpTypeKey);
 361  
 
 362  0
         return AtpAssembler.toGenericTypeInfoList(MilestoneTypeInfo.class, milestoneTypes);
 363  
     }
 364  
 
 365  
     @Override
 366  
     @Transactional(readOnly=true)
 367  
     public List<MilestoneInfo> getMilestonesByAtp(String atpKey) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 368  
 
 369  0
         List<Milestone> milestones = atpDao.findMilestonesByAtp(atpKey);
 370  
 
 371  0
         return AtpAssembler.toMilestoneInfoList(milestones);
 372  
     }
 373  
 
 374  
     @Override
 375  
     @Transactional(readOnly=true)
 376  
     public List<MilestoneInfo> getMilestonesByDates(Date startDate, Date endDate) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 377  
 
 378  0
         List<Milestone> milestones = atpDao.findMilestonesByDates(startDate, endDate);
 379  
 
 380  0
         return AtpAssembler.toMilestoneInfoList(milestones);
 381  
     }
 382  
 
 383  
     @Override
 384  
     @Transactional(readOnly=true)
 385  
     public List<MilestoneInfo> getMilestonesByDatesAndType(String milestoneTypeKey, Date startDate, Date endDate) throws InvalidParameterException, MissingParameterException, OperationFailedException {
 386  
 
 387  0
         List<Milestone> milestones = atpDao.findMilestonesByDatesAndType(milestoneTypeKey, startDate, endDate);
 388  
 
 389  0
         return AtpAssembler.toMilestoneInfoList(milestones);
 390  
     }
 391  
 
 392  
     @Override
 393  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 394  
     public StatusInfo removeDateRange(String dateRangeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 395  
 
 396  0
         atpDao.delete(DateRange.class, dateRangeKey);
 397  
 
 398  0
         StatusInfo statusInfo = new StatusInfo();
 399  0
         statusInfo.setSuccess(true);
 400  
 
 401  0
         return statusInfo;
 402  
     }
 403  
 
 404  
     @Override
 405  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 406  
     public StatusInfo removeMilestone(String milestoneKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
 407  
 
 408  0
         atpDao.delete(Milestone.class, milestoneKey);
 409  
 
 410  0
         StatusInfo statusInfo = new StatusInfo();
 411  0
         statusInfo.setSuccess(true);
 412  
 
 413  0
         return statusInfo;
 414  
     }
 415  
 
 416  
     @Override
 417  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 418  
     public AtpInfo updateAtp(String atpKey, AtpInfo atpInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 419  
 
 420  0
         CheckMissingParameters(new String[]{"atpKey", "atpInfo"}, new Object[]{atpKey, atpInfo});
 421  
 
 422  0
         atpInfo.setId(atpKey);
 423  
 
 424  0
         List<ValidationResultInfo> validationResults = validateAtp("OBJECT", atpInfo);
 425  0
         if (null != validationResults && validationResults.size() > 0) {
 426  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 427  
         }
 428  
         
 429  0
         Atp atp = AtpAssembler.toAtp(true, atpInfo, atpDao);
 430  0
         if (atp == null) {
 431  0
             throw new DoesNotExistException("Atp does not exist for key: " + atpKey);
 432  
         }
 433  
 
 434  0
         Atp updatedAtp = atpDao.update(atp);
 435  
 
 436  0
         AtpInfo result = AtpAssembler.toAtpInfo(updatedAtp);
 437  0
         return result;
 438  
     }
 439  
 
 440  
     @Override
 441  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 442  
     public DateRangeInfo updateDateRange(String dateRangeKey, DateRangeInfo dateRangeInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 443  
 
 444  0
         CheckMissingParameters(new String[]{"dateRangeKey", "dateRangeInfo"}, new Object[]{dateRangeKey, dateRangeInfo});
 445  
 
 446  0
         dateRangeInfo.setId(dateRangeKey);
 447  
 
 448  0
         List<ValidationResultInfo> validationResults = validateDateRange("OBJECT", dateRangeInfo);
 449  0
         if (null != validationResults && validationResults.size() > 0) {
 450  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 451  
         }
 452  
         
 453  0
         DateRange dateRange = AtpAssembler.toDateRange(true, dateRangeInfo, atpDao);
 454  
 
 455  0
         DateRange updatedDateRange = atpDao.update(dateRange);
 456  
 
 457  0
         DateRangeInfo result = AtpAssembler.toDateRangeInfo(updatedDateRange);
 458  0
         return result;
 459  
     }
 460  
 
 461  
     @Override
 462  
     @Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class})
 463  
     public MilestoneInfo updateMilestone(String milestoneKey, MilestoneInfo milestoneInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException {
 464  
 
 465  0
         CheckMissingParameters(new String[]{"milestoneKey", "milestoneInfo"}, new Object[]{milestoneKey, milestoneInfo});
 466  
 
 467  0
         milestoneInfo.setId(milestoneKey);
 468  
 
 469  
         // Validate MilestoneInfo
 470  0
         List<ValidationResultInfo> validationResults = validateMilestone("OBJECT", milestoneInfo);
 471  0
         if (null != validationResults && validationResults.size() > 0) {
 472  0
             throw new DataValidationErrorException("Validation error!", validationResults);
 473  
         }
 474  
         
 475  
         
 476  0
         Milestone milestone = AtpAssembler.toMilestone(true, milestoneInfo, atpDao);
 477  0
         if (milestone == null) {
 478  0
             throw new DoesNotExistException("Milestone does not exist for key: " + milestoneKey);
 479  
         }
 480  
 
 481  0
         Milestone updatedMilestone = atpDao.update(milestone);
 482  
 
 483  0
         MilestoneInfo result = AtpAssembler.toMilestoneInfo(updatedMilestone);
 484  0
         return result;
 485  
     }
 486  
 
 487  
     @Override
 488  
     public List<ValidationResultInfo> validateAtp(String validationType, AtpInfo atpInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 489  0
         checkForMissingParameter(validationType, "validationType");
 490  0
         checkForMissingParameter(atpInfo, "dateRangeInfo");
 491  
 
 492  0
         ObjectStructureDefinition objStructure = this.getObjectStructure(AtpInfo.class.getName());
 493  0
         Validator defaultValidator = validatorFactory.getValidator();
 494  0
         List<ValidationResultInfo> validationResults = defaultValidator.validateObject(atpInfo, objStructure);
 495  0
         return validationResults;
 496  
     }
 497  
 
 498  
     @Override
 499  
     public List<ValidationResultInfo> validateDateRange(String validationType, DateRangeInfo dateRangeInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 500  0
         checkForMissingParameter(validationType, "validationType");
 501  0
         checkForMissingParameter(dateRangeInfo, "dateRangeInfo");
 502  
 
 503  0
         ObjectStructureDefinition objStructure = this.getObjectStructure(DateRangeInfo.class.getName());
 504  0
         Validator defaultValidator = validatorFactory.getValidator();
 505  0
         List<ValidationResultInfo> validationResults = defaultValidator.validateObject(dateRangeInfo, objStructure);
 506  0
         return validationResults;
 507  
     }
 508  
 
 509  
     @Override
 510  
     public List<ValidationResultInfo> validateMilestone(String validationType, MilestoneInfo milestoneInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 511  0
         checkForMissingParameter(validationType, "validationType");
 512  0
         checkForMissingParameter(milestoneInfo, "milestoneInfo");
 513  
 
 514  0
         ObjectStructureDefinition objStructure = this.getObjectStructure(MilestoneInfo.class.getName());
 515  0
         Validator defaultValidator = validatorFactory.getValidator();
 516  0
         List<ValidationResultInfo> validationResults = defaultValidator.validateObject(milestoneInfo, objStructure);
 517  0
         return validationResults;
 518  
     }
 519  
 
 520  
     /**
 521  
      * Check for missing parameter and thow localized exception if missing
 522  
      * 
 523  
      * @param param
 524  
      * @param parameter
 525  
      *            name
 526  
      * @throws MissingParameterException
 527  
      */
 528  
     private void checkForMissingParameter(Object param, String paramName) throws MissingParameterException {
 529  0
         if (param == null) {
 530  0
             throw new MissingParameterException(paramName + " can not be null");
 531  
         }
 532  0
     }
 533  
 
 534  
     public AtpDao getAtpDao() {
 535  0
         return atpDao;
 536  
     }
 537  
 
 538  
     public void setAtpDao(AtpDao atpDao) {
 539  0
         this.atpDao = atpDao;
 540  0
     }
 541  
 
 542  
     public SearchManager getSearchManager() {
 543  0
         return searchManager;
 544  
     }
 545  
 
 546  
     public void setSearchManager(SearchManager searchManager) {
 547  0
         this.searchManager = searchManager;
 548  0
     }
 549  
 
 550  
     @Override
 551  
     public SearchCriteriaTypeInfo getSearchCriteriaType(String searchCriteriaTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 552  
 
 553  0
         return searchManager.getSearchCriteriaType(searchCriteriaTypeKey);
 554  
     }
 555  
 
 556  
     @Override
 557  
     public List<SearchCriteriaTypeInfo> getSearchCriteriaTypes() throws OperationFailedException {
 558  0
         return searchManager.getSearchCriteriaTypes();
 559  
     }
 560  
 
 561  
     @Override
 562  
     public SearchResultTypeInfo getSearchResultType(String searchResultTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 563  0
         checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 564  0
         return searchManager.getSearchResultType(searchResultTypeKey);
 565  
     }
 566  
 
 567  
     @Override
 568  
     public List<SearchResultTypeInfo> getSearchResultTypes() throws OperationFailedException {
 569  0
         return searchManager.getSearchResultTypes();
 570  
     }
 571  
 
 572  
     @Override
 573  
     public SearchTypeInfo getSearchType(String searchTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 574  0
         checkForMissingParameter(searchTypeKey, "searchTypeKey");
 575  0
         return searchManager.getSearchType(searchTypeKey);
 576  
     }
 577  
 
 578  
     @Override
 579  
     public List<SearchTypeInfo> getSearchTypes() throws OperationFailedException {
 580  0
         return searchManager.getSearchTypes();
 581  
     }
 582  
 
 583  
     @Override
 584  
     public List<SearchTypeInfo> getSearchTypesByCriteria(String searchCriteriaTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 585  0
         checkForMissingParameter(searchCriteriaTypeKey, "searchCriteriaTypeKey");
 586  0
         return searchManager.getSearchTypesByCriteria(searchCriteriaTypeKey);
 587  
     }
 588  
 
 589  
     @Override
 590  
     public List<SearchTypeInfo> getSearchTypesByResult(String searchResultTypeKey) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
 591  0
         checkForMissingParameter(searchResultTypeKey, "searchResultTypeKey");
 592  0
         return searchManager.getSearchTypesByResult(searchResultTypeKey);
 593  
     }
 594  
 
 595  
     @Override
 596  
     public SearchResult search(SearchRequest searchRequest) throws MissingParameterException {
 597  0
         return searchManager.search(searchRequest, atpDao);
 598  
     }
 599  
 
 600  
     @Override
 601  
     public ObjectStructureDefinition getObjectStructure(String objectTypeKey) {
 602  0
         return dictionaryServiceDelegate.getObjectStructure(objectTypeKey);
 603  
     }
 604  
 
 605  
     @Override
 606  
     public List<String> getObjectTypes() {
 607  0
         return dictionaryServiceDelegate.getObjectTypes();
 608  
     }
 609  
 
 610  
     /**
 611  
      * @return the validatorFactory
 612  
      */
 613  
     public ValidatorFactory getValidatorFactory() {
 614  0
         return validatorFactory;
 615  
     }
 616  
 
 617  
     /**
 618  
      * @param validatorFactory
 619  
      *            the validatorFactory to set
 620  
      */
 621  
     public void setValidatorFactory(ValidatorFactory validatorFactory) {
 622  0
         this.validatorFactory = validatorFactory;
 623  0
     }
 624  
 
 625  
     /**
 626  
      * @return the dictionaryServiceDelegate
 627  
      */
 628  
     public DictionaryService getDictionaryServiceDelegate() {
 629  0
         return dictionaryServiceDelegate;
 630  
     }
 631  
 
 632  
     /**
 633  
      * @param dictionaryServiceDelegate the dictionaryServiceDelegate to set
 634  
      */
 635  
     public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {
 636  0
         this.dictionaryServiceDelegate = dictionaryServiceDelegate;
 637  0
     }
 638  
     
 639  
 }