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);
  }
 private ObjectAction findAction(final ObjectSpecification specification, final String actionId) {
   final List<ObjectAction> objectActions = specification.getObjectActions(Contributed.INCLUDED);
   for (final ObjectAction objectAction : objectActions) {
     if (objectAction.getIdentifier().toClassAndNameIdentityString().equals(actionId)) {
       return objectAction;
     }
   }
   return null;
 }
示例#3
0
 private static void specificationActionMethods(
     final ObjectSpecification specification, final DebugBuilder debugBuilder) {
   try {
     final List<ObjectAction> userActions =
         specification.getObjectActions(
             ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());
     final List<ObjectAction> explActions =
         specification.getObjectActions(
             ActionType.EXPLORATION, Contributed.INCLUDED, Filters.<ObjectAction>any());
     final List<ObjectAction> prototypeActions =
         specification.getObjectActions(
             ActionType.PROTOTYPE, Contributed.INCLUDED, Filters.<ObjectAction>any());
     final List<ObjectAction> debActions =
         specification.getObjectActions(
             ActionType.DEBUG, Contributed.INCLUDED, Filters.<ObjectAction>any());
     specificationMethods(userActions, explActions, prototypeActions, debActions, debugBuilder);
   } catch (final RuntimeException e) {
     debugBuilder.appendException(e);
   }
 }
 @Programmatic
 @Override
 public Object homePage() {
   final List<ObjectAdapter> serviceAdapters = getPersistenceSession().getServices();
   for (final ObjectAdapter serviceAdapter : serviceAdapters) {
     final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
     final List<ObjectAction> objectActions = serviceSpec.getObjectActions(Contributed.EXCLUDED);
     for (final ObjectAction objectAction : objectActions) {
       final Object homePage = homePageIfUsable(serviceAdapter, objectAction);
       if (homePage != null) {
         return homePage;
       }
     }
   }
   return null;
 }
  /**
   * 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)));
  }