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

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


    private void startTransactionForUser(IsisTransactionManager transactionManager) {
        transactionManager.startTransaction();

        // specify that this command (if any) is being executed by a 'USER'
        final CommandContext commandContext = getService(CommandContext.class);
        Command command;
        if (commandContext != null) {
            command = commandContext.getCommand();
            command.setExecutor(Command.Executor.USER);
        }
    }
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 CommandContext commandContext = getServiceOrNull(CommandContext.class);
        if (commandContext == null) {
            return;
        }
        final Command command = commandContext.getCommand();
        if(command == null) {
            return;
        }

        // ensure that any changed objects means that the command should be persisted
        final Set<ObjectAdapter> changedAdapters = findChangedAdapters(changedObjectProperties);
        if(!changedAdapters.isEmpty() && command.getMemberIdentifier() != null) {
            command.setPersistHint(true);
        }

        ensureSafeSemanticsHonoured(command, changedAdapters);
    }
View Full Code Here

    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);

                if(command instanceof Command2) {
                    final Command2 command2 = (Command2) command;
                    command2.flushActionInteractionEvents();
View Full Code Here

                        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);
                    }


                    ObjectAdapter lastReturnedAdapter = null;
                    int i=0;
View Full Code Here

                        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;
                    }

View Full Code Here

                        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;
                    }

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.close(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

    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

    @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

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.