Search in sources :

Example 16 with DateTime

use of org.openntf.domino.DateTime in project org.openntf.domino by OpenNTF.

the class CreateOneMillion method runODA.

@Test
public void runODA() {
    Document doc = null;
    System.out.println("ODA normal\tSetup...");
    Session s = Factory.getSession(SessionType.CURRENT);
    Set<Document> docset = new HashSet<Document>();
    Database db = s.getDatabase("", "OneMillion.nsf", true);
    if (db != null)
        db.remove();
    Database template = s.getDatabase("", "billing.ntf", true);
    db = template.createCopy("", "OneMillion.nsf");
    assertTrue(db.isOpen());
    assertEquals(0, db.getAllDocuments().size());
    long startTime = System.currentTimeMillis();
    System.out.println("ODA normal\tSTART Test");
    for (int i = 1; i <= _Suite.MASS_DOC_COUNT; i++) {
        doc = db.createDocument();
        doc.replaceItemValue("form", "Agent");
        doc.replaceItemValue("UserName", s.createName("TestAgent/MyCompany"));
        doc.replaceItemValue("Subject", String.valueOf(System.nanoTime()));
        assertTrue(doc.save());
        if (i % 5000 == 0) {
            // System.gc();
            docset.add(doc);
            System.out.println("ODA normal\tCreated " + i + " documents so far. Still going... (" + i * 1000 / (System.currentTimeMillis() - startTime) + " docs/sec)");
        }
    }
    assertEquals(_Suite.MASS_DOC_COUNT, db.getAllDocuments().size());
    for (Document d : docset) {
        DateTime dt = d.getCreated();
        d.replaceItemValue("$Created", dt);
        assertTrue(d.save());
    }
    odaTime = (System.currentTimeMillis() - startTime);
    System.out.println("ODA normal\tTest time: " + odaTime + " ms");
}
Also used : Database(org.openntf.domino.Database) Document(org.openntf.domino.Document) DateTime(org.openntf.domino.DateTime) Session(org.openntf.domino.Session) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with DateTime

use of org.openntf.domino.DateTime in project org.openntf.domino by OpenNTF.

the class DEdgeFrameComparator method compareObjects.

@SuppressWarnings({ "unchecked", "rawtypes" })
private int compareObjects(final Object arg0, final Object arg1) {
    int result = 0;
    if (arg0 == null && arg1 == null) {
        result = 0;
    } else if (arg0 == null) {
        return -1;
    } else if (arg1 == null) {
        return 1;
    }
    if (arg0 instanceof Number && arg1 instanceof Number) {
        double d0 = ((Number) arg0).doubleValue();
        double d1 = ((Number) arg1).doubleValue();
        if (d0 > d1) {
            result = 1;
        } else if (d1 > d0) {
            result = -1;
        }
    } else if (arg0 instanceof String && arg1 instanceof String) {
        String s0 = (String) arg0;
        String s1 = (String) arg1;
        if (caseSensitive_) {
            result = s0.compareTo(s1);
        } else {
            result = s0.compareToIgnoreCase(s1);
        }
    } else if (arg0 instanceof Date && arg1 instanceof Date) {
        Date d0 = (Date) arg0;
        Date d1 = (Date) arg1;
        result = d0.compareTo(d1);
    } else if (arg0 instanceof DateTime && arg1 instanceof DateTime) {
        DateTime d0 = (DateTime) arg0;
        DateTime d1 = (DateTime) arg1;
        result = d0.compareTo(d1);
    } else if (arg0 != null && arg1 != null) {
        if (arg0 instanceof Comparable && arg1 instanceof Comparable) {
            result = ((Comparable) arg0).compareTo(arg1);
        }
    }
    return result;
}
Also used : Date(java.util.Date) DateTime(org.openntf.domino.DateTime)

Example 18 with DateTime

use of org.openntf.domino.DateTime in project org.openntf.domino by OpenNTF.

the class DVertexFrameComparator method compareObjects.

