@Override
 public Thumbnail getThumbnails() {
   Thumbnail questionThumbnail = super.getThumbnails();
   if (getAssets() != null) {
     if (questionThumbnail == null) {
       questionThumbnail = new Thumbnail();
     }
     for (AssessmentQuestionAssetAssoc assests : getAssets()) {
       if (assests != null
               && assests.getAsset() != null
               && BaseUtil.getYoutubeVideoId(assests.getAsset().getName()) != null
           || assests.getAsset().getName().contains("http://www.youtube.com")) {
         questionThumbnail.setUrl(
             "img.youtube.com/vi/"
                 + BaseUtil.getYoutubeVideoId(assests.getAsset().getUrl())
                 + "/1.jpg");
       } else {
         questionThumbnail.setUrl(
             getAssetURI()
                 + getFolder()
                 + (assests == null || assests.getAsset() == null
                     ? null
                     : assests.getAsset().getName()));
       }
       break;
     }
   }
   return questionThumbnail;
 }
Ejemplo n.º 2
0
  @Override
  @Transactional(readOnly = true, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
  public Map<String, Object> getInvites(String gooruOid, String status, int limit, int offset) {
    StringBuilder key = new StringBuilder(INVITE_USER_STATUS_KEY).append(status);
    List<Map<String, Object>> resultSet =
        getInviteRepository().getInvitee(gooruOid, key.toString(), limit, offset);
    Map<String, Object> searchResults = new HashMap<String, Object>();
    List<Map<String, Object>> users = new ArrayList<Map<String, Object>>();
    int count = 0;
    if (resultSet != null && resultSet.size() > 0) {
      for (Map<String, Object> result : resultSet) {
        Object gooruUid = result.get(GOORU_UID);
        if (gooruUid != null) {
          result.put(
              PROFILE_IMG_URL,
              BaseUtil.changeHttpsProtocolByHeader(
                      settingService.getConfigSetting(
                          ConfigConstants.PROFILE_IMAGE_URL, TaxonomyUtil.GOORU_ORG_UID))
                  + "/"
                  + String.valueOf(gooruUid)
                  + ".png");
        }
        users.add(result);
      }
      count = getInviteRepository().getInviteeCount(gooruOid, key.toString());
    }

    searchResults.put(TOTAL_HIT_COUNT, count);
    searchResults.put(SEARCH_RESULT, users);
    return searchResults;
  }
  @Override
  public ActionResponseDTO<CollectionItem> createClasspageItem(
      String assignmentGooruOid,
      String classpageGooruOid,
      CollectionItem collectionItem,
      User user,
      String type)
      throws Exception {
    Classpage classpage = null;
    if (type != null && type.equalsIgnoreCase(CollectionType.USER_CLASSPAGE.getCollectionType())) {
      if (classpageGooruOid != null) {
        classpage = this.getClasspage(classpageGooruOid, null, null);
      } else {
        classpage =
            this.getCollectionRepository()
                .getUserShelfByClasspageGooruUid(
                    user.getGooruUId(), CollectionType.USER_CLASSPAGE.getCollectionType());
      }
      if (classpage == null) {
        classpage = new Classpage();
        classpage.setTitle(MY_CLASSPAGE);
        classpage.setCollectionType(CollectionType.USER_CLASSPAGE.getCollectionType());
        classpage.setClasspageCode(BaseUtil.base48Encode(7));
        classpage.setGooruOid(UUID.randomUUID().toString());
        ContentType contentType =
            (ContentType)
                this.getCollectionRepository().get(ContentType.class, ContentType.RESOURCE);
        classpage.setContentType(contentType);
        ResourceType resourceType =
            (ResourceType)
                this.getCollectionRepository()
                    .get(ResourceType.class, ResourceType.Type.CLASSPAGE.getType());
        classpage.setResourceType(resourceType);
        classpage.setLastModified(new Date(System.currentTimeMillis()));
        classpage.setCreatedOn(new Date(System.currentTimeMillis()));
        classpage.setSharing(Sharing.PRIVATE.getSharing());
        classpage.setUser(user);
        classpage.setOrganization(user.getPrimaryOrganization());
        classpage.setCreator(user);
        classpage.setDistinguish(Short.valueOf(ZERO));
        classpage.setRecordSource(NOT_ADDED);
        classpage.setIsFeatured(0);
        this.getCollectionRepository().save(classpage);
      }
      collectionItem.setItemType(ShelfType.AddedType.SUBSCRIBED.getAddedType());
    } else {
      classpage = this.getClasspage(classpageGooruOid, null, null);
      collectionItem.setItemType(ShelfType.AddedType.ADDED.getAddedType());
    }

    Collection collection =
        this.getCollectionRepository()
            .getCollectionByGooruOid(assignmentGooruOid, classpage.getUser().getGooruUId());
    Errors errors = validateClasspageItem(classpage, collection, collectionItem);
    if (collection != null) {
      if (!errors.hasErrors()) {
        collectionItem.setCollection(classpage);
        collectionItem.setResource(collection);
        int sequence =
            collectionItem.getCollection().getCollectionItems() != null
                ? collectionItem.getCollection().getCollectionItems().size() + 1
                : 1;
        collectionItem.setItemSequence(sequence);
        this.getCollectionRepository().save(collectionItem);
      }
    } else {
      throw new Exception("invalid assignmentId -" + assignmentGooruOid);
    }

    return new ActionResponseDTO<CollectionItem>(collectionItem, errors);
  }