Search in sources :

Example 11 with DEdge

use of org.openntf.domino.graph2.impl.DEdge in project org.openntf.domino by OpenNTF.

the class JsonSearchAdapter method getJsonProperties.

@Override
public Iterator<String> getJsonProperties() {
    List<String> result = new ArrayList<String>();
    result.add("@id");
    result.add("@type");
    result.add("@editable");
    if (getIncludeDebug()) {
        result.add("@debug");
    }
    Collection<CharSequence> props = getProperties();
    if (props == null) {
        // NoteCoordinate nc = (NoteCoordinate)
        // ((VertexFrame)frame_).asVertex().getId();
        props = new ArrayList<CharSequence>();
        props.addAll(getGetters().keySet());
        if (props == null || props.size() < 5) {
            if (frame_ instanceof DVertexFrame) {
                try {
                    Set<String> raw = ((DVertexFrame) frame_).asVertex().getPropertyKeys();
                    props.addAll(CaseInsensitiveString.toCaseInsensitive(raw));
                } catch (Throwable t) {
                    Throwable cause = t.getCause();
                    if (cause != null) {
                        System.err.println("Exception trying to process a frame of type " + DGraphUtils.findInterface(frame_) + " resulting in a " + cause.getClass().getSimpleName());
                        cause.printStackTrace();
                        try {
                            throw cause;
                        } catch (Throwable e) {
                            e.printStackTrace();
                        }
                    }
                }
            } else if (frame_ instanceof DEdgeFrame) {
            // Set<CharSequence> raw = ((DEdgeFrame)
            // frame_).asMap().keySet();
            // props.addAll(CaseInsensitiveString.toCaseInsensitive(raw));
            }
        }
    }
    for (CharSequence cis : props) {
        result.add(cis.toString());
    }
    Object frame = getFrame();
    if (frame instanceof VertexFrame && getIncludeEdges()) {
        result.add("@edges");
    }
    if (getIncludeActions()) {
        result.add("@actions");
    }
    if (frame instanceof VertexFrame && getIncludeCounts()) {
        for (CaseInsensitiveString key : getCounters().keySet()) {
            result.add("@counts" + key.toString());
        }
    }
    if (frame instanceof VertexFrame) {
        Vertex v = ((VertexFrame) frame).asVertex();
        if (v instanceof DProxyVertex) {
            result.add("@proxyid");
        }
    }
    if (frame instanceof VertexFrame && getLabels() != null) {
        for (CharSequence cis : getLabels()) {
            result.add("#" + cis.toString());
        }
    }
    if (frame instanceof EdgeFrame) {
        result.add("@in");
        result.add("@out");
    }
    if (frame instanceof ViewVertex) {
        result.add("@columninfo");
    }
    if (frame instanceof ViewVertex.Contains) {
        Edge edge = ((ViewVertex.Contains) frame).asEdge();
        if (edge instanceof DEdge) {
            result.addAll(((DEdge) edge).getDelegate().keySet());
        }
    }
    Collection<CharSequence> hideProps = getHideProperties();
    if (hideProps != null && !hideProps.isEmpty()) {
        for (CharSequence cis : hideProps) {
            result.remove(cis.toString());
        }
    }
    return result.iterator();
}
Also used : ViewVertex(org.openntf.domino.graph2.builtin.ViewVertex) DVertex(org.openntf.domino.graph2.impl.DVertex) Vertex(com.tinkerpop.blueprints.Vertex) DbInfoVertex(org.openntf.domino.graph2.builtin.DbInfoVertex) DProxyVertex(org.openntf.domino.graph2.impl.DProxyVertex) DProxyVertex(org.openntf.domino.graph2.impl.DProxyVertex) EdgeFrame(com.tinkerpop.frames.EdgeFrame) DEdgeFrame(org.openntf.domino.graph2.builtin.DEdgeFrame) ArrayList(java.util.ArrayList) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) DVertexFrame(org.openntf.domino.graph2.builtin.DVertexFrame) DVertexFrame(org.openntf.domino.graph2.builtin.DVertexFrame) VertexFrame(com.tinkerpop.frames.VertexFrame) ViewVertex(org.openntf.domino.graph2.builtin.ViewVertex) DEdgeFrame(org.openntf.domino.graph2.builtin.DEdgeFrame) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonObject(com.ibm.commons.util.io.json.JsonObject) DEdge(org.openntf.domino.graph2.impl.DEdge) Edge(com.tinkerpop.blueprints.Edge) DEdge(org.openntf.domino.graph2.impl.DEdge)

Example 12 with DEdge

use of org.openntf.domino.graph2.impl.DEdge in project org.openntf.domino by OpenNTF.

the class FramedEdgeList method toVertexList.

// TODO optimize by building a NoteCoordinateList of the target vertices
public FramedVertexList<?> toVertexList() {
    // System.out.println("TEMP DEBUG converting a FramedEdgeList to a FramedVertexList");
    List<Vertex> vertList = new ArrayList<Vertex>();
    for (Edge edge : list_) {
        if (edge instanceof DEdge) {
            try {
                Vertex other = ((DEdge) edge).getOtherVertex(sourceVertex_);
                vertList.add(other);
            } catch (IllegalStateException ise) {
                System.out.println("WARNING: " + ise.getMessage());
            } catch (Throwable t) {
                t.printStackTrace();
            }
        } else {
        // System.out.println("TEMP DEBUG edge is actually a " + edge.getClass().getName());
        }
    }
    FramedVertexList<?> result = new FramedVertexList<VertexFrame>(this.framedGraph, sourceVertex_, vertList, null);
    return result;
}
Also used : DVertex(org.openntf.domino.graph2.impl.DVertex) Vertex(com.tinkerpop.blueprints.Vertex) ArrayList(java.util.ArrayList) Edge(com.tinkerpop.blueprints.Edge) DEdge(org.openntf.domino.graph2.impl.DEdge) DEdge(org.openntf.domino.graph2.impl.DEdge)

Aggregations

Vertex (com.tinkerpop.blueprints.Vertex)10 DbInfoVertex (org.openntf.domino.graph2.builtin.DbInfoVertex)9 ViewVertex (org.openntf.domino.graph2.builtin.ViewVertex)9 Edge (com.tinkerpop.blueprints.Edge)7 DVertexFrame (org.openntf.domino.graph2.builtin.DVertexFrame)7 DEdge (org.openntf.domino.graph2.impl.DEdge)7 VertexFrame (com.tinkerpop.frames.VertexFrame)6 ArrayList (java.util.ArrayList)6 DVertex (org.openntf.domino.graph2.impl.DVertex)6 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)6 DProxyVertex (org.openntf.domino.graph2.impl.DProxyVertex)5 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)4 JsonObject (com.ibm.commons.util.io.json.JsonObject)4 EdgeFrame (com.tinkerpop.frames.EdgeFrame)4 DEdgeFrame (org.openntf.domino.graph2.builtin.DEdgeFrame)4 List (java.util.List)3 FramedVertexList (org.openntf.domino.graph2.annotations.FramedVertexList)3 CategoryVertex (org.openntf.domino.graph2.builtin.CategoryVertex)3 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2