Package org.apache.isis.applib.services.bookmark

Examples of org.apache.isis.applib.services.bookmark.Bookmark


    }

    public Bookmark bookmarkFor(final Class<?> cls, final String identifier) {
        final ObjectSpecification objectSpec = getSpecificationLoader().loadSpecification(cls);
        String objectType = objectSpec.getSpecId().asString();
        return new Bookmark(objectType, identifier);
    }
View Full Code Here


    @Override
    public Bookmark asBookmark() {
        final String objectType = getObjectSpecId().asString();
        final String identifier = getIdentifier();
        return new Bookmark(objectType, identifier);
    }
View Full Code Here

            Object input = args[i];
            if (mementoService.canSet(input)) {
                argTypes.add(method.getParameterTypes()[i]);
                argObjs.add(input);
            } else {
                Bookmark argBookmark = bookmarkService.bookmarkFor(input);
                argTypes.add(Bookmark.class);
                argObjs.add(argBookmark);
            }
        }
    }
View Full Code Here

            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

     */
    @Override
    @NotInServiceMenu
    @NotContributed(As.ASSOCIATION)
    public Object lookup(final BookmarkHolder bookmarkHolder) {
        Bookmark bookmark = bookmarkHolder.bookmark();
        return bookmark != null? lookup(bookmark): null;
    }
View Full Code Here

                command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));
                command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
                command.setTargetAction(CommandUtil.targetActionNameFor(owningAction));
                command.setArguments(CommandUtil.argDescriptionFor(owningAction, arguments));
               
                final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
                command.setTarget(targetBookmark);
               
                // the background service is used here merely as a means to capture an invocation memento
                final BackgroundService backgroundService = getServicesInjector().lookupService(BackgroundService.class);
                if(backgroundService != null) {
                    final Object targetObject = unwrap(targetAdapter);
                    final Object[] args = CommandUtil.objectsFor(arguments);
                    ActionInvocationMemento aim = backgroundService.asActionInvocationMemento(method, targetObject, args);

                    if(aim != null) {
                        command.setMemento(aim.asMementoString());
                    } else {
                        throw new IsisException(
                            "Unable to build memento for action " +
                            owningAction.getIdentifier().toClassAndNameIdentityString());
                    }
                }

                // copy over the command execution 'context' (if available)
                final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
                if(commandFacet != null && !commandFacet.isDisabled()) {
                    command.setExecuteIn(commandFacet.executeIn());
                    command.setPersistence(commandFacet.persistence());
                } else {
                    // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
                    command.setExecuteIn(ExecuteIn.FOREGROUND);
                    command.setPersistence(Persistence.IF_HINTED);
                }
            }
           
           
            if( command != null &&
                command.getExecutor() == Executor.USER &&
                command.getExecuteIn() == ExecuteIn.BACKGROUND) {
               
                // persist command so can be this command can be in the 'background'
                final CommandService commandService = getServicesInjector().lookupService(CommandService.class);
                if(commandService.persistIfPossible(command)) {
                    // force persistence, then return the command itself.
                    final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(command);
                    return resultAdapter;
                } else {
                    throw new IsisException(
                            "Unable to schedule action '"
                            + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
                            + "CommandService does not support persistent commands " );
                }
            } else {
               
                // otherwise, go ahead and execute action in the 'foreground'

                if(command != null) {
                    command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
                }
               
                final Object result = method.invoke(object, executionParameters);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(" action result " + result);
                }
                if (result == null) {
                    return null;
                }

                final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(result);

                // copy over TypeOfFacet if required
                final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
                resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));

                if(command != null) {
                    if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
                        final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
                        command.setResult(bookmark);
                    }
                }
               
                final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
View Full Code Here

                        final String memento = command.getMemento();
                        final ActionInvocationMemento aim = new ActionInvocationMemento(mementoService, memento);
                       
                        final String actionId = aim.getActionId();
              
                        final Bookmark targetBookmark = aim.getTarget();
                        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);
                        }

                    } catch (Exception e) {
                        command.setException(Throwables.getStackTraceAsString(e));
View Full Code Here

            return null;
        }
        if(Bookmark.class != argType) {
            return adapterFor(arg);
        } else {
            final Bookmark argBookmark = (Bookmark)arg;
            final RootOid rootOid = RootOidDefault.create(argBookmark);
            return adapterFor(rootOid);
        }
    }
View Full Code Here

            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 {
View Full Code Here

            final String title = oidStr;
       
            final EventType eventTypeFor = eventTypeFor(changeKind);
           
            final String enlistedAdapterClass = CommandUtil.targetClassNameFor(enlistedAdapter);
            final Bookmark enlistedTarget = enlistedAdapterOid.asBookmark();
           
            final EventMetadata metadata = newEventMetadata(eventTypeFor, currentUser, timestamp, title, enlistedAdapterClass, null, enlistedTarget, null);
       
            publishingService.publishObject(payloadFactory, metadata, enlistedAdapter, changeKind, objectStringifier());
        }
View Full Code Here

TOP

Related Classes of org.apache.isis.applib.services.bookmark.Bookmark

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.