View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may	obtain a copy of the License at
7    *
8    * 	http://www.osedu.org/licenses/ECL-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.r2.lum.lrc.service.impl;
17  
18  import org.kuali.rice.core.api.criteria.QueryByCriteria;
19  import org.kuali.student.common.mock.MockService;
20  import org.kuali.student.common.util.UUIDHelper;
21  import org.kuali.student.r2.common.dto.ContextInfo;
22  import org.kuali.student.r2.common.dto.MetaInfo;
23  import org.kuali.student.r2.common.dto.StatusInfo;
24  import org.kuali.student.r2.common.dto.ValidationResultInfo;
25  import org.kuali.student.r2.common.exceptions.*;
26  import org.kuali.student.r2.core.search.dto.SearchRequestInfo;
27  import org.kuali.student.r2.core.search.dto.SearchResultInfo;
28  import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
29  import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
30  import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
31  import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
32  import org.kuali.student.r2.lum.lrc.service.LRCService;
33  import org.kuali.student.r2.lum.lrc.service.LrcServiceBusinessLogic;
34  
35  import javax.jws.WebParam;
36  import java.util.*;
37  
38  public class LrcServiceMockImpl implements LRCService, MockService {
39  
40      private LrcServiceBusinessLogic lrcServiceBusinessLogic;
41  
42      public LrcServiceBusinessLogic getLrcServiceBusinessLogic() {
43          return lrcServiceBusinessLogic;
44      }
45  
46      public void setLrcServiceBusinessLogic(LrcServiceBusinessLogic lrcServiceBusinessLogic) {
47          this.lrcServiceBusinessLogic = lrcServiceBusinessLogic;
48          if (this.lrcServiceBusinessLogic instanceof LrcServiceBusinessLogic) {
49              LrcServiceBusinessLogicImpl impl = (LrcServiceBusinessLogicImpl) lrcServiceBusinessLogic;
50              impl.setLrcService(this);
51          }
52      }
53  
54      @Override
55      public void clear() {
56          this.resultScaleMap.clear();
57          this.resultValueMap.clear();
58          this.resultValuesGroupMap.clear();
59      }
60      
61  
62      @Override
63      public ResultValuesGroupInfo getResultValuesGroup(String resultValuesGroupKey,
64              ContextInfo context)
65              throws DoesNotExistException,
66              InvalidParameterException,
67              MissingParameterException,
68              OperationFailedException,
69              PermissionDeniedException {
70          if (!this.resultValuesGroupMap.containsKey(resultValuesGroupKey)) {
71              throw new DoesNotExistException(resultValuesGroupKey);
72          }
73          ResultValuesGroupInfo rvg = this.resultValuesGroupMap.get(resultValuesGroupKey);
74          return rvg;
75      }
76  //
77  //    private void loadResultValuesWithRange(ResultValuesGroupInfo rvg,
78  //            ContextInfo contextInfo)
79  //            throws OperationFailedException {
80  //        if (!rvg.getTypeKey().equals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE)) {
81  //            return;
82  //        }
83  //        rvg.getResultValueKeys().clear();
84  //        List<ResultValueInfo> values;
85  //        try {
86  //            values = this.getResultValuesForScale(rvg.getResultScaleKey(), contextInfo);
87  //        } catch (DoesNotExistException ex) {
88  //            throw new OperationFailedException("unexpected", ex);
89  //        } catch (InvalidParameterException ex) {
90  //            throw new OperationFailedException("unexpected", ex);
91  //        } catch (MissingParameterException ex) {
92  //            throw new OperationFailedException("unexpected", ex);
93  //        } catch (OperationFailedException ex) {
94  //            throw new OperationFailedException("unexpected", ex);
95  //        } catch (PermissionDeniedException ex) {
96  //            throw new OperationFailedException("unexpected", ex);
97  //        }
98  //        for (ResultValueInfo rv : values) {
99  //            if (isWithinRange(rv, rvg)) {
100 //                rvg.getResultValueKeys().add(rv.getKey());
101 //            }
102 //        }
103 //    }
104 //
105 //    private boolean isWithinRange(ResultValueInfo rv,
106 //            ResultValuesGroupInfo rvg) {
107 //        float numericValue = Float.parseFloat(rv.getNumericValue());
108 //        float minValue = Float.parseFloat(rvg.getResultValueRange().getMinValue());
109 //        if (numericValue < minValue) {
110 //            return false;
111 //        }
112 //
113 //        float maxValue = Float.parseFloat(rvg.getResultValueRange().getMaxValue());
114 //        if (numericValue > maxValue) {
115 //            return false;
116 //        }
117 //        float increment = Float.parseFloat(rvg.getResultValueRange().getIncrement());
118 //        float diff = numericValue - minValue;
119 //        float remainder = diff % increment;
120 //        if (remainder != 0) {
121 //            return false;
122 //        }
123 //        return true;
124 //    }
125 
126     @Override
127     public List<ResultValuesGroupInfo> getResultValuesGroupsByKeys(List<String> resultValuesGroupKeys,
128             ContextInfo context)
129             throws DoesNotExistException,
130             InvalidParameterException,
131             MissingParameterException,
132             OperationFailedException,
133             PermissionDeniedException {
134         List<ResultValuesGroupInfo> list = new ArrayList<ResultValuesGroupInfo>();
135         for (String id : resultValuesGroupKeys) {
136             list.add(this.getResultValuesGroup(id, context));
137         }
138         return list;
139     }
140 
141     @Override
142     public List<ResultValuesGroupInfo> getResultValuesGroupsByResultValue(String resultValueKey,
143             ContextInfo context)
144             throws DoesNotExistException,
145             InvalidParameterException,
146             MissingParameterException,
147             OperationFailedException,
148             PermissionDeniedException {
149         List<ResultValuesGroupInfo> list = new ArrayList<ResultValuesGroupInfo>();
150         for (ResultValuesGroupInfo info : resultValuesGroupMap.values()) {
151             if (info.getResultValueKeys().contains(resultValueKey)) {
152                 list.add(info);
153             }
154         }
155         return list;
156     }
157 
158     @Override
159     public List<ResultValuesGroupInfo> getResultValuesGroupsByResultScale(String resultScaleKey,
160             ContextInfo context)
161             throws DoesNotExistException,
162             InvalidParameterException,
163             MissingParameterException,
164             OperationFailedException,
165             PermissionDeniedException {
166         List<ResultValuesGroupInfo> list = new ArrayList<ResultValuesGroupInfo>();
167         for (ResultValuesGroupInfo info : resultValuesGroupMap.values()) {
168             if (info.getResultScaleKey().contains(resultScaleKey)) {
169                 list.add(info);
170             }
171         }
172         return list;
173     }
174 
175     @Override
176     public List<String> getResultValuesGroupKeysByType(String resultValuesGroupTypeKey,
177             ContextInfo context)
178             throws DoesNotExistException,
179             InvalidParameterException,
180             MissingParameterException,
181             OperationFailedException,
182             PermissionDeniedException {
183         List<String> list = new ArrayList<String>();
184         for (ResultValuesGroupInfo info : resultValuesGroupMap.values()) {
185             if (resultValuesGroupTypeKey.equals(info.getTypeKey())) {
186                 list.add(info.getKey());
187             }
188         }
189         return list;
190     }
191     // cache variable 
192     // The LinkedHashMap is just so the values come back in a predictable order
193     private Map<String, ResultValuesGroupInfo> resultValuesGroupMap = new LinkedHashMap<String, ResultValuesGroupInfo>();
194 
195     @Override
196     public ResultValuesGroupInfo createResultValuesGroup(String resultScaleKey,
197             String resultValuesGroupTypeKey,
198             ResultValuesGroupInfo resultValuesGroupInfo,
199             ContextInfo context)
200             throws AlreadyExistsException,
201             DataValidationErrorException,
202             InvalidParameterException,
203             MissingParameterException,
204             OperationFailedException,
205             PermissionDeniedException {
206         if (resultValuesGroupMap.containsKey(resultValuesGroupInfo.getKey())) {
207             throw new AlreadyExistsException(resultValuesGroupInfo.getKey());
208         }
209         // create 
210         ResultValuesGroupInfo copy = new ResultValuesGroupInfo(resultValuesGroupInfo);
211         copy.setResultScaleKey(resultScaleKey);
212         copy.setTypeKey(resultValuesGroupTypeKey);
213         if (copy.getKey() == null) {
214             copy.setKey(UUIDHelper.genStringUUID());
215         }
216         copy.setMeta(newMeta(context));
217         resultValuesGroupMap.put(copy.getKey(), copy);
218         ResultValuesGroupInfo rvgNew = new ResultValuesGroupInfo(copy);
219         return rvgNew;
220     }
221 
222     @Override
223     public ResultValuesGroupInfo updateResultValuesGroup(String resultValuesGroupKey,
224             ResultValuesGroupInfo gradeValuesGroupInfo,
225             ContextInfo context)
226             throws DataValidationErrorException,
227             DoesNotExistException,
228             InvalidParameterException,
229             MissingParameterException,
230             OperationFailedException,
231             PermissionDeniedException,
232             VersionMismatchException {
233         // update
234         if (!resultValuesGroupKey.equals(gradeValuesGroupInfo.getKey())) {
235             throw new InvalidParameterException("The id parameter does not match the id on the info object");
236         }
237         ResultValuesGroupInfo copy = new ResultValuesGroupInfo(gradeValuesGroupInfo);
238         ResultValuesGroupInfo old = this.getResultValuesGroup(gradeValuesGroupInfo.getKey(), context);
239         if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) {
240             throw new VersionMismatchException(old.getMeta().getVersionInd());
241         }
242         copy.setMeta(updateMeta(copy.getMeta(), context));
243         this.resultValuesGroupMap.put(gradeValuesGroupInfo.getKey(), copy);
244         ResultValuesGroupInfo rvgNew = new ResultValuesGroupInfo(copy);
245         return rvgNew;
246     }
247 
248     @Override
249     public StatusInfo deleteResultValuesGroup(String resultValuesGroupKey,
250             ContextInfo context)
251             throws DoesNotExistException,
252             InvalidParameterException,
253             MissingParameterException,
254             OperationFailedException,
255             PermissionDeniedException {
256         if (this.resultValuesGroupMap.remove(resultValuesGroupKey) == null) {
257             throw new DoesNotExistException(resultValuesGroupKey);
258         }
259         return newStatus();
260     }
261 
262     @Override
263     public List<ValidationResultInfo> validateResultValuesGroup(String validationType,
264             ResultValuesGroupInfo gradeValuesGroupInfo,
265             ContextInfo context)
266             throws DoesNotExistException,
267             InvalidParameterException,
268             MissingParameterException,
269             OperationFailedException {
270         // validate
271         return new ArrayList<ValidationResultInfo>();
272     }
273 
274     @Override
275     public ResultValuesGroupInfo getCreateFixedCreditResultValuesGroup(String creditValue,
276             String scaleKey,
277             ContextInfo context)
278             throws InvalidParameterException,
279             MissingParameterException,
280             OperationFailedException,
281             PermissionDeniedException {
282         return this.lrcServiceBusinessLogic.getCreateFixedCreditResultValuesGroup(creditValue, scaleKey, context);
283     }
284 
285     @Override
286     public ResultValuesGroupInfo getCreateRangeCreditResultValuesGroup(String creditValueMin,
287             String creditValueMax,
288             String creditValueIncrement,
289             String scaleKey,
290             ContextInfo context)
291             throws InvalidParameterException,
292             MissingParameterException,
293             OperationFailedException,
294             PermissionDeniedException {
295         ResultValuesGroupInfo rvg = this.lrcServiceBusinessLogic.getCreateRangeCreditResultValuesGroup(creditValueMin,
296                 creditValueMax,
297                 creditValueIncrement, scaleKey, context);
298         return rvg;
299 
300     }
301 
302     @Override
303     public ResultValuesGroupInfo getCreateMultipleCreditResultValuesGroup(List<String> creditValues,
304             String scaleKey,
305             ContextInfo context)
306             throws InvalidParameterException,
307             MissingParameterException,
308             OperationFailedException,
309             PermissionDeniedException {
310         return this.lrcServiceBusinessLogic.getCreateMultipleCreditResultValuesGroup(creditValues, scaleKey, context);
311     }
312 
313     @Override
314     public ResultValueInfo getResultValue(String resultValueKey,
315             ContextInfo context)
316             throws DoesNotExistException,
317             InvalidParameterException,
318             MissingParameterException,
319             OperationFailedException,
320             PermissionDeniedException {
321         if (!this.resultValueMap.containsKey(resultValueKey)) {
322             throw new DoesNotExistException(resultValueKey);
323         }
324         return this.resultValueMap.get(resultValueKey);
325     }
326 
327     @Override
328     public List<ResultValueInfo> getResultValuesByKeys(List<String> resultValueKeys,
329             ContextInfo context)
330             throws DoesNotExistException,
331             InvalidParameterException,
332             MissingParameterException,
333             OperationFailedException,
334             PermissionDeniedException {
335         List<ResultValueInfo> list = new ArrayList<ResultValueInfo>();
336         for (String id : resultValueKeys) {
337             list.add(this.getResultValue(id, context));
338         }
339         return list;
340     }
341 
342     @Override
343     public List<String> getResultValueKeysByType(String resultValueTypeKey,
344             ContextInfo context)
345             throws DoesNotExistException,
346             InvalidParameterException,
347             MissingParameterException,
348             OperationFailedException,
349             PermissionDeniedException {
350         List<String> list = new ArrayList<String>();
351         for (ResultValueInfo info : resultValueMap.values()) {
352             if (resultValueTypeKey.equals(info.getTypeKey())) {
353                 list.add(info.getKey());
354             }
355         }
356         return list;
357     }
358 
359     @Override
360     public List<ResultValueInfo> getResultValuesForResultValuesGroup(String resultValuesGroupKey,
361             ContextInfo contextInfo)
362             throws DoesNotExistException,
363             InvalidParameterException,
364             MissingParameterException,
365             OperationFailedException,
366             PermissionDeniedException {
367         ResultValuesGroupInfo info = this.getResultValuesGroup(resultValuesGroupKey, contextInfo);
368         return this.getResultValuesByKeys(info.getResultValueKeys(), contextInfo);
369     }
370     // cache variable 
371     // The LinkedHashMap is just so the values come back in a predictable order
372     private Map<String, ResultValueInfo> resultValueMap = new LinkedHashMap<String, ResultValueInfo>();
373 
374     @Override
375     public ResultValueInfo createResultValue(String resultScaleKey,
376             String resultValueTypeKey,
377             ResultValueInfo resultValueInfo,
378             ContextInfo context)
379             throws AlreadyExistsException,
380             DataValidationErrorException,
381             DoesNotExistException,
382             InvalidParameterException,
383             MissingParameterException,
384             OperationFailedException,
385             PermissionDeniedException {
386         if (resultValueMap.containsKey(resultValueInfo.getKey())) {
387             throw new AlreadyExistsException(resultValueInfo.getKey());
388         }
389         // create 
390         ResultValueInfo copy = new ResultValueInfo(resultValueInfo);
391         copy.setResultScaleKey(resultScaleKey);
392         copy.setTypeKey(resultValueTypeKey);
393         if (copy.getKey() == null) {
394             copy.setKey(UUIDHelper.genStringUUID());
395         }
396         copy.setMeta(newMeta(context));
397         resultValueMap.put(copy.getKey(), copy);
398         return new ResultValueInfo(copy);
399     }
400 
401     @Override
402     public ResultValueInfo updateResultValue(String resultValueKey,
403             ResultValueInfo resultValueInfo,
404             ContextInfo context)
405             throws DataValidationErrorException,
406             DoesNotExistException,
407             InvalidParameterException,
408             MissingParameterException,
409             OperationFailedException,
410             PermissionDeniedException,
411             VersionMismatchException {
412         // update
413         if (!resultValueKey.equals(resultValueInfo.getKey())) {
414             throw new InvalidParameterException("The id parameter does not match the id on the info object");
415         }
416         ResultValueInfo copy = new ResultValueInfo(resultValueInfo);
417         ResultValueInfo old = this.getResultValue(resultValueInfo.getKey(), context);
418         if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) {
419             throw new VersionMismatchException(old.getMeta().getVersionInd());
420         }
421         copy.setMeta(updateMeta(copy.getMeta(), context));
422         this.resultValueMap.put(resultValueInfo.getKey(), copy);
423         return new ResultValueInfo(copy);
424     }
425 
426     @Override
427     public StatusInfo deleteResultValue(String resultValueKey,
428             ContextInfo context)
429             throws DoesNotExistException,
430             DependentObjectsExistException,
431             InvalidParameterException,
432             MissingParameterException,
433             OperationFailedException,
434             PermissionDeniedException {
435         List<ResultValuesGroupInfo> list = this.getResultValuesGroupsByResultValue(resultValueKey, context);
436         if (!list.isEmpty()) {
437             throw new DependentObjectsExistException(list.size() + " rvgs exist");
438         }
439         if (this.resultValueMap.remove(resultValueKey) == null) {
440             throw new DoesNotExistException(resultValueKey);
441         }
442         return newStatus();
443     }
444 
445     @Override
446     public List<ValidationResultInfo> validateResultValue(String validationType,
447             ResultValueInfo resultValueInfo,
448             ContextInfo context)
449             throws DoesNotExistException,
450             InvalidParameterException,
451             MissingParameterException,
452             OperationFailedException {
453         // validate
454         return new ArrayList<ValidationResultInfo>();
455     }
456 
457     @Override
458     public ResultValueInfo getCreateResultValueForScale(String resultValue,
459             String scaleKey,
460             ContextInfo context)
461             throws InvalidParameterException,
462             MissingParameterException,
463             OperationFailedException,
464             PermissionDeniedException {
465         return this.lrcServiceBusinessLogic.getCreateResultValueForScale(resultValue, scaleKey, context);
466     }
467 
468     @Override
469     public List<ResultValuesGroupInfo> getResultValuesGroupsByResultScaleType(String resultScaleTypeKey,
470             ContextInfo context)
471             throws DoesNotExistException,
472             InvalidParameterException,
473             MissingParameterException,
474             OperationFailedException,
475             PermissionDeniedException {
476         List<ResultValuesGroupInfo> list = new ArrayList<ResultValuesGroupInfo>();
477         List<String> scaleKeys = this.getResultScaleKeysByType(resultScaleTypeKey, context);
478         for (String scaleKey : scaleKeys) {
479             list.addAll(this.getResultValuesGroupsByResultScale(scaleKey, context));
480         }
481         return list;
482     }
483 
484     @Override
485     public ResultScaleInfo getResultScale(String resultScaleKey,
486             ContextInfo context)
487             throws DoesNotExistException,
488             InvalidParameterException,
489             MissingParameterException,
490             OperationFailedException,
491             PermissionDeniedException {
492         if (!this.resultScaleMap.containsKey(resultScaleKey)) {
493             throw new DoesNotExistException(resultScaleKey);
494         }
495         return this.resultScaleMap.get(resultScaleKey);
496     }
497 
498     @Override
499     public List<ResultScaleInfo> getResultScalesByKeys(List<String> resultScaleKeys,
500             ContextInfo context)
501             throws DoesNotExistException,
502             InvalidParameterException,
503             MissingParameterException,
504             OperationFailedException,
505             PermissionDeniedException {
506         List<ResultScaleInfo> list = new ArrayList<ResultScaleInfo>();
507         for (String id : resultScaleKeys) {
508             list.add(this.getResultScale(id, context));
509         }
510         return list;
511     }
512 
513     @Override
514     public List<String> getResultScaleKeysByType(String resultScaleTypeKey,
515             ContextInfo context)
516             throws DoesNotExistException,
517             InvalidParameterException,
518             MissingParameterException,
519             OperationFailedException,
520             PermissionDeniedException {
521         List<String> list = new ArrayList<String>();
522         for (ResultScaleInfo info : resultScaleMap.values()) {
523             if (resultScaleTypeKey.equals(info.getTypeKey())) {
524                 list.add(info.getKey());
525             }
526         }
527         return list;
528     }
529     // cache variable 
530     // The LinkedHashMap is just so the values come back in a predictable order
531     private Map<String, ResultScaleInfo> resultScaleMap = new LinkedHashMap<String, ResultScaleInfo>();
532 
533     @Override
534     public ResultScaleInfo createResultScale(String resultScaleTypeKey,
535             ResultScaleInfo resultScaleInfo,
536             ContextInfo context)
537             throws AlreadyExistsException,
538             DataValidationErrorException,
539             InvalidParameterException,
540             MissingParameterException,
541             OperationFailedException,
542             PermissionDeniedException {
543         if (resultScaleMap.containsKey(resultScaleInfo.getKey())) {
544             throw new AlreadyExistsException(resultScaleInfo.getKey());
545         }
546         // create 
547         ResultScaleInfo copy = new ResultScaleInfo(resultScaleInfo);
548         copy.setTypeKey(resultScaleTypeKey);
549         if (copy.getKey() == null) {
550             copy.setKey(UUIDHelper.genStringUUID());
551         }
552         copy.setMeta(newMeta(context));
553         resultScaleMap.put(copy.getKey(), copy);
554         return new ResultScaleInfo(copy);
555     }
556 
557     @Override
558     public ResultScaleInfo updateResultScale(String resultScaleKey,
559             ResultScaleInfo gradeScaleInfo,
560             ContextInfo context)
561             throws DataValidationErrorException,
562             DoesNotExistException,
563             InvalidParameterException,
564             MissingParameterException,
565             OperationFailedException,
566             PermissionDeniedException,
567             VersionMismatchException {
568         // update
569         if (!resultScaleKey.equals(gradeScaleInfo.getKey())) {
570             throw new InvalidParameterException("The id parameter does not match the id on the info object");
571         }
572         ResultScaleInfo copy = new ResultScaleInfo(gradeScaleInfo);
573         ResultScaleInfo old = this.getResultScale(gradeScaleInfo.getKey(), context);
574         if (!old.getMeta().getVersionInd().equals(copy.getMeta().getVersionInd())) {
575             throw new VersionMismatchException(old.getMeta().getVersionInd());
576         }
577         copy.setMeta(updateMeta(copy.getMeta(), context));
578         this.resultScaleMap.put(gradeScaleInfo.getKey(), copy);
579         return new ResultScaleInfo(copy);
580     }
581 
582     @Override
583     public StatusInfo deleteResultScale(String resultScaleKey,
584             ContextInfo context)
585             throws DoesNotExistException,
586             DependentObjectsExistException,
587             InvalidParameterException,
588             MissingParameterException,
589             OperationFailedException,
590             PermissionDeniedException {
591         List<ResultValueInfo> values = this.getResultValuesForScale(resultScaleKey, context);
592         if (!values.isEmpty()) {
593             throw new DependentObjectsExistException(values.size() + " ResultValue(s) exist");
594         }
595         List<ResultValuesGroupInfo> groups = this.getResultValuesGroupsByResultScale(resultScaleKey, context);
596         if (!groups.isEmpty()) {
597             throw new DependentObjectsExistException(groups.size() + " ResultValuesGroup(s) exist");
598         }
599         if (this.resultScaleMap.remove(resultScaleKey) == null) {
600             throw new DoesNotExistException(resultScaleKey);
601         }
602         return newStatus();
603     }
604 
605     @Override
606     public List<ValidationResultInfo> validateResultScale(String validationType,
607             ResultScaleInfo gradeScaleInfo,
608             ContextInfo context)
609             throws DoesNotExistException,
610             InvalidParameterException,
611             MissingParameterException,
612             OperationFailedException {
613         // validate
614         return new ArrayList<ValidationResultInfo>();
615     }
616 
617     @Override
618     public List<ResultValueInfo> getResultValuesForScale(String resultScaleKey,
619             ContextInfo context)
620             throws DoesNotExistException,
621             InvalidParameterException,
622             MissingParameterException,
623             OperationFailedException,
624             PermissionDeniedException {
625         List<ResultValueInfo> list = new ArrayList<ResultValueInfo>();
626         for (ResultValueInfo info : this.resultValueMap.values()) {
627             if (info.getResultScaleKey().equals(resultScaleKey)) {
628                 list.add(info);
629             }
630         }
631         return list;
632     }
633 
634     @Override
635     public ResultValueInfo getResultValueForScaleAndValue(String resultScaleKey,
636             String value,
637             ContextInfo contextInfo)
638             throws DoesNotExistException,
639             InvalidParameterException,
640             MissingParameterException,
641             OperationFailedException,
642             PermissionDeniedException {
643         List<ResultValueInfo> list = new ArrayList<ResultValueInfo>();
644         for (ResultValueInfo info : this.resultValueMap.values()) {
645             if (info.getResultScaleKey().equals(resultScaleKey)) {
646                 if (info.getValue().equals(value)) {
647                     list.add(info);
648                 }
649             }
650         }
651         if (list.isEmpty()) {
652             throw new DoesNotExistException(resultScaleKey + " " + value);
653         }
654         if (list.size() > 1) {
655             throw new OperationFailedException("too many matches " + list.size());
656         }
657         return list.get(0);
658     }
659 
660     @Override
661     public List<ResultValueInfo> getResultValuesForResultValuesGroups(List<String> resultValuesGroupKeys,
662             ContextInfo context)
663             throws DoesNotExistException,
664             InvalidParameterException,
665             MissingParameterException,
666             OperationFailedException,
667             PermissionDeniedException {
668         List<ResultValueInfo> list = new ArrayList<ResultValueInfo>();
669         Set<String> keys = new HashSet<String>();
670         for (String rvgKey : resultValuesGroupKeys) {
671             ResultValuesGroupInfo rvg = this.getResultValuesGroup(rvgKey, context);
672             for (String rvKey : rvg.getResultValueKeys()) {
673                 if (keys.add(rvKey)) {
674                     list.add(this.getResultValue(rvKey, context));
675                 }
676             }
677         }
678         return list;
679     }
680 
681     private StatusInfo newStatus() {
682         StatusInfo status = new StatusInfo();
683         status.setSuccess(Boolean.TRUE);
684         return status;
685     }
686 
687     private MetaInfo newMeta(ContextInfo context) {
688         MetaInfo meta = new MetaInfo();
689         meta.setCreateId(context.getPrincipalId());
690         meta.setCreateTime(new Date());
691         meta.setUpdateId(context.getPrincipalId());
692         meta.setUpdateTime(meta.getCreateTime());
693         meta.setVersionInd("0");
694         return meta;
695     }
696 
697     private MetaInfo updateMeta(MetaInfo old,
698             ContextInfo context) {
699         MetaInfo meta = new MetaInfo(old);
700         meta.setUpdateId(context.getPrincipalId());
701         meta.setUpdateTime(new Date());
702         meta.setVersionInd((Integer.parseInt(meta.getVersionInd()) + 1) + "");
703         return meta;
704     }
705 
706     @Override
707     public List<String> searchForResultScaleIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
708         throw new UnsupportedOperationException("Not supported yet.");
709     }
710 
711     @Override
712     public List<ResultScaleInfo> searchForResultScales(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
713         throw new UnsupportedOperationException("Not supported yet.");
714     }
715 
716     @Override
717     public List<String> searchForResultValueIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
718         throw new UnsupportedOperationException("Not supported yet.");
719     }
720 
721     @Override
722     public List<ResultValueInfo> searchForResultValues(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
723         throw new UnsupportedOperationException("Not supported yet.");
724     }
725 
726     @Override
727     public List<String> searchForResultValuesGroupIds(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
728         throw new UnsupportedOperationException("Not supported yet.");
729     }
730 
731     @Override
732     public List<ResultValuesGroupInfo> searchForResultValuesGroups(QueryByCriteria criteria, ContextInfo context) throws InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
733         throw new UnsupportedOperationException("Not supported yet.");
734     }
735 
736 
737     @Override
738     public List<TypeInfo> getSearchTypes( ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException {
739         throw new UnsupportedOperationException("Not supported yet.");
740     }
741 
742     @Override
743     public TypeInfo getSearchType(String searchTypeKey,  ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {
744         throw new UnsupportedOperationException("Not supported yet.");
745     }
746 
747     @Override
748     public SearchResultInfo search(SearchRequestInfo searchRequestInfo,  ContextInfo contextInfo) throws MissingParameterException, OperationFailedException, PermissionDeniedException {
749         throw new UnsupportedOperationException("Not supported yet.");
750     }
751 }