本文整理汇总了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;
}
示例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;
}
}
示例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;
}