Search in sources :

Example 1 with View

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

the class Database method getView.

@Override
public View getView(final Document viewDocument) {
    View result = null;
    if (viewDocument.hasItem("$Index") || viewDocument.hasItem("$Collection") || viewDocument.hasItem("$Collation") || viewDocument.hasItem("$VIEWFORMAT")) {
        String unid = viewDocument.getUniversalID();
        String rawtitles = viewDocument.getItemValue("$Title", String.class);
        String[] titles = PIPE_SPLIT.split(rawtitles);
        for (String title : titles) {
            View chk = getView(title);
            if (chk.getUniversalID().equalsIgnoreCase(unid)) {
                result = chk;
                break;
            }
        }
        if (result == null) {
            System.out.println("TEMP DEBUG Unable to find view object from document " + unid);
        }
    } else {
        Throwable t = new Throwable();
        StackTraceElement[] ste = t.getStackTrace();
        StackTraceElement elem = ste[0];
        String calledFrom1 = elem.getClassName() + "." + elem.getMethodName() + "(" + elem.getFileName() + ":" + elem.getLineNumber() + ")";
        elem = ste[1];
        String calledFrom2 = elem.getClassName() + "." + elem.getMethodName() + "(" + elem.getFileName() + ":" + elem.getLineNumber() + ")";
        elem = ste[2];
        String calledFrom3 = elem.getClassName() + "." + elem.getMethodName() + "(" + elem.getFileName() + ":" + elem.getLineNumber() + ")";
        System.err.println("TEMP DEBUG View Document " + viewDocument.getMetaversalID() + " does not have a $Index item!  " + viewDocument.getItemValueString("$Title") + " called from " + calledFrom1 + ", " + calledFrom2 + ", " + // $NON-NLS-1$
        calledFrom3);
    }
    return result;
}
Also used : View(org.openntf.domino.View)

Example 2 with View

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

the class DocumentSyncHelper method process.

/**
 * Process a specific DocumentCollection.
 *
 * WARNING: Does not currently check that all properties of the SyncHelper have been set up
 *
 * @param coll
 *            DocumentCollection of source documents
 * @since org.openntf.domino 1.0.0
 */
public void process(final DocumentCollection coll) {
    // TODO Check to make sure properties are all set up before running
    Session session = coll.getAncestorSession();
    Database targetDb = session.getDatabase(getTargetServer(), getTargetFilepath());
    View targetView = targetDb.getView(getTargetLookupView());
    Strategy strategy = getStrategy();
    DatabaseTransaction txn = null;
    if (getTransactionRule() == TransactionRule.COMMIT_AT_END) {
        txn = targetDb.startTransaction();
    }
    for (Document source : coll) {
        txn = processDocument(targetDb, targetView, strategy, txn, source);
    }
    if (getTransactionRule() == TransactionRule.COMMIT_AT_END && txn != null) {
        txn.commit();
        txn = null;
    }
}
Also used : Database(org.openntf.domino.Database) DatabaseTransaction(org.openntf.domino.transactions.DatabaseTransaction) Document(org.openntf.domino.Document) View(org.openntf.domino.View) Session(org.openntf.domino.Session)

Example 3 with View

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

the class RichTextDoclink method getView.

/* (non-Javadoc)
	 * @see org.openntf.domino.ext.RichTextDoclink#getView()
	 */
@Override
public View getView() {
    String viewId = getViewUnID();
    if (viewId != null && !viewId.isEmpty()) {
        // Use session.resolve to not run afoul of same-named views
        Database database = getDatabase();
        Session session = getAncestorSession();
        String databaseUrl = database.getURL();
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String url = databaseUrl.substring(0, databaseUrl.length() - "?OpenDatabase".length()) + "/" + viewId + "?OpenView";
        return (View) session.resolve(url);
    }
    return null;
}
Also used : Database(org.openntf.domino.Database) View(org.openntf.domino.View) Session(org.openntf.domino.Session)

Example 4 with View

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

the class IndexDatabase method initIndexDb.

protected View initIndexDb() {
    View indexView = getIndexDb().getView(TERM_VIEW_NAME);
    if (indexView == null) {
        indexView = getIndexDb().createView(TERM_VIEW_NAME, "Form=\"" + TERM_FORM_NAME + "\"");
        for (ViewColumn column : indexView.getColumns()) {
            column.setFormula(TERM_KEY_NAME);
            column.setTitle("Term");
            column.setSorted(true);
            column.setSortDescending(false);
        }
    }
    View dbView = getIndexDb().getView(DB_VIEW_NAME);
    if (dbView == null) {
        dbView = getIndexDb().createView(DB_VIEW_NAME, "Form=\"" + DB_FORM_NAME + "\"");
        for (ViewColumn column : dbView.getColumns()) {
            column.setFormula(DB_KEY_NAME);
            column.setTitle("ID");
            column.setSorted(true);
            column.setSortDescending(false);
        }
        ViewColumn titleColumn = dbView.createColumn();
        titleColumn.setFormula(DB_TITLE_NAME);
        titleColumn.setTitle("TITLE");
    }
    return indexView;
}
Also used : ViewColumn(org.openntf.domino.ViewColumn) View(org.openntf.domino.View)

Example 5 with View

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

the class IndexDatabase method getDbView.

/* (non-Javadoc)
	 * @see org.openntf.domino.big.impl.IIndexDatabase#getDbView()
	 */
@Override
public View getDbView() {
    View result = null;
    result = getIndexDb().getView(DB_VIEW_NAME);
    if (result == null) {
        initIndexDb();
        result = getIndexDb().getView(DB_VIEW_NAME);
    }
    return result;
// if (termView_ == null) {
// initIndexDb();
// termView_ = getIndexDb().getView(DB_VIEW_NAME);
// }
// return termView_;
}
Also used : View(org.openntf.domino.View)

Aggregations

View (org.openntf.domino.View)33 Session (org.openntf.domino.Session)20 Database (org.openntf.domino.Database)19 Document (org.openntf.domino.Document)9 ViewEntry (org.openntf.domino.ViewEntry)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)5 ViewNavigator (org.openntf.domino.ViewNavigator)5 HashMap (java.util.HashMap)4 ViewColumn (org.openntf.domino.ViewColumn)4 Map (java.util.Map)3 Vector (java.util.Vector)3 DocumentCollection (org.openntf.domino.DocumentCollection)3 ViewEntryCollection (org.openntf.domino.ViewEntryCollection)3 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)2 JsonObject (com.ibm.commons.util.io.json.JsonObject)2 Edge (com.tinkerpop.blueprints.Edge)2 Vertex (com.tinkerpop.blueprints.Vertex)2 EdgeFrame (com.tinkerpop.frames.EdgeFrame)2