Search in sources :

Example 1 with JsonFrameAdapter

use of org.openntf.domino.rest.resources.frames.JsonFrameAdapter in project org.openntf.domino by OpenNTF.

the class JsonSearchAdapter method getJsonProperty.

@SuppressWarnings("unlikely-arg-type")
@Override
public Object getJsonProperty(final String paramKey) {
    Object result = null;
    Object frame = getFrame();
    if (frame != null) {
        CaseInsensitiveString key = new CaseInsensitiveString(paramKey);
        if (key.equals("@id")) {
            if (frame instanceof VertexFrame) {
                result = ((VertexFrame) frame).asVertex().getId().toString();
            } else if (frame instanceof EdgeFrame) {
                result = ((EdgeFrame) frame).asEdge().getId().toString();
            }
        } else if (key.equals("@proxyid")) {
            if (frame instanceof VertexFrame) {
                Vertex v = ((VertexFrame) frame).asVertex();
                if (v instanceof DProxyVertex) {
                    result = ((DProxyVertex) v).getProperty(DProxyVertex.PROXY_ITEM, String.class);
                }
            }
        } else if (key.equals("@debug")) {
            Map<String, String> debugMap = new LinkedHashMap<String, String>();
            debugMap.put("frameIdentity", String.valueOf(System.identityHashCode(this)));
            if (frame instanceof VertexFrame) {
                Vertex v = ((VertexFrame) frame).asVertex();
                debugMap.put("vertexIdentity", String.valueOf(System.identityHashCode(v)));
            } else if (frame instanceof EdgeFrame) {
                Edge e = ((EdgeFrame) frame).asEdge();
                debugMap.put("edgeIdentity", String.valueOf(System.identityHashCode(e)));
            }
            result = debugMap;
        } else if (key.equals("@type")) {
            if (frame instanceof VertexFrame) {
                result = type_;
            } else if (frame instanceof EdgeFrame) {
                result = type_;
            }
        } else if (key.equals("@in") && frame instanceof EdgeFrame) {
            if (getInProperties() == null) {
                // why not just make a frame adapter with the vertex?
                // because that's another I/O operation. We already have the
                // information needed to
                DEdge dedge = (DEdge) ((EdgeFrame) frame).asEdge();
                Map<String, String> minProps = new LinkedHashMap<String, String>();
                minProps.put("@id", dedge.getVertexId(Direction.IN).toString());
                Class<?> inType = graph_.getTypeRegistry().getInType(type_);
                if (inType == null) {
                    minProps.put("@type", "Vertex");
                } else {
                    minProps.put("@type", inType.getName());
                }
                result = minProps;
            } else {
                ParamMap inMap = new ParamMap();
                inMap.put(Parameters.PROPS, CaseInsensitiveString.toStrings(getInProperties()));
                if (getIncludeEdges()) {
                    inMap.put(Parameters.EDGES, EMPTY_STRINGS);
                }
                if (getIncludeCounts()) {
                    inMap.put(Parameters.COUNTS, EMPTY_STRINGS);
                }
                Method inMethod = graph_.getTypeRegistry().getIn(type_);
                if (inMethod != null) {
                    try {
                        Object raw = inMethod.invoke(frame, (Object[]) null);
                        if (raw instanceof Term) {
                            result = new JsonSearchAdapter(graph_, (Term) raw, inMap, isCollectionRoute_);
                        } else if (raw instanceof Value) {
                            result = new JsonSearchAdapter(graph_, (Value) raw, inMap, isCollectionRoute_);
                        } else if (raw instanceof RichTextReference) {
                            result = new JsonSearchAdapter(graph_, (RichTextReference) raw, inMap, isCollectionRoute_);
                        } else if (raw instanceof VertexFrame) {
                            result = new JsonFrameAdapter(graph_, (VertexFrame) raw, inMap, isCollectionRoute_);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } else if (key.equals("@out") && frame instanceof EdgeFrame) {
            if (getOutProperties() == null) {
                // why not just make a frame adapter with the vertex?
                // because that's another I/O operation. We already have the
                // information needed to
                DEdge dedge = (DEdge) ((EdgeFrame) frame).asEdge();
                Map<String, String> minProps = new LinkedHashMap<String, String>();
                minProps.put("@id", dedge.getVertexId(Direction.OUT).toString());
                Class<?> outType = graph_.getTypeRegistry().getOutType(type_);
                if (outType == null) {
                    minProps.put("@type", "Vertex");
                } else {
                    minProps.put("@type", outType.getName());
                }
                result = minProps;
            } else {
                ParamMap outMap = new ParamMap();
                outMap.put(Parameters.PROPS, CaseInsensitiveString.toStrings(getOutProperties()));
                if (getIncludeEdges()) {
                    outMap.put(Parameters.EDGES, EMPTY_STRINGS);
                }
                if (getIncludeCounts()) {
                    outMap.put(Parameters.COUNTS, EMPTY_STRINGS);
                }
                Method outMethod = graph_.getTypeRegistry().getOut(type_);
                if (outMethod != null) {
                    try {
                        Object raw = outMethod.invoke(frame, (Object[]) null);
                        if (raw instanceof Term) {
                            result = new JsonSearchAdapter(graph_, (Term) raw, outMap, isCollectionRoute_);
                        } else if (raw instanceof Value) {
                            result = new JsonSearchAdapter(graph_, (Value) raw, outMap, isCollectionRoute_);
                        } else if (raw instanceof RichTextReference) {
                            result = new JsonSearchAdapter(graph_, (RichTextReference) raw, outMap, isCollectionRoute_);
                        } else if (raw instanceof VertexFrame) {
                            result = new JsonFrameAdapter(graph_, (VertexFrame) raw, outMap, isCollectionRoute_);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } else if (key.equals("@edges")) {
            Map<String, Integer> edgeCounts = new LinkedHashMap<String, Integer>();
            Set<CaseInsensitiveString> counterKeys = getCounters().keySet();
            for (CaseInsensitiveString label : counterKeys) {
                Method crystal = getCounters().get(label);
                if (crystal != null) {
                    try {
                        Object raw = crystal.invoke(getFrame(), (Object[]) null);
                        if (raw instanceof Integer) {
                            edgeCounts.put(label.toString(), (Integer) raw);
                        } else {
                        }
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                } else {
                }
            }
            result = edgeCounts;
        } else if (key.equals("@actions")) {
            List<CaseInsensitiveString> actionList = new ArrayList<CaseInsensitiveString>();
            Set<CaseInsensitiveString> actionNames = getActions().keySet();
            for (CaseInsensitiveString name : actionNames) {
                actionList.add(name);
            }
            result = actionList;
        } else if (key.startsWith("@counts")) {
            String label = key.toString().substring("@counts".length());
            Method crystal = getCounters().get(new CaseInsensitiveString(label));
            if (crystal != null) {
                try {
                    Object raw = crystal.invoke(getFrame(), (Object[]) null);
                    if (raw instanceof Integer) {
                        result = raw;
                    } else {
                    }
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            } else {
            }
        } else if (key.equals("@columninfo")) {
            if (frame instanceof ViewVertex) {
                Map<String, String> columnInfo = new LinkedHashMap<String, String>();
                if (frame instanceof ViewVertex) {
                    View view = ((ViewVertex) frame).asView();
                    for (ViewColumn column : view.getColumns()) {
                        String progName = column.getItemName();
                        String title = column.getTitle();
                        columnInfo.put(progName, title);
                    }
                } else {
                    System.err.println("Frame is not a ViewVertex. It is " + DGraphUtils.findInterface(frame));
                }
                return columnInfo;
            }
        } else if (key.equals("@viewinfo")) {
            if (frame instanceof DbInfoVertex) {
                List viewInfo = ((DbInfoVertex) frame).getViewInfo();
                return viewInfo;
            }
        } else if (key.startsWith("#") && frame instanceof VertexFrame) {
            CharSequence label = key.subSequence(1, key.length());
            Method crystal = getIncidences().get(label);
            if (crystal != null) {
                try {
                    result = crystal.invoke(frame, (Object[]) null);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                if (result != null) {
                    if (!(result instanceof Iterable)) {
                        if (result instanceof EdgeFrame) {
                            Vertex v = ((VertexFrame) frame).asVertex();
                            List<Edge> edges = new org.openntf.domino.graph2.impl.DEdgeList((DVertex) v);
                            edges.add(((EdgeFrame) result).asEdge());
                            result = new FramedEdgeList(getGraph(), ((VertexFrame) frame).asVertex(), edges, crystal.getReturnType());
                        }
                    }
                    if (getIncludeVertices()) {
                        if (result instanceof DEdgeList) {
                            result = ((DEdgeList) result).toVertexList();
                        } else if (result instanceof FramedEdgeList) {
                            result = ((FramedEdgeList<?>) result).toVertexList();
                        } else {
                            System.err.println("TEMP DEBUG: Expected a DEdgeList but got a " + result.getClass().getName());
                        }
                    }
                    if (getFilterKeys() != null && !isCollectionRoute_) {
                        List<CharSequence> filterKeys = getFilterKeys();
                        List<CharSequence> filterValues = getFilterValues();
                        Map<CharSequence, Set<CharSequence>> filterMap = new HashMap<CharSequence, Set<CharSequence>>();
                        for (int i = 0; i < filterKeys.size(); i++) {
                            String curkey = filterKeys.get(i).toString();
                            String curvalue = filterValues.get(i).toString();
                            if (Value.REPLICA_KEY.equalsIgnoreCase(curkey)) {
                                Set<CharSequence> replicas = filterMap.get(Value.REPLICA_KEY);
                                if (replicas == null) {
                                    replicas = new HashSet<CharSequence>();
                                    filterMap.put(Value.REPLICA_KEY, replicas);
                                }
                                replicas.add(new CaseInsensitiveString(curvalue));
                            } else if (Value.FORM_KEY.equalsIgnoreCase(curkey)) {
                                Set<CharSequence> forms = filterMap.get(Value.FORM_KEY);
                                if (forms == null) {
                                    forms = new HashSet<CharSequence>();
                                    filterMap.put(Value.FORM_KEY, forms);
                                }
                                forms.add(new CaseInsensitiveString(curvalue));
                            } else if (Value.FIELD_KEY.equalsIgnoreCase(curkey)) {
                                Set<CharSequence> forms = filterMap.get(Value.FIELD_KEY);
                                if (forms == null) {
                                    forms = new HashSet<CharSequence>();
                                    filterMap.put(Value.FIELD_KEY, forms);
                                }
                                forms.add(new CaseInsensitiveString(curvalue));
                            }
                        }
                        if (result instanceof FramedVertexList) {
                            // this should always be the case
                            FramedVertexList fvl = (FramedVertexList) result;
                            List<Vertex> vertList = new ArrayList<Vertex>();
                            FramedVertexList filterList = new FramedVertexList<VertexFrame>(fvl.getGraph(), fvl.getSourceVertex(), vertList, null);
                            for (Object raw : fvl) {
                                if (raw instanceof Value) {
                                    Map hits = ((Value) raw).getHits(filterMap);
                                    if (hits.size() > 0) {
                                        filterList.add((Value) raw);
                                    }
                                } else if (raw instanceof RichTextReference) {
                                    if (((RichTextReference) raw).isFilterMatch(filterMap)) {
                                        filterList.add((RichTextReference) raw);
                                    }
                                }
                            }
                            result = filterList;
                        }
                    }
                    if (getStartsValues() != null) {
                        if (result instanceof DEdgeEntryList) {
                            ((DEdgeEntryList) result).initEntryList(getStartsValues());
                        } else if (result instanceof FramedEdgeList) {
                            ((FramedEdgeList) result).applyFilter("lookup", getStartsValues());
                        }
                    }
                    if (getFilterValues() != null && getFilterKeys() == null) {
                        if (result instanceof DEdgeEntryList) {
                            ((DEdgeEntryList) result).filterEntryList(getFilterValues());
                        } else if (result instanceof FramedEdgeList) {
                            ((FramedEdgeList) result).applyFilter("filter", getFilterValues());
                        }
                    }
                    if (getOrderBys() != null) {
                        if (result instanceof FramedEdgeList) {
                            result = ((FramedEdgeList<?>) result).sortBy(getOrderBys(), getDescending());
                        } else if (result instanceof FramedVertexList) {
                            result = ((FramedVertexList<?>) result).sortBy(getOrderBys(), getDescending());
                        }
                    }
                    if (getStart() >= 0) {
                        if (getCount() > 0) {
                            int end = getStart() + getCount();
                            if (result instanceof FramedEdgeList) {
                                // System.out.println("TEMP DEBUG Sublisting
                                // a FramedEdgeList...");
                                int size = ((FramedEdgeList<?>) result).size();
                                result = ((FramedEdgeList<?>) result).subList(getStart(), (end > size ? size : end));
                            } else if (result instanceof FramedVertexList) {
                                int size = ((FramedVertexList<?>) result).size();
                                result = ((FramedVertexList<?>) result).subList(getStart(), (end > size ? size : end));
                            } else if (result instanceof DEdgeEntryList) {
                                // System.out.println("TEMP DEBUG Sublisting
                                // a DEdgeEntryList...");
                                int size = ((DEdgeEntryList) result).size();
                                result = ((DEdgeEntryList) result).subList(getStart() + 1, (end > size ? size : end));
                            }
                        } else {
                            if (result instanceof FramedEdgeList) {
                                result = ((FramedEdgeList<?>) result).subList(getStart(), ((FramedEdgeList<?>) result).size());
                            } else if (result instanceof FramedVertexList) {
                                result = ((FramedVertexList<?>) result).subList(getStart(), ((FramedVertexList<?>) result).size());
                            } else if (result instanceof DEdgeEntryList) {
                                // System.out.println("TEMP DEBUG Sublisting
                                // a DEdgeEntryList...");
                                result = ((DEdgeEntryList) result).subList(getStart() + 1, ((DEdgeEntryList) result).size());
                            }
                        }
                    }
                    if (result instanceof FramedVertexList) {
                        ParamMap listMap = new ParamMap();
                        if (getIncludeEdges()) {
                            listMap.put(Parameters.EDGES, EMPTY_STRINGS);
                        }
                        if (getIncludeCounts()) {
                            listMap.put(Parameters.COUNTS, EMPTY_STRINGS);
                        }
                        listMap.put(Parameters.PROPS, CaseInsensitiveString.toStrings(this.getProperties()));
                        listMap.put(Parameters.HIDEPROPS, CaseInsensitiveString.toStrings(this.getHideProperties()));
                        result = new JsonFrameListAdapter(getGraph(), (FramedVertexList<?>) result, listMap, isCollectionRoute_);
                    }
                }
            } else {
            // NTF actually, this is a perfectly normal outcome.
            }
        } else {
            Method crystal = getGetters().get(key);
            if (crystal != null) {
                try {
                    result = crystal.invoke(frame, (Object[]) null);
                } catch (UserAccessException uae) {
                    throw uae;
                } catch (Throwable t) {
                    if (frame instanceof EdgeFrame) {
                        result = ((EdgeFrame) frame).asEdge().getProperty(paramKey);
                    } else if (frame instanceof VertexFrame) {
                        result = ((VertexFrame) frame).asVertex().getProperty(paramKey);
                    } else {
                        System.err.println("Trying to get property " + paramKey + " from an object " + frame.getClass().getName());
                    }
                }
            } else {
                if (frame instanceof ViewVertex.Contains) {
                    result = ((EdgeFrame) frame).asEdge().getProperty(paramKey);
                } else if (frame instanceof VertexFrame) {
                    result = ((VertexFrame) frame).asVertex().getProperty(paramKey);
                } else if (frame instanceof EdgeFrame) {
                    result = ((EdgeFrame) frame).asEdge().getProperty(paramKey);
                } else {
                    System.err.println("No method found for key " + paramKey);
                }
            }
        }
    } else {
        System.err.println("Unable to get property " + paramKey + " on a null object");
    }
    return result;
}
Also used : ParamMap(org.openntf.domino.rest.service.Parameters.ParamMap) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) LinkedHashMap(java.util.LinkedHashMap) RichTextReference(org.openntf.domino.graph2.builtin.search.RichTextReference) DbInfoVertex(org.openntf.domino.graph2.builtin.DbInfoVertex) FramedEdgeList(org.openntf.domino.graph2.annotations.FramedEdgeList) ArrayList(java.util.ArrayList) DEdgeEntryList(org.openntf.domino.graph2.impl.DEdgeEntryList) DEdgeList(org.openntf.domino.graph2.DEdgeList) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) List(java.util.List) DEdgeList(org.openntf.domino.graph2.DEdgeList) HashSet(java.util.HashSet) DProxyVertex(org.openntf.domino.graph2.impl.DProxyVertex) DVertex(org.openntf.domino.graph2.impl.DVertex) Method(java.lang.reflect.Method) Term(org.openntf.domino.graph2.builtin.search.Term) FramedEdgeList(org.openntf.domino.graph2.annotations.FramedEdgeList) UserAccessException(org.openntf.domino.exceptions.UserAccessException) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Value(org.openntf.domino.graph2.builtin.search.Value) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonObject(com.ibm.commons.util.io.json.JsonObject) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ParamMap(org.openntf.domino.rest.service.Parameters.ParamMap) 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) HashSet(java.util.HashSet) Set(java.util.Set) JsonFrameAdapter(org.openntf.domino.rest.resources.frames.JsonFrameAdapter) ViewColumn(org.openntf.domino.ViewColumn) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) JsonFrameListAdapter(org.openntf.domino.rest.resources.frames.JsonFrameListAdapter) ViewVertex(org.openntf.domino.graph2.builtin.ViewVertex) EdgeFrame(com.tinkerpop.frames.EdgeFrame) DEdgeFrame(org.openntf.domino.graph2.builtin.DEdgeFrame) View(org.openntf.domino.View) UserAccessException(org.openntf.domino.exceptions.UserAccessException) DVertexFrame(org.openntf.domino.graph2.builtin.DVertexFrame) VertexFrame(com.tinkerpop.frames.VertexFrame) DEdgeEntryList(org.openntf.domino.graph2.impl.DEdgeEntryList) DEdge(org.openntf.domino.graph2.impl.DEdge) Edge(com.tinkerpop.blueprints.Edge) DEdge(org.openntf.domino.graph2.impl.DEdge)

Example 2 with JsonFrameAdapter

use of org.openntf.domino.rest.resources.frames.JsonFrameAdapter in project org.openntf.domino by OpenNTF.

the class JsonGraphWriter method outLiteral.

@Override
protected void outLiteral(Object paramObject, final boolean paramBoolean) throws IOException, JsonException {
    // paramObject.getClass().getName()));
    if (paramObject != null) {
        Class<?> objClass = paramObject.getClass();
        IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
        if (adapter != null) {
            paramObject = adapter.toJson(paramObject);
        }
    }
    if (this.getFactory().isNull(paramObject)) {
        outNull();
    // } else if (paramObject instanceof Term) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    // } else if (paramObject instanceof Value) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    // } else if (paramObject instanceof RichTextReference) {
    // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
    // isCollectionRoute_);
    // super.outObject(adapter);
    } else if (paramObject instanceof VertexFrame) {
        JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
        outObject(adapter);
    } else if (paramObject instanceof EdgeFrame) {
        JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
        outObject(adapter);
    } else if (paramObject instanceof Class<?>) {
        String className = ((Class) paramObject).getName();
        outStringLiteral(className);
    } else if (paramObject instanceof RichTextItem) {
        outRichTextItem((RichTextItem) paramObject);
    } else if (paramObject instanceof Enum) {
        String className = ((Enum) paramObject).getClass().getName();
        String enumName = ((Enum) paramObject).name();
        outStringLiteral(className + " " + enumName);
    } else if (paramObject instanceof CharSequence) {
        outStringLiteral(paramObject.toString());
    } else if (paramObject instanceof Set) {
        // System.out.println("TEMP DEBUG Got a set!");
        outArrayLiteral(((Set) paramObject).toArray());
    } else if (this.getFactory().isString(paramObject)) {
        outStringLiteral(this.getFactory().getString(paramObject));
    } else if (this.getFactory().isNumber(paramObject)) {
        outNumberLiteral(this.getFactory().getNumber(paramObject));
    } else if (this.getFactory().isBoolean(paramObject)) {
        outBooleanLiteral(this.getFactory().getBoolean(paramObject));
    } else if (this.getFactory().isObject(paramObject)) {
        outObject(paramObject, paramBoolean);
    } else if (this.getFactory().isArray(paramObject)) {
        outArrayLiteral(paramObject, paramBoolean);
    } else if (paramObject instanceof JsonReference) {
        outReference((JsonReference) paramObject);
    } else if (paramObject instanceof DateTime) {
        DateTime dt = (DateTime) paramObject;
        outDateLiteral_(dt.toJavaDate());
    } else if (paramObject instanceof DateRange) {
        DateRange dt = (DateRange) paramObject;
        outDateRangeLiteral(dt);
    } else if (paramObject instanceof NoteCoordinate) {
        outNoteCoordinate((NoteCoordinate) paramObject);
    } else if (paramObject instanceof Date) {
        outDateLiteral_((Date) paramObject);
    } else {
        outStringLiteral("JsonGenerator cannot process unknown type of " + ((paramObject != null) ? paramObject.getClass().getName() : "<null>"));
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.impl.NoteCoordinate) EdgeFrame(com.tinkerpop.frames.EdgeFrame) Set(java.util.Set) JsonFrameAdapter(org.openntf.domino.rest.resources.frames.JsonFrameAdapter) IJsonWriterAdapter(org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter) DateTime(org.openntf.domino.DateTime) Date(java.util.Date) JsonReference(com.ibm.commons.util.io.json.JsonReference) DateRange(org.openntf.domino.DateRange) VertexFrame(com.tinkerpop.frames.VertexFrame) RichTextItem(org.openntf.domino.RichTextItem)

Example 3 with JsonFrameAdapter

use of org.openntf.domino.rest.resources.frames.JsonFrameAdapter in project org.openntf.domino by OpenNTF.

the class JsonGraphWriter method outObject.

@Override
public void outObject(Object paramObject) throws IOException, JsonException {
    // + (paramObject == null ? "NULL" : paramObject.getClass().getName()));
    try {
        if (paramObject != null) {
            Class<?> objClass = paramObject.getClass();
            IJsonWriterAdapter adapter = factory_.getJsonWriterAdapter(objClass);
            if (adapter != null) {
                paramObject = adapter.toJson(paramObject);
            }
        }
        if (paramObject == null) {
            super.outNull();
        // } else if (paramObject instanceof Term) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Term) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        // } else if (paramObject instanceof Value) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (Value) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        // } else if (paramObject instanceof RichTextReference) {
        // JsonSearchAdapter adapter = new JsonSearchAdapter(graph_, (RichTextReference) paramObject, parameters_,
        // isCollectionRoute_);
        // super.outObject(adapter);
        } else if (paramObject instanceof EdgeFrame) {
            JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (EdgeFrame) paramObject, parameters_, isCollectionRoute_);
            super.outObject(adapter);
        } else if (paramObject instanceof VertexFrame) {
            JsonFrameAdapter adapter = new JsonFrameAdapter(graph_, (VertexFrame) paramObject, parameters_, isCollectionRoute_);
            super.outObject(adapter);
        } else if (paramObject instanceof Class<?>) {
            String className = ((Class<?>) paramObject).getName();
            super.outStringLiteral(className);
        } else if (paramObject instanceof RichTextItem) {
            outRichTextItem((RichTextItem) paramObject);
        } else if (paramObject instanceof Enum) {
            String className = ((Enum<?>) paramObject).getClass().getName();
            String enumName = ((Enum<?>) paramObject).name();
        } else if (paramObject instanceof NoteCoordinate) {
            String nc = ((NoteCoordinate) paramObject).toString();
            super.outStringLiteral(nc);
        } else if (paramObject instanceof org.openntf.domino.impl.View.DominoColumnInfo) {
            String itemName = ((org.openntf.domino.impl.View.DominoColumnInfo) paramObject).getItemName();
            super.outStringLiteral(itemName);
        } else if (paramObject instanceof Set) {
            // System.out.println("TEMP DEBUG outObject received a Set");
            outArrayLiteral(((Set) paramObject).toArray());
        } else if (paramObject instanceof DateTime) {
            outDateLiteral((DateTime) paramObject);
        } else if (paramObject instanceof DateRange) {
            outDateRangeLiteral((DateRange) paramObject);
        } else if (paramObject instanceof NoteCoordinate) {
            outNoteCoordinate((NoteCoordinate) paramObject);
        } else if (paramObject instanceof Throwable) {
            outException((Throwable) paramObject);
        } else {
            // Class<?> clazz = paramObject.getClass();
            // String name = clazz.getName();
            super.outObject(paramObject);
        }
    } catch (UserAccessException uae) {
        throw uae;
    } catch (RuntimeException re) {
        throw re;
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : NoteCoordinate(org.openntf.domino.big.impl.NoteCoordinate) EdgeFrame(com.tinkerpop.frames.EdgeFrame) Set(java.util.Set) JsonFrameAdapter(org.openntf.domino.rest.resources.frames.JsonFrameAdapter) IJsonWriterAdapter(org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter) UserAccessException(org.openntf.domino.exceptions.UserAccessException) DateTime(org.openntf.domino.DateTime) DateRange(org.openntf.domino.DateRange) VertexFrame(com.tinkerpop.frames.VertexFrame) RichTextItem(org.openntf.domino.RichTextItem)

Aggregations

EdgeFrame (com.tinkerpop.frames.EdgeFrame)3 VertexFrame (com.tinkerpop.frames.VertexFrame)3 Set (java.util.Set)3 JsonFrameAdapter (org.openntf.domino.rest.resources.frames.JsonFrameAdapter)3 DateRange (org.openntf.domino.DateRange)2 DateTime (org.openntf.domino.DateTime)2 RichTextItem (org.openntf.domino.RichTextItem)2 NoteCoordinate (org.openntf.domino.big.impl.NoteCoordinate)2 UserAccessException (org.openntf.domino.exceptions.UserAccessException)2 IJsonWriterAdapter (org.openntf.domino.rest.json.JsonGraphFactory.IJsonWriterAdapter)2 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)1 JsonObject (com.ibm.commons.util.io.json.JsonObject)1 JsonReference (com.ibm.commons.util.io.json.JsonReference)1 Edge (com.tinkerpop.blueprints.Edge)1 Vertex (com.tinkerpop.blueprints.Vertex)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1