本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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();
}
示例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());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}