Java Code Examples for lotus.domino.Document#replaceItemValue()
The following examples show how to use
lotus.domino.Document#replaceItemValue() .
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: DelegateProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
/** * Removes a delegate from the calendar profile. * * @param profile * @param delegateName * @throws NotesException */ private void profileRemoveDelegate(Document profile, String delegateName) throws NotesException { Session session = profile.getParentDatabase().getParent(); // Do for each delegate access item for ( int i = 0; i < s_items.length; i++ ) { // Read the item value Vector values = profile.getItemValue(s_items[i]); // Remove this name from the vector for ( int j = 0; j < values.size(); j++ ) { String strName = (String)values.get(j); Name name = session.createName(strName); if ( delegateName.equals(name.getAbbreviated())) { values.remove(j); profile.replaceItemValue(s_items[i], values); break; } } } }
Example 2
Source File: NotesRunner.java From org.openntf.domino with Apache License 2.0 | 6 votes |
public void run2(final Session session) throws NotesException { Database db = session.getDatabase("", "log.nsf"); Document doc = db.createDocument(); Item names = doc.replaceItemValue("Names", "CN=Nathan T Freeman/O=REDPILL"); names.setAuthors(true); doc.replaceItemValue("form", "test"); doc.save(true); String nid = doc.getNoteID(); doc.recycle(); doc = db.getDocumentByID(nid); Vector<Double> numbers = new Vector<Double>(); numbers.add(new Double(1)); numbers.add(new Double(2)); doc.replaceItemValue("Names", numbers); doc.save(true); doc.recycle(); doc = db.getDocumentByID(nid); names = doc.getFirstItem("Names"); System.out.println("Names is " + names.getType() + " with " + names.isNames() + " and " + names.isAuthors() + " and value " + names.getText()); doc.recycle(); db.recycle(); }
Example 3
Source File: BaseJNATestClass.java From domino-jna with Apache License 2.0 | 5 votes |
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 4
Source File: MimeMessageParser.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
private static void writeAddresses(Document document, String itemName, AddressList addresses) throws NotesException { document.removeItem(itemName); if ( addresses != null && addresses.size() > 0 ) { Vector<String> values = new Vector<String>(); for ( int i = 0; i < addresses.size(); i++ ) { Address address = addresses.get(i); values.add(address.toString()); } document.replaceItemValue(itemName, values); } }
Example 5
Source File: JsonMessageParser.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public void fromJson(Document document) throws JsonException { // SPR #DDEY9L6MX5: Add a Form item try { if ( !document.hasItem(FORM_ITEM) ) { document.replaceItemValue(FORM_ITEM, MEMO_FORM); } } catch (NotesException e) { // Ignore exception } JsonFactory factory = new JsonObjectFactory(document); JsonParser.fromJson(factory, _reader); }
Example 6
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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(); } }
Example 7
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
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(); } }
Example 8
Source File: Create200KLotus.java From org.openntf.domino with Apache License 2.0 | 5 votes |
@Override public void run() { try { Document doc = null; System.out.println("START Creation of Documents:" + new Date().toString()); Session s = Factory.getSession(SessionType.CURRENT); Set<Document> docset = new HashSet<Document>(); Database db = s.getDatabase("", "OneMillionLotus.nsf", true); if (!db.isOpen()) { Database db2 = s.getDatabase("", "billing.ntf", true); db = db2.createCopy("", "OneMillionLotus.nsf"); if (!db.isOpen()) db.open(); } for (int i = 1; i < 200000; i++) { doc = db.createDocument(); doc.replaceItemValue("form", "doc"); doc.replaceItemValue("Subject", String.valueOf(System.nanoTime())); doc.save(); doc.recycle(); if (i % 5000 == 0) { System.out.println("Created " + i + " documents so far. Still going..."); } } System.out.println("ENDING Creation of Documents: " + new Date().toString()); } catch (lotus.domino.NotesException e) { System.out.println(e.toString()); } }
Example 9
Source File: DelegateProvider.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
/** * Adds a delegate to the calendar profile. * * @param profile * @param delegate * @throws NotesException */ private void profileAddDelegate(Document profile, Delegate delegate) throws NotesException { Session session = profile.getParentDatabase().getParent(); Name name = session.createName(delegate.getName()); DelegateAccess da = delegate.getAccess(); String appendItems[] = null; if ( da.getWhat() == DelegateAccess.What.CALENDAR ) { if ( da.isCreate() || da.isEdit() || da.isDelete() ) { appendItems = new String[] {READ_CALENDAR_ITEM, WRITE_CALENDAR_ITEM}; } else { appendItems = new String[] {READ_CALENDAR_ITEM}; } } else if ( da.getWhat() == DelegateAccess.What.MAIL ) { if ( da.isEdit() ) { if ( da.isDelete() ) { appendItems = new String[] {WRITE_CALENDAR_ITEM, EDIT_MAIL_ITEM, DELETE_MAIL_ITEM}; } else { appendItems = new String[] {WRITE_CALENDAR_ITEM, EDIT_MAIL_ITEM}; } } else if ( da.isCreate() ) { if ( da.isDelete() ) { appendItems = new String[] {WRITE_CALENDAR_ITEM, WRITE_MAIL_ITEM, DELETE_MAIL_ITEM}; } else { appendItems = new String[] {WRITE_CALENDAR_ITEM, WRITE_MAIL_ITEM}; } } else { appendItems = new String[] {READ_MAIL_ITEM}; } } // Do for each delegate access item if ( appendItems != null ) { for ( int i = 0; i < appendItems.length; i++ ) { // Read the item value Vector values = profile.getItemValue(appendItems[i]); // Add the name to the vector values.add(name.getCanonical()); profile.replaceItemValue(appendItems[i], values); } } }
Example 10
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
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(); } } }
Example 11
Source File: DataInitializer.java From XPagesExtensionLibrary with Apache License 2.0 | 4 votes |
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(); } }
Example 12
Source File: NotesRunner.java From org.openntf.domino with Apache License 2.0 | 4 votes |
public void run1(final Session session) throws NotesException { Long sessId = getLotusId(session); sessionid.set(sessId); Database db = session.getDatabase("", "names.nsf"); System.out.println("Db id:" + getLotusId(db)); Name name = null; int i = 0; try { for (i = 0; i <= 100000; i++) { name = session.createName(UUID.randomUUID().toString()); getLotusId(name); DateTime dt = session.createDateTime(new Date()); getLotusId(dt); DateTime end = session.createDateTime(new Date()); getLotusId(end); DateRange dr = session.createDateRange(dt, end); getLotusId(dr); Document doc = db.createDocument(); getLotusId(doc); Item i1 = doc.replaceItemValue("Foo", dr); getLotusId(i1); Item i2 = doc.replaceItemValue("Bar", dr.getText()); getLotusId(i2); Item i3 = doc.replaceItemValue("Blah", dr.getStartDateTime().getLocalTime()); getLotusId(i3); lotus.domino.ColorObject color = session.createColorObject(); getLotusId(color); color.setRGB(128, 128, 128); Item i4 = doc.replaceItemValue("color", color.getNotesColor()); getLotusId(i4); i1.recycle(); i2.recycle(); i3.recycle(); i4.recycle(); DateTime create = doc.getCreated(); getLotusId(create); @SuppressWarnings("unused") String lc = create.getLocalTime(); // if (i % 10000 == 0) { // System.out.println(Thread.currentThread().getName() + " Name " + i + " is " + name.getCommon() + " " // + "Local time is " + lc + " " + dr.getText()); // } dr.recycle(); doc.recycle(); dt.recycle(); end.recycle(); create.recycle(); color.recycle(); name.recycle(); } } catch (Throwable t) { t.printStackTrace(); System.out.println("Exception at loop point " + i); } }