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


Java Element.setText方法代码示例

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


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

示例1: setExtraContent

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

示例2: setExtraContent

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

示例3: update

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public LearningActivityTry update(long latId, int score, double position, int plays) throws SystemException, PortalException {

		System.out.println("update: " + latId);
		
		LearningActivityTry lat=learningActivityTryPersistence.fetchByPrimaryKey(latId);
		
		lat.setResult(score);
		
		try {			
			Element resultadoXML=SAXReaderUtil.createElement("result");
			Document resultadoXMLDoc=SAXReaderUtil.createDocument(resultadoXML);
			Element positionXML=SAXReaderUtil.createElement("position");
			positionXML.setText(String.valueOf(position));		
			resultadoXML.add(positionXML);
			Element scoreXML=SAXReaderUtil.createElement("score");
			scoreXML.setText(String.valueOf(score));		
			resultadoXML.add(scoreXML);
			Element playsXML=SAXReaderUtil.createElement("plays");
			playsXML.setText(String.valueOf(plays));		
			resultadoXML.add(playsXML);		
			lat.setTryResultData(resultadoXMLDoc.formattedString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		lat.setEndDate(new Date());
		
		lat = learningActivityTryLocalService.updateLearningActivityTry(lat);
		
		return lat;
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:33,代码来源:LearningActivityTryLocalServiceImpl.java

示例4: setExtraContent

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

示例5: createLearningActivityTry

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@JSONWebService
	public LearningActivityTry createLearningActivityTry(long actId,long userId, int score, double position, int plays) throws SystemException, PortalException
	{
		User user=this.getUser();
		if(user.getUserId()==userId)
		{
		LearningActivityTry lat=learningActivityTryPersistence.create(counterLocalService.increment(
				LearningActivityTry.class.getName()));
		lat.setActId(actId);
		lat.setUserId(userId);
		java.util.Date today=new java.util.Date(System.currentTimeMillis());
		lat.setStartDate(today);
		lat.setResult(score);
		
		try {			
			Element resultadoXML=SAXReaderUtil.createElement("result");
			Document resultadoXMLDoc=SAXReaderUtil.createDocument(resultadoXML);
			Element positionXML=SAXReaderUtil.createElement("position");
			positionXML.setText(String.valueOf(position));		
			resultadoXML.add(positionXML);
			Element scoreXML=SAXReaderUtil.createElement("score");
			scoreXML.setText(String.valueOf(score));		
			resultadoXML.add(scoreXML);
			Element playsXML=SAXReaderUtil.createElement("plays");
			playsXML.setText(String.valueOf(plays));		
			resultadoXML.add(playsXML);		
			lat.setTryResultData(resultadoXMLDoc.formattedString());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		lat.setEndDate(new java.util.Date(System.currentTimeMillis()));
		
//		learningActivityTryPersistence.update(lat, true);
		learningActivityTryLocalService.updateLearningActivityTry(lat);
		
		ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
		
		if(serviceContext!=null){
			courseResultLocalService.softInitializeByGroupIdAndUserId(serviceContext.getScopeGroupId(), serviceContext.getUserId());
		}
		
		//auditing
		if(serviceContext!=null){
			AuditingLogFactory.audit(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), LearningActivityTry.class.getName(), 
				actId, serviceContext.getUserId(), AuditConstants.ADD, null);
		}else{
			LearningActivity la = learningActivityPersistence.fetchByPrimaryKey(actId);
			if(la!=null){
				AuditingLogFactory.audit(la.getCompanyId(), la.getGroupId(), LearningActivityTry.class.getName(), 
						actId, la.getUserId(), AuditConstants.ADD, null);
			}
		}
		
		return lat;
		}
		return null;
	}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:59,代码来源:LearningActivityTryServiceImpl.java

示例6: addfiles

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void addfiles(ActionRequest actionRequest, ActionResponse actionResponse)
		throws Exception {

	ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);

	String jspPage = ParamUtil.getString(actionRequest, "jspPage");
	long actId = ParamUtil.getLong(actionRequest, "resId", 0);
	String description = request.getParameter("description");
	String youtubecode=ParamUtil.getString(request,"youtubecode","");
	boolean videoControlEnabled=ParamUtil.getBoolean(request,"videoControl");
	LearningActivity larn = LearningActivityServiceUtil.getLearningActivity(actId);
	String extraContent=larn.getExtracontent();
	Document document = SAXReaderUtil.createDocument();
	Element rootElement = document.addElement("multimediaentry");
	if(extraContent!=null &&!"".equals(extraContent)&&!Validator.isNumber(extraContent))
	{
		document=SAXReaderUtil.read(extraContent);
		rootElement =document.getRootElement();
	}

	if(!"".equals(youtubecode))
	{
		Element video=rootElement.element("video");
		if(video!=null)
		{
			video.detach();
			rootElement.remove(video);
		}
		video = SAXReaderUtil.createElement("video");
		video.setText(youtubecode);		
		rootElement.add(video);
	}
	
	Element videoControl=rootElement.element("video-control");
	if(videoControl!=null)
	{
		videoControl.detach();
		rootElement.remove(videoControl);
	}
	
	videoControl = SAXReaderUtil.createElement("video-control");
	videoControl.setText(String.valueOf(videoControlEnabled));		
	rootElement.add(videoControl);
	
	larn.setExtracontent(document.formattedString());
	larn.setDescription( description,themeDisplay.getLocale());
	//LearningActivityServiceUtil.modLearningActivity(larn, serviceContext);

	LearningActivityServiceUtil.modLearningActivity(larn);
	//auditing
	AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), themeDisplay.getUserId(), AuditConstants.UPDATE, null);
	
	SessionMessages.add(actionRequest, "activity-saved-successfully");
	actionResponse.setRenderParameter("jspPage", jspPage);
	actionResponse.setRenderParameter("actionEditingDetails", "true");	
	actionResponse.setRenderParameter("resId", Long.toString(actId));
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:59,代码来源:ResourceExternalActivity.java

示例7: setActivity

import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public void setActivity(ActionRequest actionRequest,
		ActionResponse actionResponse) throws IOException, NestableException {
	long actId = ParamUtil.getLong(actionRequest, "actId");
	UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
	String text = ParamUtil.getString(uploadRequest, "text");
	ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	User user = UserLocalServiceUtil.getUser(themeDisplay.getUserId());
	boolean isSetTextoEnr =  StringPool.TRUE.equals(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"textoenr"));
	boolean isSetFichero =  StringPool.TRUE.equals(LearningActivityLocalServiceUtil.getExtraContentValue(actId,"fichero"));

	LearningActivity learningActivity = LearningActivityLocalServiceUtil.getLearningActivity(actId);
	LearningActivityTryLocalServiceUtil.getTriesCountByActivityAndUser(actId, user.getUserId());

	if((learningActivity.getTries()!=0)&&(learningActivity.getTries()<=LearningActivityTryLocalServiceUtil.getTriesCountByActivityAndUser(actId, user.getUserId()))) {
		//TODO
		SessionErrors.add(actionRequest, "onlineActivity.max-tries");	
	}
	else {

		//ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

		Element resultadosXML=SAXReaderUtil.createElement("results");
		Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);

		if(isSetFichero) {
			String fileName = uploadRequest.getFileName("fileName");
			File file = uploadRequest.getFile("fileName");
			String mimeType = uploadRequest.getContentType("fileName");
			if (Validator.isNull(fileName)) {
				SessionErrors.add(actionRequest, "onlineActivity.mandatory.file");
				actionRequest.setAttribute("actId", actId);
				actionResponse.setRenderParameter("text", text);
				return;
			}
			if(	file.getName().endsWith(".bat") 
					|| file.getName().endsWith(".com")
					|| file.getName().endsWith(".exe")
					|| file.getName().endsWith(".msi") ){

				SessionErrors.add(actionRequest, "onlineActivity.not.allowed.file.type");
				actionResponse.setRenderParameter("text", text);
				actionRequest.setAttribute("actId", actId);
				return;
			}

			long repositoryId = DLFolderConstants.getDataRepositoryId(themeDisplay.getScopeGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
			long folderId = createDLFolders(user.getUserId(), repositoryId, actionRequest);

			//Subimos el Archivo en la Document Library
			ServiceContext serviceContext= ServiceContextFactory.getInstance( DLFileEntry.class.getName(), actionRequest);
			//Damos permisos al archivo para usuarios de comunidad.
			serviceContext.setAddGroupPermissions(true);
			FileEntry document = DLAppLocalServiceUtil.addFileEntry(
					themeDisplay.getUserId(), repositoryId , folderId , fileName, mimeType, fileName, StringPool.BLANK, StringPool.BLANK, file , serviceContext ) ;

			Element fileXML=SAXReaderUtil.createElement(FILE_XML);
			fileXML.addAttribute("id", Long.toString(document.getFileEntryId()));
			resultadosXML.add(fileXML);
		}

		if(isSetTextoEnr){
			Element richTextXML=SAXReaderUtil.createElement(RICH_TEXT_XML);
			richTextXML.setText(text);
			resultadosXML.add(richTextXML);				
		}
		else {
			Element textXML=SAXReaderUtil.createElement(TEXT_XML);
			textXML.setText(text);
			resultadosXML.add(textXML);				
		}

		LearningActivityTry learningActivityTry =  LearningActivityTryLocalServiceUtil.createLearningActivityTry(actId,ServiceContextFactory.getInstance(actionRequest));
		learningActivityTry.setTryResultData(resultadosXMLDoc.formattedString());	
		//learningActivityTry.setEndDate(new Date());
		//learningActivityTry.setResult(0);
		LearningActivityTryLocalServiceUtil.updateLearningActivityTry(learningActivityTry);
		SessionMessages.add(actionRequest, "onlinetaskactivity.updating");
	}

}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:81,代码来源:OnlineActivity.java


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