Package org.apache.isis.core.metamodel.spec.feature

Examples of org.apache.isis.core.metamodel.spec.feature.ObjectAction


    public ObjectAdapter[] getArgumentsAsArray() {
      if(this.arguments.size() < this.getActionMemento().getAction().getParameterCount()) {
        primeArgumentModels();
      }
     
        final ObjectAction objectAction = getActionMemento().getAction();
        final ObjectAdapter[] arguments = new ObjectAdapter[objectAction.getParameterCount()];
        for (int i = 0; i < arguments.length; i++) {
            final ScalarModel scalarModel = this.arguments.get(i);
            arguments[i] = scalarModel.getObject();
        }
        return arguments;
View Full Code Here


    /**
     * Bookmarkable if the {@link ObjectAction action} has a {@link BookmarkPolicyFacet bookmark} policy
     * of {@link BookmarkPolicy#AS_ROOT root}, and has safe {@link ObjectAction#getSemantics() semantics}.
     */
    public boolean isBookmarkable() {
        final ObjectAction action = getActionMemento().getAction();
        final BookmarkPolicyFacet bookmarkPolicy = action.getFacet(BookmarkPolicyFacet.class);
        final boolean safeSemantics = action.getSemantics() == ActionSemantics.Of.SAFE;
        return bookmarkPolicy.value() == BookmarkPolicy.AS_ROOT && safeSemantics;
    }
View Full Code Here

    }

    // //////////////////////////////////////
   
    public List<ActionParameterMemento> primeArgumentModels() {
        final ObjectAction objectAction = getActionMemento().getAction();

        final List<ObjectActionParameter> parameters = objectAction.getParameters();
        final List<ActionParameterMemento> mementos = buildParameterMementos(parameters);
        for (final ActionParameterMemento apm : mementos) {
            getArgumentModel(apm);
        }
       
View Full Code Here

                final ObjectSpecification serviceSpec = serviceAdapter.getSpecification();
                if (serviceSpec.isHidden()) {
                    continue;
                }
                final ObjectAdapterMemento serviceAdapterMemento = logicalServiceAction.serviceAdapterMemento;
                final ObjectAction objectAction = logicalServiceAction.objectAction;
                final Builder subMenuItemBuilder = serviceMenuItem.newSubMenuItem(serviceAdapterMemento, objectAction, cssMenuContext);
                if (subMenuItemBuilder == null) {
                    // not visible
                    continue;
                }
View Full Code Here

            final ActionModel actionModel = getActionModel();
           
            final ObjectAdapter[] pendingArguments = actionModel.getArgumentsAsArray();
           
            try {
                final ObjectAction action = actionModel.getActionMemento().getAction();
                final int numParams = action.getParameterCount();
                for (int i = 0; i < numParams; i++) {
                    final ScalarPanelAbstract paramPanel = paramPanels.get(i);
                    if(paramPanel != null) {
                        // this could throw a ConcurrencyException as we may have to reload the
                        // object adapter of the action in order to compute the choices
View Full Code Here

           
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick() {
                final ObjectAction objectAction = actionMemento.getAction();
                final ConcurrencyChecking concurrencyChecking =
                        ConcurrencyChecking.concurrencyCheckingFor(objectAction.getSemantics());

                try {
                    final List<ObjectAdapterMemento> toggleMementosList = model.getToggleMementosList();

                    final Iterable<ObjectAdapter> toggledAdapters =
                            Iterables.transform(toggleMementosList, ObjectAdapterMemento.Functions.fromMemento(concurrencyChecking));
                   
                    final List<Object> domainObjects = Lists.newArrayList(Iterables.transform(toggledAdapters, ObjectAdapter.Functions.getObject()));
                   
                   
                    final Bulk.InteractionContext bulkInteractionContext = Bulk.InteractionContext.current.get();
                    if (bulkInteractionContext != null) {
                        bulkInteractionContext.setInvokedAs(InvokedAs.BULK);
                        bulkInteractionContext.setDomainObjects(domainObjects);
                    }
                   
                    final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
                    final Command command;
                    if (commandContext != null) {
                        command = commandContext.getCommand();
                        command.setExecutor(Executor.USER);
                    } else {
                        command = null;
                    }


                    ObjectAdapter lastReturnedAdapter = null;
                    int i=0;
                    for(final ObjectAdapter adapter : toggledAdapters) {
   
                        int numParameters = objectAction.getParameterCount();
                        if(numParameters != 0) {
                            return;
                        }
                        if (bulkInteractionContext != null) {
                            bulkInteractionContext.setIndex(i++);
                        }
                        lastReturnedAdapter = objectAction.execute(adapter, new ObjectAdapter[]{});
                    }
                   
                    model.clearToggleMementosList();
                    toggleboxColumn.clearToggles();
                    final ActionModel actionModelHint = model.getActionModelHint();
                    if(actionModelHint != null && actionModelHint.getActionMemento().getAction().getSemantics().isIdempotentInNature()) {
                        ObjectAdapter resultAdapter = actionModelHint.getObject();
                        model.setObjectList(resultAdapter);
                    } else {
                        model.setObject(persistentAdaptersWithin(model.getObject()));
                    }
                   
                    if(lastReturnedAdapter != null) {
                        final ActionResultResponse resultResponse =
                                ActionResultResponseType.determineAndInterpretResult(actionModelHint, null, lastReturnedAdapter);
                        resultResponse.getHandlingStrategy().handleResults(this, resultResponse);
                    }

                } catch(final ConcurrencyException ex) {
                   
                    recover();
                    // display a warning to the user so that they know that the action wasn't performed
                    getMessageBroker().addWarning(ex.getMessage());
                    return;

                } catch(final RuntimeException ex) {
                   
                    final RecoverableException appEx = ActionModel.getApplicationExceptionIfAny(ex);
                    if (appEx != null) {

                        recover();
                       
                        getMessageBroker().setApplicationError(appEx.getMessage());
                       
                        // there's no need to abort the transaction, it will have already been done
                        // (in IsisTransactionManager#executeWithinTransaction(...)).
                        return;
                    }
                    throw ex;
                }
            }
           
            private void recover() {
                // resync with the objectstore
                final List<ObjectAdapterMemento> toggleMementosList = Lists.newArrayList(model.getToggleMementosList());
                for (ObjectAdapterMemento oam : toggleMementosList) {
                    // just requesting the adapter will sync the OAM's version with the objectstore
                    oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
                }
               
                // discard any adapters that might have been deleted
                model.setObject(persistentAdaptersWithin(model.getObject()));
               
                // attempt to preserve the toggled adapters
                final List<ObjectAdapter> adapters = model.getObject();
                model.clearToggleMementosList();
                for (ObjectAdapterMemento oam : toggleMementosList) {
                    final ObjectAdapter objectAdapter = oam.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
                    if(adapters.contains(objectAdapter)) {
                        // in case it has been deleted...
                        model.toggleSelectionOn(objectAdapter);
                    }
                }
            }

            private List<ObjectAdapter> persistentAdaptersWithin(List<ObjectAdapter> adapters) {
                return Lists.newArrayList(Iterables.filter(adapters, new Predicate<ObjectAdapter>() {
                    @Override
                    public boolean apply(ObjectAdapter input) {
                        return !input.isTransient() && !input.isDestroyed();
                    }
                }));
            }

        };
        link.add(new JGrowlBehaviour());
        final boolean explorationOrPrototype = CssMenuItem.isExplorationOrPrototype(objectAction);
        final String actionIdentifier = CssMenuItem.actionIdentifierFor(objectAction);
        final String cssClass = CssMenuItem.cssClassFor(objectAction);

        return new LinkAndLabel(link, objectAction.getName(), null, false, explorationOrPrototype, actionIdentifier, cssClass);
    }
View Full Code Here

        }
        return actionParameter;
    }

    private static ObjectActionParameter actionParameterFor(ActionMemento actionMemento, int number) {
        final ObjectAction action = actionMemento.getAction();
        return action.getParameters().get(number);
    }
