private void addContributeeActionsIfAny(
      final ObjectAdapter serviceAdapter, final List<ObjectAction> contributeeActionsToAppendTo) {
    final ObjectSpecification specification = serviceAdapter.getSpecification();
    if (specification == this) {
      return;
    }
    final List<ObjectAction> contributeeActions = Lists.newArrayList();
    final List<ObjectAction> serviceActions =
        specification.getObjectActions(
            ActionType.ALL, Contributed.INCLUDED, Filters.<ObjectAction>any());
    for (final ObjectAction serviceAction : serviceActions) {
      if (isAlwaysHidden(serviceAction)) {
        continue;
      }
      final NotContributedFacet notContributed = serviceAction.getFacet(NotContributedFacet.class);
      if (notContributed != null && notContributed.toActions()) {
        continue;
      }
      if (!(serviceAction instanceof ObjectActionImpl)) {
        continue;
      }
      final ObjectActionImpl contributedAction = (ObjectActionImpl) serviceAction;

      // see if qualifies by inspecting all parameters
      final int contributeeParam = contributeeParameterMatchOf(contributedAction);
      if (contributeeParam != -1) {
        ObjectActionContributee contributeeAction =
            new ObjectActionContributee(
                serviceAdapter, contributedAction, contributeeParam, this, objectMemberContext);
        facetProcessor.processMemberOrder(metadataProperties, contributeeAction);
        contributeeActions.add(contributeeAction);
      }
    }
    contributeeActionsToAppendTo.addAll(contributeeActions);
  }
예제 #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
  Property actionReturnTypeFor(final ObjectAction objectAction) {

    final ObjectSpecification specification = objectAction.getReturnType();
    TypeOfFacet typeOfFacet = objectAction.getFacet(TypeOfFacet.class);
    if (typeOfFacet != null) {
      ObjectSpecification elementSpec = typeOfFacet.valueSpec();
      if (elementSpec != null) {
        return arrayPropertyOf(elementSpec);
      }
    }
    return modelFor(specification);
  }
 private void addIfReturnsSubtype(
     final ObjectAction serviceAction, final List<ObjectAction> matchingActionsToAppendTo) {
   final ObjectSpecification returnType = serviceAction.getReturnType();
   if (returnType == null) {
     return;
   }
   if (returnType.isParentedOrFreeCollection()) {
     final TypeOfFacet facet = serviceAction.getFacet(TypeOfFacet.class);
     if (facet != null) {
       final ObjectSpecification elementType = facet.valueSpec();
       addIfReturnsSubtype(serviceAction, elementType, matchingActionsToAppendTo);
     }
   } else {
     addIfReturnsSubtype(serviceAction, returnType, matchingActionsToAppendTo);
   }
 }
  /**
   * Synthesises {@link ObjectAssociation}s from matching {@link ObjectAction}s of any of the
   * services that accept one parameter
   */
  private List<ObjectAssociation> createContributeeAssociations(
      final ObjectAdapter serviceAdapter) {

    final ObjectSpecification specification = serviceAdapter.getSpecification();
    final List<ObjectAction> serviceActions =
        specification.getObjectActions(
            ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());

    final List<ObjectActionImpl> contributedActions = Lists.newArrayList();
    for (final ObjectAction serviceAction : serviceActions) {
      if (isAlwaysHidden(serviceAction)) {
        continue;
      }
      final NotContributedFacet notContributed = serviceAction.getFacet(NotContributedFacet.class);
      if (notContributed != null && notContributed.toAssociations()) {
        continue;
      }
      if (!serviceAction.hasReturn()) {
        continue;
      }
      if (serviceAction.getParameterCount() != 1
          || contributeeParameterMatchOf(serviceAction) == -1) {
        continue;
      }
      if (!(serviceAction instanceof ObjectActionImpl)) {
        continue;
      }
      if (!serviceAction.getSemantics().isSafeInNature()) {
        continue;
      }
      contributedActions.add((ObjectActionImpl) serviceAction);
    }

    return Lists.newArrayList(
        Iterables.transform(
            contributedActions, createContributeeAssociationFunctor(serviceAdapter, this)));
  }