本文整理汇总了Java中com.liferay.portal.kernel.xml.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于com.liferay.portal.kernel.xml包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doImportData
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
@Override
protected PortletPreferences doImportData(PortletDataContext portletDataContext, String portletId,
PortletPreferences portletPreferences, String data) throws Exception {
if (!portletDataContext.getBooleanParameter(NAMESPACE, "task-records")) {
return null;
}
portletDataContext.importPortletPermissions(TimetrackerPortletPermission.RESOURCE_NAME);
Element entriesElement = portletDataContext.getImportDataGroupElement(TaskRecord.class);
List<Element> entryElements = entriesElement.elements();
for (Element entryElement : entryElements) {
StagedModelDataHandlerUtil.importStagedModel(portletDataContext, entryElement);
}
return null;
}
示例2: doImportData
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
@Override
protected PortletPreferences doImportData(PortletDataContext portletDataContext, String portletId,
PortletPreferences portletPreferences, String data) throws Exception {
if (!portletDataContext.getBooleanParameter(NAMESPACE, "contacts")) {
return null;
}
portletDataContext.importPortletPermissions(ContactManagerPortletPermission.RESOURCE_NAME);
Element entriesElement = portletDataContext.getImportDataGroupElement(Contact.class);
List<Element> entryElements = entriesElement.elements();
for (Element entryElement : entryElements) {
StagedModelDataHandlerUtil.importStagedModel(portletDataContext, entryElement);
}
return null;
}
示例3: getResults
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
Object returnObj = null;
try {
Method method = QuestionType.class.getMethod("getResults", ActionRequest.class, long.class);
returnObj = clp.invoke(new MethodHandler(method, actionRequest, questionId));
}
catch (Throwable t) {
t = ClpSerializer.translateThrowable(t);
if (t instanceof RuntimeException) {
throw (RuntimeException)t;
}
else {
throw new RuntimeException(t.getClass().getName() +
" is not a valid exception");
}
}
return ((Element)returnObj);
}
示例4: exportQuestionAnswers
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
public void exportQuestionAnswers(PortletDataContext context, Element root, long questionId, LearningActivity activity) throws PortalException, SystemException{
try {
ClassLoader classLoader = clp.getClassLoader();
Class laTypeClass = Class.forName(LearningActivityType.class.getName(),true, classLoader);
Class laClass = Class.forName(LearningActivity.class.getName(),true, classLoader);
Object learningActivityObj = translateLearningActivity(activity);
Method method = laTypeClass.getMethod("exportQuestionAnswers", PortletDataContext.class, Element.class, long.class, laClass);
clp.invoke(new MethodHandler(method, context, root, questionId, learningActivityObj));
}
catch (Throwable t) {
t = ClpSerializer.translateThrowable(t);
if (t instanceof RuntimeException) {
throw (RuntimeException)t;
}
else {
throw new RuntimeException(t.getClass().getName() +
" is not a valid exception");
}
}
}
示例5: importQuestionAnswers
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
public void importQuestionAnswers(PortletDataContext context, Element entryElement, long questionId, long userId, ServiceContext serviceContext) throws SystemException, PortalException{
try {
ClassLoader classLoader = clp.getClassLoader();
Class laTypeClass = Class.forName(LearningActivityType.class.getName(),true, classLoader);
Method method = laTypeClass.getMethod("importQuestionAnswers", PortletDataContext.class, Element.class, long.class, long.class, ServiceContext.class);
clp.invoke(new MethodHandler(method, context, entryElement, questionId, userId, serviceContext));
}
catch (Throwable t) {
t = ClpSerializer.translateThrowable(t);
if (t instanceof RuntimeException) {
throw (RuntimeException)t;
}
else {
throw new RuntimeException(t.getClass().getName() +
" is not a valid exception");
}
}
}
示例6: importXML
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
public void importXML(long actId, Element question, TestAnswerLocalService testAnswerLocalService) throws SystemException, PortalException {
try {
ClassLoader classLoader = clp.getClassLoader();
Class testAnswerLocalServiceClass = Class.forName(TestAnswerLocalService.class.getName(), true, classLoader);
Method method = QuestionType.class.getMethod("importXML", long.class, Element.class, testAnswerLocalServiceClass);
clp.invoke(new MethodHandler(method, actId, question, testAnswerLocalService));
}
catch (Throwable t) {
t = ClpSerializer.translateThrowable(t);
if (t instanceof RuntimeException) {
throw (RuntimeException)t;
}
else {
throw new RuntimeException(t.getClass().getName() +
" is not a valid exception");
}
}
}
示例7: getResults
import com.liferay.portal.kernel.xml.Element; //导入依赖的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;
}
示例8: getAnswersSelected
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
protected String getAnswersSelected(Document document,long questionId){
String answerGiven = "";
if(document != null){
Iterator<Element> nodeItr = document.getRootElement().elementIterator();
while(nodeItr.hasNext()) {
Element element = nodeItr.next();
if("question".equals(element.getName()) && questionId == Long.valueOf(element.attributeValue("id"))){
Iterator<Element> elementItr = element.elementIterator();
while(elementItr.hasNext()) {
Element elementElement = elementItr.next();
if("answer".equals(elementElement.getName())) {
try {
answerGiven = elementElement.getText();
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
}
}
}
return answerGiven;
}
示例9: getResults
import com.liferay.portal.kernel.xml.Element; //导入依赖的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;
}
示例10: exportXML
import com.liferay.portal.kernel.xml.Element; //导入依赖的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;
}
示例11: getAnswersSelected
import com.liferay.portal.kernel.xml.Element; //导入依赖的package包/类
protected String getAnswersSelected(Document document, long questionId) {
String answer = "";
if(document != null){
Iterator<Element> nodeItr = document.getRootElement().elementIterator();
while(nodeItr.hasNext()) {
Element element = nodeItr.next();
if("question".equals(element.getName()) && questionId == Long.valueOf(element.attributeValue("id"))){
Iterator<Element> elementItr = element.elementIterator();
if(elementItr.hasNext()) {
Element elementElement = elementItr.next();
if("answer".equals(elementElement.getName())) {
try {
answer = elementElement.getText();
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
}
}
}
}
return answer;
}
示例12: 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);
}
示例13: exportXML
import com.liferay.portal.kernel.xml.Element; //导入依赖的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;
}
示例14: 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;
}
示例15: getRequiredActivities
import com.liferay.portal.kernel.xml.Element; //导入依赖的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;
}