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


Java CourseDbLoader.loadById方法代码示例

本文整理汇总了Java中blackboard.persist.course.CourseDbLoader.loadById方法的典型用法代码示例。如果您正苦于以下问题:Java CourseDbLoader.loadById方法的具体用法?Java CourseDbLoader.loadById怎么用?Java CourseDbLoader.loadById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在blackboard.persist.course.CourseDbLoader的用法示例。


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

示例1: getOldContextId

import blackboard.persist.course.CourseDbLoader; //导入方法依赖的package包/类
public static String getOldContextId(B2Context b2Context, String contextIdType) {

    B2Context courseContext = new B2Context(b2Context.getRequest());
    courseContext.setIgnoreContentContext(true);

    String contextIds = "";
    String old = courseContext.getSetting(false, true, "x_courseid", "");
    if ((old.length() > 0) && !contextIdType.equals(Constants.DATA_COURSEID)) {
      StringBuilder contexts = new StringBuilder();
      try {
        BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
        CourseDbLoader courseLoader = (CourseDbLoader)bbPm.getLoader(CourseDbLoader.TYPE);
        String[] courses = old.split(",");
        Course course;
        Id courseId;
        String contextId;
        for (int i = 0; i < courses.length; i++) {
          courseId = Id.generateId(Course.DATA_TYPE, courses[i]);
          course = courseLoader.loadById(courseId);
          if (contextIdType.equals(Constants.DATA_PRIMARYKEY)) {
            contextId = course.getId().toExternalString();
          } else if (contextIdType.equals(Constants.DATA_UUID) && B2Context.getIsVersion(9, 1, 13)) {
            contextId = course.getUuid();
          } else {
            contextId = course.getBatchUid();
          }
          contexts.append(",").append(urlEncode(contextId));
        }
        contextIds = contexts.substring(1);
      } catch (PersistenceException ex) {
        Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return contextIds;

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

示例2: getCourseForId

import blackboard.persist.course.CourseDbLoader; //导入方法依赖的package包/类
@Override
public Course getCourseForId(String id) {
    try {
        CourseDbLoader courseDbLoader = CourseDbLoader.Default.getInstance();
        return new BbCourse(courseDbLoader.loadById(BlackboardUtilities.getIdFromPk(id, blackboard.data.course.Course.class)));
    } catch (PersistenceException ex) {
        Logger.getLogger(BbCourseService.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
开发者ID:pfgray,项目名称:lmsrest,代码行数:11,代码来源:BbCourseService.java

示例3: recreateLessonsAfterCourseCopy

import blackboard.persist.course.CourseDbLoader; //导入方法依赖的package包/类
/**
    * Recreates lessons after course has been copied. I.e. asks LAMS server to clone old lesson and then updates BB
    * link with the newly created lesson Id.
    * 
    * @param courseIdParam
    *            id of the course that has been copied
    * @return
    * @throws PersistenceException
    * @throws ValidationException
    * @throws IOException
    * @throws ServletException
    * @throws SAXException 
    * @throws ParserConfigurationException 
    */
   private static String recreateLessonsAfterCourseCopy(String _course_id)
    throws PersistenceException, ValidationException, ServletException, IOException, ParserConfigurationException, SAXException {
String newLessonIds = "";

BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
ContentDbPersister persister = ContentDbPersister.Default.getInstance();
CourseDbLoader courseLoader = CourseDbLoader.Default.getInstance();

PkId courseId = (PkId) bbPm.generateId(Course.DATA_TYPE, _course_id);
Course course = courseLoader.loadById(courseId);
String courseIdStr = course.getCourseId();

logger.debug("Starting clonning course lessons (courseId=" + courseId + ").");

// find a teacher that will be assigned as lesson's author on LAMS side
User teacher = BlackboardUtil.getCourseTeacher(courseId);

//find all lessons that should be updated
List<Content> lamsContents = BlackboardUtil.getLamsLessonsByCourse(courseId, false);
for (Content content : lamsContents) {

    String _content_id = content.getId().toExternalString();

    String url = content.getUrl();
    String urlLessonId = getParameterValue(url, "lsid");
    String urlCourseId = getParameterValue(url, "course_id");
    String urlContentId = getParameterValue(url, "content_id");

    //in case when both courseId and contentId don't coincide with the ones from URL - means lesson needs to be cloned
    if (!urlCourseId.equals(_course_id) && !urlContentId.equals(_content_id)) {

	final Long newLessonId = LamsSecurityUtil.cloneLesson(teacher, courseIdStr, urlLessonId);

	// update lesson id
	content.setLinkRef(Long.toString(newLessonId));

	// update URL
	url = replaceParameterValue(url, "lsid", Long.toString(newLessonId));
	url = replaceParameterValue(url, "course_id", _course_id);
	url = replaceParameterValue(url, "content_id", _content_id);
	content.setUrl(url);

	// persist updated content
	persister.persist(content);

	//update lineitem details
	LineitemUtil.updateLineitemLessonId(content, _course_id, newLessonId, teacher.getUserName());

	logger.debug("Lesson (lessonId=" + urlLessonId + ") was successfully cloned to the one (lessonId="
		+ newLessonId + ").");

	newLessonIds += newLessonId + ", ";
    }

}

return newLessonIds;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:73,代码来源:LinkToolsServlet.java


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