Package org.apache.isis.applib.services.command

Examples of org.apache.isis.applib.services.command.Command


    private void completeCommandIfConfigured() {
        final CommandContext commandContext = getServiceOrNull(CommandContext.class);
        if(commandContext != null) {
            final CommandService commandService = getServiceOrNull(CommandService.class);
            if(commandService != null) {
                final Command command = commandContext.getCommand();
                commandService.complete(command);
            }
        }
    }
View Full Code Here


            final RootOid adapterOid = (RootOid) currentInvocation.getTarget().getOid();
            final String oidStr = getOidMarshaller().marshal(adapterOid);
            final Identifier actionIdentifier = action.getIdentifier();
            final String title = oidStr + ": " + actionIdentifier.toNameParmsIdentityString();
           
            final Command command = currentInvocation.getCommand();
            final String targetClass = command.getTargetClass();
            final String targetAction = command.getTargetAction();
            final Bookmark target = command.getTarget();
            final String memberIdentifier = command.getMemberIdentifier();
           
            final EventMetadata metadata = newEventMetadata(EventType.ACTION_INVOCATION, currentUser, timestamp, title, targetClass, targetAction, target, memberIdentifier);
            publishingService.publishAction(payloadFactory, metadata, currentInvocation, objectStringifier());
        } finally {
            // ensures that cannot publish this action more than once
View Full Code Here

            final ObjectAdapter[] arguments) {

        try {

            final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
            final Command command = commandContext != null ? commandContext.getCommand() : null;

            // pick up existing event (saved in thread local during the validation phase)
            final ActionInteractionEvent<?> existingEvent = actionInteractionFacet.currentInteraction.get();

            // ... post the executing event
View Full Code Here

    @ActionSemantics(Of.SAFE)
    @NotInServiceMenu
    @NotContributed(As.ACTION)
    @Render(Type.EAGERLY)
    public List<CommandJdo> siblingCommands(final CommandJdo siblingCommand) {
        final Command parent = siblingCommand.getParent();
        if(parent == null || !(parent instanceof CommandJdo)) {
            return Collections.emptyList();
        }
        final CommandJdo parentJdo = (CommandJdo) parent;
        final List<CommandJdo> siblingCommands = backgroundCommandRepository.findByParent(parentJdo);
View Full Code Here

            bulkInteractionContext.setInvokedAs(InvokedAs.REGULAR);
            bulkInteractionContext.setDomainObjects(Collections.singletonList(contributee.getObject()));
        }

        final CommandContext commandContext = getServicesProvider().lookupService(CommandContext.class);
        final Command command = commandContext != null ? commandContext.getCommand() : null;

        if(command != null && command.getExecutor() == Executor.USER) {

            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));
    }
View Full Code Here

            raiseWarning(target, feedbackForm, invalidReasonIfAny);
            return false;
        }
       
        final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
        final Command command;
        if (commandContext != null) {
            command = commandContext.getCommand();
            command.setExecutor(Executor.USER);
        } else {
            command = null;
        }
       
       
        // the object store could raise an exception (eg uniqueness constraint)
        // so we handle it here.
        try {
            // could be programmatic flushing, so must include in the try... finally
            final ObjectAdapter resultAdapter = executeActionHandlingApplicationExceptions();
     
            // flush any queued changes, so concurrency or violation exceptions (if any)
            // will be thrown here
            getTransactionManager().flushTransaction();
           
            ActionResultResponse resultResponse = ActionResultResponseType.determineAndInterpretResult(this.getActionModel(), target, resultAdapter);
            resultResponse.getHandlingStrategy().handleResults(this, resultResponse);

            if (actionModel.isBookmarkable()) {
                bookmarkPage(actionModel);
            }
           
            if(actionPrompt != null) {
                actionPrompt.closePrompt(target);
                // cos will be reused next time, so mustn't cache em.
                actionModel.clearArguments();
            }

            return true;

        } catch (RuntimeException ex) {

            String message = recognizeException(ex, target, feedbackForm);
           
            if (message != null) {
                // no need to add to message broker, should already have been added...
               
                if(feedbackForm == null) {
                    // forward on instead to void page
                    // (otherwise, we'll have rendered an action parameters page
                    // and so we'll be staying on that page)
                    ActionResultResponseHandlingStrategy.REDIRECT_TO_VOID.handleResults(this, null);
                }

                return false;
            }
           
            // not handled, so capture and propagate
            if(command != null) {
                command.setException(Throwables.getStackTraceAsString(ex));
            }

            throw ex;
        }
    }
View Full Code Here

        final CommandContext commandContext = getServiceOrNull(CommandContext.class);
        if(commandContext == null) {
            return;
        }
        final CommandService commandService = getServiceOrNull(CommandService.class);
        final Command command =
                commandService != null
                    ? commandService.create()
                    : new CommandDefault();
        commandContext.setCommand(command);

        if(command.getTimestamp() == null) {
            command.setTimestamp(Clock.getTimeAsJavaSqlTimestamp());
        }
        if(command.getUser() == null) {
            command.setUser(getAuthenticationSession().getUserName());
        }
       
        // the remaining properties are set further down the call-stack, if an action is actually performed
    }
View Full Code Here

        }
        final CommandService commandService = getServiceOrNull(CommandService.class);
        if(commandService == null) {
            return;
        }
        final Command command = commandContext.getCommand();
        commandService.startTransaction(command, transactionId);
    }
View Full Code Here

    private void persistCurrentCommandIfRequired() {
        if(commandContext == null || commandService == null) {
            return;
        }
        final Command command = commandContext.getCommand();
        final CommandJdo commandJdo = commandService.asUserInitiatedCommandJdo(command);
        if(commandJdo == null) {
            return;
        }
        persistIfNotAlready(commandJdo);
View Full Code Here

                final List<Class<?>> argTypes = Lists.newArrayList();
                final List<Object> argObjs = Lists.newArrayList();
                CommandUtil.buildMementoArgLists(mementoService, bookmarkService, proxiedMethod, args, argTypes, argObjs);

                final Command command = commandContext.getCommand();
               
                final ActionInvocationMemento aim =
                        new ActionInvocationMemento(mementoService,
                                actionIdentifier,
                                domainObjectBookmark,
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.services.command.Command

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.