Search in sources :

Example 1 with ViewEntryCoordinate

use of org.openntf.domino.big.ViewEntryCoordinate in project org.openntf.domino by OpenNTF.

the class DElementStore method findElementDelegate.

// @Override
@Override
public Object findElementDelegate(final Object delegateKey) throws IllegalStateException, IllegalArgumentException {
    Object result = null;
    Object del = null;
    del = getStoreDelegate();
    if (isProxied()) {
        // System.out.println("TEMP DEBUG Retrieving from proxied store for key " + String.valueOf(delegateKey));
        NoteCoordinate nc = null;
        if (delegateKey instanceof NoteCoordinate) {
            nc = (NoteCoordinate) delegateKey;
        } else if (delegateKey instanceof CharSequence) {
            nc = NoteCoordinate.Utils.getNoteCoordinate((CharSequence) delegateKey);
        }
        if (nc != null) {
            long dbkey = nc.getReplicaLong();
            if (getProxyStoreKey().equals(dbkey)) {
                del = getProxyStoreDelegate();
            }
        }
    }
    if (del instanceof Database) {
        Database db = (Database) del;
        boolean isDeletedDoc;
        db.getAncestorSession().setFixEnable(Fixes.MIME_BLOCK_ITEM_INTERFACE, false);
        if (delegateKey instanceof Serializable) {
            if (delegateKey instanceof ViewEntryCoordinate) {
                result = ((ViewEntryCoordinate) delegateKey).getViewEntry();
            } else if (delegateKey instanceof NoteCoordinate) {
                String unid = ((NoteCoordinate) delegateKey).getUNID();
                try {
                    result = db.getDocumentWithKey(unid, false);
                } catch (UserAccessException uae) {
                // this is normal and acceptable. Don't report.
                } catch (RuntimeException re) {
                    throw re;
                }
                if (result != null) {
                    if (((Document) result).isDeleted()) {
                        isDeletedDoc = true;
                        result = null;
                    }
                }
            // System.out.println("Retrieved result using NoteCoordinate with unid " + unid);
            } else if (delegateKey instanceof CharSequence) {
                String skey = ((CharSequence) delegateKey).toString();
                if (skey.length() > 50) {
                    String prefix = skey.subSequence(0, 2).toString();
                    String mid = skey.subSequence(2, 50).toString();
                    if ((prefix.equals("EC") || prefix.equals("ED") || prefix.equals("ET") || prefix.equals("EU")) && DominoUtils.isMetaversalId(mid)) {
                        ViewEntryCoordinate vec = ViewEntryCoordinate.Utils.getViewEntryCoordinate(skey);
                        result = vec.getViewEntry();
                    } else if ((prefix.equals("VC") || prefix.equals("VD") || prefix.equals("VT") || prefix.equals("VU")) && DominoUtils.isMetaversalId(mid)) {
                        ViewEntryCoordinate vec = ViewEntryCoordinate.Utils.getViewEntryCoordinate(skey);
                        result = vec.getViewEntry();
                    }
                }
            }
            if (result == null) {
                result = db.getDocumentWithKey((Serializable) delegateKey, false);
                if (result != null) {
                    if (((Document) result).isDeleted()) {
                        isDeletedDoc = true;
                        result = null;
                    }
                }
            }
            if (result != null) {
                // }
                if (isProxied()) {
                    // System.out.println("TEMP DEBUG from findElementDelegate: ElementStore "
                    // + ((Database) getStoreDelegate()).getApiPath() + "is proxied. Setting up proxy on delegate...");
                    result = setupProxy(result, (Serializable) delegateKey);
                } else {
                // System.out.println("TEMP DEBUG ElementStore " + ((Database) getStoreDelegate()).getApiPath() + " is not proxied.");
                }
            }
        } else {
            if (delegateKey != null) {
                System.out.println("WARNING: Unknown delegatekey of type " + delegateKey.getClass().getName() + ". Creating a brand new delegate.");
            }
            // null is a perfectly valid key, since it means we want to let the system assign it.
            result = db.createDocument();
        // throw new IllegalArgumentException("Cannot find a delegate with a key of type "
        // + (delegateKey == null ? "null" : delegateKey.getClass().getName()));
        }
    } else {
        throw new IllegalStateException("ElementStore delegate is not a Database; it's a " + (del == null ? "null" : del.getClass().getName()) + ". We don't handle this case yet.");
    // TODO NTF alternative strategies...
    }
    // }
    return result;
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) Serializable(java.io.Serializable) Document(org.openntf.domino.Document) UserAccessException(org.openntf.domino.exceptions.UserAccessException) ViewEntryCoordinate(org.openntf.domino.big.ViewEntryCoordinate) Database(org.openntf.domino.Database)

