| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.kuali.student.enrollment.class2.courseofferingset.service.impl; |
| 6 | |
|
| 7 | |
import java.util.ArrayList; |
| 8 | |
import java.util.Date; |
| 9 | |
import java.util.LinkedHashMap; |
| 10 | |
import java.util.List; |
| 11 | |
import java.util.Map; |
| 12 | |
import javax.annotation.Resource; |
| 13 | |
import org.kuali.rice.core.api.criteria.QueryByCriteria; |
| 14 | |
import org.kuali.student.enrollment.courseofferingset.dto.SocInfo; |
| 15 | |
import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultInfo; |
| 16 | |
import org.kuali.student.enrollment.courseofferingset.dto.SocRolloverResultItemInfo; |
| 17 | |
import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService; |
| 18 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 19 | |
import org.kuali.student.r2.common.dto.MetaInfo; |
| 20 | |
import org.kuali.student.r2.common.dto.StatusInfo; |
| 21 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 22 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 23 | |
import org.kuali.student.r2.common.exceptions.DependentObjectsExistException; |
| 24 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 25 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 26 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 27 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 28 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 29 | |
import org.kuali.student.r2.common.exceptions.ReadOnlyException; |
| 30 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 31 | |
|
| 32 | |
import javax.jws.WebParam; |
| 33 | |
import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetServiceBusinessLogic; |
| 34 | |
import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants; |
| 35 | |
|
| 36 | 0 | public class CourseOfferingSetServiceMockImpl implements CourseOfferingSetService { |
| 37 | |
|
| 38 | |
private CourseOfferingSetServiceBusinessLogic businessLogic; |
| 39 | |
|
| 40 | |
public CourseOfferingSetServiceBusinessLogic getBusinessLogic() { |
| 41 | 0 | return businessLogic; |
| 42 | |
} |
| 43 | |
|
| 44 | |
public void setBusinessLogic(CourseOfferingSetServiceBusinessLogic businessLogic) { |
| 45 | 0 | this.businessLogic = businessLogic; |
| 46 | 0 | } |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
@Override |
| 53 | |
public SocInfo getSoc(String socId, ContextInfo context) |
| 54 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 55 | |
PermissionDeniedException { |
| 56 | 0 | if (!this.socMap.containsKey(socId)) { |
| 57 | 0 | throw new DoesNotExistException(socId); |
| 58 | |
} |
| 59 | 0 | return this.socMap.get(socId); |
| 60 | |
} |
| 61 | |
|
| 62 | |
@Override |
| 63 | |
public List<SocInfo> getSocsByIds(List<String> socIds, ContextInfo context) |
| 64 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 65 | |
PermissionDeniedException { |
| 66 | 0 | List<SocInfo> list = new ArrayList<SocInfo>(); |
| 67 | 0 | for (String id : socIds) { |
| 68 | 0 | list.add(this.getSoc(id, context)); |
| 69 | |
} |
| 70 | 0 | return list; |
| 71 | |
} |
| 72 | |
|
| 73 | |
@Override |
| 74 | |
public List<String> getSocIdsByTerm(String termId, ContextInfo context) |
| 75 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 76 | |
PermissionDeniedException { |
| 77 | 0 | List<String> list = new ArrayList<String>(); |
| 78 | 0 | for (SocInfo info : socMap.values()) { |
| 79 | 0 | if (termId.equals(info.getTermId())) { |
| 80 | 0 | list.add(info.getId()); |
| 81 | |
} |
| 82 | |
} |
| 83 | 0 | return list; |
| 84 | |
} |
| 85 | |
|
| 86 | |
@Override |
| 87 | |
public List<String> getSocIdsByTermAndSubjectArea(String termId, String subjectArea, ContextInfo context) |
| 88 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 89 | |
PermissionDeniedException { |
| 90 | 0 | List<String> list = new ArrayList<String>(); |
| 91 | 0 | for (SocInfo info : socMap.values()) { |
| 92 | 0 | if (termId.equals(info.getTermId())) { |
| 93 | 0 | if (subjectArea.equals(info.getSubjectArea())) { |
| 94 | 0 | list.add(info.getId()); |
| 95 | |
} |
| 96 | |
} |
| 97 | |
} |
| 98 | 0 | return list; |
| 99 | |
} |
| 100 | |
|
| 101 | |
@Override |
| 102 | |
public List<String> getSocIdsByTermAndUnitsContentOwner(String termId, String unitsContentOwnerId, ContextInfo context) |
| 103 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 104 | |
PermissionDeniedException { |
| 105 | 0 | List<String> list = new ArrayList<String>(); |
| 106 | 0 | for (SocInfo info : socMap.values()) { |
| 107 | 0 | if (termId.equals(info.getTermId())) { |
| 108 | 0 | if (unitsContentOwnerId.equals(info.getUnitsContentOwnerId())) { |
| 109 | 0 | list.add(info.getId()); |
| 110 | |
} |
| 111 | |
} |
| 112 | |
} |
| 113 | 0 | return list; |
| 114 | |
} |
| 115 | |
|
| 116 | |
@Override |
| 117 | |
public List<String> getSocIdsByType(String typeKey, ContextInfo context) |
| 118 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 119 | |
PermissionDeniedException { |
| 120 | 0 | List<String> list = new ArrayList<String>(); |
| 121 | 0 | for (SocInfo info : socMap.values()) { |
| 122 | 0 | if (typeKey.equals(info.getTypeKey())) { |
| 123 | 0 | list.add(info.getId()); |
| 124 | |
} |
| 125 | |
} |
| 126 | 0 | return list; |
| 127 | |
} |
| 128 | |
|
| 129 | |
|
| 130 | 0 | private Map<String, SocInfo> socMap = new LinkedHashMap<String, SocInfo>(); |
| 131 | |
|
| 132 | |
@Override |
| 133 | |
public SocInfo createSoc(String termId, String socTypeKey, SocInfo socInfo, ContextInfo context) |
| 134 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 135 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 136 | |
|
| 137 | 0 | if (!socTypeKey.equals(socInfo.getTypeKey())) { |
| 138 | 0 | throw new InvalidParameterException("The type parameter does not match the type on the info object"); |
| 139 | |
} |
| 140 | |
|
| 141 | 0 | SocInfo copy = new SocInfo(socInfo); |
| 142 | 0 | if (copy.getId() == null) { |
| 143 | 0 | copy.setId(socMap.size() + ""); |
| 144 | |
} |
| 145 | 0 | copy.setMeta(newMeta(context)); |
| 146 | 0 | socMap.put(copy.getId(), copy); |
| 147 | 0 | return new SocInfo(copy); |
| 148 | |
} |
| 149 | |
|
| 150 | |
@Override |
| 151 | |
public SocInfo updateSoc(String socId, SocInfo socInfo, ContextInfo context) |
| 152 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 153 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 154 | |
|
| 155 | 0 | if (!socId.equals(socInfo.getId())) { |
| 156 | 0 | throw new InvalidParameterException("The id parameter does not match the id on the info object"); |
| 157 | |
} |
| 158 | 0 | SocInfo copy = new SocInfo(socInfo); |
| 159 | 0 | SocInfo old = this.getSoc(socInfo.getId(), context); |
| 160 | 0 | if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) { |
| 161 | 0 | throw new VersionMismatchException(old.getMeta().getVersionInd()); |
| 162 | |
} |
| 163 | 0 | copy.setMeta(updateMeta(copy.getMeta(), context)); |
| 164 | 0 | this.socMap.put(socInfo.getId(), copy); |
| 165 | 0 | return new SocInfo(copy); |
| 166 | |
} |
| 167 | |
|
| 168 | |
@Override |
| 169 | |
public StatusInfo deleteSoc(String socId, ContextInfo context) |
| 170 | |
throws DependentObjectsExistException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 171 | |
OperationFailedException, PermissionDeniedException { |
| 172 | 0 | if (this.socMap.remove(socId) == null) { |
| 173 | 0 | throw new DoesNotExistException(socId); |
| 174 | |
} |
| 175 | 0 | return newStatus(); |
| 176 | |
} |
| 177 | |
|
| 178 | |
@Override |
| 179 | |
public List<ValidationResultInfo> validateSoc(String validationType, SocInfo socInfo, ContextInfo context) |
| 180 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 181 | |
|
| 182 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 183 | |
} |
| 184 | |
|
| 185 | |
@Override |
| 186 | |
public List<String> getSocIdsByCourseOffering(String courseOfferingId, ContextInfo context) |
| 187 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 188 | |
PermissionDeniedException { |
| 189 | 0 | List<String> list = new ArrayList<String>(); |
| 190 | 0 | for (SocInfo info : socMap.values()) { |
| 191 | 0 | if (this.isCourseOfferingInSoc(info.getId(), courseOfferingId, context)) { |
| 192 | 0 | list.add(info.getId()); |
| 193 | |
} |
| 194 | |
} |
| 195 | 0 | return list; |
| 196 | |
} |
| 197 | |
|
| 198 | |
@Override |
| 199 | |
public List<String> getCourseOfferingIdsBySoc(String socId, ContextInfo context) |
| 200 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 201 | |
PermissionDeniedException { |
| 202 | 0 | return this.businessLogic.getCourseOfferingIdsBySoc(socId, context); |
| 203 | |
} |
| 204 | |
|
| 205 | |
@Override |
| 206 | |
public Integer deleteCourseOfferingsBySoc(String socId, ContextInfo context) |
| 207 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 208 | |
PermissionDeniedException { |
| 209 | 0 | return this.businessLogic.deleteCourseOfferingsBySoc(socId, context); |
| 210 | |
} |
| 211 | |
|
| 212 | |
@Override |
| 213 | |
public Boolean isCourseOfferingInSoc(String socId, String courseOfferingId, ContextInfo context) |
| 214 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 215 | |
PermissionDeniedException { |
| 216 | 0 | return this.businessLogic.isCourseOfferingInSoc(socId, courseOfferingId, context); |
| 217 | |
} |
| 218 | |
|
| 219 | |
@Override |
| 220 | |
public List<String> getPublishedCourseOfferingIdsBySoc(String socId, ContextInfo context) |
| 221 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 222 | |
PermissionDeniedException { |
| 223 | 0 | return this.businessLogic.getPublishedCourseOfferingIdsBySoc(socId, context); |
| 224 | |
} |
| 225 | |
|
| 226 | |
@Override |
| 227 | |
public List<String> getUnpublishedCourseOfferingIdsBySoc(String socId, ContextInfo context) |
| 228 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 229 | |
PermissionDeniedException { |
| 230 | 0 | return this.businessLogic.getUnpublishedActivityOfferingIdsBySoc(socId, context); |
| 231 | |
} |
| 232 | |
|
| 233 | |
@Override |
| 234 | |
public List<String> getUnpublishedActivityOfferingIdsBySoc(String socId, ContextInfo context) |
| 235 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 236 | |
PermissionDeniedException { |
| 237 | 0 | return this.businessLogic.getUnpublishedActivityOfferingIdsBySoc(socId, context); |
| 238 | |
} |
| 239 | |
|
| 240 | |
@Override |
| 241 | |
public List<String> getUnscheduledActivityOfferingIdsBySoc(String socId, ContextInfo context) |
| 242 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 243 | |
PermissionDeniedException { |
| 244 | 0 | throw new OperationFailedException("not impemented"); |
| 245 | |
} |
| 246 | |
|
| 247 | |
@Override |
| 248 | |
public List<String> getCourseOfferingIdsWithUnscheduledFinalExamsBySoc(String socId, ContextInfo context) |
| 249 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 250 | |
PermissionDeniedException { |
| 251 | 0 | throw new OperationFailedException("not been implemented"); |
| 252 | |
} |
| 253 | |
|
| 254 | |
@Override |
| 255 | |
public StatusInfo scheduleSoc(String socId, ContextInfo context) |
| 256 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 257 | |
PermissionDeniedException { |
| 258 | 0 | throw new OperationFailedException("scheduleSoc has not been implemented"); |
| 259 | |
} |
| 260 | |
|
| 261 | |
@Override |
| 262 | |
public SocInfo rolloverSoc(String sourceSocId, String targetTermId, List<String> optionKeys, ContextInfo context) |
| 263 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 264 | |
PermissionDeniedException { |
| 265 | 0 | return this.businessLogic.rolloverSoc(sourceSocId, targetTermId, optionKeys, context); |
| 266 | |
} |
| 267 | |
|
| 268 | |
@Override |
| 269 | |
public SocRolloverResultInfo getSocRolloverResult(String rolloverResultId, ContextInfo context) |
| 270 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 271 | |
PermissionDeniedException { |
| 272 | 0 | if (!this.socRolloverResultMap.containsKey(rolloverResultId)) { |
| 273 | 0 | throw new DoesNotExistException(rolloverResultId); |
| 274 | |
} |
| 275 | 0 | SocRolloverResultInfo info = new SocRolloverResultInfo(this.socRolloverResultMap.get(rolloverResultId)); |
| 276 | 0 | this.updateCalculatedFields(info, context); |
| 277 | 0 | return info; |
| 278 | |
} |
| 279 | |
|
| 280 | |
private void updateCalculatedFields(SocRolloverResultInfo info, ContextInfo context) throws OperationFailedException { |
| 281 | |
try { |
| 282 | 0 | if (info.getSourceSocId() != null) { |
| 283 | 0 | SocInfo sourceSoc = this.getSoc(info.getSourceSocId(), context); |
| 284 | 0 | info.setSourceTermId(sourceSoc.getTermId()); |
| 285 | |
} |
| 286 | |
|
| 287 | 0 | if (info.getStateKey().equals(CourseOfferingSetServiceConstants.FINISHED_RESULT_STATE_KEY)) { |
| 288 | 0 | List<SocRolloverResultItemInfo> items = this.getSocRolloverResultItemsByResultId(info.getId(), context); |
| 289 | 0 | int success = 0; |
| 290 | 0 | int failure = 0; |
| 291 | 0 | for (SocRolloverResultItemInfo item : items) { |
| 292 | 0 | if (item.getStateKey().equals(CourseOfferingSetServiceConstants.SUCCESS_RESULT_ITEM_STATE_KEY)) { |
| 293 | 0 | success++; |
| 294 | |
} else { |
| 295 | 0 | failure++; |
| 296 | |
} |
| 297 | |
} |
| 298 | 0 | info.setItemsCreated(success); |
| 299 | 0 | info.setItemsSkipped(failure); |
| 300 | |
} |
| 301 | 0 | } catch (Exception ex) { |
| 302 | 0 | throw new OperationFailedException("unexpected", ex); |
| 303 | 0 | } |
| 304 | 0 | } |
| 305 | |
|
| 306 | |
@Override |
| 307 | |
public List<SocRolloverResultInfo> getSocRolloverResultsByIds(List<String> rolloverResultIds, ContextInfo context) |
| 308 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 309 | |
PermissionDeniedException { |
| 310 | 0 | List<SocRolloverResultInfo> list = new ArrayList<SocRolloverResultInfo>(); |
| 311 | 0 | for (String id : rolloverResultIds) { |
| 312 | 0 | list.add(this.getSocRolloverResult(id, context)); |
| 313 | |
} |
| 314 | 0 | return list; |
| 315 | |
} |
| 316 | |
|
| 317 | |
@Override |
| 318 | |
public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByIds(List<String> rolloverResultItemIds, ContextInfo context) |
| 319 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 320 | |
PermissionDeniedException { |
| 321 | 0 | List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(); |
| 322 | 0 | for (String id : rolloverResultItemIds) { |
| 323 | 0 | list.add(this.getSocRolloverResultItem(id, context)); |
| 324 | |
} |
| 325 | 0 | return list; |
| 326 | |
} |
| 327 | |
|
| 328 | |
@Override |
| 329 | |
public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultId(String socRolloverResultId, ContextInfo context) |
| 330 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 331 | |
PermissionDeniedException { |
| 332 | 0 | List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(); |
| 333 | 0 | for (SocRolloverResultItemInfo info : socRolloverResultItemMap.values()) { |
| 334 | 0 | if (socRolloverResultId.equals(info.getSocRolloverResultId())) { |
| 335 | 0 | list.add(info); |
| 336 | |
} |
| 337 | |
} |
| 338 | 0 | return list; |
| 339 | |
} |
| 340 | |
|
| 341 | |
@Override |
| 342 | |
public List<SocRolloverResultInfo> getSocRolloverResultsBySourceAndTargetSocs(String sourceSocId, String targetSocId, ContextInfo context) throws |
| 343 | |
DoesNotExistException, |
| 344 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 345 | 0 | List<SocRolloverResultInfo> list = new ArrayList<SocRolloverResultInfo>(); |
| 346 | |
|
| 347 | 0 | for (SocRolloverResultInfo info : socRolloverResultMap.values()) { |
| 348 | 0 | if (sourceSocId.equals(info.getSourceSocId())) { |
| 349 | 0 | if (targetSocId.equals(info.getTargetSocId())) { |
| 350 | 0 | list.add(info); |
| 351 | |
} |
| 352 | |
} |
| 353 | |
} |
| 354 | 0 | return list; |
| 355 | |
} |
| 356 | |
|
| 357 | |
@Override |
| 358 | |
public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultIdAndSourceCourseOfferingId(String socRolloverResultId, String sourceCourseOfferingId, ContextInfo context) |
| 359 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 360 | |
PermissionDeniedException { |
| 361 | 0 | List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(); |
| 362 | 0 | for (SocRolloverResultItemInfo info : socRolloverResultItemMap.values()) { |
| 363 | 0 | if (socRolloverResultId.equals(info.getSocRolloverResultId())) { |
| 364 | 0 | if (sourceCourseOfferingId.equals(info.getTargetCourseOfferingId())) { |
| 365 | 0 | list.add(info); |
| 366 | |
} |
| 367 | |
} |
| 368 | |
} |
| 369 | 0 | return list; |
| 370 | |
} |
| 371 | |
|
| 372 | |
@Override |
| 373 | |
public List<SocRolloverResultItemInfo> getSocRolloverResultItemsByResultIdAndTargetCourseOfferingId(String socRolloverResultId, String targetCourseOfferingId, ContextInfo context) |
| 374 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 375 | |
PermissionDeniedException { |
| 376 | 0 | List<SocRolloverResultItemInfo> list = new ArrayList<SocRolloverResultItemInfo>(); |
| 377 | 0 | for (SocRolloverResultItemInfo info : socRolloverResultItemMap.values()) { |
| 378 | 0 | if (socRolloverResultId.equals(info.getSocRolloverResultId())) { |
| 379 | 0 | if (targetCourseOfferingId.equals(info.getTargetCourseOfferingId())) { |
| 380 | 0 | list.add(info); |
| 381 | |
} |
| 382 | |
} |
| 383 | |
} |
| 384 | 0 | return list; |
| 385 | |
} |
| 386 | |
|
| 387 | |
@Override |
| 388 | |
public List<String> getSocRolloverResultIdsByTargetSoc(String targetSocId, ContextInfo context) |
| 389 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 390 | |
PermissionDeniedException { |
| 391 | 0 | List<String> list = new ArrayList<String>(); |
| 392 | 0 | for (SocRolloverResultInfo info : socRolloverResultMap.values()) { |
| 393 | 0 | if (targetSocId.equals(info.getTargetSocId())) { |
| 394 | 0 | list.add(info.getId()); |
| 395 | |
} |
| 396 | |
} |
| 397 | 0 | return list; |
| 398 | |
} |
| 399 | |
|
| 400 | |
@Override |
| 401 | |
public List<String> getSocRolloverResultIdsBySourceSoc(String sourceSocId, ContextInfo context) |
| 402 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 403 | |
PermissionDeniedException { |
| 404 | 0 | List<String> list = new ArrayList<String>(); |
| 405 | 0 | for (SocRolloverResultInfo info : socRolloverResultMap.values()) { |
| 406 | 0 | if (sourceSocId.equals(info.getSourceSocId())) { |
| 407 | 0 | list.add(info.getId()); |
| 408 | |
} |
| 409 | |
} |
| 410 | 0 | return list; |
| 411 | |
} |
| 412 | |
|
| 413 | |
@Override |
| 414 | |
public SocRolloverResultInfo reverseRollover(String rolloverResultId, List<String> optionKeys, ContextInfo context) |
| 415 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 416 | |
PermissionDeniedException { |
| 417 | 0 | return this.businessLogic.reverseRollover(rolloverResultId, optionKeys, context); |
| 418 | |
} |
| 419 | |
|
| 420 | |
|
| 421 | 0 | private Map<String, SocRolloverResultInfo> socRolloverResultMap = new LinkedHashMap<String, SocRolloverResultInfo>(); |
| 422 | |
|
| 423 | |
@Override |
| 424 | |
public SocRolloverResultInfo createSocRolloverResult(String socRolloverResultTypeKey, SocRolloverResultInfo socRolloverResultInfo, ContextInfo context) |
| 425 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 426 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 427 | |
|
| 428 | 0 | if (!socRolloverResultTypeKey.equals(socRolloverResultInfo.getTypeKey())) { |
| 429 | 0 | throw new InvalidParameterException("The type parameter does not match the type on the info object"); |
| 430 | |
} |
| 431 | 0 | SocRolloverResultInfo copy = new SocRolloverResultInfo(socRolloverResultInfo); |
| 432 | 0 | if (copy.getId() == null) { |
| 433 | 0 | copy.setId(socRolloverResultMap.size() + ""); |
| 434 | |
} |
| 435 | 0 | copy.setMeta(newMeta(context)); |
| 436 | 0 | socRolloverResultMap.put(copy.getId(), copy); |
| 437 | 0 | return new SocRolloverResultInfo(copy); |
| 438 | |
} |
| 439 | |
|
| 440 | |
@Override |
| 441 | |
public SocRolloverResultInfo updateSocRolloverResult(String socRolloverResultId, SocRolloverResultInfo socRolloverResultInfo, ContextInfo context) |
| 442 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 443 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 444 | |
|
| 445 | 0 | if (!socRolloverResultId.equals(socRolloverResultInfo.getId())) { |
| 446 | 0 | throw new InvalidParameterException("The id parameter does not match the id on the info object"); |
| 447 | |
} |
| 448 | 0 | SocRolloverResultInfo copy = new SocRolloverResultInfo(socRolloverResultInfo); |
| 449 | 0 | SocRolloverResultInfo old = this.getSocRolloverResult(socRolloverResultInfo.getId(), context); |
| 450 | 0 | if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) { |
| 451 | 0 | throw new VersionMismatchException(old.getMeta().getVersionInd()); |
| 452 | |
} |
| 453 | 0 | copy.setMeta(updateMeta(copy.getMeta(), context)); |
| 454 | 0 | this.socRolloverResultMap.put(socRolloverResultInfo.getId(), copy); |
| 455 | 0 | return new SocRolloverResultInfo(copy); |
| 456 | |
} |
| 457 | |
|
| 458 | |
@Override |
| 459 | |
public SocRolloverResultInfo updateSocRolloverProgress(String socRolloverResultId, Integer itemsProcessed, ContextInfo context) |
| 460 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 461 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 462 | 0 | SocRolloverResultInfo info = this.getSocRolloverResult(socRolloverResultId, context); |
| 463 | 0 | info = new SocRolloverResultInfo(info); |
| 464 | 0 | info.setItemsProcessed(itemsProcessed); |
| 465 | 0 | return this.updateSocRolloverResult(info.getId(), info, context); |
| 466 | |
} |
| 467 | |
|
| 468 | |
@Override |
| 469 | |
public StatusInfo deleteSocRolloverResult(String socRolloverResultId, ContextInfo context) |
| 470 | |
throws DoesNotExistException, DependentObjectsExistException, |
| 471 | |
InvalidParameterException, MissingParameterException, OperationFailedException, |
| 472 | |
PermissionDeniedException { |
| 473 | 0 | List<SocRolloverResultItemInfo> items = this.getSocRolloverResultItemsByResultId(socRolloverResultId, context); |
| 474 | 0 | if (!items.isEmpty()) { |
| 475 | 0 | throw new DependentObjectsExistException(items.size() + " items exist"); |
| 476 | |
} |
| 477 | 0 | if (this.socRolloverResultMap.remove(socRolloverResultId) == null) { |
| 478 | 0 | throw new DoesNotExistException(socRolloverResultId); |
| 479 | |
} |
| 480 | 0 | return newStatus(); |
| 481 | |
} |
| 482 | |
|
| 483 | |
@Override |
| 484 | |
public List<ValidationResultInfo> validateSocRolloverResult(String validationType, SocRolloverResultInfo socRolloverResultInfo, ContextInfo context) |
| 485 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 486 | |
|
| 487 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 488 | |
} |
| 489 | |
|
| 490 | |
@Override |
| 491 | |
public SocRolloverResultItemInfo getSocRolloverResultItem(String socRolloverResultItemId, ContextInfo context) |
| 492 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 493 | |
PermissionDeniedException { |
| 494 | 0 | if (!this.socRolloverResultItemMap.containsKey(socRolloverResultItemId)) { |
| 495 | 0 | throw new DoesNotExistException(socRolloverResultItemId); |
| 496 | |
} |
| 497 | 0 | return this.socRolloverResultItemMap.get(socRolloverResultItemId); |
| 498 | |
} |
| 499 | |
|
| 500 | |
|
| 501 | 0 | private Map<String, SocRolloverResultItemInfo> socRolloverResultItemMap = new LinkedHashMap<String, SocRolloverResultItemInfo>(); |
| 502 | |
|
| 503 | |
@Override |
| 504 | |
public SocRolloverResultItemInfo createSocRolloverResultItem(String socRolloverResultId, String socRolloverResultItemTypeKey, SocRolloverResultItemInfo socRolloverResultItemInfo, ContextInfo context) |
| 505 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 506 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 507 | |
|
| 508 | 0 | if (!socRolloverResultItemTypeKey.equals(socRolloverResultItemInfo.getTypeKey())) { |
| 509 | 0 | throw new InvalidParameterException("The type parameter does not match the type on the info object"); |
| 510 | |
} |
| 511 | |
|
| 512 | 0 | SocRolloverResultItemInfo copy = new SocRolloverResultItemInfo(socRolloverResultItemInfo); |
| 513 | 0 | if (copy.getId() == null) { |
| 514 | 0 | copy.setId(socRolloverResultItemMap.size() + ""); |
| 515 | |
} |
| 516 | 0 | copy.setMeta(newMeta(context)); |
| 517 | 0 | socRolloverResultItemMap.put(copy.getId(), copy); |
| 518 | 0 | return new SocRolloverResultItemInfo(copy); |
| 519 | |
} |
| 520 | |
|
| 521 | |
@Override |
| 522 | |
public Integer createSocRolloverResultItems(String socRolloverResultId, String typeKey, |
| 523 | |
List<SocRolloverResultItemInfo> infos, ContextInfo context) |
| 524 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
| 525 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
| 526 | 0 | int count = 0; |
| 527 | 0 | for (SocRolloverResultItemInfo info : infos) { |
| 528 | 0 | count++; |
| 529 | 0 | this.createSocRolloverResultItem(socRolloverResultId, typeKey, info, context); |
| 530 | |
} |
| 531 | 0 | return new Integer(count); |
| 532 | |
} |
| 533 | |
|
| 534 | |
@Override |
| 535 | |
public SocRolloverResultItemInfo updateSocRolloverResultItem(String socRolloverResultItemId, SocRolloverResultItemInfo socRolloverResultItemInfo, ContextInfo context) |
| 536 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
| 537 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
| 538 | |
|
| 539 | 0 | if (!socRolloverResultItemId.equals(socRolloverResultItemInfo.getId())) { |
| 540 | 0 | throw new InvalidParameterException("The id parameter does not match the id on the info object"); |
| 541 | |
} |
| 542 | 0 | SocRolloverResultItemInfo copy = new SocRolloverResultItemInfo(socRolloverResultItemInfo); |
| 543 | 0 | SocRolloverResultItemInfo old = this.getSocRolloverResultItem(socRolloverResultItemInfo.getId(), context); |
| 544 | 0 | if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) { |
| 545 | 0 | throw new VersionMismatchException(old.getMeta().getVersionInd()); |
| 546 | |
} |
| 547 | 0 | copy.setMeta(updateMeta(copy.getMeta(), context)); |
| 548 | 0 | this.socRolloverResultItemMap.put(socRolloverResultItemInfo.getId(), copy); |
| 549 | 0 | return new SocRolloverResultItemInfo(copy); |
| 550 | |
} |
| 551 | |
|
| 552 | |
@Override |
| 553 | |
public StatusInfo deleteSocRolloverResultItem(String socRolloverResultItemId, ContextInfo context) |
| 554 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, |
| 555 | |
PermissionDeniedException { |
| 556 | 0 | if (this.socRolloverResultItemMap.remove(socRolloverResultItemId) == null) { |
| 557 | 0 | throw new DoesNotExistException(socRolloverResultItemId); |
| 558 | |
} |
| 559 | 0 | return newStatus(); |
| 560 | |
} |
| 561 | |
|
| 562 | |
@Override |
| 563 | |
public List<ValidationResultInfo> validateSocRolloverResultItem(String validationType, SocRolloverResultItemInfo socRolloverResultItemInfo, ContextInfo context) |
| 564 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 565 | |
|
| 566 | 0 | return new ArrayList<ValidationResultInfo>(); |
| 567 | |
} |
| 568 | |
|
| 569 | |
@Override |
| 570 | |
public List<String> searchForSocRolloverResultIds(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "context") ContextInfo context) throws |
| 571 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 572 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 573 | |
} |
| 574 | |
|
| 575 | |
@Override |
| 576 | |
public List<SocRolloverResultInfo> searchForSocRolloverResults(@WebParam(name = "criteria") QueryByCriteria criteria, @WebParam(name = "context") ContextInfo context) throws |
| 577 | |
InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
| 578 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 579 | |
} |
| 580 | |
|
| 581 | |
private MetaInfo newMeta(ContextInfo context) { |
| 582 | 0 | MetaInfo meta = new MetaInfo(); |
| 583 | 0 | meta.setCreateId(context.getPrincipalId()); |
| 584 | 0 | meta.setCreateTime(new Date()); |
| 585 | 0 | meta.setUpdateId(context.getPrincipalId()); |
| 586 | 0 | meta.setUpdateTime(meta.getCreateTime()); |
| 587 | 0 | meta.setVersionInd("0"); |
| 588 | 0 | return meta; |
| 589 | |
} |
| 590 | |
|
| 591 | |
private StatusInfo newStatus() { |
| 592 | 0 | StatusInfo status = new StatusInfo(); |
| 593 | 0 | status.setSuccess(Boolean.TRUE); |
| 594 | 0 | return status; |
| 595 | |
} |
| 596 | |
|
| 597 | |
private MetaInfo updateMeta(MetaInfo old, ContextInfo context) { |
| 598 | 0 | MetaInfo meta = new MetaInfo(old); |
| 599 | 0 | meta.setUpdateId(context.getPrincipalId()); |
| 600 | 0 | meta.setUpdateTime(new Date()); |
| 601 | 0 | meta.setVersionInd((Integer.parseInt(meta.getVersionInd()) + 1) + ""); |
| 602 | 0 | return meta; |
| 603 | |
} |
| 604 | |
} |