Search in sources :

Example 1 with Item

use of lotus.domino.Item in project org.openntf.domino by OpenNTF.

the class NotesRunner method run1.

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);
    }
}
Also used : Document(lotus.domino.Document) DateTime(lotus.domino.DateTime) Date(java.util.Date) Name(lotus.domino.Name) Item(lotus.domino.Item) DateRange(lotus.domino.DateRange) Database(lotus.domino.Database)

Example 2 with Item

use of lotus.domino.Item in project org.openntf.domino by OpenNTF.

the class NotesRunner method run2.

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();
}
Also used : Item(lotus.domino.Item) Database(lotus.domino.Database) Document(lotus.domino.Document) Vector(java.util.Vector)

Example 3 with Item

use of lotus.domino.Item in project org.openntf.domino by OpenNTF.

the class DominoRunner method run.

@Override
public void run() {
    try {
        System.out.println("Starting NotesRunner");
        Session session = NotesFactory.createSession();
        sessionid.set(getLotusId(session));
        Database db = session.getDatabase("", "log.nsf");
        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);
                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();
                if (name != null)
                    name.recycle();
            }
        } catch (Throwable t) {
            t.printStackTrace();
            System.out.println("Exception at loop point " + i);
        }
        session.recycle();
    } catch (Throwable t) {
        t.printStackTrace();
    }
    System.out.println("FINI!");
}
Also used : Document(lotus.domino.Document) DateTime(lotus.domino.DateTime) Date(java.util.Date) Name(lotus.domino.Name) Item(lotus.domino.Item) DateRange(lotus.domino.DateRange) Database(lotus.domino.Database) Session(lotus.domino.Session)

Aggregations

Database (lotus.domino.Database)3 Document (lotus.domino.Document)3 Item (lotus.domino.Item)3 Date (java.util.Date)2 DateRange (lotus.domino.DateRange)2 DateTime (lotus.domino.DateTime)2 Name (lotus.domino.Name)2 Vector (java.util.Vector)1 Session (lotus.domino.Session)1