Example 2 with ViewEntryCoordinate

use of org.openntf.domino.big.ViewEntryCoordinate in project org.openntf.domino by OpenNTF.

the class DEntryEdge method getVertexId.

@Override
public Object getVertexId(final Direction direction) {
    if (Direction.OUT.equals(direction)) {
        if (outKey_ == null) {
            try {
                ViewEntry entry = (org.openntf.domino.ViewEntry) getDelegate();
                if (entry.isDocument()) {
                    String mid = entry.getDocument().getMetaversalID();
                    setOutId(NoteCoordinate.Utils.getNoteCoordinate(mid));
                } else if (entry.isCategory()) {
                    String entryid = delegateKey_.toString();
                    String mid = "V" + entryid.substring(1);
                    setOutId(ViewEntryCoordinate.Utils.getViewEntryCoordinate(mid));
                } else if (entry.isTotal()) {
                    setOutId("TOTAL");
                // FIXME NTF Implement this please
                } else {
                    Exception e = new UnimplementedException();
                    e.printStackTrace();
                    try {
                        throw e;
                    } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                }
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
    } else if (Direction.IN.equals(direction)) {
        if (inKey_ == null) {
            // NTF only occurs when EntryEdge is manifested by direct request from ID rather than iteration of EdgeEntryList
            ViewEntryCoordinate vec = (ViewEntryCoordinate) delegateKey_;
            String mid = vec.getViewDocument().getMetaversalID();
            setInId(NoteCoordinate.Utils.getNoteCoordinate(mid));
        }
    }
    return super.getVertexId(direction);
}
Also used : ViewEntryCoordinate(org.openntf.domino.big.ViewEntryCoordinate) ViewEntry(org.openntf.domino.ViewEntry) UnimplementedException(org.openntf.domino.exceptions.UnimplementedException) UnimplementedException(org.openntf.domino.exceptions.UnimplementedException)

Example 3 with ViewEntryCoordinate

use of org.openntf.domino.big.ViewEntryCoordinate in project org.openntf.domino by OpenNTF.

the class ViewEntryList method get.

@Override
public ViewEntryCoordinate get(final int arg0) {
    if (navigator_ != null) {
        ViewEntry entry = getNavigator().getNth(arg0);
        ViewEntryCoordinate vec = new org.openntf.domino.big.impl.ViewEntryCoordinate(entry);
        vec.setSourceNav(getNavigator());
        return vec;
    } else {
        ViewEntry entry = getCollection().getNthEntry(arg0);
        ViewEntryCoordinate vec = new org.openntf.domino.big.impl.ViewEntryCoordinate(entry);
        vec.setSourceColl(getCollection());
        return vec;
    }
}
Also used : ViewEntryCoordinate(org.openntf.domino.big.ViewEntryCoordinate) ViewEntry(org.openntf.domino.ViewEntry)

Example 4 with ViewEntryCoordinate

use of org.openntf.domino.big.ViewEntryCoordinate in project org.openntf.domino by OpenNTF.

the class ViewEntryList method contains.

@Override
public boolean contains(final Object arg0) {
    if (arg0 instanceof ViewEntryCoordinate) {
        ViewEntryCoordinate vec = (ViewEntryCoordinate) arg0;
        if (navigator_ != null) {
            ViewEntry current = getNavigator().getCurrent();
            boolean result = getNavigator().gotoPos(vec.getPosition(), org.openntf.domino.ViewNavigator.DEFAULT_SEPARATOR);
            getNavigator().gotoEntry(current);
            return result;
        } else {
        // TODO implement
        }
    }
    if (arg0 instanceof ViewEntry) {
        ViewEntry ve = (ViewEntry) arg0;
        if (navigator_ != null) {
            ViewEntry current = getNavigator().getCurrent();
            boolean result = getNavigator().gotoEntry(ve);
            getNavigator().gotoEntry(current);
            return result;
        } else {
            return getCollection().contains(ve);
        }
    }
    return false;
}
Also used : ViewEntryCoordinate(org.openntf.domino.big.ViewEntryCoordinate) ViewEntry(org.openntf.domino.ViewEntry)

Aggregations

ViewEntryCoordinate (org.openntf.domino.big.ViewEntryCoordinate)4 ViewEntry (org.openntf.domino.ViewEntry)3 Serializable (java.io.Serializable)1 Database (org.openntf.domino.Database)1 Document (org.openntf.domino.Document)1 NoteCoordinate (org.openntf.domino.big.NoteCoordinate)1 UnimplementedException (org.openntf.domino.exceptions.UnimplementedException)1 UserAccessException (org.openntf.domino.exceptions.UserAccessException)1