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


Java Database.createDocument方法代码示例

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


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

示例1: onInterval

import lotus.domino.Database; //导入方法依赖的package包/类
/**
 * On interval.
 */
private void onInterval(){
	Session session = null;
	try{
		session = this.openSession();
		Database db = session.getDatabase(StringCache.EMPTY, dbPath());
		Document doc = db.createDocument();
		doc.replaceItemValue(FUNCTION, Const.ON_MESSAGE);
		doc.replaceItemValue(EVENT, Const.ON_INTERVAL);
		Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
		agent.runWithDocumentContext(doc);
	}catch(NotesException n){
		
		LOG.log(Level.SEVERE, null, n);
	}finally{
		this.closeSession(session);
	}
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:21,代码来源:AgentScript.java

示例2: getUserDoc

import lotus.domino.Database; //导入方法依赖的package包/类
/**
 * Gets the user doc.
 *
 * @param session the session
 * @param create the create
 * @return the user doc
 * @throws NotesException the notes exception
 */
private Document getUserDoc(Session session, boolean create) throws NotesException{
	Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
	Document doc = null;

	View users = db.getView(Const.VIEW_USERS);
	View sessions = db.getView(Const.VIEW_SESSIONS);
	doc = users.getDocumentByKey(user.getUserId().trim(),true);
	if(doc == null){
		doc = sessions.getDocumentByKey(user.getSessionId(),true);
	}
	//if we get here... create the doc.
	if(doc==null && create){
		doc = db.createDocument();
	}
	//cleanup
	users.recycle();
	sessions.recycle();

	return doc;
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:29,代码来源:ApplyStatus.java

示例3: saveToDb

import lotus.domino.Database; //导入方法依赖的package包/类
public void saveToDb(Database db) throws NotesException {
	Document pDoc=null;
	
	if(isNew()) {
		pDoc=db.createDocument();
		pDoc.replaceItemValue("Form", "Participant");
	} else {
		pDoc=db.getDocumentByID(getNoteId());
	}
	
	if(isDeleted()) {
		// Might not be able to delete it. So change the form.
		pDoc.replaceItemValue("Form", "Participant_DELETED");
	} else { 
	
		pDoc.replaceItemValue("MainDocId", getMainDocId());
		pDoc.replaceItemValue("Name", getName());
		pDoc.replaceItemValue("LCVFlag", isLcvProvided()?"1":"");
	}
	
	pDoc.computeWithForm(false, false);
	pDoc.save();
	noteId=pDoc.getNoteID();
}
 
开发者ID:sbasegmez,项目名称:Blogged,代码行数:25,代码来源:Participant.java

示例4: onOpenOrClose

import lotus.domino.Database; //导入方法依赖的package包/类
/**
 * On open or close.
 *
 * @param fun the fun
 */
private void onOpenOrClose(String fun){
	Session session = null;
	try{
		session = this.openSession();
		Database db = session.getDatabase(StringCache.EMPTY, dbPath());

		Document doc = db.createDocument();

		IUser user = (IUser) this.args[0];

		doc.replaceItemValue("userId",user.getUserId());
		doc.replaceItemValue("sessionId",user.getSessionId());
		doc.replaceItemValue("host",user.getHost());
		doc.replaceItemValue("status",user.getStatus());
		doc.replaceItemValue("uris",ColUtils.toVector(user.getUris()));
		doc.replaceItemValue(FUNCTION, fun);

		RichTextItem item = doc.createRichTextItem("Body");
		item.appendText(JSONUtils.toJson(user));
		doc.replaceItemValue("Form", user.getClass().getName());

		Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
		agent.runWithDocumentContext(doc);


	}catch(NotesException n){
		
		LOG.log(Level.SEVERE, null, n);
	}finally{
		this.closeSession(session);
	}

}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:39,代码来源:AgentScript.java

示例5: onMessage

import lotus.domino.Database; //导入方法依赖的package包/类
/**
 * On message.
 */
private void onMessage(){
	Session session = null;
	try{
		session = this.openSession();
		Database db = session.getDatabase(StringCache.EMPTY, dbPath());

		Document doc = db.createDocument();

		SocketMessage msg = (SocketMessage) this.args[0];

		doc.replaceItemValue(FUNCTION, Const.ON_MESSAGE);
		doc.replaceItemValue("from", msg.getFrom());
		doc.replaceItemValue("to", msg.getTo());
		doc.replaceItemValue("text", msg.getText());
		doc.replaceItemValue(EVENT, Const.ON_MESSAGE);
		doc.replaceItemValue("targets", ColUtils.toVector(msg.getTargets()));

		RichTextItem item = doc.createRichTextItem("Body");
		item.appendText(msg.toJson());
		doc.replaceItemValue("Form", SocketMessage.class.getName());

		Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
		agent.runWithDocumentContext(doc);



	}catch(NotesException n){
		
		LOG.log(Level.SEVERE, null, n);
	}finally{
		this.closeSession(session);
	}
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:37,代码来源:AgentScript.java

示例6: getStoreDoc

import lotus.domino.Database; //导入方法依赖的package包/类
private Document getStoreDoc() {
	Database database=ExtLibUtil.getCurrentDatabase();
			
	Document doc=null;
	View view=null;

	try {
		view=database.getView("tokenstores");
		String serverName=database.getServer();
		
		doc=view.getDocumentByKey(serverName, true);
		
		if(doc==null) {
			doc=database.createDocument();
			doc.replaceItemValue("Form", "tokenstore");
			doc.replaceItemValue("ServerName", serverName);
			doc.computeWithForm(false, false);
			doc.save();
		}
		
	} catch (NotesException e) {
		e.printStackTrace();
	} finally {
		DevelopiUtils.recycleObject(view);
	}

	return doc;
}
 
开发者ID:sbasegmez,项目名称:ic14demos,代码行数:29,代码来源:MemoryStore.java

示例7: createUser

import lotus.domino.Database; //导入方法依赖的package包/类
void createUser(Database db, String id, String firstName, String lastName, String city, String state, String email) throws NotesException {
	Document doc = db.createDocument();
	try {
		doc.replaceItemValue("Form","Contact");		
		doc.replaceItemValue("Id",id);		
		doc.replaceItemValue("FirstName",firstName);		
		doc.replaceItemValue("LastName",lastName);		
		doc.replaceItemValue("City",city);		
		doc.replaceItemValue("State",state);		
		doc.replaceItemValue("email",email);		
		doc.save();
	} finally {
		doc.recycle();
	}
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:16,代码来源:DataInitializer.java

示例8: createState

import lotus.domino.Database; //导入方法依赖的package包/类
void createState(Database db, String key, String name) throws NotesException {
	Document doc = db.createDocument();
	try {
		doc.replaceItemValue("Form","State");		
		doc.replaceItemValue("Key",key);		
		doc.replaceItemValue("Name",name);		
		doc.save();
	} finally {
		doc.recycle();
	}
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:12,代码来源:DataInitializer.java

示例9: run

import lotus.domino.Database; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {

	if(TaskRunner.getInstance().isClosing()){
		return;
	}

	//if the message has already been persisted don't process it again.
	if(!msg.isPersisted()){

		Session session = this.openSession();
		try {
			//mark object as persisted so we don't keep persisting.
			msg.setPersisted(true);
			
			Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
			Document doc = db.createDocument();
			doc.replaceItemValue("Form", "fmSocketMessage");
			doc.replaceItemValue("text", msg.getText());
			doc.replaceItemValue("to", msg.getTo());
			doc.replaceItemValue("from", msg.getFrom());
			doc.replaceItemValue("event", StringCache.EMPTY);
			doc.replaceItemValue("durable", String.valueOf(msg.isDurable()));
			doc.replaceItemValue("persisted", String.valueOf(msg.isPersisted()));

			
			this.attach(doc, msg);

			db.recycle();
			doc.recycle();

		} catch (NotesException e) {
			LOG.log(Level.SEVERE,null, e);

		}finally{
			this.closeSession(session);
		}
	}

}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:42,代码来源:QueueMessage.java

示例10: run

import lotus.domino.Database; //导入方法依赖的package包/类
@Override
@Stopwatch
public void run() {
	
	if(TaskRunner.getInstance().isClosing()){
		return;
	}
	
	Session session = this.openSession();
	try {
		Database db = session.getDatabase(StringCache.EMPTY, Const.WEBSOCKET_PATH);
		View view = db.getView(Const.VIEW_SERVER_STATUS);

		//first stamp the document with latest time stamp
		Document doc = view.getDocumentByKey(ServerInfo.getInstance().getServerName(),true);
		if(doc==null){
			doc = db.createDocument();
		}

		//update the server status doc.
		doc.replaceItemValue(Const.FIELD_HOST, ServerInfo.getInstance().getServerName());
		doc.replaceItemValue("updateDtm", db.getParent().createDateTime(new Date()));
		doc.replaceItemValue(Const.FIELD_STATUS, Const.STATUS_ONLINE);
		doc.replaceItemValue("Form", "fmServerStatus");
		doc.save();
		doc.recycle();

		//now check the server we're monitoring make sure its up.
		doc = view.getDocumentByKey(Config.getInstance().getClustermateMonitor(), true);
		if(doc!=null && Const.STATUS_ONLINE.equals(doc.getItemValueString(Const.FIELD_STATUS))){

			//calculate elapsedSeconds minus the thread run interval.
			long elapsedSeconds = DateUtils.getTimeDiffSec(doc.getLastModified().toJavaDate(), new Date()) - Const.CLUSTERMATE_MONITOR_INTERVAL;
			if(elapsedSeconds >= Config.getInstance().getClustermateExpiration()){
				this.setClustermateUsersOffline(db, Config.getInstance().getClustermateMonitor());
			}
		}

	} catch (NotesException e) {
		LOG.log(Level.SEVERE,null,e);

	}finally{
		this.closeSession(session);
	}

}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:47,代码来源:ClustermateMonitor.java

示例11: getFirstMimeEntity

import lotus.domino.Database; //导入方法依赖的package包/类
public MIMEEntity getFirstMimeEntity(boolean ignoreForm) throws NotesException {
	
	if ( _mimeEntity == null ) {

		Database database = _document.getParentDatabase();
		Session session = database.getParent();
		boolean restoreConvertMime = false;
		
		if (session.isConvertMime()) {
			// Do not convert MIME to rich text.
			session.setConvertMIME(false);
			restoreConvertMime = true;
		}
		
		try {
			Item item = _document.getFirstItem(_itemName);
			if (item != null) {
				if (item.getType() == Item.RICHTEXT) {
					if ( ITEM_BODY.equalsIgnoreCase(_itemName) && !ignoreForm) {
						_document.removeItem("$KeepPrivate"); //$NON-NLS-1$
						_document.convertToMIME(lotus.domino.Document.CVT_RT_TO_PLAINTEXT_AND_HTML, 0);
						_mimeEntity = _document.getMIMEEntity(_itemName);
					}
					else {
						_tempDocument = database.createDocument();
						_tempDocument.copyItem(item, ITEM_BODY);	
						_tempDocument.convertToMIME(lotus.domino.Document.CVT_RT_TO_PLAINTEXT_AND_HTML, 0);
						_mimeEntity = _tempDocument.getMIMEEntity(ITEM_BODY);	
					}
				} 
				else if (item.getType() == Item.MIME_PART) {
					_mimeEntity = _document.getMIMEEntity(_itemName);
				}
			}
		}
		finally {
			if (restoreConvertMime) {
				session.setConvertMime(true);
			}
		}
	}

	return _mimeEntity;
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:45,代码来源:MimeEntityHelper.java

示例12: createDiscussionDocument

import lotus.domino.Database; //导入方法依赖的package包/类
void createDiscussionDocument(Database db, Document parent, ArrayList<String> users, int[] pos, int nDoc) throws NotesException, IOException {
	DateTime date = db.getParent().createDateTime(new Date());
	String[] loremIpsum = SampleDataUtil.readLoremIpsum(); 
	for(int j=0; j<nDoc; j++) {
		pos[pos.length-1] = j+1; 
			
		Document doc = db.createDocument();
		try {
			doc.replaceItemValue("Form","Discussion");		
			StringBuilder b = new StringBuilder();
			for(int i=0; i<pos.length; i++) {
				if(i>0) {
					b.append("/");
				}
				b.append(pos[i]);
			}
			int idx = (int)(Math.random()*(loremIpsum.length-1));
			String body = loremIpsum[idx];
			int dot = body.indexOf('.');
			if(dot<0) {dot=body.length()-1;}
			int coma = body.indexOf(',');
			if(coma<0) {coma=body.length()-1;}
			String title = body.substring(0,Math.min(dot,coma));

			// Get a random author
			int x = Math.min((int)(Math.random()*((double)users.size())),users.size());
			String author = users.get(x);
			
			doc.replaceItemValue("Title",title);
			doc.replaceItemValue("Body",body);
			doc.replaceItemValue("Author",author);
			doc.replaceItemValue("Date",date);
			if(parent!=null) {
				doc.makeResponse(parent);
			}
			doc.computeWithForm(false, false);
			doc.save();
	
			if(pos.length<disc_maxDepth) {
				double r = Math.random();
				if(r<=(1.0/(double)pos.length)) {
					int[] newPos = new int[pos.length+1];
					System.arraycopy(pos, 0, newPos, 0, pos.length);
					int n = (int)(Math.random()*5);
					createDiscussionDocument(db, doc, users, newPos, n);
				}
			}
			// Move the date to the day before if requested
			boolean mvd = Math.random()<=0.40;
			if(mvd) {
				// Previous day...
				date.adjustDay(-1);
			}
		} finally {
			doc.recycle();
		}
	}
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:59,代码来源:DataInitializer.java

示例13: createAllType

import lotus.domino.Database; //导入方法依赖的package包/类
void createAllType(Database db, int index) throws NotesException {
	Session session = db.getParent();
	String sIndex = Integer.toString(index);
	Document doc = db.createDocument();
	try {
		doc.replaceItemValue("Form","AllTypes");	
		
		doc.replaceItemValue("fldIcon",index);		
		doc.replaceItemValue("fldText","text_"+sIndex);		
		doc.replaceItemValue("fldNumber",index*100);
		doc.replaceItemValue("fldDate",createDate(session, 2010, 1, index));
		doc.replaceItemValue("fldTime",createTime(session, 5, 1, index));
		doc.replaceItemValue("fldDateTime",createDateTime(session, 2011, 2, index, 8, 9, index));
		doc.replaceItemValue("fldDateTimeRange",createDateTimeRange(session, 2012, 3, index, 8, 9, index));
		doc.replaceItemValue("fldDialogList","dlg_"+sIndex);	
		
		Vector<Object> mx = new Vector<Object>();
		mx.add("text_"+sIndex+"_1");
		mx.add("text_"+sIndex+"_2");
		mx.add("text_"+sIndex+"_3");
		doc.replaceItemValue("fldText2",mx);		
		
		Vector<Object> mn = new Vector<Object>();
		mn.add(index*100+1);
		mn.add(index*100+2);
		mn.add(index*100+3);
		doc.replaceItemValue("fldNumber2",mn);		

		Vector<Object> md = new Vector<Object>();
		md.add(createDate(session, 2010, 1, index));
		md.add(createDate(session, 2010, 2, index));
		md.add(createDate(session, 2010, 3, index));
		doc.replaceItemValue("fldDate2",md);		

		Vector<Object> mt = new Vector<Object>();
		mt.add(createTime(session, 6, 1, index));
		mt.add(createTime(session, 6, 2, index));
		mt.add(createTime(session, 6, 3, index));
		doc.replaceItemValue("fldTime2",mt);		

		Vector<Object> mdt = new Vector<Object>();
		mdt.add(createDateTime(session, 2011, 1, index, 6, 1, index));
		mdt.add(createDateTime(session, 2011, 2, index, 6, 2, index));
		mdt.add(createDateTime(session, 2011, 3, index, 6, 3, index));
		doc.replaceItemValue("fldDateTime2",mdt);		

		if(false) { // DateTime range do not work with multiple values?
			Vector<Object> mrg = new Vector<Object>();
			mrg.add(createDateTimeRange(session, 2012, 2, index, 4, 1, index));
			mrg.add(createDateTimeRange(session, 2012, 3, index, 5, 1, index));
			mrg.add(createDateTimeRange(session, 2012, 4, index, 6, 1, index));
			doc.replaceItemValue("fldDateTimeRange2",mrg);
		}
		
		Vector<Object> mdg = new Vector<Object>();
		mdg.add("dlgx_"+sIndex+"_1");
		mdg.add("dlgx_"+sIndex+"_1");
		mdg.add("dlgx_"+sIndex+"_1");
		doc.replaceItemValue("fldDialogList2",mdg);		

		doc.save();
	} finally {
		doc.recycle();
	}
}
 
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:66,代码来源:DataInitializer.java

示例14: onError

import lotus.domino.Database; //导入方法依赖的package包/类
/**
 * On error.
 */
private void onError(){
	Session session = null;
	try{
		session = this.openSession();
		Database db = session.getDatabase(StringCache.EMPTY, dbPath());

		Document doc = db.createDocument();

		IUser user = (IUser) this.args[0];

		Exception e = (Exception) args[0];

		e.printStackTrace();

		doc.replaceItemValue("error", e.getMessage() );
		doc.replaceItemValue(FUNCTION, Const.ON_ERROR);

		RichTextItem item = doc.createRichTextItem("Body");
		item.appendText(JSONUtils.toJson(user));
		doc.replaceItemValue("Form", user.getClass().getName());


		Agent agent = db.getAgent(StrUtils.rightBack(this.getSource(), "/"));
		agent.runWithDocumentContext(doc);


	}catch(NotesException n){
		
		LOG.log(Level.SEVERE, null, n);
	}finally{
		this.closeSession(session);
	}

}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:38,代码来源:AgentScript.java


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