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


Java SAXReaderUtil.read方法代码示例

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


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

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

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

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

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

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

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

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

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

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

示例10: getEvaluationModel

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

示例11: updateCourse

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

示例12: convertXMLExtraContentToHashMap

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
public HashMap<String, String> convertXMLExtraContentToHashMap(long actId) throws SystemException, PortalException 
{
	HashMap<String, String> hashMap = new HashMap<String, String>();
	String xml ="";

	try {			
		LearningActivity activity = learningActivityPersistence.fetchByPrimaryKey(actId);

		if(activity != null  && !activity.getExtracontent().equals("")){
			xml = activity.getExtracontent();
		}
		else{
			return hashMap;
		}
		Document document;

		document = SAXReaderUtil.read(xml);
		Element rootElement = document.getRootElement();

		for(Element key:rootElement.elements()){

			if(key.getName().contains("document")){
				hashMap.put(key.getName(), key.attributeValue("id") );
			}else{
				hashMap.put(key.getName(), key.getText());
			}

		}

	} catch (DocumentException e) {
	}

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

示例13: isJournalStructureXSD

import com.liferay.portal.kernel.xml.SAXReaderUtil; //导入方法依赖的package包/类
protected boolean isJournalStructureXSD(String xsd) throws Exception {
	Document document = SAXReaderUtil.read(xsd);

	Element rootElement = document.getRootElement();

	Attribute availableLocalesAttribute = rootElement.attribute(
		"available-locales");

	if (availableLocalesAttribute == null) {
		return true;
	}

	return false;
}
 
开发者ID:rivetlogic,项目名称:liferay-evernote,代码行数:15,代码来源:FileSystemImporter.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 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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:63,代码来源:TaskOnlineLearningActivityType.java

示例15: setEvaluationModel

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


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