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