Examples of ObjectAction


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

                    throw new UnsupportedOperationException(
                            "Only actions can be executed in the background "
                                    + "(method " + proxiedMethod.getName() + " represents a " + member.getFeatureType().name() + "')");
                }

                final ObjectAction action = (ObjectAction) member;

                final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
                final String targetClassName = CommandUtil.targetClassNameFor(targetAdapter);
                final String targetActionName = CommandUtil.targetActionNameFor(action);
                final String targetArgs = CommandUtil.argDescriptionFor(action, adaptersFor(args));
View Full Code Here

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

        }
        if(!(member instanceof ObjectAction)) {
            return null;
        }

        final ObjectAction action = (ObjectAction) member;
        final String actionIdentifier = CommandUtil.actionIdentifierFor(action);
       
        final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);

        final List<Class<?>> argTypes = Lists.newArrayList();
View Full Code Here

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

        final ObjectAdapter onAdapter = performContext.getOnAdapter();
        final ObjectMember objectMember = performContext.getObjectMember();
        final CellBinding onMemberBinding = performContext.getPeer().getOnMemberBinding();
        final List<ScenarioCell> argumentCells = performContext.getArgumentCells();

        final ObjectAction objectAction = (ObjectAction) objectMember;

        final int parameterCount = objectAction.getParameterCount();
        final boolean isContributedOneArgAction = objectAction.isContributed() && parameterCount == 1;

        ObjectAdapter[] proposedArguments;
        if (!isContributedOneArgAction) {

            // lookup arguments
            proposedArguments = performContext.getPeer().getAdapters(onAdapter, objectAction, onMemberBinding, argumentCells);

            // validate arguments
            final Consent argSetValid = objectAction.isProposedArgumentSetValid(onAdapter, proposedArguments);
            if (argSetValid.isVetoed()) {
                throw ScenarioBoundValueException.current(onMemberBinding, argSetValid.getReason());
            }
        } else {
            proposedArguments = new ObjectAdapter[] { onAdapter };
        }

        // execute
        result = objectAction.execute(onAdapter, proposedArguments);

        // all OK.
    }
View Full Code Here

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

                    final Object targetObject = bookmarkService.lookup(targetBookmark);

                    final ObjectAdapter targetAdapter = adapterFor(targetObject);
                    final ObjectSpecification specification = targetAdapter.getSpecification();

                    final ObjectAction objectAction = findAction(specification, actionId);
                    if(objectAction == null) {
                        throw new Exception("Unknown action '" + actionId + "'");
                    }

                    final ObjectAdapter[] argAdapters = argAdaptersFor(aim);
                    final ObjectAdapter resultAdapter = objectAction.execute(targetAdapter, argAdapters);
                    if(resultAdapter != null) {
                        Bookmark resultBookmark = CommandUtil.bookmarkFor(resultAdapter);
                        command.setResult(resultBookmark);
                    }