@SuppressWarnings("unchecked")
private int compareObjects(final Object arg0, final Object arg1) {
    int result = 0;
    if (arg0 == null && arg1 == null) {
        result = 0;
    } else if (arg0 == null) {
        return -1;
    } else if (arg1 == null) {
        return 1;
    }
    if (arg0 instanceof Number && arg1 instanceof Number) {
        double d0 = ((Number) arg0).doubleValue();
        double d1 = ((Number) arg1).doubleValue();
        if (d0 > d1) {
            result = 1;
        } else if (d1 > d0) {
            result = -1;
        }
    } else if (arg0 instanceof String && arg1 instanceof String) {
        String s0 = (String) arg0;
        String s1 = (String) arg1;
        if (caseSensitive_) {
            result = s0.compareTo(s1);
        } else {
            result = s0.compareToIgnoreCase(s1);
        }
    } else if (arg0 instanceof Date && arg1 instanceof Date) {
        Date d0 = (Date) arg0;
        Date d1 = (Date) arg1;
        result = d0.compareTo(d1);
    } else if (arg0 instanceof DateTime && arg1 instanceof DateTime) {
        DateTime d0 = (DateTime) arg0;
        DateTime d1 = (DateTime) arg1;
        result = d0.compareTo(d1);
    } else if (arg0 != null && arg1 != null) {
        if (arg0 instanceof Comparable && arg1 instanceof Comparable) {
            result = ((Comparable<Object>) arg0).compareTo(arg1);
        }
    }
    return result;
}
Also used : Date(java.util.Date) DateTime(org.openntf.domino.DateTime)

Example 19 with DateTime

use of org.openntf.domino.DateTime in project org.openntf.domino by OpenNTF.

the class ElementComparator method compareProps.

@SuppressWarnings({ "rawtypes", "unchecked" })
private int compareProps(final IDominoElement arg0, final IDominoElement arg1) {
    int result = 0;
    for (IDominoProperties key : dProps_) {
        boolean isInteger = Integer.class.equals(key.getType());
        java.lang.Object v0 = DominoElement.getReflectiveProperty(arg0, key);
        java.lang.Object v1 = DominoElement.getReflectiveProperty(arg1, key);
        if (v0 == null && v1 == null) {
            if (isInteger) {
                v0 = Integer.MAX_VALUE;
                v1 = Integer.MAX_VALUE;
            } else {
                result = 0;
            }
        } else if (v0 == null) {
            if (isInteger) {
                v0 = Integer.MAX_VALUE;
            } else {
                return -1;
            }
        } else if (v1 == null) {
            if (isInteger) {
                v1 = Integer.MAX_VALUE;
            } else {
                return 1;
            }
        }
        if (v0 instanceof Number && v1 instanceof Number) {
            double d0 = ((Number) v0).doubleValue();
            double d1 = ((Number) v1).doubleValue();
            if (d0 > d1) {
                result = 1;
            } else if (d1 > d0) {
                result = -1;
            }
        } else if (v0 instanceof String && v1 instanceof String) {
            String s0 = (String) v0;
            String s1 = (String) v1;
            if (caseSensitive_) {
                result = s0.compareTo(s1);
            } else {
                result = s0.compareToIgnoreCase(s1);
            }
        } else if (v0 instanceof Date && v1 instanceof Date) {
            Date d0 = (Date) v0;
            Date d1 = (Date) v1;
            result = d0.compareTo(d1);
        } else if (v0 instanceof DateTime && v1 instanceof DateTime) {
            DateTime d0 = (DateTime) v0;
            DateTime d1 = (DateTime) v1;
            result = d0.compareTo(d1);
        } else if (v0 != null && v1 != null) {
            if (v1.getClass() == v0.getClass() && Comparable.class.isAssignableFrom(v0.getClass())) {
                result = ((Comparable) v0).compareTo(v1);
            }
        }
        if (result != 0) {
            break;
        }
    }
    if (result == 0) {
        result = ((Comparable) arg0.getId()).compareTo(arg1.getId());
    // if (result == 0) {
    // System.out.println("Element comparator still ended up with match!??!");
    // result = -1;
    // }
    }
    return result;
}
Also used : Date(java.util.Date) DateTime(org.openntf.domino.DateTime)

Aggregations

DateTime (org.openntf.domino.DateTime)19 Date (java.util.Date)8 DocumentCollection (org.openntf.domino.DocumentCollection)4 Item (org.openntf.domino.Item)4 Vector (java.util.Vector)3 Document (org.openntf.domino.Document)3 RichTextItem (org.openntf.domino.RichTextItem)3 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)3 JsonException (com.ibm.commons.util.io.json.JsonException)2 EdgeFrame (com.tinkerpop.frames.EdgeFrame)2 VertexFrame (com.tinkerpop.frames.VertexFrame)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Set (java.util.Set)2 NotesException (lotus.domino.NotesException)2 Database (org.openntf.domino.Database)2 DateRange (org.openntf.domino.DateRange)2 Session (org.openntf.domino.Session)2 NoteCoordinate (org.openntf.domino.big.impl.NoteCoordinate)2 UserAccessException (org.openntf.domino.exceptions.UserAccessException)2