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);
}
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);
}
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_;
}
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);
}
}
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();
}
}
Aggregations