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

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


        final ObjectAssociation property = aap.getProperty();
        final String memberId = property.getIdentifier().toClassAndNameIdentityString();
        final String propertyId = property.getId();

        final String targetClass = CommandUtil.targetClassNameFor(adapter);
        final Bookmark target = new Bookmark(objectType, identifier);

        auditingService3.audit(getTransactionId(), targetClass, target, memberId, propertyId, preValue, postValue, user, timestamp);
    }
View Full Code Here


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

                command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));

                // 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(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
                    command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
                }
            }


            if( command != null &&
                    command.getExecutor() == Command.Executor.USER &&
                    command.getExecuteIn() == org.apache.isis.applib.annotation.Command.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 InvocationResult.forActionThatReturned(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());
                }

                Object result = method.invoke(targetPojo, executionParameters);

                if (LOG.isDebugEnabled()) {
                    LOG.debug(" action result " + result);
                }
                if (result == null) {
                    if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
                        // if this was a void method on a ViewModel.Cloneable, then (to save boilerplate in the domain)
                        // automatically do the clone and return the clone instead.
                        final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) targetAdapter.getObject();
                        final Object clone = cloneable.clone();
                        final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
                        return InvocationResult.forActionThatReturned(clonedAdapter);
                    }
                    return InvocationResult.forActionThatReturned(null);
                }

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

                if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
                    // if the object returned is a ViewModel.Cloneable, then
                    // (to save boilerplate in the domain) automatically do the clone.
                    final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) result;
                    result = cloneable.clone();
                    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

            if(mementoKeys.contains(propertyId)) {
                final Class<?> propertyType = property.getSpecification().getCorrespondingClass();
                propertyValue = memento.get(propertyId, propertyType);
            } else if(mementoKeys.contains(propertyId + ".bookmark")) {
                final Bookmark propertyValueBookmark = memento.get(propertyId + ".bookmark", Bookmark.class);
                propertyValue = bookmarkService.lookup(propertyValueBookmark);
            }

            if(propertyValue != null) {
                property.set(viewModelAdapter, adapterManager.adapterFor(propertyValue));
View Full Code Here

                if(propertyValueAdapter != null) {
                    final Object propertyValue = propertyValueAdapter.getObject();
                    if(mementoService.canSet(propertyValue)) {
                        memento.set(property.getId(), propertyValue);
                    } else {
                        final Bookmark propertyValueBookmark = bookmarkService.bookmarkFor(propertyValue);
                        memento.set(property.getId() + ".bookmark", propertyValueBookmark);
                    }
                }
            }
            return memento.asString();
View Full Code Here

    private DomainObjectServices domainObjectServices;
   
    @Override
    @Programmatic
    public Object lookup(final BookmarkHolder bookmarkHolder) {
        Bookmark bookmark = bookmarkHolder.bookmark();
        return bookmark != null? lookup(bookmark): null;
    }
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

                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));
               
                final Bookmark domainObjectBookmark = bookmarkService.bookmarkFor(domainObject);

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

        }

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

        final List<Class<?>> argTypes = Lists.newArrayList();
        final List<Object> argObjs = Lists.newArrayList();
        CommandUtil.buildMementoArgLists(mementoService, bookmarkService, method, args, argTypes, argObjs);
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

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.