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


Java Element.addAttribute方法代码示例

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


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

示例1: 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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:18,代码来源:FreetextQuestionType.java

示例2: 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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:24,代码来源:OptionsQuestionType.java

示例3: 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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:21,代码来源:SortableQuestionType.java

示例4: 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;
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:26,代码来源:DraganddropQuestionType.java

示例5: convertHashMapToString

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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: exportQuestionAnswers

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public void exportQuestionAnswers(PortletDataContext context, Element root, long questionId, LearningActivity activity) throws PortalException, SystemException{
	List<TestAnswer> answers=TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
	for(TestAnswer answer:answers){
		String patha = getEntryPath(context, answer);
		Element entryElementa= root.addElement("questionanswer");
		entryElementa.addAttribute("path", patha);
		context.addZipEntry(patha, answer);
		
		//Exportar los ficheros que tiene la descripcion de la respuesta
		ModuleDataHandlerImpl m = new ModuleDataHandlerImpl();
		ExportUtil.descriptionFileParserDescriptionToLar("<root><Description>"+answer.getAnswer()+"</Description></root>", activity.getGroupId(), activity.getModuleId(), context, entryElementa);	
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:15,代码来源:BaseQuestionType.java

示例7: exportXML

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例8: getResults

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例9: getResults

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例10: getResults

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例11: generateAssetVocabularyElement

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例12: generateAssetCategoryElement

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的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

示例13: doExportData

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
protected String doExportData(final PortletDataContext portletDataContext, String portletId,
        PortletPreferences portletPreferences) throws Exception {

    Element rootElement = addExportDataRootElement(portletDataContext);

    if (!portletDataContext.getBooleanParameter(NAMESPACE, "task-records")) {
        return getExportDataRootElementString(rootElement);
    }

    portletDataContext.addPortletPermissions(TimetrackerPortletPermission.RESOURCE_NAME);

    rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId()));

    ActionableDynamicQuery actionableDynamicQuery = _taskRecordLocalService
            .getExportActionableDynamicQuery(portletDataContext);

    long groupId = portletDataContext.getScopeGroupId();

    actionableDynamicQuery.setGroupId(groupId);
    
    actionableDynamicQuery.performActions();

    return getExportDataRootElementString(rootElement);
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:26,代码来源:TimetrackerPortletDataHandler.java

示例14: doExportData

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
protected String doExportData(final PortletDataContext portletDataContext, String portletId,
        PortletPreferences portletPreferences) throws Exception {

    Element rootElement = addExportDataRootElement(portletDataContext);

    if (!portletDataContext.getBooleanParameter(NAMESPACE, "contacts")) {
        return getExportDataRootElementString(rootElement);
    }

    portletDataContext.addPortletPermissions(ContactManagerPortletPermission.RESOURCE_NAME);

    rootElement.addAttribute("group-id", String.valueOf(portletDataContext.getScopeGroupId()));

    ActionableDynamicQuery actionableDynamicQuery = _contactLocalService
            .getExportActionableDynamicQuery(portletDataContext);
    
    long groupId = portletDataContext.getScopeGroupId();

    actionableDynamicQuery.setGroupId(groupId);

    actionableDynamicQuery.performActions();

    return getExportDataRootElementString(rootElement);
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:26,代码来源:ContactManagerPortletDataHandler.java

示例15: addZipEntry

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public String addZipEntry(LearningActivity actividad, Long assetEntryId,PortletDataContext context, Element entryElementLoc)
		throws PortalException, SystemException {
	
	AssetEntry docAsset= AssetEntryLocalServiceUtil.getAssetEntry(assetEntryId);
	
	log.info("mimeType: " + docAsset.getMimeType());
	DLFileEntry docfile=DLFileEntryLocalServiceUtil.getDLFileEntry(docAsset.getClassPK());
	
	log.info("docFile: " + docfile.getFileEntryId());
	String extension = "";
	if(!docfile.getTitle().endsWith(docfile.getExtension()) && docfile.getExtension().equals("")){
		if(docfile.getMimeType().equals("image/jpeg")){
			extension= ".jpg";
		}else if(docfile.getMimeType().equals("image/png")){
			extension= ".png";
		}else if(docfile.getMimeType().equals("video/mpeg")){
			extension= ".mpeg";
		}else if(docfile.getMimeType().equals("application/pdf")){
			extension= ".pdf";
		}else{
			String ext[] = extension.split("/");
			if(ext.length>1){
				extension = ext[1];
			}
		}
	}else if(!docfile.getTitle().endsWith(docfile.getExtension()) && !docfile.getExtension().equals("")){
		extension="."+docfile.getExtension();
	}

	log.info("file Title: " + docfile.getTitle());
	String title = changeSpecialCharacter(docfile.getTitle());
	title += extension;
	log.info("title: " + title);
	
	String pathqu = getEntryPath(context, docfile);
	String pathFile = getFilePath(context, docfile,actividad.getActId());
	Element entryElementfe= entryElementLoc.addElement("dlfileentry");
	entryElementfe.addAttribute("path", pathqu);
	entryElementfe.addAttribute("file", pathFile+title);
	context.addZipEntry(pathqu, docfile);
	
	log.info("pathqu: " + pathqu);
	log.info("pathFile: " + pathFile);

	//Guardar el fichero en el zip.
	InputStream input = DLFileEntryLocalServiceUtil.getFileAsStream(docfile.getUserId(), docfile.getFileEntryId(), docfile.getVersion());

	context.addZipEntry(getFilePath(context, docfile,actividad.getActId())+title, input);
	
	String txt = (actividad.getTypeId() == 2) ? "external":"internal";
	log.info("    - Resource "+ txt + ": " + title);

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


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