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


Java SAXReaderUtil.createElement方法代码示例

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


在下文中一共展示了SAXReaderUtil.createElement方法的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: getResults

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
	List<TestAnswer> testAnswers = new ArrayList<TestAnswer>();
	try {
		testAnswers.addAll(TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId));
	} catch (SystemException e) {
		e.printStackTrace();
	}

	List<Long> answersId = new ArrayList<Long>();
	long[] answers = ParamUtil.getLongValues(actionRequest, "question_"+questionId+"_ans");
	for(long id:answers){
		answersId.add(id);
	}

	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:answersId){
		Element answerXML=SAXReaderUtil.createElement("answer");
		answerXML.addAttribute("id", Long.toString(answer));
		questionXML.add(answerXML);
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:30,代码来源:SortableQuestionType.java

示例10: getResults

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
	List<TestAnswer> testAnswers = new ArrayList<TestAnswer>();
	try {
		testAnswers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
	} catch (SystemException e) {
		e.printStackTrace();
	}
	
	TestAnswer solution = null;
	if(testAnswers!=null && testAnswers.size()>0)
		solution = testAnswers.get(0);
	
	String answer = "";
	
	if(solution!=null){
		int i = getQuestionSols(solution.getAnswer()).size();
		for(int k=0; k<i; k++){
			if(answer!="") answer+=",";
			answer+= ParamUtil.getString(actionRequest, "question_"+questionId+"_"+k, "").replace(",", ""); //Quito la , de la respuesta del usaurio
		}
	}
   	
	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,代码行数:38,代码来源:FillblankQuestionType.java

示例11: getResults

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
	List<TestAnswer> testAnswers = new ArrayList<TestAnswer>();
	try {
		testAnswers.addAll(TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId));
	} catch (SystemException e) {
		e.printStackTrace();
	}

	//me quedo solo con un array con la solucion
	for(java.util.ListIterator<TestAnswer> itr = testAnswers.listIterator(); itr.hasNext();){
		TestAnswer tanswer = itr.next();
		if(!tanswer.isIsCorrect()) itr.remove();
	}

	List<Long> answersId = new ArrayList<Long>();
	for(int i=0;i<testAnswers.size();i++){
		answersId.add(ParamUtil.getLong(actionRequest, "question_"+questionId+"_"+i+"hidden"));
	}

	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:answersId){
		Element answerXML=SAXReaderUtil.createElement("answer");
		answerXML.addAttribute("id", Long.toString(answer));
		questionXML.add(answerXML);
	}
	return questionXML;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:35,代码来源:DraganddropQuestionType.java

