本文整理汇总了Java中com.liferay.portal.kernel.xml.Element.element方法的典型用法代码示例。如果您正苦于以下问题:Java Element.element方法的具体用法?Java Element.element怎么用?Java Element.element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.xml.Element
的用法示例。
在下文中一共展示了Element.element方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void importXML(long actId, Element question, TestAnswerLocalService testAnswerLocalService)throws SystemException, PortalException {
//"cloze"
Element name=question.element("name");
String description=(name!=null)?name.elementText("text"):"";
TestQuestion theQuestion=TestQuestionLocalServiceUtil.addQuestion(actId,description,getTypeId());
Element questiontext=question.element("questiontext");
String answer=questiontext.elementText("text");
Element generalFeedback=question.element("generalfeedback");
String feedback=generalFeedback.elementText("text");
String feedbackCorrect = "", feedbackNoCorrect="";
if(feedback.contains("//")){
String[] split = feedback.split("//");
if(split.length == 2){
feedbackCorrect = split[0];
feedbackNoCorrect = split[1];
}else{
feedbackCorrect = feedback;
feedbackNoCorrect = feedback;
}
}else{
feedbackCorrect = feedback;
feedbackNoCorrect = feedback;
}
testAnswerLocalService.addTestAnswer(theQuestion.getQuestionId(), answer, feedbackCorrect, feedbackNoCorrect, true);
}
示例2: getScore
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public static long getScore(Course course) throws DocumentException, PortalException, SystemException
{
long score=0;
String extraData=course.getCourseExtraData();
if(extraData!=null &&extraData.startsWith("<?xml"))
{
Document document = SAXReaderUtil.read(extraData);
Element rootElement=document.getRootElement();
Element scoreElement=rootElement.element("score");
if(scoreElement!=null)
{
score=Long.valueOf(scoreElement.attributeValue("value"));
}
}
return score;
}
示例3: update
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void update(ActionRequest actionRequest,ActionResponse actionResponse) throws Exception{
LearningActivity learningActivity = LearningActivityLocalServiceUtil.getLearningActivity(ParamUtil.getLong(actionRequest, "actId"));
Document document = SAXReaderUtil.read(learningActivity.getExtracontent());
Element rootElement = document.getRootElement();
Element firedDateElement = rootElement.element("firedDate");
//if(firedDateElement==null){
rootElement.addElement("firedDate").setText(_dateFormat.format(new Date()));
learningActivity.setExtracontent(document.formattedString());
LearningActivityLocalServiceUtil.updateLearningActivity(learningActivity);
evaluate(learningActivity.getActId());
//}
PortletURL viewPortletURL = ((LiferayPortletResponse)actionResponse).createRenderURL();
viewPortletURL.setParameter("jspPage","/html/evaluationtaskactivity/view.jsp");
String returnToFullPageURL = actionRequest.getParameter("returnToFullPageURL");
if(Validator.isNotNull(returnToFullPageURL)) {
viewPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
}
actionResponse.sendRedirect(viewPortletURL.toString());
}
示例4: publish
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void publish(ActionRequest actionRequest,ActionResponse actionResponse) throws Exception{
LearningActivity learningActivity = LearningActivityLocalServiceUtil.getLearningActivity(ParamUtil.getLong(actionRequest, "actId"));
Document document = SAXReaderUtil.read(learningActivity.getExtracontent());
Element rootElement = document.getRootElement();
Element publishDate = rootElement.element("publishDate");
if(publishDate==null){
rootElement.addElement("publishDate").setText(_dateFormat.format(new Date()));
}
learningActivity.setExtracontent(document.formattedString());
LearningActivityLocalServiceUtil.updateLearningActivity(learningActivity);
PortletURL viewPortletURL = ((LiferayPortletResponse)actionResponse).createRenderURL();
viewPortletURL.setParameter("jspPage","/html/evaluationtaskactivity/view.jsp");
String returnToFullPageURL = actionRequest.getParameter("returnToFullPageURL");
if(Validator.isNotNull(returnToFullPageURL)) {
viewPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
}
actionResponse.sendRedirect(viewPortletURL.toString());
}
示例5: setExtraContent
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
PortletResponse portletResponse, LearningActivity learningActivity)
throws NumberFormatException, Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
if(!team.equalsIgnoreCase("0")){
teamId = Long.parseLong(team);
}
Document document = null;
Element rootElement = null;
if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
document = SAXReaderUtil.createDocument();
rootElement = document.addElement("survey");
}
else
{
document=SAXReaderUtil.read(learningActivity.getExtracontent());
rootElement =document.getRootElement();
}
Element teamElement=rootElement.element("team");
if(teamElement!=null)
{
teamElement.detach();
rootElement.remove(teamElement);
}
if(teamId!=0){
teamElement = SAXReaderUtil.createElement("team");
teamElement.setText(Long.toString(teamId));
rootElement.add(teamElement);
}
learningActivity.setExtracontent(document.formattedString());
return null;
}
示例6: setExtraContent
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
PortletResponse portletResponse, LearningActivity learningActivity)
throws NumberFormatException, Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
if(!team.equalsIgnoreCase("0")){
teamId = Long.parseLong(team);
}
Document document = null;
Element rootElement = null;
if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
document = SAXReaderUtil.createDocument();
rootElement = document.addElement("offline");
}
else
{
document=SAXReaderUtil.read(learningActivity.getExtracontent());
rootElement =document.getRootElement();
}
Element teamElement=rootElement.element("team");
if(teamElement!=null)
{
teamElement.detach();
rootElement.remove(teamElement);
}
if(teamId!=0){
teamElement = SAXReaderUtil.createElement("team");
teamElement.setText(Long.toString(teamId));
rootElement.add(teamElement);
}
learningActivity.setExtracontent(document.formattedString());
return null;
}
示例7: importXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void importXML(long actId, Element question, TestAnswerLocalService testAnswerLocalService)throws SystemException, PortalException {
//"essay","numerical","shortanswer"
Element questiontext=question.element("questiontext");
String description=questiontext.elementText("text");
TestQuestion theQuestion=TestQuestionLocalServiceUtil.addQuestion(actId,description,getTypeId());
if(!"essay".equals(question.attributeValue("type"))){//los essay en moodle nunca tienen respuesta
for(Element answerElement:question.elements("answer")){
boolean correct=("100".equals(answerElement.attributeValue("fraction")))? true:false;
String answer=answerElement.elementText("text");
String feedback="", feedbackCorrect="", feedbackNoCorrect="";
if(answerElement.element("feedback")!=null && answerElement.element("feedback").element("text")!=null)
feedback=answerElement.element("feedback").element("text").getText();
if(feedback.contains("//")){
String[] split = feedback.split("//");
if(split.length == 2){
feedbackCorrect = split[0];
feedbackNoCorrect = split[1];
}else{
feedbackCorrect = feedback;
feedbackNoCorrect = feedback;
}
}else{
feedbackCorrect = feedback;
feedbackNoCorrect = feedback;
}
testAnswerLocalService.addTestAnswer(theQuestion.getQuestionId(), answer, feedbackCorrect, feedbackNoCorrect, correct);
return;//porque inicialmente solo aceptamos una respuesta
}
}
}
示例8: importXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void importXML(long actId, Element question, TestAnswerLocalService testAnswerLocalService)throws SystemException, PortalException {
Element questiontext=question.element("questiontext");
String description=questiontext.elementText("text");
TestQuestion theQuestion=TestQuestionLocalServiceUtil.addQuestion(actId,description,getTypeId());
for(Element answerElement:question.elements("answer")){
boolean correct=(!"0".equals(answerElement.attributeValue("fraction")))? true:false;
String answer=answerElement.elementText("text");
String feedback="";
if(answerElement.element("feedback")!=null && answerElement.element("feedback").element("text")!=null)
feedback=answerElement.element("feedback").element("text").getText();
testAnswerLocalService.addTestAnswer(theQuestion.getQuestionId(), answer, feedback, feedback, correct);
}
}
示例9: importXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void importXML(long actId, Element question, TestAnswerLocalService testAnswerLocalService)throws SystemException, PortalException {
Element questiontext=question.element("questiontext");
String description=questiontext.elementText("text");
TestQuestion theQuestion=TestQuestionLocalServiceUtil.addQuestion(actId,description,getTypeId());
for(Element answerElement:question.elements("answer")){
boolean correct=true;
String answer=answerElement.elementText("text");
testAnswerLocalService.addTestAnswer(theQuestion.getQuestionId(), answer, "", "", correct);
}
}
示例10: getEvaluationModel
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public JSONObject getEvaluationModel(Course course) throws PortalException,
SystemException, DocumentException, IOException {
if(Validator.isNull(course.getCourseExtraData())) {
return JSONFactoryUtil.createJSONObject();
}
Document document=SAXReaderUtil.read(course.getCourseExtraData());
Element rootElement =document.getRootElement();
JSONObject model = JSONFactoryUtil.createJSONObject();
try {
Element firedDateElement = rootElement.element("firedDate");
if(firedDateElement!=null){
Date firedDate =(Date)_dateFormat.parseObject(firedDateElement.getTextTrim());
model.put("firedDate", firedDate);
}
} catch (Throwable e) {
}
model.put("passPuntuation", Long.toString(GetterUtil.getLong(rootElement.elementText("passPuntuation"))));
List<Element> evaluations = rootElement.elements("evaluation");
if(!evaluations.isEmpty()){
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
model.put("evaluations", jsonArray);
for (Element evaluation : evaluations) {
long id = GetterUtil.getLong(evaluation.elementText("id"));
if(id!=0){
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonArray.put(jsonObject);
jsonObject.put("id", id);
jsonObject.put("weight", GetterUtil.getLong(evaluation.elementText("weight")));
}
}
}
return model;
}
示例11: updateCourse
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void updateCourse(ActionRequest actionRequest,ActionResponse actionResponse) throws Exception{
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
Course course=CourseLocalServiceUtil.fetchByGroupCreatedId(themeDisplay.getScopeGroupId());
Document document = SAXReaderUtil.read(course.getCourseExtraData());
Element rootElement = document.getRootElement();
Element firedDateElement = rootElement.element("firedDate");
if(firedDateElement==null){
rootElement.addElement("firedDate").setText(_dateFormat.format(new Date()));
course.setCourseExtraData(document.formattedString());
CourseLocalServiceUtil.updateCourse(course);
/*
Message message = new Message();
message.put("courseId", course.getCourseId());
MessageBusUtil.sendMessage("liferay/lms/evaluationAverage", message);
*/
CourseEval courseEval = new CourseEvalRegistry().getCourseEval(course.getCourseEvalId());
if(!courseEval.updateCourse(course)){
SessionErrors.add(actionRequest, "evaluationAvg.evaluation.error");
}
}
PortletURL viewPortletURL = ((LiferayPortletResponse)actionResponse).createRenderURL();
viewPortletURL.setParameter("jspPage","/html/evaluationAvg/view.jsp");
viewPortletURL.setParameter(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY,StringPool.TRUE);
String returnToFullPageURL = actionRequest.getParameter("returnToFullPageURL");
if(Validator.isNotNull(returnToFullPageURL)) {
viewPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
}
actionResponse.sendRedirect(viewPortletURL.toString());
}
示例12: setExtraContent
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
PortletResponse portletResponse, LearningActivity learningActivity)
throws NumberFormatException, Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
String fichero = ParamUtil.getString(uploadRequest, "fichero", StringPool.FALSE);
String textoenr = ParamUtil.getString(uploadRequest, "textoenr", StringPool.FALSE);
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
if(!team.equalsIgnoreCase("0")){
teamId = Long.parseLong(team);
}
Document document = null;
Element rootElement = null;
if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
document = SAXReaderUtil.createDocument();
rootElement = document.addElement("online");
}
else
{
document=SAXReaderUtil.read(learningActivity.getExtracontent());
rootElement =document.getRootElement();
}
Element ficheroXML=rootElement.element("fichero");
if(ficheroXML!=null)
{
ficheroXML.detach();
rootElement.remove(ficheroXML);
}
ficheroXML=SAXReaderUtil.createElement("fichero");
ficheroXML.addText(fichero);
rootElement.add(ficheroXML);
Element textoenrXML=rootElement.element("textoenr");
if(textoenrXML!=null)
{
textoenrXML.detach();
rootElement.remove(textoenrXML);
}
textoenrXML=SAXReaderUtil.createElement("textoenr");
textoenrXML.addText(textoenr);
rootElement.add(textoenrXML);
Element teamElement=rootElement.element("team");
if(teamElement!=null)
{
teamElement.detach();
rootElement.remove(teamElement);
}
if(teamId!=0){
teamElement = SAXReaderUtil.createElement("team");
teamElement.setText(Long.toString(teamId));
rootElement.add(teamElement);
}
learningActivity.setExtracontent(document.formattedString());
return null;
}
示例13: setEvaluationModel
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public void setEvaluationModel(Course course, JSONObject model)
throws PortalException, SystemException, DocumentException,
IOException {
Document document = null;
Element rootElement = null;
Date firedDate = null;
if((course.getCourseExtraData()!=null)&&(course.getCourseExtraData().trim().length()!=0)){
try {
document=SAXReaderUtil.read(course.getCourseExtraData());
rootElement =document.getRootElement();
Element firedDateElement = rootElement.element("firedDate");
if(firedDateElement!=null){
firedDate =(Date)_dateFormat.parseObject(firedDateElement.getTextTrim());
}
} catch (Throwable e) {
}
}
document = SAXReaderUtil.createDocument();
rootElement = document.addElement("eval");
rootElement.addElement("courseEval").setText(EvaluationAvgCourseEval.class.getName());
if(firedDate!=null){
rootElement.addElement("firedDate").setText(_dateFormat.format(firedDate));
}
rootElement.addElement("passPuntuation").setText(Long.toString(model.getLong("passPuntuation")));
JSONArray jsonArray = model.getJSONArray("evaluations");
if(jsonArray!=null){
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject evaluation = jsonArray.getJSONObject(i);
long id = evaluation.getLong("id");
if(id!=0){
Element evaluationElement = rootElement.addElement("evaluation");
evaluationElement.addElement("id").setText(Long.toString(id));
evaluationElement.addElement("weight").setText(Long.toString(evaluation.getLong("weight")));
}
}
}
course.setCourseExtraData(document.formattedString());
}
示例14: addfiles
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void addfiles(ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);
String jspPage = ParamUtil.getString(actionRequest, "jspPage");
long actId = ParamUtil.getLong(actionRequest, "resId", 0);
String description = request.getParameter("description");
String youtubecode=ParamUtil.getString(request,"youtubecode","");
boolean videoControlEnabled=ParamUtil.getBoolean(request,"videoControl");
LearningActivity larn = LearningActivityServiceUtil.getLearningActivity(actId);
String extraContent=larn.getExtracontent();
Document document = SAXReaderUtil.createDocument();
Element rootElement = document.addElement("multimediaentry");
if(extraContent!=null &&!"".equals(extraContent)&&!Validator.isNumber(extraContent))
{
document=SAXReaderUtil.read(extraContent);
rootElement =document.getRootElement();
}
if(!"".equals(youtubecode))
{
Element video=rootElement.element("video");
if(video!=null)
{
video.detach();
rootElement.remove(video);
}
video = SAXReaderUtil.createElement("video");
video.setText(youtubecode);
rootElement.add(video);
}
Element videoControl=rootElement.element("video-control");
if(videoControl!=null)
{
videoControl.detach();
rootElement.remove(videoControl);
}
videoControl = SAXReaderUtil.createElement("video-control");
videoControl.setText(String.valueOf(videoControlEnabled));
rootElement.add(videoControl);
larn.setExtracontent(document.formattedString());
larn.setDescription( description,themeDisplay.getLocale());
//LearningActivityServiceUtil.modLearningActivity(larn, serviceContext);
LearningActivityServiceUtil.modLearningActivity(larn);
//auditing
AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), themeDisplay.getUserId(), AuditConstants.UPDATE, null);
SessionMessages.add(actionRequest, "activity-saved-successfully");
actionResponse.setRenderParameter("jspPage", jspPage);
actionResponse.setRenderParameter("actionEditingDetails", "true");
actionResponse.setRenderParameter("resId", Long.toString(actId));
}
示例15: importJournalArticle
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
protected void importJournalArticle(
PortletDataContext portletDataContext, Layout layout,
Element layoutElement)
throws Exception {
UnicodeProperties typeSettingsProperties =
layout.getTypeSettingsProperties();
String articleId = typeSettingsProperties.getProperty(
"article-id", StringPool.BLANK);
if (Validator.isNull(articleId)) {
return;
}
JournalPortletDataHandlerImpl.importReferencedData(
portletDataContext, layoutElement);
Element structureElement = layoutElement.element("structure");
if (structureElement != null) {
JournalPortletDataHandlerImpl.importStructure(
portletDataContext, structureElement);
}
Element templateElement = layoutElement.element("template");
if (templateElement != null) {
JournalPortletDataHandlerImpl.importTemplate(
portletDataContext, templateElement);
}
Element articleElement = layoutElement.element("article");
if (articleElement != null) {
JournalPortletDataHandlerImpl.importArticle(
portletDataContext, articleElement);
}
Map<String, String> articleIds =
(Map<String, String>)portletDataContext.getNewPrimaryKeysMap(
JournalArticle.class + ".articleId");
articleId = MapUtil.getString(articleIds, articleId, articleId);
typeSettingsProperties.setProperty("article-id", articleId);
JournalContentSearchLocalServiceUtil.updateContentSearch(
portletDataContext.getScopeGroupId(), layout.isPrivateLayout(),
layout.getLayoutId(), StringPool.BLANK, articleId, true);
}