Java Code Examples for lotus.domino.Document#computeWithForm()

The following examples show how to use lotus.domino.Document#computeWithForm() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseJNATestClass.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
private void createSampleDbDirProfile(Database db) throws NotesException {
	Document docProfile = db.getProfileDocument("DirectoryProfile", null);
	docProfile.replaceItemValue("Form", "DirectoryProfile");
	docProfile.replaceItemValue("Domain", db.getParent().evaluate("@Domain", docProfile));
	docProfile.replaceItemValue("GroupSortDefault", "1");
	docProfile.replaceItemValue("AutoPopulateMembersInterval", "30");
	docProfile.replaceItemValue("SecureInetPasswords", "1");
	docProfile.replaceItemValue("AltLanguageInfoAllowed", "1");
	docProfile.computeWithForm(false, false);
	docProfile.save(true, false);
	docProfile.recycle();
}
 
Example 2
Source File: DataInitializer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
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();
		}
	}
}