示例12: update

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public LearningActivityTry update(long latId, int score, double position, int plays) throws SystemException, PortalException {

		System.out.println("update: " + latId);
		
		LearningActivityTry lat=learningActivityTryPersistence.fetchByPrimaryKey(latId);
		
		lat.setResult(score);
		
		try {			
			Element resultadoXML=SAXReaderUtil.createElement("result");
			Document resultadoXMLDoc=SAXReaderUtil.createDocument(resultadoXML);
			Element positionXML=SAXReaderUtil.createElement("position");
			positionXML.setText(String.valueOf(position));		
			resultadoXML.add(positionXML);
			Element scoreXML=SAXReaderUtil.createElement("score");
			scoreXML.setText(String.valueOf(score));		
			resultadoXML.add(scoreXML);
			Element playsXML=SAXReaderUtil.createElement("plays");
			playsXML.setText(String.valueOf(plays));		
			resultadoXML.add(playsXML);		
			lat.setTryResultData(resultadoXMLDoc.formattedString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		lat.setEndDate(new Date());
		
		lat = learningActivityTryLocalService.updateLearningActivityTry(lat);
		
		return lat;
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:33,代码来源:LearningActivityTryLocalServiceImpl.java

示例13: generateAssetVocabularyElement

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
private Element generateAssetVocabularyElement(AssetVocabulary vocab) {
	Element vocabElem = SAXReaderUtil.createElement(vocab.getName());
	vocabElem.addAttribute("id", String.valueOf(vocab.getVocabularyId()));
	vocabElem.addAttribute("companyId", String.valueOf(vocab.getCompanyId()));
	vocabElem.addAttribute("groupId", String.valueOf(vocab.getGroupId()));
	return vocabElem;
}
 
开发者ID:rivetlogic,项目名称:hr-portal,代码行数:8,代码来源:WebArticleHelperLocalServiceImpl.java

示例14: generateAssetCategoryElement

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
private Element generateAssetCategoryElement(AssetCategory cat) {
	Element e = SAXReaderUtil.createElement(cat.getName());
	e.addAttribute("id", String.valueOf(cat.getCategoryId()));
	e.addAttribute("companyId", String.valueOf(cat.getCompanyId()));
	e.addAttribute("groupId", String.valueOf(cat.getGroupId()));
	e.addAttribute("vocabularyId", String.valueOf(cat.getVocabularyId()));
	e.addAttribute("parentCategoryId", String.valueOf(cat.getParentCategoryId()));
	return e;
}
 
开发者ID:rivetlogic,项目名称:hr-portal,代码行数:10,代码来源:WebArticleHelperLocalServiceImpl.java

示例15: QuestionTypeRegistry

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public void correct	(ActionRequest actionRequest,ActionResponse actionResponse)	throws Exception {

		long actId=ParamUtil.getLong(actionRequest, "actId");
		long latId=ParamUtil.getLong(actionRequest,"latId" );
		boolean isTablet = ParamUtil.getBoolean(actionRequest,"isTablet" );
		String navigate = ParamUtil.getString(actionRequest, "navigate");
		boolean isPartial = false;
		if (Validator.isNotNull(navigate)) {
			if (Validator.equals(navigate, "backward") || Validator.equals(navigate, "forward")) {
				isPartial = true;
			}
		}

		LearningActivityTry larntry=LearningActivityTryLocalServiceUtil.getLearningActivityTry(latId);

		//Comprobar que el usuario tenga intentos posibles.
		if (larntry.getEndDate() == null){

			long correctanswers=0,penalizedAnswers=0;
			Element resultadosXML=SAXReaderUtil.createElement("results");
			Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

			long[] questionIds = ParamUtil.getLongValues(actionRequest, "question");


			for (long questionId : questionIds) {
				TestQuestion question = TestQuestionLocalServiceUtil.fetchTestQuestion(questionId);
				QuestionType qt = new QuestionTypeRegistry().getQuestionType(question.getQuestionType());
				if(!isPartial){
					if(qt.correct(actionRequest, questionId)>0) {
						correctanswers += qt.correct(actionRequest, questionId) ;
					}else if(question.isPenalize()){
						penalizedAnswers++;
					}
				}
				resultadosXML.add(qt.getResults(actionRequest, questionId));								
			}

			long random = GetterUtil.getLong(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"random"));
			long score=isPartial ? 0 : correctanswers/((random!=0 && random<questionIds.length)?random:questionIds.length);
			if(score < 0)score = 0;
			
			LearningActivityResult learningActivityResult = LearningActivityResultLocalServiceUtil.getByActIdAndUserId(actId, PortalUtil.getUserId(actionRequest));
			long oldResult=-1;
			if(learningActivityResult!=null) oldResult=learningActivityResult.getResult();

			larntry.setTryResultData(resultadosXMLDoc.formattedString());
			if (!isPartial) {
				larntry.setResult(score);
				larntry.setEndDate(new java.util.Date(System.currentTimeMillis()));
			}

			LearningActivityTryLocalServiceUtil.updateLearningActivityTry(larntry);

			actionResponse.setRenderParameters(actionRequest.getParameterMap());

			if (isPartial) {
				actionResponse.setRenderParameter("improve", ParamUtil.getString(actionRequest, "improve", Boolean.FALSE.toString()));
				if(isTablet)actionResponse.setRenderParameter("isTablet", Boolean.toString(true));
				actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/view.jsp");
			} else {
				actionResponse.setRenderParameter("oldResult", Long.toString(oldResult));
				actionResponse.setRenderParameter("correction", Boolean.toString(true));
				if(isTablet)actionResponse.setRenderParameter("isTablet", Boolean.toString(true));
				actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/results.jsp");
			}
		}else{
			actionResponse.setRenderParameters(actionRequest.getParameterMap());
			actionRequest.setAttribute("actId", actId);
			actionResponse.setRenderParameter("jspPage", "/html/execactivity/test/preview.jsp");
		}						

	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:74,代码来源:ExecActivity.java


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