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


Java SAXReaderUtil类代码示例

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


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

示例1: getResults

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
	String answer= ParamUtil.getString(actionRequest, "question_"+questionId, "");

	Element questionXML=SAXReaderUtil.createElement("question");
	questionXML.addAttribute("id", Long.toString(questionId));

	long currentQuestionId = ParamUtil.getLong(actionRequest, "currentQuestionId");
	if (currentQuestionId == questionId) {
		questionXML.addAttribute("current", "true");
	}

	Element answerXML=SAXReaderUtil.createElement("answer");
	answerXML.addText(answer);
	questionXML.add(answerXML);

	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:18,代码来源:FreetextQuestionType.java

示例2: getResults

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
	long[] answersId= ParamUtil.getLongValues(actionRequest, "question_"+questionId);

	List<Long> arrayAnswersId = new ArrayList<Long>();
	for(long answerId:answersId) arrayAnswersId.add(answerId);

	Element questionXML=SAXReaderUtil.createElement("question");
	questionXML.addAttribute("id", Long.toString(questionId));

	long currentQuestionId = ParamUtil.getLong(actionRequest, "currentQuestionId");
	if (currentQuestionId == questionId) {
		questionXML.addAttribute("current", "true");
	}

	for(long answer:arrayAnswersId){
		if(answer >0){
			Element answerXML=SAXReaderUtil.createElement("answer");
			answerXML.addAttribute("id", Long.toString(answer));
			questionXML.add(answerXML);
		}
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:24,代码来源:OptionsQuestionType.java

示例3: exportXML

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public Element exportXML(long questionId) {
	XMLType="sort";
	Element questionXML = super.exportXML(questionId);
	try {
		List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
		for(TestAnswer answer:answers){
			Element answerE = SAXReaderUtil.createElement("answer");
			answerE.addAttribute("fraction", "100");
			
			Element text = SAXReaderUtil.createElement("text");
			text.addText(answer.getAnswer());
			answerE.add(text);
			
			questionXML.add(answerE);
		}
	} catch (SystemException e) {
		e.printStackTrace();
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:21,代码来源:SortableQuestionType.java

示例4: exportXML

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public Element exportXML(long questionId) {
	XMLType = "draganddrop";
	Element questionXML = super.exportXML(questionId);
	try {
		List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
		for(TestAnswer answer:answers){
			Element answerE = SAXReaderUtil.createElement("answer");
			answerE.addAttribute("fraction", (answer.isIsCorrect())?"100":"0");
			
			Element text = SAXReaderUtil.createElement("text");
			text.addText(answer.getAnswer());
			answerE.add(text);
			
			Element feedback = SAXReaderUtil.createElement("feedback");
			Element feedText = SAXReaderUtil.createElement("text");
			feedText.addText(answer.getFeedbackCorrect());
			feedback.add(feedText);
			answerE.add(feedback);
			questionXML.add(answerE);
		}
	} catch (SystemException e) {
		e.printStackTrace();
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:26,代码来源:DraganddropQuestionType.java

示例5: getScore

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:17,代码来源:PonderatedCourseEval.java

示例6: getRequiredActivities

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public static java.util.List<Long> getRequiredActivities(Course course) throws DocumentException, PortalException, SystemException
{
	java.util.List<Long> result=new java.util.ArrayList<Long>();
	String extraData=course.getCourseExtraData();
	if(extraData!=null &&extraData.startsWith("<?xml"))
	{
	Document document = SAXReaderUtil.read(extraData);
	Element rootElement=document.getRootElement();
	java.util.List<Element> reqElements=rootElement.elements("required");
	for(Element reqElement:reqElements)
	{
		long actId=Long.parseLong(reqElement.attributeValue("actId"));
		LearningActivity larn=LearningActivityLocalServiceUtil.fetchLearningActivity(actId);
		if(larn!=null&& larn.getGroupId()==course.getGroupCreatedId()&& larn.getWeightinmodule()>0)
		{
			result.add(actId);
		}
	}
	}
	return result;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:22,代码来源:PonderatedCourseEval.java

示例7: getActivitiesWeight

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public static java.util.Map<Long, Long> getActivitiesWeight(Course course) throws PortalException, SystemException, DocumentException
{
	java.util.Map<Long, Long> result =new java.util.HashMap<Long, Long>();
	String extraData=course.getCourseExtraData();
	if(extraData!=null &&extraData.startsWith("<?xml"))
	{
	Document document = SAXReaderUtil.read(extraData);
	Element rootElement=document.getRootElement();
	java.util.List<Element> reqElements=rootElement.elements("weight");
	for(Element reqElement:reqElements)
	{
		long actId=Long.parseLong(reqElement.attributeValue("actId"));
		long ponderation=Long.parseLong(reqElement.attributeValue("ponderation"));
		LearningActivity larn=LearningActivityLocalServiceUtil.fetchLearningActivity(actId);
		if(larn!=null&& larn.getGroupId()==course.getGroupCreatedId()&& larn.getWeightinmodule()>0)
		{
			result.put(actId,ponderation);
		}
	}
	}
	return result;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:23,代码来源:PonderatedCourseEval.java

示例8: updateCourse

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
@Override
public boolean updateCourse(Course course, long userId) throws SystemException {
	try {
		if((course.getCourseExtraData()==null)&&(course.getCourseExtraData().trim().length()==0)) {
			return false;
		}
		
		Document document=SAXReaderUtil.read(course.getCourseExtraData());
		Element rootElement =document.getRootElement();
		
		long passPuntuation = GetterUtil.getLong(rootElement.elementText("passPuntuation"),-1);
		if(passPuntuation<0){
			return false;
		}
		
		Map<Long,Long> evaluations=getEvaluations(course,rootElement);
		if(evaluations.size()==0){
			return false;
		}
		
		updateCourseResult(course, passPuntuation, evaluations, userId);	
		return true;
	} catch (DocumentException e) {
		throw new SystemException(e);
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:27,代码来源:EvaluationAvgCourseEval.java

示例9: getMapTryResultData

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public HashMap<Long, Long> getMapTryResultData(long actId,long userId) throws SystemException, PortalException 
{
	HashMap<Long, Long> answersMap = new HashMap<Long, Long>();
	LearningActivityTry actTry = getLastLearningActivityTryByActivityAndUser(actId, userId);
	String xml = actTry.getTryResultData();
	
	if(xml.equals(""))
		return answersMap;
		
	Document document;
	try {
		document = SAXReaderUtil.read(xml);
		Element rootElement = document.getRootElement();
		
		for(Element question:rootElement.elements("question")){
			for(Element answer:question.elements("answer")){
    			answersMap.put(Long.valueOf(question.attributeValue("id")), Long.valueOf(answer.attributeValue("id"))) ;
			}
		}
	} catch (DocumentException e) {
	}
	
	return answersMap;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:25,代码来源:LearningActivityTryLocalServiceImpl.java

示例10: convertHashMapToString

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public String convertHashMapToString(HashMap<String, String> map, int typeId) throws IOException, SystemException{
	Element resultadosXML=SAXReaderUtil.createElement(getNameLearningActivity(typeId));
	Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

	Iterator<Entry<String, String>> it = map.entrySet().iterator();

	while (it.hasNext()) {
		Map.Entry<String, String> e = (Map.Entry<String, String>)it.next();
		Element eleXML=SAXReaderUtil.createElement(String.valueOf(e.getKey()));
		if(e.getKey().toString().contains("document")){
			eleXML.addAttribute("id", String.valueOf(e.getValue()));
		}else{
			eleXML.addText(String.valueOf(e.getValue()));
		}
		resultadosXML.add(eleXML);
	}
	return resultadosXMLDoc.formattedString();
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:20,代码来源:LearningActivityLocalServiceImpl.java

示例11: update

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的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());
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:27,代码来源:EvaluationActivity.java

示例12: publish

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的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());
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:26,代码来源:EvaluationActivity.java

示例13: setExtraContent

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:41,代码来源:SurveyLearningActivityType.java

示例14: setExtraContent

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:41,代码来源:TaskOfflineLearningActivityType.java

示例15: exportXML

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入依赖的package包/类
public Element exportXML(long questionId) {
	XMLType="multichoice";
	Element questionXML = super.exportXML(questionId);
	try {
		List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
		for(TestAnswer answer:answers){
			Element answerE = SAXReaderUtil.createElement("answer");
			answerE.addAttribute("fraction", (answer.isIsCorrect())?"100":"0");
			
			Element text = SAXReaderUtil.createElement("text");
			text.addText(answer.getAnswer());
			answerE.add(text);
			
			Element feedback = SAXReaderUtil.createElement("feedback");
			Element feedText = SAXReaderUtil.createElement("text");
			feedText.addText(answer.getFeedbackCorrect());
			feedback.add(feedText);
			answerE.add(feedback);
			questionXML.add(answerE);
		}
		Element single = SAXReaderUtil.createElement("single");
		single.addText(XMLSingle);
		questionXML.add(single);
	} catch (SystemException e) {
		e.printStackTrace();
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:29,代码来源:OptionsQuestionType.java


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