| 1 | |
package org.kuali.student.enrollment.class1.lrr.service.impl; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import javax.jws.WebParam; |
| 7 | |
import javax.jws.WebService; |
| 8 | |
|
| 9 | |
import org.kuali.student.enrollment.class1.lrr.dao.LrrDao; |
| 10 | |
import org.kuali.student.enrollment.class1.lrr.dao.ResultSourceDao; |
| 11 | |
import org.kuali.student.enrollment.class1.lrr.model.LearningResultRecordEntity; |
| 12 | |
import org.kuali.student.enrollment.class1.lrr.model.ResultSourceEntity; |
| 13 | |
import org.kuali.student.enrollment.lrr.dto.LearningResultRecordInfo; |
| 14 | |
import org.kuali.student.enrollment.lrr.dto.ResultSourceInfo; |
| 15 | |
import org.kuali.student.enrollment.lrr.service.LearningResultRecordService; |
| 16 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 17 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 18 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 19 | |
import org.kuali.student.r2.common.exceptions.AlreadyExistsException; |
| 20 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 21 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 22 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 23 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 24 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 25 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 26 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 27 | |
import org.kuali.student.r2.common.util.constants.LrrServiceConstants; |
| 28 | |
import org.kuali.student.r2.core.state.dto.StateInfo; |
| 29 | |
import org.kuali.student.r2.core.state.service.StateService; |
| 30 | |
import org.springframework.transaction.annotation.Transactional; |
| 31 | |
|
| 32 | |
@WebService(endpointInterface = "org.kuali.student.enrollment.lrr.service.LearningResultRecordService", serviceName = "LearningResultRecordService", portName = "LearningResultRecordService", targetNamespace = "http://student.kuali.org/wsdl/lrr") |
| 33 | |
@Transactional(readOnly = true, noRollbackFor = {org.kuali.student.common.exceptions.DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
| 34 | 0 | public class LearningResultRecordServiceImpl implements LearningResultRecordService { |
| 35 | |
|
| 36 | |
private LrrDao lrrDao; |
| 37 | |
private ResultSourceDao resultSourceDao; |
| 38 | |
|
| 39 | |
@Override |
| 40 | |
public LearningResultRecordInfo getLearningResultRecord( |
| 41 | |
@WebParam(name = "learningResultRecordId") String learningResultRecordId, |
| 42 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 43 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 44 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 45 | |
} |
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public List<LearningResultRecordInfo> getLearningResultRecordsForLpr(@WebParam(name = "lprId") String lprId) |
| 49 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 50 | |
OperationFailedException { |
| 51 | 0 | List<LearningResultRecordInfo> dtos = new ArrayList<LearningResultRecordInfo>(); |
| 52 | 0 | List<LearningResultRecordEntity> lrrs = lrrDao.getLearningResultRecordsForLpr(lprId); |
| 53 | 0 | for (LearningResultRecordEntity lrr : lrrs) { |
| 54 | 0 | LearningResultRecordInfo dto = lrr.toDto(); |
| 55 | 0 | dtos.add(dto); |
| 56 | 0 | } |
| 57 | 0 | return dtos; |
| 58 | |
} |
| 59 | |
|
| 60 | |
@Override |
| 61 | |
public List<LearningResultRecordInfo> getLearningResultRecordsForLprIds( |
| 62 | |
@WebParam(name = "lprIds") List<String> lprIds, @WebParam(name = "context") ContextInfo context) |
| 63 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 64 | |
OperationFailedException { |
| 65 | 0 | List<LearningResultRecordInfo> dtos = new ArrayList<LearningResultRecordInfo>(); |
| 66 | 0 | List<LearningResultRecordEntity> lrrs = lrrDao.getLearningResultRecordsForLprIds(lprIds); |
| 67 | 0 | for (LearningResultRecordEntity lrr : lrrs) { |
| 68 | 0 | LearningResultRecordInfo dto = lrr.toDto(); |
| 69 | 0 | dtos.add(dto); |
| 70 | 0 | } |
| 71 | 0 | return dtos; |
| 72 | |
} |
| 73 | |
|
| 74 | |
@Override |
| 75 | |
public List<LearningResultRecordInfo> getLearningResultRecordsBySourceId( |
| 76 | |
@WebParam(name = "lprIds") List<String> sourceIds, @WebParam(name = "context") ContextInfo context) |
| 77 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 78 | |
OperationFailedException { |
| 79 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 80 | |
} |
| 81 | |
|
| 82 | |
@Override |
| 83 | |
@Transactional(readOnly = false) |
| 84 | |
public LearningResultRecordInfo createLearningResultRecord( |
| 85 | |
@WebParam(name = "learningResultRecord") LearningResultRecordInfo learningResultRecord, |
| 86 | |
@WebParam(name = "context") ContextInfo context) throws AlreadyExistsException, |
| 87 | |
DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 88 | |
OperationFailedException, PermissionDeniedException { |
| 89 | 0 | LearningResultRecordEntity lrr = lrrDao.find(learningResultRecord.getId()); |
| 90 | 0 | if (lrr != null) { |
| 91 | 0 | throw new AlreadyExistsException("Record already exists for " + learningResultRecord.getId()); |
| 92 | |
} else { |
| 93 | 0 | LearningResultRecordEntity newLrr = new LearningResultRecordEntity(learningResultRecord); |
| 94 | |
|
| 95 | 0 | List<ResultSourceEntity> resultSourceEntities = new ArrayList(); |
| 96 | |
|
| 97 | 0 | if (learningResultRecord.getResultSourceIds() != null |
| 98 | |
&& !learningResultRecord.getResultSourceIds().isEmpty()) { |
| 99 | |
try{ |
| 100 | 0 | resultSourceEntities = resultSourceDao.findByIds(learningResultRecord.getResultSourceIds()); |
| 101 | 0 | }catch (DoesNotExistException doesNotExist){ |
| 102 | 0 | throw new OperationFailedException( doesNotExist.getMessage(), doesNotExist); |
| 103 | 0 | } |
| 104 | |
} |
| 105 | 0 | newLrr.setResultSourceList(resultSourceEntities); |
| 106 | |
|
| 107 | 0 | lrrDao.merge(newLrr); |
| 108 | 0 | return lrrDao.find(newLrr.getId()).toDto(); |
| 109 | |
} |
| 110 | |
|
| 111 | |
} |
| 112 | |
|
| 113 | |
@Override |
| 114 | |
@Transactional(readOnly = false) |
| 115 | |
public LearningResultRecordInfo updateLearningResultRecord( |
| 116 | |
@WebParam(name = "learningResultRecordId") String learningResultRecordId, |
| 117 | |
@WebParam(name = "learningResultRecordInfo") LearningResultRecordInfo learningResultRecordInfo, |
| 118 | |
@WebParam(name = "context") ContextInfo context) throws DataValidationErrorException, |
| 119 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 120 | |
PermissionDeniedException, VersionMismatchException { |
| 121 | |
|
| 122 | 0 | LearningResultRecordEntity lrr = lrrDao.find(learningResultRecordId); |
| 123 | |
|
| 124 | 0 | if (lrr == null) { |
| 125 | 0 | throw new DoesNotExistException(learningResultRecordId); |
| 126 | |
} |
| 127 | |
|
| 128 | 0 | LearningResultRecordEntity modifiedLrr = new LearningResultRecordEntity(learningResultRecordInfo); |
| 129 | 0 | List<ResultSourceEntity> resultSourceEntities = new ArrayList(); |
| 130 | 0 | if (learningResultRecordInfo.getResultSourceIds() != null |
| 131 | |
&& !learningResultRecordInfo.getResultSourceIds().isEmpty()) { |
| 132 | 0 | resultSourceEntities = resultSourceDao.findByIds(learningResultRecordInfo.getResultSourceIds()); |
| 133 | |
} |
| 134 | 0 | modifiedLrr.setResultSourceList(resultSourceEntities); |
| 135 | |
|
| 136 | 0 | lrrDao.merge(modifiedLrr); |
| 137 | |
|
| 138 | 0 | return lrrDao.find(modifiedLrr.getId()).toDto(); |
| 139 | |
} |
| 140 | |
|
| 141 | |
@Override |
| 142 | |
@Transactional(readOnly = false) |
| 143 | |
public StatusInfo deleteLearningResultRecord( |
| 144 | |
@WebParam(name = "learningResultRecordId") String learningResultRecordId, |
| 145 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 146 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 147 | 0 | LearningResultRecordEntity lrr = lrrDao.find(learningResultRecordId); |
| 148 | |
|
| 149 | 0 | if (lrr == null) { |
| 150 | 0 | throw new DoesNotExistException(learningResultRecordId); |
| 151 | |
} |
| 152 | |
|
| 153 | 0 | StatusInfo status = new StatusInfo(); |
| 154 | 0 | status.setSuccess(Boolean.TRUE); |
| 155 | |
|
| 156 | 0 | lrr.setLrrState(LrrServiceConstants.RESULT_RECORD_DELETED_STATE_KEY); |
| 157 | 0 | lrrDao.merge(lrr); |
| 158 | |
|
| 159 | 0 | return status; |
| 160 | |
|
| 161 | |
} |
| 162 | |
|
| 163 | |
@Override |
| 164 | |
public List<ValidationResultInfo> validateLearningResultRecord( |
| 165 | |
@WebParam(name = "validationType") String validationType, |
| 166 | |
@WebParam(name = "learningResultRecordInfo") LearningResultRecordInfo learningResultRecordInfo, |
| 167 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 168 | |
MissingParameterException, OperationFailedException { |
| 169 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 170 | |
} |
| 171 | |
|
| 172 | |
@Override |
| 173 | |
public ResultSourceInfo getResultSource(@WebParam(name = "resultSourceId") String resultSourceId, |
| 174 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 175 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 176 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 177 | |
} |
| 178 | |
|
| 179 | |
@Override |
| 180 | |
public List<ResultSourceInfo> getResultSourcesByIds( |
| 181 | |
@WebParam(name = "resultSourceIds") List<String> resultSourceIds, |
| 182 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 183 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 184 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 185 | |
} |
| 186 | |
|
| 187 | |
@Override |
| 188 | |
public List<ResultSourceInfo> getResultSourcesByType( |
| 189 | |
@WebParam(name = "resultSourceTypeKey") String resultSourceTypeKey, |
| 190 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 191 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 192 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 193 | |
} |
| 194 | |
|
| 195 | |
@Override |
| 196 | |
@Transactional(readOnly = false) |
| 197 | |
public ResultSourceInfo createResultSource(@WebParam(name = "resultSourceInfo") ResultSourceInfo sourceInfo, |
| 198 | |
@WebParam(name = "context") ContextInfo context) throws AlreadyExistsException, |
| 199 | |
DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 200 | |
OperationFailedException, PermissionDeniedException { |
| 201 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 202 | |
} |
| 203 | |
|
| 204 | |
@Override |
| 205 | |
@Transactional(readOnly = false) |
| 206 | |
public ResultSourceInfo updateResultSource(@WebParam(name = "resultSourceId") String resultSourceId, |
| 207 | |
@WebParam(name = "resultSourceInfo") ResultSourceInfo resultSourceInfo, |
| 208 | |
@WebParam(name = "context") ContextInfo context) throws DataValidationErrorException, |
| 209 | |
DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 210 | |
PermissionDeniedException, VersionMismatchException { |
| 211 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 212 | |
} |
| 213 | |
|
| 214 | |
@Override |
| 215 | |
@Transactional(readOnly = false) |
| 216 | |
public StatusInfo deleteResultSource(@WebParam(name = "deleteResultSourceId") String resultSourceId, |
| 217 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 218 | |
MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 219 | 0 | throw new UnsupportedOperationException("Method not implemented."); |
| 220 | |
} |
| 221 | |
|
| 222 | |
@Override |
| 223 | |
public List<ValidationResultInfo> validateResultSource(@WebParam(name = "validationType") String validationType, |
| 224 | |
@WebParam(name = "resultSourceInfo") ResultSourceInfo resultSourceInfo, |
| 225 | |
@WebParam(name = "context") ContextInfo context) throws DoesNotExistException, InvalidParameterException, |
| 226 | |
MissingParameterException, OperationFailedException { |
| 227 | 0 | return null; |
| 228 | |
} |
| 229 | |
|
| 230 | |
public LrrDao getLrrDao() { |
| 231 | 0 | return lrrDao; |
| 232 | |
} |
| 233 | |
|
| 234 | |
public void setLrrDao(LrrDao lrrDao) { |
| 235 | 0 | this.lrrDao = lrrDao; |
| 236 | 0 | } |
| 237 | |
|
| 238 | |
public ResultSourceDao getResultSourceDao() { |
| 239 | 0 | return resultSourceDao; |
| 240 | |
} |
| 241 | |
|
| 242 | |
public void setResultSourceDao(ResultSourceDao resultSourceDao) { |
| 243 | 0 | this.resultSourceDao = resultSourceDao; |
| 244 | 0 | } |
| 245 | |
|
| 246 | |
@Override |
| 247 | |
public List<LearningResultRecordInfo> getLearningResultRecordsForLprAndType(String lprId, String lrrType) |
| 248 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 249 | |
OperationFailedException { |
| 250 | |
|
| 251 | 0 | return new ArrayList<LearningResultRecordInfo>(); |
| 252 | |
} |
| 253 | |
|
| 254 | |
} |