本文整理汇总了Java中blackboard.persist.content.ContentDbLoader.loadById方法的典型用法代码示例。如果您正苦于以下问题:Java ContentDbLoader.loadById方法的具体用法?Java ContentDbLoader.loadById怎么用?Java ContentDbLoader.loadById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blackboard.persist.content.ContentDbLoader
的用法示例。
在下文中一共展示了ContentDbLoader.loadById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例6: 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);
}