@Override public ObjectAdapter[][] getChoices( final ObjectAdapter target, final InteractionInitiatedBy interactionInitiatedBy) { final ObjectAdapter[][] serviceChoices = serviceAction.getChoices(serviceAdapter, interactionInitiatedBy); return removeElementFromArray(serviceChoices, contributeeParam, new ObjectAdapter[][] {}); }
public Consent isProposedArgumentSetValid( final ObjectAdapter contributee, final ObjectAdapter[] proposedArguments, final InteractionInitiatedBy interactionInitiatedBy) { ObjectAdapter[] serviceArguments = argsPlusContributee(contributee, proposedArguments); return serviceAction.isProposedArgumentSetValid( serviceAdapter, serviceArguments, interactionInitiatedBy); }
@Override public Consent isUsable( final ObjectAdapter contributee, final InteractionInitiatedBy interactionInitiatedBy, final Where where) { final UsabilityContext<?> ic = serviceAction.createUsableInteractionContext(serviceAdapter, interactionInitiatedBy, where); ic.putContributee(this.contributeeParam, contributee); return InteractionUtils.isUsableResult(this, ic).createConsent(); }
@Override public ObjectAdapter execute( final ObjectAdapter contributee, final ObjectAdapter[] arguments, final InteractionInitiatedBy interactionInitiatedBy) { // this code also exists in ActionInvocationFacetViaMethod // we need to repeat it here because the target adapter should be the contributee, not the // contributing service. final BulkFacet bulkFacet = getFacet(BulkFacet.class); if (bulkFacet != null) { final ActionInvocationContext actionInvocationContext = getServicesInjector().lookupService(ActionInvocationContext.class); if (actionInvocationContext != null && actionInvocationContext.getInvokedOn() == null) { actionInvocationContext.setInvokedOn(InvokedOn.OBJECT); actionInvocationContext.setDomainObjects( Collections.singletonList(contributee.getObject())); } final Bulk.InteractionContext bulkInteractionContext = getServicesInjector().lookupService(Bulk.InteractionContext.class); if (bulkInteractionContext != null && bulkInteractionContext.getInvokedAs() == null) { bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR); actionInvocationContext.setDomainObjects( Collections.singletonList(contributee.getObject())); } } final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class); final Command command = commandContext != null ? commandContext.getCommand() : null; if (command != null && command.getExecutor() == Executor.USER) { if (command.getTarget() != null) { // already set up by a edit form // don't overwrite } else { command.setTargetClass(CommandUtil.targetClassNameFor(contributee)); command.setTargetAction(CommandUtil.targetActionNameFor(this)); command.setArguments(CommandUtil.argDescriptionFor(this, arguments)); final Bookmark targetBookmark = CommandUtil.bookmarkFor(contributee); command.setTarget(targetBookmark); } } return serviceAction.execute( serviceAdapter, argsPlusContributee(contributee, arguments), interactionInitiatedBy); }
/** * @param contributeeParam - the parameter number which corresponds to the contributee, and so * should be suppressed. */ public ObjectActionContributee( final ObjectAdapter serviceAdapter, final ObjectActionImpl serviceAction, final int contributeeParam, final ObjectSpecification contributeeType, final ObjectMemberDependencies objectMemberDependencies) { super(serviceAction.getFacetedMethod(), objectMemberDependencies); this.serviceAdapter = serviceAdapter; this.serviceAction = serviceAction; this.contributeeType = contributeeType; this.contributeeParam = contributeeParam; // copy over facets from contributed to own. FacetUtil.copyFacets(serviceAction.getFacetedMethod(), facetHolder); // calculate the identifier final Identifier contributorIdentifier = serviceAction.getFacetedMethod().getIdentifier(); final String memberName = contributorIdentifier.getMemberName(); List<String> memberParameterNames = contributorIdentifier.getMemberParameterNames(); identifier = Identifier.actionIdentifier( getOnType().getCorrespondingClass().getName(), memberName, memberParameterNames); }
public synchronized List<ObjectActionParameter> getParameters() { if (this.parameters == null) { final List<ObjectActionParameter> serviceParameters = serviceAction.getParameters(); final List<ObjectActionParameterContributee> contributeeParameters = Lists.newArrayList(); int contributeeParamNum = 0; for (int serviceParamNum = 0; serviceParamNum < serviceParameters.size(); serviceParamNum++) { if (serviceParamNum == contributeeParam) { // skip so is omitted from the Contributed action continue; } final ObjectActionParameterAbstract serviceParameter = (ObjectActionParameterAbstract) serviceParameters.get(serviceParamNum); final ObjectActionParameterContributee contributedParam; if (serviceParameter instanceof ObjectActionParameterParseable) { contributedParam = new ObjectActionParameterParseableContributee( serviceAdapter, serviceAction, serviceParameter, serviceParamNum, contributeeParamNum, this); } else if (serviceParameter instanceof OneToOneActionParameterImpl) { contributedParam = new OneToOneActionParameterContributee( serviceAdapter, serviceAction, serviceParameter, serviceParamNum, contributeeParamNum, this); } else { throw new RuntimeException( "Unknown implementation of ObjectActionParameter; " + serviceParameter.getClass().getName()); } contributeeParameters.add(contributedParam); contributeeParamNum++; } this.parameters = contributeeParameters; } return ObjectExtensions.asListT(parameters, ObjectActionParameter.class); }
@Override public ObjectAdapter[] getDefaults(final ObjectAdapter target) { final ObjectAdapter[] contributorDefaults = serviceAction.getDefaults(serviceAdapter); return removeElementFromArray(contributorDefaults, contributeeParam, new ObjectAdapter[] {}); }
public int getParameterCount() { return serviceAction.getParameterCount() - 1; }