当前位置: 首页>>代码示例>>Java>>正文


Java ContentDbLoader类代码示例

本文整理汇总了Java中blackboard.persist.content.ContentDbLoader的典型用法代码示例。如果您正苦于以下问题:Java ContentDbLoader类的具体用法?Java ContentDbLoader怎么用?Java ContentDbLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContentDbLoader类属于blackboard.persist.content包,在下文中一共展示了ContentDbLoader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showModifyLessonPage

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
private void showModifyLessonPage(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException {

// retrive the LAMS lesson
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, request.getParameter("content_id"));
ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader(ContentDbLoader.TYPE);
Content bbContent = (Content) courseDocumentLoader.loadById(contentId);

// get LAMS lessons's properties
Calendar startDate = bbContent.getStartDate();
Calendar endDate = bbContent.getEndDate();
FormattedText description = bbContent.getBody();

request.setAttribute("bbContent", bbContent);
request.setAttribute("startDate", startDate);
request.setAttribute("endDate", endDate);
request.setAttribute("description", description);

request.getRequestDispatcher("/modules/modify.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:LessonManagerServlet.java

示例2: delete

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
private void delete(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException, ParserConfigurationException, SAXException {

//remove Lineitem object from Blackboard DB
String _content_id = request.getParameter("content_id");
String _course_id = request.getParameter("course_id");
LineitemUtil.removeLineitem(_content_id, _course_id);

// remove internalContentId -> externalContentId key->value pair (it's used for GradebookServlet)
PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, "LamsStorage");
ExtraInfo ei = pei.getExtraInfo();
ei.clearEntry(_content_id);
PortalUtil.savePortalExtraInfo(pei);

//remove lesson from LAMS server
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance();
Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id);
Content bbContent = courseDocumentLoader.loadById(contentId);
String lsId = bbContent.getLinkRef();
String userName = ctx.getUser().getUserName();
Boolean isDeletedSuccessfully = LamsSecurityUtil.deleteLesson(userName, lsId);

System.out.println("Lesson (bbContentId:" + _content_id + ") successfully deleted by userName:" + userName);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:LessonManagerServlet.java

示例3: removeLineitem

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
/**
    * Removes lineitem. Throws exception if lineitem is not found.
    * 
    * @param _content_id
    * @param _course_id
    * @throws PersistenceException
    * @throws ServletException
    */
   public static void removeLineitem(String _content_id, String _course_id)
    throws PersistenceException, ServletException {
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance();
LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance();

Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id);
Content bbContent = courseDocumentLoader.loadById(contentId);
//check isGradecenter option is ON and thus there should exist associated lineitem object
if (!bbContent.getIsDescribed()) {
    return;
}

Id lineitemId = getLineitem(_content_id, _course_id, true);
linePersister.deleteById(lineitemId);

//Remove bbContentId -> lineitemid pair from the storage
PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, LAMS_LINEITEM_STORAGE);
ExtraInfo ei = pei.getExtraInfo();
ei.clearEntry(_content_id);
PortalUtil.savePortalExtraInfo(pei);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:LineitemUtil.java

示例4: setContext

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
private boolean setContext(B2Context b2Context, String contentId) {

    boolean ok = true;
    try {
      BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
      ContentDbLoader contentLoader = (ContentDbLoader)bbPm.getLoader(ContentDbLoader.TYPE);
      Id id = bbPm.generateId(Content.DATA_TYPE, contentId);
      Content content = contentLoader.loadById(id);
      b2Context.setContext(Resource.initContext(content.getCourseId(), id));
    } catch (PersistenceException e) {
      Logger.getLogger(LinkSetting.class.getName()).log(Level.SEVERE, null, e);
      ok = false;
    }

    return ok;

  }
 
开发者ID:ubc,项目名称:enhanced-basiclti-b2,代码行数:18,代码来源:LinkSetting.java

示例5: getBbAssignment

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
public BbAssignment getBbAssignment(Lineitem lineitem, Course course) {
    System.out.println("****Calling BbAssignmentBuilder ");
    //if it's a discussion Assignment, get the link for the outcome definition's link id, and somehow attach the description to that!
    if(lineitem.getOutcomeDefinition() != null){
        System.out.println("****OutcomeDef was not null...");
        Id contentId = lineitem.getOutcomeDefinition().getContentId();
        try {
            ContentDbLoader contentDbLoader = ContentDbLoader.Default.getInstance();
            Content content = contentDbLoader.loadById(contentId);
            
            if(content != null && content.getBody() != null){
                return new BbAssignment(lineitem, course, content.getBody().getText());
            } else {
                return new BbAssignment(lineitem, course, "Assignment");
            }
        } catch (PersistenceException ex) {
            Logger.getLogger(DiscussionAssignmentBuilder.class.getName()).log(Level.SEVERE, null, ex);
            return new BbAssignment(lineitem, course, null);
        }
    } else {
        return new BbAssignment(lineitem, course, null);
    }
    
}
 
开发者ID:pfgray,项目名称:lmsrest,代码行数:25,代码来源:BbAssignmentBuilder.java

示例6: getLamsLessonsByCourse

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
/**
    * Returns all LAMS lessons from the specified course.
    * 
    * @param courseId
    *            BB course id
    * @return list of LAMS lessons
    * @throws PersistenceException
    */
   public static List<Content> getLamsLessonsByCourse(PkId courseId, boolean includeLessonsCreatedByOldNtuPlugin) throws PersistenceException {

ContentDbLoader contentLoader = ContentDbLoader.Default.getInstance();
CourseTocDbLoader cTocDbLoader = CourseTocDbLoader.Default.getInstance();

// get a CourseTOC (Table of Contents) loader. We will need this to iterate through all of the "areas"
// within the course
List<CourseToc> courseTocs = cTocDbLoader.loadByCourseId(courseId);

// iterate through the course TOC items
List<Content> lamsContents = new ArrayList<Content>();
for (CourseToc courseToc : courseTocs) {

    // determine if the TOC item is of type "CONTENT" rather than applicaton, or something else
    if ((courseToc.getTargetType() == CourseToc.Target.CONTENT) && (courseToc.getContentId() != Id.UNSET_ID)) {
	// we have determined that the TOC item is content, next we need to load the content object and
	// iterate through it
	// load the content tree into an object "content" and iterate through it
	List<Content> contents = contentLoader.loadListById(courseToc.getContentId());
	// iterate through the content items in this content object
	for (Content content : contents) {
	    // only LAMS content
	    if ("resource/x-lams-lamscontent".equals(content.getContentHandler())
		    || includeLessonsCreatedByOldNtuPlugin && content.getContentHandler().equals("resource/x-ntu-hdllams")) {
		lamsContents.add(content);
	    }
	}
    }
}

return lamsContents;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:BlackboardUtil.java

示例7: getLineitem

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
/**
    * Finds lineitem by userId and lamsLessonId. The same as above method but first finds bbContentId and also checks
    * Grade center option is ON.
    * 
    * @param isThrowException whether exception should be thrown in case Gradecenter option is OFF or it should return simple null
    * @throws ServletException
    * @throws PersistenceException
    */
   public static Lineitem getLineitem(Id userId, String lamsLessonIdParam, boolean isThrowException)
    throws ServletException, PersistenceException {
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
ContentDbLoader contentDbLoader = ContentDbLoader.Default.getInstance();

//Finds bbContentId from "LamsStorage" corresponding to specified lamsLessonId.
//Note: bbContentId can be null in case it's Chen Rui's BB, which doesn't have "LamsStorage".
PortalExtraInfo portalExtraInfo = PortalUtil.loadPortalExtraInfo(null, null, "LamsStorage");
ExtraInfo extraInfo = portalExtraInfo.getExtraInfo();
Set<String> bbContentIds = extraInfo.getKeys();
String bbContentId = null;
for (String bbContentIdIter : bbContentIds) {
    String lamsLessonId = extraInfo.getValue(bbContentIdIter);
    if (lamsLessonIdParam.equals(lamsLessonId)) {
	bbContentId = bbContentIdIter;
	break;
    }
}

if (bbContentId != null) {
    Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, bbContentId);
    Content bbContent = contentDbLoader.loadById(contentId);
    // check isGradecenter option is ON (bbContent.isDescribed field is used for storing isGradecenter parameter)
    if (!bbContent.getIsDescribed()) {
	if (isThrowException) {
	    throw new LamsBuildingBlockException("Operation failed due to lesson (lessonId=" + lamsLessonIdParam
		    + ", bbContentId=" + bbContentId + ") has gradecenter option switched OFF.");
	} else {
	    return null;
	}
    }
}

//get lineitem
return LineitemUtil.getLineitem(bbContentId == null ? "" : bbContentId, userId, lamsLessonIdParam);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:LineitemUtil.java

示例8: doCopy

import blackboard.persist.content.ContentDbLoader; //导入依赖的package包/类
@Override
public void doCopy(CopyControl copyControl) {

  B2Context courseContext = new B2Context(null);
  VirtualInstallationManager vMgr = VirtualInstallationManagerFactory.getInstance();
  VirtualHost vHost = vMgr.getDefaultVirtualHost();
  courseContext.setContext(ContextManagerFactory.getInstance().setContext(vHost.getId(),
     copyControl.getDestinationCourseId(), Id.UNSET_ID, Id.UNSET_ID, Id.UNSET_ID));
  courseContext.setIgnoreContentContext(true);
  Map<String,String> settings = courseContext.getSettings(false, true);
  if (!settings.isEmpty()) {
    copyControl.getLogger().logInfo(String.format(this.getB2Context().getResourceString("copy.start", "%s"), this.getName()));
    int numItems = 0;
    int numRefs = 0;
    String name;
    for (Iterator<String> iter = settings.keySet().iterator(); iter.hasNext();) {
      name = iter.next();
      if (name.startsWith("x_")) {
        courseContext.setSetting(false, true, name, null);
      }
    }

    courseContext.setSetting(false, true, "courseid", copyControl.getDestinationCourseId().toExternalString());
    courseContext.setSetting(false, true, "x_courseid", getNewValue(copyControl.getSourceCourseId().toExternalString(), settings.get("x_courseid")));
    try {
      BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
      ContentDbLoader courseDocumentLoader = (ContentDbLoader)bbPm.getLoader(ContentDbLoader.TYPE);
      List<Content> items = courseDocumentLoader.loadMapView(copyControl.getSourceCourseId(), null);
      String source;
      String dest;
      Id destId;
      boolean isLTI;
      String ltiUrl = courseContext.getPath();
      for (Iterator<Content> iter = items.iterator(); iter.hasNext();) {
        Content item = iter.next();
        List<Content> children = courseDocumentLoader.loadListById(item.getId(), null, true);
        for (Iterator<Content> iter2 = children.iterator(); iter2.hasNext();) {
          Content child = iter2.next();
          source = child.getId().toExternalString();
          destId = copyControl.lookupIdMapping(child.getId());
          if (destId.isSet()) {
            isLTI = child.getContentHandler().equals("resource/x-" + this.getComponentHandle());
            if (isLTI) {
              numItems++;
            } else {
              isLTI = child.getBody().getText().contains(ltiUrl);
              if (isLTI) {
                numRefs++;
              }
            }
            if (isLTI) {
              dest = destId.toExternalString();
              courseContext.setSetting(false, true, "x" + dest, getNewValue(source, settings.get("x" + source)));
            }
          }
        }
      }
    } catch (PersistenceException e) {
      copyControl.getLogger().logError(e.getMessage());
    }
    courseContext.persistSettings(false, true);
    String msg = String.format(this.getB2Context().getResourceString("copy.summary", "%d"), numItems);
    if (numRefs > 0) {
      msg += " " + String.format(this.getB2Context().getResourceString("links.summary", "%d"), numRefs);
    }
    copyControl.getLogger().logInfo(msg);
  }

}
 
开发者ID:ubc,项目名称:enhanced-basiclti-b2,代码行数:70,代码来源:OscBasicLTICxComponent.java


注:本文中的blackboard.persist.content.ContentDbLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。