View Full Code Here

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

    public ObjectAdapter completeTask(final Context context, final Page page) {
        final ObjectAdapter targetAdapter = getTarget(context);
        final ObjectAdapter[] entryAdapters = getEntries(context);

        if (targetAdapter.isTransient()) {
            final ObjectAction action = targetAdapter.getSpecification().getObjectAction(ActionType.USER, "save", ObjectSpecification.EMPTY_LIST);
            if (action == null) {
                getPersistenceSession().makePersistent(targetAdapter);
            } else {
                action.execute(targetAdapter, new ObjectAdapter[0]);
            }
        } else {
            saveState(targetAdapter, entryAdapters);
        }
View Full Code Here

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

    }

    @Override
    public ObjectAction getObjectAction(final String nameParmsIdentityString) {
        for (final ActionType type : ActionType.values()) {
            final ObjectAction action = getObjectAction(type, nameParmsIdentityString);
            if (action != null) {
                return action;
            }
        }
        return null;
View Full Code Here

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

    }

    private static Component[] createMenu(final String menuName, final ObjectAdapter target, final List<ObjectAction> actions, final Context context, final String targetObjectId) {
        final List<Component> menuItems = new ArrayList<Component>();
        for (int j = 0; j < actions.size(); j++) {
            final ObjectAction action = actions.get(j);
            final String name = action.getName();
            Component menuItem = null;
            if (action.getActions().size() > 0) {
                final Component[] components = createMenu(name, target, action.getActions(), context, targetObjectId);
                menuItem = context.getComponentFactory().createSubmenu(name, components);
            } else {
                if (!action.isVisible(IsisContext.getAuthenticationSession(), target, where).isAllowed()) {
                    continue;
                }

                if (action.getType() == ActionType.USER) {
                    // carry on, process this action
                } else if (action.getType() == ActionType.EXPLORATION) {
                    final boolean isExploring = IsisContext.getDeploymentType().isExploring();
                    if (isExploring) {
                        // carry on, process this action
                    } else {
                        // ignore this action, skip onto next
                        continue;
                    }
                } else if (action.getType() == ActionType.PROTOTYPE) {
                    final boolean isPrototyping = IsisContext.getDeploymentType().isPrototyping();
                    if (isPrototyping) {
                        // carry on, process this action
                    } else {
                        // ignore this action, skip onto next
                        continue;
                    }
                } else if (action.getType() == ActionType.DEBUG) {
                    // TODO: show if debug "gesture" present
                } else {
                    // ignore this action, skip onto next
                    continue;
                }

                final String actionId = context.mapAction(action);
                boolean collectParameters;
                if (action.getParameterCount() == 0) {
                    collectParameters = false;
                    // TODO use new promptForParameters method instead of all
                    // this
                } else if (action.getParameterCount() == 1 && action.isContributed() && target.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
                    collectParameters = false;
                } else {
                    collectParameters = true;
                }
                final Consent consent = action.isUsable(IsisContext.getAuthenticationSession(), target, where);
                final String consentReason = consent.getReason();
                menuItem = context.getComponentFactory().createMenuItem(actionId, action.getName(), action.getDescription(), consentReason, action.getType(), collectParameters, targetObjectId);
            }
            if (menuItem != null) {
                menuItems.add(menuItem);
            }
        }
View Full Code Here

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

        if (idString == null) {
            throw new ActionException("Task no longer in progress");
        }
        final ObjectAdapter target = context.getMappedObject(idString);
        final String id = request.getActionId();
        final ObjectAction action = context.getMappedAction(id);
        if (action == null) {
            throw new ActionException("No such action: " + id);
        }

        boolean executeImmediately = false;
        // TODO use new promptForParameters method instead of all this
        final boolean isContributedMethod = action.isContributed();
        if (action.getParameterCount() == 0) {
            executeImmediately = true;
        } else if (action.getParameterCount() == 1 && isContributedMethod && target.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
            executeImmediately = true;
        }

        if (executeImmediately) {
            final ObjectAdapter[] parameters = isContributedMethod ? new ObjectAdapter[] { target } : null;
            final ObjectAdapter result = action.execute(target, parameters);
            final MessageBroker broker = IsisContext.getMessageBroker();
            final List<String> messages = broker.getMessages();
            final List<String> warnings = broker.getWarnings();
            context.setMessagesAndWarnings(messages, warnings);
            context.processChanges();
View Full Code Here

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

            requestedParamNum = Integer.valueOf(arg0Cell.getText());
        } catch (final NumberFormatException ex) {
            throw ScenarioBoundValueException.current(arg0Binding, ex.getMessage());
        }

        final ObjectAction noa = (ObjectAction) nakedObjectMember;
        final int parameterCount = noa.getParameterCount();
        if (requestedParamNum < 0 || requestedParamNum > parameterCount - 1) {
            throw ScenarioBoundValueException.current(arg0Binding, "(must be between 0 and " + (parameterCount - 1) + ")");
        }

        final ObjectAdapter[][] allParameterChoices = noa.getChoices(onAdapter);
        result = performContext.getPeer().toAdaptedListOfPojos(allParameterChoices[requestedParamNum]);
    }
View Full Code Here

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

            if (intent == Intent.CHECK_IF_VALID) {
                throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only the 'invoke' method", memberName));
            }

            final ObjectAction noa = (ObjectAction) objectMember;
            return handleActionMethod(args, getAuthenticationSession(), targetAdapter, noa, memberName);
        }

        throw new UnsupportedOperationException(String.format("Unknown member type '%s'", objectMember));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.