コード例 #1
0
  private Map<String, Object> mergeCollectionItemMetaData(Map<String, Object> content) {
    Object data = content.get(META_DATA);
    if (data != null) {
      Map<String, Object> metaData =
          JsonDeserializer.deserialize(
              String.valueOf(data), new TypeReference<Map<String, Object>>() {});
      content.putAll(metaData);
    }
    Map<String, Object> resourceFormat = new HashMap<String, Object>();
    resourceFormat.put(VALUE, content.get(VALUE));
    resourceFormat.put(DISPLAY_NAME, content.get(DISPLAY_NAME));
    content.put(RESOURCEFORMAT, resourceFormat);
    Object ratingAverage = content.get(AVERAGE);
    String typeName = (String) content.get(RESOURCE_TYPE);
    Map<String, Object> resourceType = new HashMap<String, Object>();
    resourceType.put(NAME, typeName);
    content.put(RESOURCE_TYPE, resourceType);
    if (ratingAverage != null) {
      Map<String, Object> rating = new HashMap<String, Object>();
      rating.put(AVERAGE, content.get(AVERAGE));
      rating.put(COUNT, content.get(COUNT));
      content.put(RATING, rating);
    }

    Object thumbnail = content.get(THUMBNAIL);
    if (thumbnail != null) {
      StringBuilder imagePath = new StringBuilder();
      imagePath.append(content.get(FOLDER)).append(thumbnail);
      content.put(THUMBNAILS, GooruImageUtil.getThumbnails(imagePath.toString()));
    }
    if (typeName.equalsIgnoreCase(ResourceType.Type.ASSESSMENT_QUESTION.getType())) {
      // To-Do, need fix later, by getting answer and hints details
      // without querying the assessment object
      String gooruOid = (String) content.get(GOORU_OID);
      AssessmentQuestion assessmentQuestion = this.getQuestionService().getQuestion(gooruOid);
      if (assessmentQuestion != null && !assessmentQuestion.isQuestionNewGen()) {
        content.put(ANSWERS, assessmentQuestion.getAnswers());
        content.put(HINTS, assessmentQuestion.getHints());
      } else {
        String json = getMongoQuestionsService().getQuestionByIdWithJsonAdjustments(gooruOid);
        if (json != null) {
          content.putAll(
              JsonDeserializer.deserialize(json, new TypeReference<Map<String, Object>>() {}));
        }
      }
    }
    content.put(USER, setUser(content.get(GOORU_UID), content.get(USER_NAME)));
    content.put(ASSET_URI, ConfigProperties.getBaseRepoUrl());
    content.remove(THUMBNAIL);
    content.remove(META_DATA);
    content.remove(VALUE);
    content.remove(DISPLAY_NAME);
    content.remove(AVERAGE);
    content.remove(COUNT);
    content.remove(GOORU_UID);
    content.remove(USER_NAME);
    return content;
  }
コード例 #2
0
 @SuppressWarnings("unchecked")
 private void updateCollectionMetaDataSummary(Long collectionId, String type, String action) {
   ContentMeta lessonContentMeta = this.getContentRepository().getContentMeta(collectionId);
   if (lessonContentMeta != null) {
     Map<String, Object> metaData =
         JsonDeserializer.deserialize(
             lessonContentMeta.getMetaData(), new TypeReference<Map<String, Object>>() {});
     Map<String, Object> summary = (Map<String, Object>) metaData.get(SUMMARY);
     if (summary != null && summary.size() > 0) {
       int resourceCount = ((Number) summary.get(MetaConstants.RESOURCE_COUNT)).intValue();
       int questionCount = ((Number) summary.get(MetaConstants.QUESTION_COUNT)).intValue();
       if (type.equalsIgnoreCase(RESOURCE)) {
         summary.put(
             MetaConstants.RESOURCE_COUNT,
             action.equalsIgnoreCase(ADD) ? (resourceCount + 1) : (resourceCount - 1));
       }
       if (type.equalsIgnoreCase(QUESTION)) {
         summary.put(
             MetaConstants.QUESTION_COUNT,
             action.equalsIgnoreCase(ADD) ? (questionCount + 1) : (questionCount - 1));
       }
       metaData.put(SUMMARY, summary);
       updateContentMeta(lessonContentMeta, metaData);
     }
   }
 }
コード例 #3
0
 private Feedback buildFeedbackFromInputParameters(String data, HttpServletRequest request) {
   Feedback feedback = JsonDeserializer.deserialize(data, Feedback.class);
   CustomTableValue feedbackCategory = new CustomTableValue();
   feedbackCategory.setValue(getFeedbackCategory(request));
   feedback.setCategory(feedbackCategory);
   CustomTableValue product = new CustomTableValue();
   product.setValue(
       isMobileDevice(request)
           ? CustomProperties.Product.MOBILE.getProduct()
           : CustomProperties.Product.WEB.getProduct());
   feedback.setProduct(product);
   return feedback;
 }
コード例 #4
0
 private void updateCollectionSettings(Collection collection, Collection newCollection) {
   ContentSettings contentSettings = null;
   final Map<String, String> settings = new HashMap<String, String>();
   if (collection.getContentSettings() != null && collection.getContentSettings().size() > 0) {
     contentSettings = collection.getContentSettings().iterator().next();
     final Map<String, String> contentSettingsMap =
         JsonDeserializer.deserialize(
             contentSettings.getData(), new TypeReference<Map<String, String>>() {});
     settings.putAll(contentSettingsMap);
   }
   settings.putAll(newCollection.getSettings());
   newCollection.setSettings(settings);
   ContentSettings contentSetting =
       contentSettings == null ? new ContentSettings() : contentSettings;
   contentSetting.setContent(collection);
   contentSetting.setData(
       new JSONSerializer().exclude(EXCLUDE).serialize(newCollection.getSettings()));
   this.getCollectionDao().save(contentSetting);
 }
コード例 #5
0
 private AttachDTO buildAttachFromInputParameters(String data) {
   return JsonDeserializer.deserialize(data, AttachDTO.class);
 }
コード例 #6
0
 private TaskAssoc buildTaskAssocFromInputParameters(String data) {
   return JsonDeserializer.deserialize(data, TaskAssoc.class);
 }
コード例 #7
0
 private ContextDTO buildContextInputParam(String data) {
   return JsonDeserializer.deserialize(data, ContextDTO.class);
 }