View Full Code Here

    // BookmarkableModel
    //////////////////////////////////////////////////

    public PageParameters getPageParameters() {
        final ObjectAdapter adapter = getTargetAdapter();
        final ObjectAction objectAction = getActionMemento().getAction();
        final PageParameters pageParameters = createPageParameters(
                adapter, objectAction, ConcurrencyChecking.NO_CHECK);

        // capture argument values
        final ObjectAdapter[] argumentsAsArray = getArgumentsAsArray();
View Full Code Here

    }

    @Override
    public String getTitle() {
        final ObjectAdapter adapter = getTargetAdapter();
        final ObjectAction objectAction = getActionMemento().getAction();
       
        final StringBuilder buf = new StringBuilder();
        final ObjectAdapter[] argumentsAsArray = getArgumentsAsArray();
        for(ObjectAdapter argumentAdapter: argumentsAsArray) {
            if(buf.length() > 0) {
                buf.append(",");
            }
            buf.append(abbreviated(titleOf(argumentAdapter), 8));
        }

        return adapter.titleString(null) + "." + objectAction.getName() + (buf.length()>0?"(" + buf.toString() + ")":"");
    }
View Full Code Here

    }

    private void setArgumentsIfPossible(final PageParameters pageParameters) {
        List<String> args = PageParameterNames.ACTION_ARGS.getListFrom(pageParameters);

        final ObjectAction action = actionMemento.getAction();
        final List<ObjectSpecification> parameterTypes = action.getParameterTypes();

        for (int paramNum = 0; paramNum < args.size(); paramNum++) {
            String encoded = args.get(paramNum);
            setArgument(paramNum, parameterTypes.get(paramNum), encoded);
        }
View Full Code Here

TOP

Related Classes of org.apache.isis.core.metamodel.spec.feature.ObjectAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.