예제 #1
0
 public void updateCollaborators(
     Resource resource,
     List<String> collaboratorsList,
     User apiCaller,
     String predicate,
     Set<Segment> collectionSegments,
     Set<AssessmentSegment> quizSegments) {
   if (collaboratorsList != null && collaboratorsList.size() > 0 && !collaboratorsList.isEmpty()) {
     List<User> userList = this.getUserRepository().findByIdentities(collaboratorsList);
     updateCollaborators(resource, userList, apiCaller, predicate, true);
     if (collectionSegments != null && collectionSegments.size() > 0) {
       for (Segment segment : collectionSegments) {
         for (ResourceInstance resourceInstance : segment.getResourceInstances()) {
           if (resourceInstance != null) {
             updateCollaborators(
                 resourceInstance.getResource(), userList, apiCaller, predicate, false);
           }
         }
       }
     } else if (quizSegments != null && quizSegments.size() > 0) {
       for (AssessmentSegment quizSegment : quizSegments) {
         for (AssessmentSegmentQuestionAssoc quizSegmentQuestionAssoc :
             quizSegment.getSegmentQuestions()) {
           if (quizSegmentQuestionAssoc != null) {
             updateCollaborators(
                 quizSegmentQuestionAssoc.getQuestion(), userList, apiCaller, predicate, false);
           }
         }
       }
     }
   }
 }
 public static Segment getCollectionSegment(Learnguide collection, String segmentId) {
   for (Segment segment : collection.getResourceSegments()) {
     if (segment.getSegmentId().equals(segmentId)) {
       return segment;
     }
   }
   return null;
 }
예제 #3
0
 public Segment setSegmentImageAbsolutePath(Resource resource, Segment segment) {
   if (resource != null && segment != null && segment.getSegmentImage() != null) {
     segment.setSegmentImage(
         resource.getAssetURI()
             + resource.getFolder()
             + Constants.SEGMENT_FOLDER
             + "/"
             + segment.getSegmentImage());
   }
   return segment;
 }
 public static void resetSegmentsSequence(Resource resource) {
   if (resource == null || resource.getResourceSegments() == null) {
     return;
   }
   List<Segment> segmentsList = new ArrayList<Segment>();
   segmentsList.addAll(resource.getResourceSegments());
   Collections.sort(segmentsList, new SegmentComparator());
   int sequence = 0;
   for (Segment segment : segmentsList) {
     segment.setSequence(++sequence);
   }
   resource.getResourceSegments().clear();
   resource.getResourceSegments().addAll(segmentsList);
 }
 public static void resetInstancesSequence(Segment segment) {
   if (segment == null || segment.getResourceInstances() == null) {
     return;
   }
   List<ResourceInstance> resourceInstances = new ArrayList<ResourceInstance>();
   resourceInstances.addAll(segment.getResourceInstances());
   Collections.sort(resourceInstances, new ResourceInstanceComparator());
   int sequence = 0;
   for (ResourceInstance resourceInstance : resourceInstances) {
     resourceInstance.setSequence(++sequence);
   }
   segment.getResourceInstances().clear();
   segment.getResourceInstances().addAll(resourceInstances);
 }