コード例 #1
0
ファイル: Dump.java プロジェクト: wangyaosnake/isis
  public static void specification(
      final ObjectSpecification specification, final DebugBuilder debugBuilder) {
    try {
      debugBuilder.appendTitle(specification.getClass().getName());
      debugBuilder.appendAsHexln("Hash code", specification.hashCode());
      debugBuilder.appendln("ID", specification.getIdentifier());
      debugBuilder.appendln("Full Name", specification.getFullIdentifier());
      debugBuilder.appendln("Short Name", specification.getShortIdentifier());
      debugBuilder.appendln("Singular Name", specification.getSingularName());
      debugBuilder.appendln("Plural Name", specification.getPluralName());
      debugBuilder.appendln("Description", specification.getDescription());
      debugBuilder.blankLine();
      debugBuilder.appendln("Features", featureList(specification));
      debugBuilder.appendln(
          "Type", specification.isParentedOrFreeCollection() ? "Collection" : "Object");
      if (specification.superclass() != null) {
        debugBuilder.appendln("Superclass", specification.superclass().getFullIdentifier());
      }
      debugBuilder.appendln("Interfaces", specificationNames(specification.interfaces()));
      debugBuilder.appendln("Subclasses", specificationNames(specification.subclasses()));
      debugBuilder.blankLine();
      debugBuilder.appendln("Service", specification.isService());
      debugBuilder.appendln("Encodable", specification.isEncodeable());
      debugBuilder.appendln("Parseable", specification.isParseable());
      debugBuilder.appendln("Aggregated", specification.isValueOrIsParented());
    } catch (final RuntimeException e) {
      debugBuilder.appendException(e);
    }

    if (specification instanceof DebuggableWithTitle) {
      ((DebuggableWithTitle) specification).debugData(debugBuilder);
    }

    debugBuilder.blankLine();

    debugBuilder.appendln("Facets");
    final Class<? extends Facet>[] facetTypes = specification.getFacetTypes();
    debugBuilder.indent();
    if (facetTypes.length == 0) {
      debugBuilder.appendln("none");
    } else {
      for (final Class<? extends Facet> type : facetTypes) {
        final Facet facet = specification.getFacet(type);
        debugBuilder.appendln(facet.toString());
      }
    }
    debugBuilder.unindent();
    debugBuilder.blankLine();

    debugBuilder.appendln("Fields");
    debugBuilder.indent();
    specificationFields(specification, debugBuilder);
    debugBuilder.unindent();

    debugBuilder.appendln("Object Actions");
    debugBuilder.indent();
    specificationActionMethods(specification, debugBuilder);
    debugBuilder.unindent();
  }
コード例 #2
0
ファイル: Dump.java プロジェクト: wangyaosnake/isis
  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();
  }
コード例 #3
0
ファイル: Dump.java プロジェクト: wangyaosnake/isis
 private static void appendActionDetails(
     final DebugBuilder debug, final String desc, final List<ObjectAction> actions) {
   debug.appendln(desc);
   debug.indent();
   for (int i = 0; i < actions.size(); i++) {
     actionDetails(actions.get(i), 8, i, debug);
   }
   debug.unindent();
 }
コード例 #4
0
 @Override
 public void debugData(final DebugBuilder debug) {
   debug.blankLine();
   debug.appendln("Title", getFacet(TitleFacet.class));
   final IconFacet iconFacet = getFacet(IconFacet.class);
   if (iconFacet != null) {
     debug.appendln("Icon", iconFacet);
   }
   debug.unindent();
 }
コード例 #5
0
 private void debugList(final DebugBuilder debug, final List<ObjectAdapter> list) {
   debug.indent();
   if (list.size() == 0) {
     debug.appendln("none");
   } else {
     for (final ObjectAdapter adapter : list) {
       debug.appendln(adapter.toString());
     }
   }
   debug.unindent();
 }
コード例 #6
0
 @Override
 public void debugData(final DebugBuilder debug) {
   debug.appendTitle("Domain Objects");
   for (final ObjectSpecId specId : persistedObjects.specifications()) {
     debug.appendln(specId.asString());
     final ObjectStoreInstances instances = instancesFor(specId);
     instances.debugData(debug);
   }
   debug.unindent();
   debug.appendln();
 }
コード例 #7
0
ファイル: Dump.java プロジェクト: wangyaosnake/isis
  private static void specificationFields(
      final ObjectSpecification specification, final DebugBuilder debugBuilder) {
    final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED);
    debugBuilder.appendln("All");
    debugBuilder.indent();
    for (int i = 0; i < fields.size(); i++) {
      debugBuilder.appendln((i + 1) + "." + fields.get(i).getId());
    }
    debugBuilder.unindent();

    final List<ObjectAssociation> fields2 =
        specification.getAssociations(
            Contributed.EXCLUDED, ObjectAssociation.Filters.VISIBLE_AT_LEAST_SOMETIMES);
    debugBuilder.appendln("Static");
    debugBuilder.indent();
    for (int i = 0; i < fields2.size(); i++) {
      debugBuilder.appendln((i + 1) + "." + fields2.get(i).getId());
    }
    debugBuilder.unindent();
    debugBuilder.appendln();

    try {
      if (fields.size() == 0) {
        debugBuilder.appendln("none");
      } else {
        for (int i = 0; i < fields.size(); i++) {

          final ObjectAssociation field = fields.get(i);
          debugBuilder.appendln(
              (i + 1) + "." + field.getId() + "  (" + field.getClass().getName() + ")");

          debugBuilder.indent();
          final String description = field.getDescription();
          if (description != null && !description.equals("")) {
            debugBuilder.appendln("Description", description);
          }
          final String help = field.getHelp();
          if (help != null && !help.equals("")) {
            debugBuilder.appendln(
                "Help",
                help.substring(0, Math.min(30, help.length())) + (help.length() > 30 ? "..." : ""));
          }

          debugBuilder.appendln("ID", field.getIdentifier());
          debugBuilder.appendln("Short ID", field.getId());
          debugBuilder.appendln("Name", field.getName());
          final String type =
              field.isOneToManyAssociation()
                  ? "Collection"
                  : field.isOneToOneAssociation() ? "Object" : "Unknown";
          debugBuilder.appendln("Type", type);
          final ObjectSpecification fieldSpec = field.getSpecification();
          final boolean hasIdentity =
              !(fieldSpec.isParentedOrFreeCollection()
                  || fieldSpec.isParented()
                  || fieldSpec.isValue());
          debugBuilder.appendln("Has identity", hasIdentity);
          debugBuilder.appendln("Spec", fieldSpec.getFullIdentifier());

          debugBuilder.appendln(
              "Flags",
              (field.isAlwaysHidden() ? "" : "Visible ")
                  + (field.isNotPersisted() ? "Not Persisted " : " ")
                  + (field.isMandatory() ? "Mandatory " : ""));

          final Class<? extends Facet>[] facets = field.getFacetTypes();
          if (facets.length > 0) {
            debugBuilder.appendln("Facets");
            debugBuilder.indent();
            boolean none = true;
            for (final Class<? extends Facet> facet : facets) {
              debugBuilder.appendln(field.getFacet(facet).toString());
              none = false;
            }
            if (none) {
              debugBuilder.appendln("none");
            }
            debugBuilder.unindent();
          }

          debugBuilder.appendln(field.debugData());

          debugBuilder.unindent();
        }
      }
    } catch (final RuntimeException e) {
      debugBuilder.appendException(e);
    }
  }