private static void actionDetails( final ObjectAction objectAction, final int indent, final int count, final DebugBuilder debugBuilder) { debugBuilder.appendln( (count + 1) + "." + objectAction.getId() + " (" + objectAction.getClass().getName() + ")"); debugBuilder.indent(); try { if (objectAction.getDescription() != null && !objectAction.getDescription().equals("")) { debugBuilder.appendln("Description", objectAction.getDescription()); } debugBuilder.appendln("ID", objectAction.getId()); debugBuilder.appendln(objectAction.debugData()); debugBuilder.appendln("On type", objectAction.getOnType()); final Class<? extends Facet>[] facets = objectAction.getFacetTypes(); if (facets.length > 0) { debugBuilder.appendln("Facets"); debugBuilder.indent(); for (final Class<? extends Facet> facet : facets) { debugBuilder.appendln(objectAction.getFacet(facet).toString()); } debugBuilder.unindent(); } final ObjectSpecification returnType = objectAction.getReturnType(); debugBuilder.appendln("Returns", returnType == null ? "VOID" : returnType.toString()); final List<ObjectActionParameter> parameters = objectAction.getParameters(); if (parameters.size() == 0) { debugBuilder.appendln("Parameters", "none"); } else { debugBuilder.appendln("Parameters"); debugBuilder.indent(); final List<ObjectActionParameter> p = objectAction.getParameters(); for (int j = 0; j < parameters.size(); j++) { debugBuilder.append(p.get(j).getName()); debugBuilder.append(" ("); debugBuilder.append(parameters.get(j).getSpecification().getFullIdentifier()); debugBuilder.appendln(")"); debugBuilder.indent(); final Class<? extends Facet>[] parameterFacets = p.get(j).getFacetTypes(); for (final Class<? extends Facet> parameterFacet : parameterFacets) { debugBuilder.appendln(p.get(j).getFacet(parameterFacet).toString()); } debugBuilder.unindent(); } debugBuilder.unindent(); } } catch (final RuntimeException e) { debugBuilder.appendException(e); } debugBuilder.unindent(); }
/** * As {@link #graph(ObjectAdapter, AuthenticationSession)}, but appending to the provided {@link * DebugBuilder}. * * @see #graph(ObjectAdapter, AuthenticationSession) */ public static void graph( final ObjectAdapter object, final AuthenticationSession authenticationSession, final DebugBuilder debugBuilder) { simpleObject(object, debugBuilder); debugBuilder.appendln(); debugBuilder.append(object); graph(object, 0, Lists.<ObjectAdapter>newArrayList(), authenticationSession, debugBuilder); }
private static void graph( final ObjectAdapter adapter, final int level, final List<ObjectAdapter> ignoreAdapters, final AuthenticationSession authenticationSession, final DebugBuilder debugBuilder) { if (level > 3) { debugBuilder.appendln("..."); // only go 3 levels? } else { debugBuilder.append("\n"); if (adapter.getSpecification().isParentedOrFreeCollection()) { collectionGraph(adapter, level, ignoreAdapters, authenticationSession, debugBuilder); } else if (adapter.getSpecification().isNotCollection()) { objectGraph(adapter, level, ignoreAdapters, debugBuilder, authenticationSession); } else { debugBuilder.append("??? " + adapter); } } }
private static void objectGraph( final ObjectAdapter adapter, final int level, final List<ObjectAdapter> ignoreAdapters, final DebugBuilder s, final AuthenticationSession authenticationSession) { ignoreAdapters.add(adapter); try { // work through all its fields final List<ObjectAssociation> fields = adapter.getSpecification().getAssociations(Contributed.EXCLUDED); for (int i = 0; i < fields.size(); i++) { final ObjectAssociation field = fields.get(i); final ObjectAdapter obj = field.get(adapter); final String name = field.getId(); graphIndent(level, s); if (field.isVisible(authenticationSession, adapter, where).isVetoed()) { s.append(name + ": (not visible)"); s.append("\n"); } else { if (obj == null) { s.append(name + ": null\n"); /* * } else if (obj.getSpecification().isParseable()) { * s.append(name + ": " + obj.titleString()); * s.append("\n"); */ } else { if (ignoreAdapters.contains(obj)) { s.append(name + ": " + obj + "*\n"); } else { s.append(name + ": " + obj); graph(obj, level + 1, ignoreAdapters, authenticationSession, s); } } } } } catch (final RuntimeException e) { s.appendException(e); } }
private static void collectionGraph( final ObjectAdapter collectionAdapter, final int level, final List<ObjectAdapter> ignoreAdapters, final AuthenticationSession authenticationSession, final DebugBuilder debugBuilder) { if (ignoreAdapters.contains(collectionAdapter)) { debugBuilder.append("*\n"); } else { ignoreAdapters.add(collectionAdapter); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter); for (final ObjectAdapter element : facet.collection(collectionAdapter)) { graphIndent(level, debugBuilder); debugBuilder.append(element); if (ignoreAdapters.contains(element)) { debugBuilder.append("*\n"); } else { graph(element, level + 1, ignoreAdapters, authenticationSession, debugBuilder); } } } }
private static void graphIndent(final int level, final DebugBuilder debugBuilder) { for (int indent = 0; indent < level; indent++) { debugBuilder.append(DebugUtils.indentString(4) + "|"); } debugBuilder.append(DebugUtils.indentString(4) + "+--"); }