Search in sources :

Example 6 with DocumentCollection

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

the class DocumentSyncHelper method processSince.

/**
 * Extended method to process, allowing the developer to define to only process source documents modified since a given Java date
 *
 * @param sourceDb
 *            Database source documents are in
 * @param sinceDate
 *            Date since when documents should have been modified
 * @since org.openntf.domino 1.0.0
 */
public void processSince(final Database sourceDb, final Date sinceDate) {
    DateTime dt = sourceDb.getAncestorSession().createDateTime(sinceDate);
    DocumentCollection sourceCollection = sourceDb.getModifiedDocuments(dt, ModifiedDocClass.DATA);
    process(sourceCollection);
}
Also used : DocumentCollection(org.openntf.domino.DocumentCollection) DateTime(org.openntf.domino.DateTime)

Example 7 with DocumentCollection

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

the class DocumentSyncHelper method processSince.

/**
 * Extended method to process, allowing the developer to define to only process source documents modified since a given Java date
 *
 * @param sourceDb
 *            Database source documents are in
 * @param sinceDate
 *            Date since when documents should have been modified
 * @param formName
 *            String form name to restrict DocumentCollection to
 * @since org.openntf.domino 1.0.0
 */
public void processSince(final Database sourceDb, final Date sinceDate, final String formName) {
    DateTime dt = sourceDb.getAncestorSession().createDateTime(sinceDate);
    DocumentCollection sourceCollection = sourceDb.getModifiedDocuments(dt, ModifiedDocClass.DATA);
    // $NON-NLS-1$ //$NON-NLS-2$
    sourceCollection.FTSearch("[Form] = \"" + formName + "\"");
    process(sourceCollection);
}
Also used : DocumentCollection(org.openntf.domino.DocumentCollection) DateTime(org.openntf.domino.DateTime)

Example 8 with DocumentCollection

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

the class View method checkUnique.

/* (non-Javadoc)
	 * @see org.openntf.domino.ext.View#checkUnique(java.lang.Object, org.openntf.domino.Document)
	 */
@Override
public boolean checkUnique(final Object key, final Document srcDoc) {
    boolean retVal_ = false;
    try {
        DocumentCollection dc = this.getAllDocumentsByKey(key, true);
        for (Document checkDoc : dc) {
            if (null == srcDoc) {
                return false;
            } else {
                if (!checkDoc.getUniversalID().equals(srcDoc.getUniversalID())) {
                    return retVal_;
                }
            }
        }
        retVal_ = true;
    } catch (Exception e) {
        DominoUtils.handleException(e);
    }
    return retVal_;
}
Also used : DocumentCollection(org.openntf.domino.DocumentCollection) Document(org.openntf.domino.Document) InvalidClassException(java.io.InvalidClassException) BackendBridgeSanityCheckException(org.openntf.domino.exceptions.BackendBridgeSanityCheckException) NotesException(lotus.domino.NotesException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 9 with DocumentCollection

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

the class DocumentList method iterator.

@Override
public Iterator<org.openntf.domino.Document> iterator() {
    // a new DocumentCollection from the parent and use the DocumentCollectionIterator because it's 4 times faster
    if (isSorted()) {
        return new DocumentIterator(this);
    } else {
        org.openntf.domino.Database db = getParentDatabase();
        org.openntf.domino.DocumentCollection mergeColl = db.createMergeableDocumentCollection();
        for (int nid : getNids()) {
            mergeColl.merge(nid);
        }
        return new DocumentCollectionIterator(mergeColl);
    }
}
Also used : DocumentCollection(org.openntf.domino.DocumentCollection) Database(org.openntf.domino.Database)

Example 10 with DocumentCollection

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

the class SortedCollectionTest method run.

@Override
public void run() {
    Session session = Factory.getSession(SessionType.CURRENT);
    Database db = session.getDatabase("", "CollTest.nsf");
    DocumentCollection coll = db.getAllDocuments();
    // System.out.println("UNSORTED");
    for (Document doc : coll) {
    // System.out.println(doc.getItemValueString("MainSortValue") + " " + doc.getLastModifiedDate().getTime());
    }
    List<String> criteria = new ArrayList<String>();
    criteria.add("MainSortValue");
    criteria.add("@modifieddate");
    try {
        DocumentSorter sorter = new DocumentSorter(coll, criteria);
        // System.out.println("SORTING...");
        long startTime = System.nanoTime();
        DocumentCollection sortedColl = sorter.sort();
        long endTime = System.nanoTime();
        System.out.println("Completed resort in " + ((endTime - startTime) / 1000000) + "ms");
        // System.out.println("SORTED");
        for (Document doc : sortedColl) {
            System.out.println(doc.getItemValueString("MainSortValue") + " " + doc.getLastModifiedDate().getTime() + " " + Integer.valueOf(doc.getNoteID(), 16));
        }
        DocumentSorter.DocumentData[] dataset = sorter._debugGetDataset();
        for (DocumentSorter.DocumentData data : dataset) {
            StringBuilder sb = new StringBuilder();
            for (Serializable s : data._debugGetValues()) {
                sb.append(s);
                sb.append(',');
            }
            System.out.println(sb.toString());
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) DocumentCollection(org.openntf.domino.DocumentCollection) Document(org.openntf.domino.Document) Database(org.openntf.domino.Database) DocumentSorter(org.openntf.domino.helpers.DocumentSorter) Session(org.openntf.domino.Session)

Aggregations

DocumentCollection (org.openntf.domino.DocumentCollection)23 Database (org.openntf.domino.Database)9 NotesException (lotus.domino.NotesException)8 Document (org.openntf.domino.Document)8 Session (org.openntf.domino.Session)7 OpenNTFNotesException (org.openntf.domino.exceptions.OpenNTFNotesException)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 DateTime (org.openntf.domino.DateTime)4 HashMap (java.util.HashMap)3 Vector (java.util.Vector)3 View (org.openntf.domino.View)3 DocumentSorter (org.openntf.domino.helpers.DocumentSorter)3 Encapsulated (org.openntf.domino.types.Encapsulated)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 Map (java.util.Map)2 Test (org.junit.Test)2 Item (org.openntf.domino.Item)2 NoteCollection (org.openntf.domino.NoteCollection)2