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

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


        if (object == null) {
            throw new ScimpiException("Object not specified when looking for " + methodName);
        }

        final List<ObjectAction> actions = object.getSpecification().getObjectActions(Contributed.INCLUDED);
        final ObjectAction action = findAction(actions, methodName);
        /*
         * if (action == null) { actions =
         * object.getSpecification().getServiceActionsFor(ObjectActionType.USER,
         * ObjectActionType.EXPLORATION, ObjectActionType.DEBUG); action =
         * findAction(actions, methodName); }
View Full Code Here


        return action;
    }

    private static ObjectAction findAction(final List<ObjectAction> actions, final String methodName) {
        for (int i = 0; i < actions.size(); i++) {
            final ObjectAction objectAction = actions.get(i);
            if (objectAction.getId().equals(methodName)) {
                return objectAction;
            }
        }
        return null;
    }
View Full Code Here

                final String roleFieldName = context.getParameter(PREFIX + "roles-field");
                String resultName = context.getParameter(LOGON_RESULT_NAME);
                resultName = resultName == null ? "_" + USER : resultName;

                final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
                final ObjectAction loginAction = MethodsUtils.findAction(object, loginMethodName);
                final int parameterCount = loginAction.getParameterCount();
                final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
                List<ObjectActionParameter> parameters2 = loginAction.getParameters();
                if (parameters.length != 2) {
                    throw new ScimpiException("Expected two parameters for the log-on method: " + loginMethodName);
                }

                Localization localization = IsisContext.getLocalization();
                ParseableFacet facet = parameters2.get(0).getSpecification().getFacet(ParseableFacet.class);
                parameters[0] = facet.parseTextEntry(null, username, localization);
                facet = parameters2.get(1).getSpecification().getFacet(ParseableFacet.class);
                parameters[1] = facet.parseTextEntry(null, password, localization);
                final ObjectAdapter result = loginAction.execute(object, parameters);
                isValid = result != null;
                if (isValid) {
                    ObjectSpecification specification = result.getSpecification();
                    ObjectAssociation association = specification.getAssociation(roleFieldName);
                    if (association == null) {
View Full Code Here

        try {
            final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
            // FIXME need to find method based on the set of parameters.
            // otherwise overloaded method may be incorrectly
            // selected.
            final ObjectAction action = MethodsUtils.findAction(object, methodName);
            entryState = validateParameters(context, action, object);

            AuthenticationSession session = context.getSession();
            if (session == null && action.isVisible(new AnonymousSession(), object, where).isVetoed()) {
                session = new AnonymousSession();
            }

            final Version originalVersion = context.getVersion(version);
            object.checkLock(originalVersion);
            if (entryState.isValid()) {
                final boolean hasResult = invokeMethod(context, resultName, object, action, entryState);
                String view = context.getParameter(hasResult ? "_" + VIEW : "_" + VOID);

                final int questionMark = view == null ? -1 : view.indexOf("?");
                if (questionMark > -1) {
                    final String params[] = view.substring(questionMark + 1).split("&");
                    for (final String param : params) {
                        final int equals = param.indexOf("=");
                        context.addVariable(param.substring(0, equals), param.substring(equals + 1), Scope.REQUEST);
                        view = view.substring(0, questionMark);
                    }
                }
                context.setRequestPath(view);
                if (message != null) {
                    final MessageBroker messageBroker = getMessageBroker();
                    messageBroker.addMessage(message);
                }
                if (override != null) {
                    context.addVariable(resultName, override, Scope.REQUEST);
                }
                if (!action.hasReturn() && context.getVariable(resultName) == null) {
                    context.addVariable(resultName, objectId, Scope.REQUEST);
                }
            } else {
                entryState.setForm(formId);
                context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
View Full Code Here

            block.replaceContent(field, selector);
        } else {
            final String objectId = request.getOptionalProperty(OBJECT);
            final String methodName = request.getRequiredProperty(METHOD);
            final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
            final ObjectAction action = MethodsUtils.findAction(object, methodName);
            if (action.getParameterCount() == 0) {
                final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
                final String selector = showSelectionList(request, collection, block.getCurrent(field), block.isNullable(field), type);
                block.replaceContent(field, selector);
            } else {
                final String id = "selector_options";
                final String id2 = (String) request.getContext().getVariable(id);
View Full Code Here

        final String objectId = request.getOptionalProperty(OBJECT);
        final ObjectAdapter object = MethodsUtils.findObject(context, objectId);

        final String methodName = request.getRequiredProperty(METHOD);
        final ObjectAction action = MethodsUtils.findAction(object, methodName);

        final String variableName = request.getOptionalProperty(RESULT_NAME);
        final String scopeName = request.getOptionalProperty(SCOPE);

        final ActionContent parameterBlock = new ActionContent(action);
        request.setBlockContent(parameterBlock);
        request.processUtilCloseTag();
        final ObjectAdapter[] parameters = parameterBlock.getParameters(request);

        if (!MethodsUtils.isVisibleAndUsable(object, action, where)) {
            throw new ForbiddenException(action, ForbiddenException.VISIBLE_AND_USABLE);
        }

        // swap null parameter of the object's type to run a contributed method
        if (false /*action.isContributed()*/) {
            final List<ObjectActionParameter> parameterSpecs = action.getParameters();
            for (int i = 0; i < parameters.length; i++) {
                if (parameters[i] == null && object.getSpecification().isOfType(parameterSpecs.get(i).getSpecification())) {
                    parameters[i] = object;
                    break;
                }
View Full Code Here

        final String messageSegment = completionMessage == null ? "" : "&amp;" + "_" + MESSAGE + "=" + URLEncoder.encode(completionMessage);

        final RequestContext context = request.getContext();
        final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
        final String version = context.mapVersion(object);
        final ObjectAction action = MethodsUtils.findAction(object, method);

        final ActionContent parameterBlock = new ActionContent(action);
        request.setBlockContent(parameterBlock);
        request.pushNewBuffer();
        request.processUtilCloseTag();
        final String text = request.popBuffer();
       
        final String[] parameters = parameterBlock.getParameters();
        final String target;
        /*
        if (action.isContributed()) {
            System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
            parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
            target =  request.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
            if (!action.hasReturn() && resultOverride == null) {
                resultOverride = parameters[0];
            }
        } else {
            target =  StringEscapeUtils.escapeHtml(request.getContext().mapObject(object, Scope.INTERACTION));
        }
         */
       
        final ObjectAdapter[] objectParameters;
       
        // TODO copied from ActionButton
        //final ObjectAdapter target;
        if (false /*action.isContributed() */) {
//            objectParameters= null;
//            System.arraycopy(parameters, 0, parameters, 1, parameters.length - 1);
//            parameters[0] = request.getContext().mapObject(object, Scope.REQUEST);
//            target =  request.getContext().mapObject(action.realTarget(object), Scope.REQUEST);
//            if (!action.hasReturn() && resultOverride == null) {
//                resultOverride = parameters[0];
//            }
        } else {
            objectParameters = new ObjectAdapter[parameters.length];
            // target = object;
            target =  StringEscapeUtils.escapeHtml(request.getContext().mapObject(object, Scope.INTERACTION));
            int i = 0;
            for (final ObjectActionParameter spec : action.getParameters()) {
                final ObjectSpecification type = spec.getSpecification();
                if (parameters[i] == null) {
                    objectParameters[i] = null;
                } else if (type.getFacet(ParseableFacet.class) != null) {
                    final ParseableFacet facet = type.getFacet(ParseableFacet.class);
View Full Code Here

    public void process(final Request request) {
        final String objectId = request.getOptionalProperty(OBJECT);
        final String methodName = request.getRequiredProperty(METHOD);

        final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
        final ObjectAction action = MethodsUtils.findAction(object, methodName);

        request.appendAsHtmlEncoded(action.getName());
    }
View Full Code Here

            final InclusionList inclusionList,
            final String view,
            final String cancelTo) {
        actions = inclusionList.includedActions(actions);
        for (int j = 0; j < actions.size(); j++) {
            final ObjectAction action = actions.get(j);
            if (false /* action instanceof ObjectActionSet */) {
//                request.appendHtml("<div class=\"actions\">");
//                writeMethods(request, adapter, action.getActions(), objectId, showForms, inclusionList, view, cancelTo);
//                request.appendHtml("</div>");
            } else if (false /*action.isContributed()*/) {
View Full Code Here

    }


    @Test
    public void mapAction_then_getMappedAction() {
        final ObjectAction action = new ObjectActionNoop();
        final String id = context.mapAction(action);
        assertEquals(action, context.getMappedAction(id));
    }
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.